• C#
  • Java
  • VB
  • C++
  • Python
Contact us
Tick-by-Tick Data

Tick-by-tick data corresponding to the data shown in the TWS Time & Sales Window is available starting with TWS v969 and API v973.04. The maximum number of simultaneous tick-by-tick subscriptions allowed for a user is determined by the same formula used to calculate maximum number of market depth subscriptions Limitations.

  • The tick type field is case sensitive - it must be BidAsk, Last, AllLast, MidPoint. AllLast has additional trade types such as combos, derivatives, and average price trades which are not included in Last.
  • Tick-by-tick data for options is currently only available historically and not in real time.
  • Tick-by-tick data for indices is only provided for indices which are on CME.
  • Tick-by-tick data is not available for combos.
  • No more than 1 tick-by-tick request can be made for the same instrument within 15 seconds.
  • client.reqTickByTickData(19001, ContractSamples.USStockAtSmart(), "Last", 0, false);
    client.reqTickByTickData(19002, ContractSamples.USStockAtSmart(), "AllLast", 0, false);
    client.reqTickByTickData(19003, ContractSamples.USStockAtSmart(), "BidAsk", 0, true);
    client.reqTickByTickData(19004, ContractSamples.EurGbpFx(), "MidPoint", 0, false);
  • client.reqTickByTickData(19001, ContractSamples.USStockAtSmart(), "Last", 0, false);
    client.reqTickByTickData(19002, ContractSamples.USStockAtSmart(), "AllLast", 0, false);
    client.reqTickByTickData(19003, ContractSamples.USStockAtSmart(), "BidAsk", 0, true);
    client.reqTickByTickData(19004, ContractSamples.EurGbpFx(), "MidPoint", 0, false);
  • client.reqTickByTickData(19001, ContractSamples.EuropeanStock(), "Last", 0, False)
    client.reqTickByTickData(19002, ContractSamples.EuropeanStock(), "AllLast", 0, False)
    client.reqTickByTickData(19003, ContractSamples.EuropeanStock(), "BidAsk", 0, True)
    client.reqTickByTickData(19004, ContractSamples.EurGbpFx(), "MidPoint", 0, False)
  • m_pClient->reqTickByTickData(20005, ContractSamples::EuropeanStock(), "Last", 10, false);
    m_pClient->reqTickByTickData(20006, ContractSamples::EuropeanStock(), "AllLast", 10, false);
    m_pClient->reqTickByTickData(20007, ContractSamples::EuropeanStock(), "BidAsk", 10, false);
    m_pClient->reqTickByTickData(20008, ContractSamples::EurGbpFx(), "MidPoint", 10, true);
  • 1  self.reqTickByTickData(19001, ContractSamples.EuropeanStock2(), "Last", 0, True)
    2  self.reqTickByTickData(19002, ContractSamples.EuropeanStock2(), "AllLast", 0, False)
    3  self.reqTickByTickData(19003, ContractSamples.EuropeanStock2(), "BidAsk", 0, True)
    4  self.reqTickByTickData(19004, ContractSamples.EurGbpFx(), "MidPoint", 0, False)

