Historical Time and Sales Data

High Resolution Historical Data

The highest granularity of historical data from LYNX's database can be retrieved using the API function LYNXApi.EClient.reqHistoricalTicks . This corresponds to the TWS Historical Time & Sales Window. TWS build 968+ and API version 973.04+ is required.

  • Historical Tick-By-Tick data is not available for combos
  • Data will not be returned from multiple trading sessions in a single request; Multiple requests must be used
  • To complete a full second, more ticks may be returned than requested

[!NOTE] The historical Time&Sales feature in Python API is available starting in API v973.06+.

** Python **

self.reqHistoricalTicks(18001, ContractSamples.USStockAtSmart(),
"20170712 21:39:33", "", 10, "TRADES", 1,True, [])

self.reqHistoricalTicks(18002, ContractSamples.USStockAtSmart(),"20170712 21:39:33", "", 10, "BID_ASK", 1, True, [])

self.reqHistoricalTicks(18003, ContractSamples.USStockAtSmart(),"20170712 21:39:33", "", 10,"MIDPOINT", 1, True, [])

** Java **

client.reqHistoricalTicks(18001, ContractSamples.USStockAtSmart(), "20170712 21:39:33", null, 10, "TRADES", 1, true, null);
client.reqHistoricalTicks(18002, ContractSamples.USStockAtSmart(), "20170712 21:39:33", null, 10, "BID_ASK", 1, true, null);
client.reqHistoricalTicks(18003, ContractSamples.USStockAtSmart(), "20170712 21:39:33", null, 10, "MIDPOINT", 1, true, null);
  • requestId, id of the request
  • contract, Contract object that is subject of query.
  • startDateTime, i.e. "20170701 12:01:00". Uses TWS timezone specified at login.
  • endDateTime, i.e. "20170701 13:01:00". In TWS timezone. Exactly one of startDateTime or endDateTime must be defined.
  • numberOfTicks, Number of distinct data points. Max is 1000 per request.
  • whatToShow, (Bid_Ask, Midpoint, or Trades) Type of data requested.
  • useRth, Data from regular trading hours (1), or all available hours (0).
  • ignoreSize, Omit updates that reflect only changes in size, and not price. Applicable to Bid_Ask data requests.
  • miscOptions Should be defined as null; reserved for internal use.

Data is returned to the functions LYNXApi.EWrapper.historicalTicks (for whatToShow=MIDPOINT), LYNXApi.EWrapper.historicalTicksBidAsk (for whatToShow=BID_ASK), and LYNXApi.EWrapper.historicalTicksLast for (for whatToShow=TRADES), depending on the type of data requested.

** Python **

def historicalTicks(self, reqId: int, ticks: ListOfHistoricalTick, done: bool):
    for tick in ticks:
        print("HistoricalTick. ReqId:", reqId, tick)

def historicalTicksBidAsk(self, reqId: int, ticks: ListOfHistoricalTickBidAsk,done: bool):
    for tick in ticks:
        print("HistoricalTickBidAsk. ReqId:", reqId, tick)

def historicalTicksLast(self, reqId: int, ticks: ListOfHistoricalTickLast,done: bool):
    for tick in ticks:
        print("HistoricalTickLast. ReqId:", reqId, tick)

** Java **

public void historicalTicks(int reqId, List<HistoricalTick> ticks, boolean done) {
for (HistoricalTick tick : ticks) {
    System.out.println(EWrapperMsgGenerator.historicalTick(reqId, tick.time(), tick.price(), tick.size()));

public void historicalTicksBidAsk(int reqId, List<HistoricalTickBidAsk> ticks, boolean done) {
for (HistoricalTickBidAsk tick : ticks) {
    System.out.println(EWrapperMsgGenerator.historicalTickBidAsk(reqId, tick.time(), tick.tickAttribBidAsk(), tick.priceBid(), tick.priceAsk(), tick.sizeBid(),

public void historicalTicksLast(int reqId, List<HistoricalTickLast> ticks, boolean done) {
for (HistoricalTickLast tick : ticks) {
    System.out.println(EWrapperMsgGenerator.historicalTickLast(reqId, tick.time(), tick.tickAttribLast(), tick.price(), tick.size(), tick.exchange(),