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.0,
    ask_size=480.0,
    volume=17353480.0,
    change=3.97,
    change_pct=0.58
)
FieldTypeDescription
conidintContract ID
symbolstrTicker symbol
lastfloatLast trade price
bidfloatBest bid price
askfloatBest ask price
bid_sizefloatBid size
ask_sizefloatAsk size
volumefloatDaily 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.

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.475
)
FieldTypeDescription
timestampintUnix timestamp (ms)
openfloatOpen price
highfloatHigh price
lowfloatLow price
closefloatClose price
volumefloatVolume

Duration & Bar Size Options

Duration: "1 D", "1 W", "1 M", "2 M"

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

Short-form History

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

Period: "1d", "1w", "1m", "2m"

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
}

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 during certain periods. Use get_quote() as fallback.

Contract ID Resolution

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

Returns: int or None