My strategy depends on the close of the candles, so i am using ccxt,fetch_ohlcv(limit=300), as i need sma of last 300 candles, executing the code twice every minute for two different symbols, can i keep on hitting the endpoint every second as my market order is getting way different price than i intend, as it is sleeping for 30 seconds.
I’m not familiar with ccxt,fetch_ohlcv(limit=300)
, but using the websocket stream would probably be better than the REST API: https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-streams
can you me code in python, to get last 300 candles using websocket stream? is it possible? I tought stream gives only live data.
If I understood your context correctly:
You can request for 300 Klines with the REST endpoint first and then as the market goes on, use the latest Kline from websocket stream to renew your local 300 klines and have an updated SMA calculation.