Historical OHLC Bar Data

View as MarkdownOpen in Claude
Request historical data for an instrument in the form of OHLC bars.

Query parameters

conidlongRequired
IB contract ID of the requested instrument.
periodstringRequiredDefaults to 1d
A time duration away from startTime into the future to be divided into bars of the specified width. Supported Period Sizes * `min` - Minutes * `h` - Hour(s) * `d` - Day(s) * `w` - Week(s) * `m` - Month(s) * `y` - Year(s)
barstringRequiredDefaults to 1min
The width of the bars into which the interval determined by period and startTime will be divided. It is not required that bar evenly divide period; partial bars can be returned. Supported Bar Sizes * `S` - Second(s) * `min` - Minute(s) * `h` - Hour(s) * `d` - Day(s) * `w` - Week(s) * `m` - Month(s)
exchangestringOptional

Exchange (or SMART) from which data is requested.

outsideRthbooleanOptionalDefaults to false
Indicates whether data outside of regular trading hours should be included in response.
startTimestringOptional

A fixed UTC date-time reference point for the historical data request, from which the specified period extends. Format is YYYYMMDD-hh:mm:ss. If omitted, the current time is used, and direction must be omitted or 1.

directionenumOptionalDefaults to -1
Indicates whether data should begin or end at the start time. * `-1` - Historical data will begin away from the start time, ending at the current time/startTime. * `1` - Historical data begins at the start time, moving towards the current time. Only supported when startTime is included.
Allowed values:
sourcestringOptionalDefaults to Last
The type of data to be returned in the historical bars. Supported Bar Sizes * `Bid_Ask` - The OHLC bid/ask values. * `Last` - The OHLC trade values. * `Midpoint` - The OHLC of the Bid-Ask midpoint.

Response

Historical data query successfully returned data.
iserverHistoryBidAskResponseobject
Object containing the requested historical data and related metadata.
OR
iserverHistoryLastResponseobject
Object containing the requested historical data and related metadata.
OR
iserverHistoryMidpointResponseobject
Object containing the requested historical data and related metadata.

Errors

400
Bad Request Error
401
Unauthorized Error
500
Internal Server Error
503
Service Unavailable Error