Coder Social home page Coder Social logo

Comments (8)

carlosmiei avatar carlosmiei commented on June 4, 2024

Hello @eurekawild,

What's the best way of reproducing the issue? Do we have to wait an hour?

from ccxt.

eurekawild avatar eurekawild commented on June 4, 2024

Hello @eurekawild,

What's the best way of reproducing the issue? Do we have to wait an hour?

I dont have a best way. In my program, the same code for Binance is well. Maybe something is wrong in OKX, like the frequency limit etc. Now I restart my program per one hour, It's OK for me.

from ccxt.

eurekawild avatar eurekawild commented on June 4, 2024
async def symbol_loop(ex, symbol, timeframe):
    try:
        await ex.watch_ohlcv(symbol, timeframe)
    except Exception as e:
        traceback.print_exc()
        return
    cur_ohlcvs = await ex.fetch_ohlcv(symbol, timeframe, None,100)
    while True:
        latest_ohlcvs = ex.ohlcvs[symbol][timeframe]
        for ohlcv in latest_ohlcvs:
            last_ohlcv = cur_ohlcvs[-1]
            if ohlcv[0] > last_ohlcv[0]:
                cur_ohlcvs.append(ohlcv)
                cur_ohlcvs.pop(0)
            elif ohlcv[0] == last_ohlcv[0]:
                cur_ohlcvs[-1] = ohlcv
        print("cur ohlcvs:", cur_ohlcvs)
        await ex.sleep(5000)

This is the core code in my production environment. I just call the func watch_ohlcv() once, the func fetch_ohlcv() once. in the loop I just visit the ohlcv cache in ex. So I think it is not my code problem, and also not the question of the frequency limit. The code is simple and clear, but the ohlcvs stoped updating after the code runing an hour or two. So something is wrong in the func watch_ohlcv() in OKX exchange in my opinion.

from ccxt.

makarid avatar makarid commented on June 4, 2024

I can confirm the same. I am trying OKX watchOrderbook and it doesn't work but the same code for Bybit works. Version 4.3.11

Example code:
const exchange = new pro.okx({
"enableRateLimit": true,
"apiKey": okexApiKey,
"secret": okexSecret,
"password": okexPass,
});

watchOrderBooks(exchange, ["BTC-USDT-SWAP","ETH-USDT-SWAP"])

async function watchOrderBooks(exchange, perpSymbols) {
while (true) {
try {
for (const symbol of perpSymbols) {
console.log("Symbol: "+ symbol)
const orderbook = await exchange.watchOrderBook(symbol, 50)
}
} catch (e) {
logger.error (e.message)
}
}
}

If you run this code, the ETH-USDT-SWAP never console.logs.

from ccxt.

makarid avatar makarid commented on June 4, 2024

Also, when i am trying the same code without apikey i am getting okx requires "apiKey" credential. Does the OKX needs API keys for public orderbooks? By the way, it works on 4.1.11 version

from ccxt.

pcriadoperez avatar pcriadoperez commented on June 4, 2024

Hi @makarid , for the apiKey error you can set the params.depth to 'books' and that should fix it. I also opened a PR to default to it

from ccxt.

pcriadoperez avatar pcriadoperez commented on June 4, 2024

Hi @makarid , I believe I found the problem, I think your api keys don't have VIP4 permission to use the depth channel books50-l2-tbt and the library wasn't throwing the error correctly so it appeared to be "stuck"

I opened one PR to default to the public channel and another to properly throw the error in this event. In the meantime the code should work if you use the depth channel books

from ccxt.

makarid avatar makarid commented on June 4, 2024

Thank you very much @pcriadoperez !

from ccxt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.