Depending on the data type chosen in IBApi::EClient::reqTickByTickData, data will be returned to one of the functions IBApi::EWrapper::tickByTickAllLast, IBApi::EWrapper::tickByTickBidAsk, or IBApi::EWrapper::tickByTickMidPoint. Additionally, if a non-zero value is input for the argument numberOfTicks in IBApi::EClient::reqTickByTickData, historical tick data is first returned to one of the functions IBApi::EWrapper::historicalTicksLast, IBApi::EWrapper::historicalTicksBidAsk, or IBApi::EWrapper::historicalTicks, respectively.

  • public void tickByTickBidAsk(int reqId, long time, double bidPrice, double askPrice, int bidSize, int askSize, TickAttribBidAsk tickAttribBidAsk)
    {
    Console.WriteLine("Tick-By-Tick. Request Id: {0}, TickType: BidAsk, Time: {1}, BidPrice: {2}, AskPrice: {3}, BidSize: {4}, AskSize: {5}, BidPastLow: {6}, AskPastHigh: {7}",
    reqId, Util.UnixSecondsToString(time, "yyyyMMdd-HH:mm:ss zzz"), bidPrice, askPrice, bidSize, askSize, tickAttribBidAsk.BidPastLow, tickAttribBidAsk.AskPastHigh);
    }
  • @Override
    public void tickByTickBidAsk(int reqId, long time, double bidPrice, double askPrice, int bidSize, int askSize,
    TickAttribBidAsk tickAttribBidAsk) {
    System.out.println(EWrapperMsgGenerator.tickByTickBidAsk(reqId, time, bidPrice, askPrice, bidSize, askSize, tickAttribBidAsk));
    }
  • Public Sub tickByTickBidAsk(reqId As Integer, time As Long, bidPrice As Double, askPrice As Double, bidSize As Integer, askSize As Integer, tickAttribBidAsk As TickAttribBidAsk) Implements EWrapper.tickByTickBidAsk
    Console.WriteLine("Tick-By-Tick. Request Id: {0}, TickType: BidAsk, Time: {1}, BidPrice: {2}, AskPrice: {3}, BidSize: {4}, AskSize: {5}, BidPastLow: {6}, AskPastHigh: {7}",
    reqId, Util.UnixSecondsToString(time, "yyyyMMdd-HH:mm:ss zzz"), bidPrice, askPrice, bidSize, askSize, tickAttribBidAsk.BidPastLow, tickAttribBidAsk.AskPastHigh)
    End Sub
  • void TestCppClient::tickByTickBidAsk(int reqId, time_t time, double bidPrice, double askPrice, int bidSize, int askSize, const TickAttribBidAsk& tickAttribBidAsk) {
    printf("Tick-By-Tick. ReqId: %d, TickType: BidAsk, Time: %s, BidPrice: %g, AskPrice: %g, BidSize: %d, AskSize: %d, BidPastLow: %d, AskPastHigh: %d\n",
    reqId, ctime(&time), bidPrice, askPrice, bidSize, askSize, tickAttribBidAsk.bidPastLow, tickAttribBidAsk.askPastHigh);
    }
  • 1  def tickByTickBidAsk(self, reqId: int, time: int, bidPrice: float, askPrice: float,
    2  bidSize: int, askSize: int, tickAttribBidAsk: TickAttribBidAsk):
    3  super().tickByTickBidAsk(reqId, time, bidPrice, askPrice, bidSize,
    4  askSize, tickAttribBidAsk)
    5  print("BidAsk. ReqId:", reqId,
    6  "Time:", datetime.datetime.fromtimestamp(time).strftime("%Y%m%d %H:%M:%S"),
    7  "BidPrice:", bidPrice, "AskPrice:", askPrice, "BidSize:", bidSize,
    8  "AskSize:", askSize, "BidPastLow:", tickAttribBidAsk.bidPastLow, "AskPastHigh:", tickAttribBidAsk.askPastHigh)


  • public void tickByTickAllLast(int reqId, int tickType, long time, double price, int size, TickAttribLast tickAttribLast, string exchange, string specialConditions)
    {
    Console.WriteLine("Tick-By-Tick. Request Id: {0}, TickType: {1}, Time: {2}, Price: {3}, Size: {4}, Exchange: {5}, Special Conditions: {6}, PastLimit: {7}, Unreported: {8}",
    reqId, tickType == 1 ? "Last" : "AllLast", Util.UnixSecondsToString(time, "yyyyMMdd-HH:mm:ss zzz"), price, size, exchange, specialConditions, tickAttribLast.PastLimit, tickAttribLast.Unreported);
    }
  • @Override
    public void tickByTickAllLast(int reqId, int tickType, long time, double price, int size, TickAttribLast tickAttribLast,
    String exchange, String specialConditions) {
    System.out.println(EWrapperMsgGenerator.tickByTickAllLast(reqId, tickType, time, price, size, tickAttribLast, exchange, specialConditions));
    }
  • Public Sub tickByTickAllLast(reqId As Integer, tickType As Integer, time As Long, price As Double, size As Integer, tickAttribLast As TickAttribLast, exchange As String, specialConditions As String) Implements EWrapper.tickByTickAllLast
    Dim tickTypeStr As String
    If tickType = 1 Then
    tickTypeStr = "Last"
    Else
    tickTypeStr = "AllLast"
    End If
    Console.WriteLine("Tick-By-Tick. Request Id: {0}, TickType: {1}, Time: {2}, Price: {3}, Size: {4}, Exchange: {5}, Special Conditions: {6}, PastLimit: {7}, Unreported: {8}",
    reqId, tickTypeStr, Util.UnixSecondsToString(time, "yyyyMMdd-HH:mm:ss zzz"), price, size, exchange, specialConditions, tickAttribLast.PastLimit, tickAttribLast.Unreported)
    End Sub
  • void TestCppClient::tickByTickAllLast(int reqId, int tickType, time_t time, double price, int size, const TickAttribLast& tickAttribLast, const std::string& exchange, const std::string& specialConditions) {
    printf("Tick-By-Tick. ReqId: %d, TickType: %s, Time: %s, Price: %g, Size: %d, PastLimit: %d, Unreported: %d, Exchange: %s, SpecialConditions:%s\n",
    reqId, (tickType == 1 ? "Last" : "AllLast"), ctime(&time), price, size, tickAttribLast.pastLimit, tickAttribLast.unreported, exchange.c_str(), specialConditions.c_str());
    }
  • 1  def tickByTickAllLast(self, reqId: int, tickType: int, time: int, price: float,
    2  size: int, tickAtrribLast: TickAttribLast, exchange: str,
    3  specialConditions: str):
    4  super().tickByTickAllLast(reqId, tickType, time, price, size, tickAtrribLast,
    5  exchange, specialConditions)
    6  if tickType == 1:
    7  print("Last.", end='')
    8  else:
    9  print("AllLast.", end='')
    10  print(" ReqId:", reqId,
    11  "Time:", datetime.datetime.fromtimestamp(time).strftime("%Y%m%d %H:%M:%S"),
    12  "Price:", price, "Size:", size, "Exch:" , exchange,
    13  "Spec Cond:", specialConditions, "PastLimit:", tickAtrribLast.pastLimit, "Unreported:", tickAtrribLast.unreported)
  • Trade data for non-reportable trades, such as combos and block trades, are included in the 'AllLast' data type available with the real time data feed but are not recorded in the historical database.


  • public void tickByTickMidPoint(int reqId, long time, double midPoint)
    {
    Console.WriteLine("Tick-By-Tick. Request Id: {0}, TickType: MidPoint, Time: {1}, MidPoint: {2}",
    reqId, Util.UnixSecondsToString(time, "yyyyMMdd-HH:mm:ss zzz"), midPoint);
    }
  • @Override
    public void tickByTickMidPoint(int reqId, long time, double midPoint) {
    System.out.println(EWrapperMsgGenerator.tickByTickMidPoint(reqId, time, midPoint));
    }
  • Public Sub tickByTickMidPoint(reqId As Integer, time As Long, midPoint As Double) Implements EWrapper.tickByTickMidPoint
    Console.WriteLine("Tick-By-Tick. Request Id: {0}, TickType: MidPoint, Time: {1}, MidPoint: {2}",
    reqId, Util.UnixSecondsToString(time, "yyyyMMdd-HH:mm:ss zzz"), midPoint)
    End Sub
  • void TestCppClient::tickByTickMidPoint(int reqId, time_t time, double midPoint) {
    printf("Tick-By-Tick. ReqId: %d, TickType: MidPoint, Time: %s, MidPoint: %g\n", reqId, ctime(&time), midPoint);
    }
  • 1  @iswrapper
    2  def tickByTickMidPoint(self, reqId: int, time: int, midPoint: float):
    3  super().tickByTickMidPoint(reqId, time, midPoint)
    4  print("Midpoint. ReqId:", reqId,
    5  "Time:", datetime.datetime.fromtimestamp(time).strftime("%Y%m%d %H:%M:%S"),
    6  "MidPoint:", midPoint)


Tick-by-tick subscriptions can be cancelled using the function IBApi::EClient::cancelTickByTickData

  • client.cancelTickByTickData(19001);
    client.cancelTickByTickData(19002);
    client.cancelTickByTickData(19003);
    client.cancelTickByTickData(19004);
  • client.cancelTickByTickData(19001);
    client.cancelTickByTickData(19002);
    client.cancelTickByTickData(19003);
    client.cancelTickByTickData(19004);
  • client.cancelTickByTickData(19001)
    client.cancelTickByTickData(19002)
    client.cancelTickByTickData(19003)
    client.cancelTickByTickData(19004)
  • m_pClient->cancelTickByTickData(20001);
    m_pClient->cancelTickByTickData(20002);
    m_pClient->cancelTickByTickData(20003);
    m_pClient->cancelTickByTickData(20004);
  • 1  self.cancelTickByTickData(19001)
    2  self.cancelTickByTickData(19002)
    3  self.cancelTickByTickData(19003)
    4  self.cancelTickByTickData(19004)