-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Historical Data Websocket for Real-Time OHLC Data #38
Comments
hey @jackroc97 That's right the Market History is not quite what you'd expect it to be. In fact, the documentation states: https://www.interactivebrokers.com/campus/ibkr-api-page/cpapi-v1/#ws-sub-historical-data
To get live data, you want to use the MARKET_DATA channel as shown in ws_02 example: https://github.com/Voyz/ibind/blob/master/examples/ws_02_intermediate.py You can find the list of fields you may want to use here: https://github.com/Voyz/ibind/blob/master/ibind/client/ibkr_definitions.py Or here: https://www.interactivebrokers.com/campus/ibkr-api-page/cpapi-v1/#market-data-fields Let me know if it makes sense 👍 |
Thanks for the response @Voyz! So it seems that there is no "native" way to stream live OHLC values through the Web API, similar to how you can using the TWS API? I had previously been using the TWS API, but I have been frustrated with it recently and decided to try switching over to the Web API. My goal is to construct a live feed of OHLCV candles on the minute timescale. My initial approach was to use the
I'm not really sure what to do with the data that is missing one of the two fields. How can there be a price with no size, or a size with no price? |
Understood, thanks for pointing out that MARKET_DATA's ohlc are daily, not live. Did you try talking to IBKR support and see what they say on the topic?
I've seen this before. IBKR support told me that these are incomplete data points and that I can collect or ignore these until a full datapoint comes out. As for your application - can I suggest calling the market history REST endpoint on a minutely interval? Would that work for you? |
Thanks again for the response.
Not yet, but I may reach out to them and see what their recommendations are.
I think that would probably be an acceptable solution for me, thanks! |
I am trying to stream 1 min OHLC data in real-time. I've tried using the market history example as a starting point for this. I am a little confused on how to interpret the data. The first response is OHLC for the 1 min bar for the previous minute (for example, if I run the script at 17:06, it would be the bar for 17:05). A sample response is shown below:
The subsequent responses however only contain either just "open" or "open" and "close" data, with no time associated. For example:
Is it possible to use this websocket endpoint to get a real-time stream of OHLC bars, or would that be a misuse of it? It appears to return data in realtime, but seems to be incomplete... or perhaps I am misinterpreting the response.
The text was updated successfully, but these errors were encountered: