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

def historicalTicks(self, reqId: int, ticks: ListOfHistoricalTickLast, done: bool):
for tick in ticks:
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

def historicalTicksBidAsk(self, reqId: int, ticks: ListOfHistoricalTickLast, done: bool):
for tick in ticks:
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

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