I’m trying to get daily prices for Quarterly Futures for both COIN-M and USDT-M.
I’m using the continuousKlines function, with contractType set to CURRENT_QUARTER or NEXT_QUARTER
I also need prices for the recently expired contract (e.g. June 2022 …PREVIOUS_QUARTER???)
I know that I can download prices from https://data.binance.vision/
I really only want one set of code rather than a mix of the API and download from data.binance.vision
It needs to be reliable: I see that there are gaps at data.binance.vision
It needs to be timely: I need the data a few hours after the close, ideally sooner.
I need to run the code every day. I have downloaded the history that I need so far.
I need to access about 5 days’ history to allow for IT/Operational failures on my side.
At some point I may want more frequent intraday data.
What is the best way of sourcing this data?
For historical data, use data.binance.vision as the exchange does not support expired contracts. Once you sync up to real-time, I suggest listening to the websocket instead of sending requests to the REST API. This requires less resources if your use-case is time sensitive.
Thanks - I’ll take a look at the websocket.
So it looks like whenever a contract expires, I need to go back to data.binance.vision to get the closing price
Assuming you were not listening to the contract’s stream via the websocket, correct.
…ok that’s interesting. My understanding is that the closing price is constantly being published as the latest price. How would you know what the formal close is for the day? Just take the last one received?
If you are listening to a kline stream, check if the close time is equal to end of day and that the kline is closed ("x" == True
). If this is the case, you may use the close price of said kline as the close time of the day.
1 Like
Great - thanks - v helpful