Hello, I am testing algorithm live on IBKR account and for some reason bars we get in real-time are a little bit different from what is visible in TWS, usually a couple of ticks difference, but it is a bit annoying because algorithm can behave differently because of this and it is a pain to debug.
Do you know why this happens and if it is possible to avoid?
Also, quick related question: are ticks marked as suspicious if IBKR data is used? I suppose no, but to confirm…
Yuri Lopukhov
Perhaps this answers my question:
To accomplish this, it effectively sends a price snapshot for each
instrument at regular intervals. This interval seems to be about 300
milliseconds. For each of bid, ask, and last it compares the current price
and size with the values at the last snapshot. If the price is different it
sends both price and size. If the price is the same, but the size is
different it sends only the size. If both price and size are the same, it
doesn't send either. If there have been any trades since the last snapshot,
it sends the (accumulated) volume (so where the price and size haven't
changed but there have been one or more trades, this can be detected from
the increased volume).
…
There is an irritating side effect of this technique, which is that price
movements between shapshots may not be reported at all: for example if the
last price at snapshot 1 is 100, and then price moves up to 102 and then
back to 101 by snapshot 2, the price reported at snapshot 2 will be 101, and
the 102 price will not be reported at all. This leads to occasional
incorrect highs and lows of bars, but rarely by more than one tick: whether
that is significant depends very much on the trading strategy used.
Not sure if you want to confirm this…
Fred Painchaud
Hi Yuri,
I'd say you should also have a look at this:
Fred
Alexander Klochenok
I'd also be very interested in this, I can't be the only intraday trader on 1 min and 2 min charts that notices the IBKR data feed isn't logging candles like TWS. Fred Painchaud , we have all seen the data discrepancies cross-platform. This would refer to the same broker having different prices between its QC(IBKR) data feed and its own charting platform.
Fred Painchaud
Hi Alexander,
Yeah. So while this is not 100% sure, my point is why wouldn't the QC feed be different than the IBKR feed, even inside IBKR? I see two platforms there.
Fred
Alexander Klochenok
That's in essence my question in reverse… why would the IBKR API data that is sent to us be different from the data IB uses for its charts on TWS?
Fred Painchaud
Because of
Fred Painchaud
Hi Alex,
More seriously - if you use the QC feed in your algo while connected to an IBKR account, then, you use the QC feed. It can thus be different than the IBKR data feed. If you use the IBKR data feed from your algo, then, it should be == to the IBKR data feed, yes.
Fred
Mak K
Hi,
If there are “data issues” with solely the IBKR data feed I would suggest you message their support, otherwise I would say these are just data discrepancies as Fred pointed out,
Thanks!
Yuri Lopukhov
Perhaps I wasn't specific enough, but I am using IBKR data.
If I was using QC data, difference would be more than 1-2 ticks. Also, this should have given you more context:
“are ticks marked as suspicious if IBKR data is used?”
Thank you for your efforts, but it seems the link I provided above explains the problem quite well.
I can't accept my own answer though…
Fred Painchaud
Hi Yuri,
Then, I have no idea. I assumed the question was somehow related to QC/LEAN. But it seems it is 100% related to IBKR and how THEY handle THEIR data.
It looks like it would be a question for IBKR.
Maybe someone else on this forum will know why IBKR real-time is ≠ than IBKR TWS. And if they use the suspicious flag or not.
Fred
Yuri Lopukhov
Fred Painchaud
a) It related to HOW QC/LEAN retrieves IBKR data from IBKR API, which is not covered in documentation.
b) It is related to how QC live instances with IBKR data (which are rented by me and other QC users from QC) trade, so this is QC's area of responsibility. If I was using IBKR API directly, I would be talking to their support.
So I believe it is somehow related to QC/LEAN. if you cannot provide helpful feedback, please leave it for someone else.
Fred Painchaud
Hi Yuri,
Does
“Another point worth making is that the snapshots are taken at different times for different TWS sessions. This is sensible from IB's point of view because it means they don't have to send updates to all their thousands of users at once. But it has the interesting side effect that if you run two copies of TWS (eg different logins to the same account) you'll get slightly different data from them, because the snapshotting is not being done simultaneously.”
explain it?
Replace “different TWS sessions” with “one API connection and one TWS session".
Fred
Karl H
Hi Yuri. Yes, I just noticed similar discrepancies. Here are five recent closes for QQQ. I would think that closes would be a global standard value but apparently not. I'm guessing that inside of IBroker they are using one data provider for the charts and one for the API. Usually the differences are small, but not always. Half a percent difference could be serious in an algorithmic system.
Yuri Lopukhov
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!