Appearance
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
)| Field | Type | Description |
|---|---|---|
conid | int | Contract ID |
symbol | str | Ticker symbol |
last | float | Last trade price |
bid | float | Best bid price |
ask | float | Best ask price |
bid_size | float | Bid size |
ask_size | float | Ask size |
volume | float | Daily volume |
change | float | Price change |
change_pct | float | Percent change |
Quick Price
python
price = client.get_price("SPY") # Returns float: 693.2Returns 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
)| Field | Type | Description |
|---|---|---|
timestamp | int | Unix timestamp (ms) |
open | float | Open price |
high | float | High price |
low | float | Low price |
close | float | Close price |
volume | float | Volume |
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: 416904Returns: int or None