开云体育

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

API data not the same as TWS data?


 

Hi there. I'm retrieving data from stocks using a Python script and the methods?tickPrice, tickSize and updateMktDepthL2
?
It looks like it is working, but checking the data I get from the API is not?similar at all to the data shown in TWS (or other apps). I'm wondering if I'm doing things right. I have been?reading about this on the internet and it happens to be a common?subject. I know I should count with some deviation, the bars I could build with fetched?data are not going to be exactly?the same as the TWS bars, but the samples I have checked are far away from being close.?
?
I'm trying to build?a system that takes data from the order book and trades (prices) to make a study, but with the provided?accuracy is impossible. I don't need a 100% accuracy, let's say a 98% will be fine.?
?
By the way, I haven't found any documentation about the retrieved data, is there someone who can give me a link or confirm my understanding is right:
?
05/09/2024 15:29:59.427 HBAN tickPrice reqId: 3 tickType: BID price: 14.85 attrib: CanAutoExecute: 1 PastLimit: 0 PreOpen: 0
05/09/2024 15:29:59.427 HBAN tickSize reqId: 3 tickType: BID_SIZE size: 2300
?
The first line means an order has been filled in the BID side at 14.85? ?
The second line means the order had a size of 2300
So the last crossed price will be 14.85?
The same is true for ASK side orders.
?
05/09/2024 15:30:00.275 HBAN tickPrice reqId: 3 tickType: LAST price: 14.85 attrib: CanAutoExecute: 0 PastLimit: 0 PreOpen: 0
05/09/2024 15:30:00.276 HBAN tickSize reqId: 3 tickType: LAST_SIZE size: 2300?
?
This is much more tricky, it could be: 1) a confirmation of the previous trade, so they are always redundant, 2) Market orders crossed with other market orders
Could anyone confirm?
?
Thank you,


 

You are probably looking for the list of available tick types that you can find at

There you will see that BID, BID_SIZE, ASK, and ASK_SIZE are not related to trades but to, well, the current Bid/Ask prices and sizes. Trades are reported through the LAST and LAST_SIZE ticks.

You should not see any differences between prices in TWS and data feeds you receive from TWS as long as you compare the same data sources (such as real time data feeds from reqMktData, reqTickByTickData, reqRealTimeBars, and reqMktDepth or historical data). Due to their different nature and purposes, prices from different feeds can be different.

闯ü谤驳别苍

?

?

?
?
On Fri, Sep 13, 2024 at 07:20 AM, Lalo F. wrote:

Hi there. I'm retrieving data from stocks using a Python script and the methods?tickPrice, tickSize and updateMktDepthL2
?
It looks like it is working, but checking the data I get from the API is not?similar at all to the data shown in TWS (or other apps). I'm wondering if I'm doing things right. I have been?reading about this on the internet and it happens to be a common?subject. I know I should count with some deviation, the bars I could build with fetched?data are not going to be exactly?the same as the TWS bars, but the samples I have checked are far away from being close.?
?
I'm trying to build?a system that takes data from the order book and trades (prices) to make a study, but with the provided?accuracy is impossible. I don't need a 100% accuracy, let's say a 98% will be fine.?
?
By the way, I haven't found any documentation about the retrieved data, is there someone who can give me a link or confirm my understanding is right:
?
05/09/2024 15:29:59.427 HBAN tickPrice reqId: 3 tickType: BID price: 14.85 attrib: CanAutoExecute: 1 PastLimit: 0 PreOpen: 0
05/09/2024 15:29:59.427 HBAN tickSize reqId: 3 tickType: BID_SIZE size: 2300
?
The first line means an order has been filled in the BID side at 14.85? ?
The second line means the order had a size of 2300
So the last crossed price will be 14.85?
The same is true for ASK side orders.
?
05/09/2024 15:30:00.275 HBAN tickPrice reqId: 3 tickType: LAST price: 14.85 attrib: CanAutoExecute: 0 PastLimit: 0 PreOpen: 0
05/09/2024 15:30:00.276 HBAN tickSize reqId: 3 tickType: LAST_SIZE size: 2300?
?
This is much more tricky, it could be: 1) a confirmation of the previous trade, so they are always redundant, 2) Market orders crossed with other market orders
Could anyone confirm?
?
Thank you,