Receiving Time and Sales data

View as MarkdownOpen in Claude

Data is returned to unique functions based on what is requested in the whatToShow field.

  • IBApi.EWrapper.historicalTicks for whatToShow=MIDPOINT
  • IBApi.EWrapper.historicalTicksBidAsk for whatToShow=BID_ASK
  • IBApi.EWrapper.historicalTicksLast for for whatToShow=TRADES

EWrapper.historicalTicks (

reqId: int, id of the request

ticks: ListOfHistoricalTick, object containing a list of tick values for the requested timeframe.

done: bool, return whether or not this is the end of the historical ticks requested.
)

For whatToShow=MIDPOINT

1def historicalTicks(self, reqId: int, ticks: ListOfHistoricalTickLast, done: bool):
2 for tick in ticks:
3 print("historicalTicks. ReqId:", reqId, tick)

EWrapper.historicalTicksBidAsk (

reqId: int, id of the request

ticks: ListOfHistoricalTick, object containing a list of tick values for the requested timeframe.

done: bool, return whether or not this is the end of the historical ticks requested.
)

For whatToShow=BidAsk

1def historicalTicksBidAsk(self, reqId: int, ticks: ListOfHistoricalTickLast, done: bool):
2 for tick in ticks:
3 print("historicalTicksBidAsk. ReqId:", reqId, tick)

EWrapper.historicalTicksLast (

reqId: int, id of the request

ticks: ListOfHistoricalTick, object containing a list of tick values for the requested timeframe.

done: bool, return whether or not this is the end of the historical ticks requested.
)

For whatToShow=Last & AllLast

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