Skip to content

Market Data

Quotes

python
quote = client.get_quote("SPY")

Returns: Quote dataclass

python
Quote(
    conid=756733,
    symbol='SPY',
    last=693.2,
    bid=693.19,
    ask=693.2,
    bid_size=5560,
    ask_size=480,
    volume=17353480,
    change=3.97,
    change_pct=0.58
)
FieldTypeDescription
conidintContract ID
symbolstrTicker symbol
lastfloatLast trade price
bidfloatBest bid price
askfloatBest ask price
bid_sizeintBid size
ask_sizeintAsk size
volumeintDaily volume
changefloatPrice change
change_pctfloatPercent change

Quick Price

python
price = client.get_price("SPY")  # Returns float: 693.2

Returns last price, falls back to bid or ask if unavailable.

Batch Quotes

Fetch quotes for multiple symbols in a single call:

python
quotes = client.get_tickers("SPY", "QQQ", "IWM", "DIA")

Returns: List[Quote]

python
[
    Quote(conid=756733, symbol='SPY', last=693.2, bid=693.19, ask=693.2, ...),
    Quote(conid=320227571, symbol='QQQ', last=520.15, bid=520.14, ask=520.16, ...),
    ...
]

More efficient than calling get_quote() in a loop. Falls back to individual lookups if batch endpoint fails.

Dividend Yield

python
data = client.get_dividend_yield("SPY")

Returns: Dict

python
{
    'conid': 756733,
    'symbol': 'SPY',
    'dividend_yield': 0.0099,
    'annual_dividend_forward': 7.32,
    'annual_dividend_ttm': 7.38,
    'spot_price': 738.94,
    'yield_basis': 'forward_12m',
    'market_data_availability': 'RpB'
}

Fund Account Behavior

Fund accounts may return None for dividend yield and greeks fields. Paper accounts return string-formatted values.

Historical Bars

python
bars = client.get_historical_bars("SPY", duration="2 M", bar_size="1 day")

Returns: List[Bar]

python
Bar(
    timestamp=1769178600000,
    open=688.15,
    high=690.96,
    low=687.16,
    close=689.23,
    volume=1207682
)
FieldTypeDescription
timestampintUnix timestamp (ms)
openfloatOpen price
highfloatHigh price
lowfloatLow price
closefloatClose price
volumeintVolume

Duration & Bar Size Options

Duration (IB-style strings):

DaysWeeksMonthsYears
"1 D", "2 D", "3 D", "4 D", "5 D", "7 D", "10 D", "14 D""1 W", "2 W", "3 W", "4 W""1 M", "2 M", "3 M", "6 M""1 Y", "2 Y"

Case-insensitive: "5 D", "5 d", and "5D" all work.

Bar Size: "1 min", "5 mins", "15 mins", "30 mins", "1 hour", "1 day"

Historical Data (pandas)

python
df = client.get_historical_data("SPY", duration="1 D", bar_size="30 mins")

Returns: pd.DataFrame with columns: date, open, high, low, close, volume.

Short-form History

python
bars = client.get_history("SPY", period="1d", bar_size="5min")

Returns: List[Bar]

Period (short-form): "1d", "2d", "3d", "4d", "5d", "7d", "10d", "14d", "1w""4w", "1m""6m", "1y""2y"

Bar Size: "1min", "5min", "15min", "30min", "1h", "1d"

Market Depth (L2)

python
depth = client.get_market_depth(conid, rows=3)

Returns: Dict

python
{
    'conid': 756733,
    'bid': 693.19,
    'ask': 693.2,
    'bid_size': 5560.0,
    'ask_size': 480.0,
    'rows': 3
}

Returns parsed floats. Use this instead of get_option_quote() when you need numeric bid/ask for options.

Last Trade

python
last = client.get_last_trade(conid)

Returns: Dict

python
{
    'conid': 756733,
    'last': 693.2,
    'last_size': 100.0,
    'volume': 17353480.0
}

WARNING

For indices like SPX, last may be None. Use get_quote("SPX") which pulls snapshot fields for indices.

Tick History

python
ticks = client.get_ticks(conid, start="20260126-09:30:00", end="20260126-16:00:00")

Returns: Dict with tick data. tick_type defaults to "TRADES".

Halt Status

python
status = client.get_halt_status(conid)
halted = client.is_halted(conid)  # Returns bool

Trading Hours

python
hours = client.get_trading_hours("SPY")
is_open = client.is_market_open_for("SPY")  # Returns bool

Contract ID Resolution

python
conid = client.get_conid("SPY")           # Stock: 756733
conid = client.get_index_conid("SPX")     # Index: 416904

Returns: int or None