开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

discrepancy with historic data


 

Hi, when i download historic data on say BIDU, primary exchange is NASDAQ (ISLAND on ib) i dont get the correct info relating to open price.
?
For example, on the 5th Feb just gone, the open price for BIDU was 90.21 according to TWS tick history which correlates to the info on the TWS quote summary, but when i download, with primary exchange set to ISLAND?
i get 90.28. Infact i cant get 90.21 with any variation i can think of sofar? Does anyone have any thoughts on why this is? Is it a shortcoming of the download functionality or could i be doing something else incorrect? Regards B.
?
contract = Stock('BIDU', 'ISLAND', 'USD')
? ? ? ? ? ? ? ? ? ? ib.qualifyContracts(contract)
? ? ? ? ? ? ? ??? ? ? ? ? ? ? ?
bars = ib.reqHistoricalData(
? ? ? ? ? ? ? ? ? ? ? ? ? ? contract,
? ? ? ? ? ? ? ? ? ? ? ? ? ? endDateTime='',
? ? ? ? ? ? ? ? ? ? ? ? ? ? durationStr='1 Y',
? ? ? ? ? ? ? ? ? ? ? ? ? ? barSizeSetting='1 Day',
? ? ? ? ? ? ? ? ? ? ? ? ? ? whatToShow='TRADES',
? ? ? ? ? ? ? ? ? ? ? ? ? ? useRTH=True,
? ? ? ? ? ? ? ? ? ? ? ? ? ? formatDate=2)


 

Hey woolloomooloo,?
?
Yahoo Finance shows the opening price was $90.25. Perhaps they had the same issue as you (seeing the two numbers of 9.21 and 9.28) and just took an average of the two lol.
?
?
Pulling up BIDU's opening price data on 2/5/25, I show the following price action (note that I'm on MST so the market opens at 7:30 for me):
?
?
The above data is sorted Z-A and the bottom-most 4 rows have a code of T indicating those trades were made during non-regular trading hours.?Hovering over and clicking on the code's link takes me to this site here:
?
I imagine the the API's opening price of $90.28 is based on the 4th row (whose value is $90.28 and is the final row having a code of T) or perhaps it's the 5th row's data (whose value is $90.29^8, whatever that means).
?
A few rows further up, we find your $90.21 for the ISLAND exchange with a code of Q, which I believe is the number that you saw a month ago.?
?
All that to say, the two numbers are valid for different reasons. Hopefully that helps clear up the mystery that you were staring down. I for one hate to endure mysteries when my money is involved.?
?
?


 

For the opening there's an auction and the price of the auction is the opening price (code=Q); note the high volume.
In-between the first ticks and the big auction there are some odd-lot trades (code=I) that could not be matched.
?
On the other hand, ticks relate to normal trade and the first tick is different than the opening auction price.
?
There is a good explanation on CME client systems wiki if you are so technically inclined. Here's an intro video that summarizes the approach.
I assume it's similar on the exchange you mentioned.
?
Net, for you as a trader, if you want to catch the opening price, you need to use:
- MOO orders (MKT with TIF=OPG) -> you get what price you get but guaranteed
- LOO orders (LMT with TIF=OPG) -> you try to make the market and have a say in the auction; if your limit is way off the auction price, it stays as normal LMT order after the auction
- LMT orders that are enabled for outside liquid hours (LMT with TIF=GTC and Outside RTH = True)
- OVERNIGHT orders
- non-US Auctions: MOO orders (MTL with TIF=AUC)
?
NB: IB might simulate MKT orders even if they are earmarked for open (TIF=OPG).
NB2: Back testing and paper trade cannot deal with the opening auction.
?
How and where you want to include the opening price - you need to really think about it hard.
?
* Liquidity: For 1 lot, don't worry about it. If you have $10m exposure and you need to get out cause some news came out, then you wouldn't be asking here. So don't worry about it.
* Trading Strategy: If 90.21 vs 90.28 is a deal breaker for your strategy, then the strategy is wrong 100%. I said.


 

thanks for the responses. i realised/figured out that the open print will get the first trade after 9.30.00 which isn't necessarily the open auction.