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.
** Python **
self.reqTickByTickData(19001, ContractSamples.EuropeanStock2(), "Last", 0, True)
self.reqTickByTickData(19002, ContractSamples.EuropeanStock2(), "AllLast", 0, False)
self.reqTickByTickData(19003, ContractSamples.EuropeanStock2(), "BidAsk", 0, True)
self.reqTickByTickData(19004, ContractSamples.EurGbpFx(), "MidPoint", 0, False)
** Java **
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);
Depending on the data type chosen in LYNXApi.EClient.reqTickByTickData , data will be returned to one of the functions LYNXApi.EWrapper.tickByTickAllLast , LYNXApi.EWrapper.tickByTickBidAsk , or LYNXApi.EWrapper.tickByTickMidPoint . Additionally, if a non-zero value is input for the argument numberOfTicks in LYNXApi.EClient.reqTickByTickData , historical tick data is first returned to one of the functions LYNXApi.EWrapper.historicalTicksLast , LYNXApi.EWrapper.historicalTicksBidAsk , or LYNXApi.EWrapper.historicalTicks , respectively.
** Python **
def tickByTickBidAsk(self, reqId: int, time: int, bidPrice: float, askPrice: float,bidSize: int, askSize: int, tickAttribBidAsk: TickAttribBidAsk):
super().tickByTickBidAsk(reqId, time, bidPrice, askPrice, bidSize,
askSize, tickAttribBidAsk)
print("BidAsk. ReqId:", reqId,"Time:", datetime.datetime.fromtimestamp(time).strftime("%Y%m%d %H:%M:%S"),
"BidPrice:", bidPrice, "AskPrice:", askPrice, "BidSize:", bidSize,
"AskSize:", askSize, "BidPastLow:", tickAttribBidAsk.bidPastLow, "AskPastHigh:", tickAttribBidAsk.askPastHigh)
** Java **
@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));
}
** Python **
def tickByTickAllLast(self, reqId: int, tickType: int, time: int, price: float, size: int, tickAtrribLast: TickAttribLast, exchange: str, specialConditions: str):
super().tickByTickAllLast(reqId, tickType, time, price, size,
tickAtrribLast,exchange,
specialConditions)
if tickType == 1:
print("Last.", end='')
else:
print("AllLast.", end='')
print(" ReqId:", reqId,"Time:",
datetime.datetime.fromtimestamp(time).strftime("%Y%m%d %H:%M:%S"), "Price:", price, "Size:", size, "Exch:" , exchange,"Spec Cond:", specialConditions, "PastLimit:", tickAtrribLast.pastLimit, "Unreported:", tickAtrribLast.unreported)
** Java **
@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));
}
- 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.
** Python **
@iswrapper
def tickByTickMidPoint(self, reqId: int, time: int, midPoint: float):
super().tickByTickMidPoint(reqId, time, midPoint)
print("Midpoint. ReqId:", reqId,
"Time:",
datetime.datetime.fromtimestamp(time).strftime("%Y%m%d
%H:%M:%S"),
"MidPoint:",
midPoint)
** Java **
@Override
public void tickByTickMidPoint(int reqId, long time, double midPoint) {
System.out.println(EWrapperMsgGenerator.tickByTickMidPoint(reqId, time, midPoint));
}
** Python **
self.cancelTickByTickData(19001)
self.cancelTickByTickData(19002)
self.cancelTickByTickData(19003)
self.cancelTickByTickData(19004)
** Java **
client.cancelTickByTickData(19001);
client.cancelTickByTickData(19002);
client.cancelTickByTickData(19003);
client.cancelTickByTickData(19004);
Tick-by-tick subscriptions can be cancelled using the function LYNXApi.EClient.cancelTickByTickData