Skip to navigation

Earliest Data Point

View as MarkdownOpen in Claude

Introduction

EClient.reqHeadTimestamp() is used to find the first available point of data for a given whatToShow value. This data can then be used in tandem with EClient.reqHistoricalBars() or EClient.reqHistoricalTicks()

ReqHeadTimeStamp counts as an ongoing historical data request. As a result, users should always:

Request HeadTimeStamp

EClient.reqHeadTimestamp (tickerId, contract, whatToShow, useRTH, formatDate)

Returns the timestamp of earliest available historical data for a contract and data type.

tickerId
int

A unique identifier which will serve to identify the incoming data.

contract
object

The IBApi.Contract you are interested in.

whatToShow
string

The type of data to retrieve. See Historical Data Types

useRTH
int

Whether (1) or not (0) to retrieve data generated only within Regular Trading Hours (RTH)

formatDate
int

Using 1 will return UTC time in YYYYMMDD-hh:mm:ss format. Using 2 will return epoch time.

self.reqHeadTimeStamp(1, ContractSamples.USStockAtSmart(), "TRADES", 1, 1)

Receive HeadTimeStamp

EWrapper.headTimestamp(requestId, headTimestamp)

The data requested will be returned to EWrapper.headTimeStamp.

requestId
int

Request identifier used to track data.

headTimestamp
string

Value identifying earliest data date

def headTimestamp(self, reqId, headTimestamp):
print(reqId, headTimestamp)

Cancel HeadTimeStamp

EWrapper.cancelHeadTimeStamp(tickerId)

A reqHeadTimeStamp request can be cancelled with EClient.cancelHeadTimestamp

tickerId
int

Request identifier used to track data.

self.cancelHeadTimeStamp(14001)