¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

tickByTickAllLast returns tickType = 1 instead of 4


 

I noticed that `tickByTickAllLast` returns tickType = 1 (which is BID), while I was expecting LAST (4). The request was made with `reqTickByTickData`. Does anybody know why it is?


 

Not sure I understand exactly what you are asking. Can you clarify. to and not to .

It depends on the instrument and market condition. but the majority of trades take place at the current Ask price or the current Bid price. Below a snapshot from ESU2 this afternoon:

  • Both trades took place at the same price
  • But that was the current askPrice for the first trade and the current bidPrice for the second trade, since the Ask/Bid prices had changed between the trades.

TickByTickType Arrival Time IBKR TS LastPrice LastSize bPrice bSize aPrice aSize
TickByTickBidAsk 1659640500.459690 1659640500 ? ? 4,159.25 43 4,159.50 36
TickByTickLast 1659640500.459850 1659640500 4,159.50 6 ? ? ? ?
? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ?
TickByTickType Arrival Time IBKR TS LastPrice LastSize bPrice bSize aPrice aSize
TickByTickBidAsk 1659640500.583550 1659640500 ? ? 4,159.50 9 4,159.75 64
TickByTickLast 1659640500.583550 1659640500 4,159.50 2 ? ? ? ?


 

The parameter tickType in tickByTickAllLast() has no connection with the Tick Types of reqMktData().

Rather, it is related to the tickType argument used in : i.e. "Last" (1), "AllLast" (2), "BidAsk" (3) and "MidPoint" (4).

3 and 4 have dedicated callbacks whereas 1 and 2 both use with tickType set accordingly.


 

How do i subscribe to?TickByTickLast and?TickByTickBidAsk both for the same Contract/Instrument?

If I do

reqTickByTickData(ticker, contract, "Last", 0, true);
reqTickByTickData(ticker, contract, "BidAsk", 0, true);

for 2 contracts, meaning 4 requests

only one of the 2 for each contract get subscribed...


 

So what error message do you get?

I assume your variable "ticker" has the same value for both calls, but the requestId for each TWS API request must be unique in the sense that no two outstanding requests or subscriptions shall have the same requestId.

A good practice is that you create a function "nextRequestId()" that provides a unique ID for each TWS API request you make.

´³¨¹°ù²µ±ð²Ô


On Thu, Sep 7, 2023 at 05:47 AM, <gmpat4u@...> wrote:
How do i subscribe to?TickByTickLast and?TickByTickBidAsk both for the same Contract/Instrument?

If I do

reqTickByTickData(ticker, contract, "Last", 0, true);
reqTickByTickData(ticker, contract, "BidAsk", 0, true);

for 2 contracts, meaning 4 requests

only one of the 2 for each contract get subscribed...


 

Thanks I can try it out, yes I might be using same ticker for both - I presumed that both triggers separate callbacks so that could be ok...
Thanks again for taking time for this question...

On a separate note, can you please answer my question here if possible? I am waiting on that as well.
[email protected] | How do I know from the data coming to tickByTickAllLast whether its Buy (green) or Sell (red) indicated in the Time And Sale window of TWS