Get a marketdata ticker for a symbol and venue. Tickers include basic summary statistics like volumes, open interest, settlement price, as well as slowly changing dimensions e.g. dividend yields, P/E ratios, market caps for equities.
ticker = await client.get_ticker(
symbol="AAPL US Equity/USD",
venue="US-EQUITIES"
)
use architect_api::marketdata::Ticker;
let ticker: Ticker = client.get_ticker("AAPL US Equity/USD", "US-EQUITIES").await?;
use architect_api::marketdata::L1BookSnapshot;
let snap: L1BookSnapshot = client.get_l1_book_snapshot(
"GC 20250626 CME Future/USD",
"CME"
).await?;
// get multiple snapshots
let snaps: Vec<L1BookSnapshot> = client.get_l1_book_snapshots(
&[
"GC 20250626 CME Future/USD",
"ES 20250620 CME Future/USD"
],
"CME"
).await?;
{
"s": "GC 20250626 CME Future/USD", // symbol
"tn": 710661000, // timestamp (seconds since epoch)
"ts": 1747336563, // nanoseconds part of timestamp
"a": ["3227.500000000", "3"], // ask price and size
"b": ["3227.200000000", "3"] // bid price and size
}
Stream L1 book snapshots
Stream L1 book snapshots for the given symbols, for the given venue.
async for snap in client.stream_l1_book_snapshots(
symbols=["BTC Crypto/USD"],
venue="COINBASE"
):
print(snap)
use architect_api::marketdata::L1BookSnapshot;
use futures::StreamExt;
let mut stream = client.stream_l1_book_snapshots(&["BTC Crypto/USD"], "COINBASE").await?;
while let Some(item) = stream.next().await {
let snap: L1BookSnapshot = item?;
}
Subscribe to L1 book
Subscribe to the L1 book for a symbol and venue in a background task. The current state of the book is available anytime via the returned reference. Calling subscribe again for the same symbol and venue will return the same reference. Call the unsubscribe method to terminate the subscription.
Stream L2 book updates for a given symbol and venue. This is a diff stream; the first message will contain a full snapshot, and subsequent messages represent diffs to be applied successively to maintain the state of the book.
from architect_py import L2BookSnapshot, L2BookDiff
async for update in client.stream_l2_book_updates(
symbol="BTC Crypto/USD",
venue="COINBASE"
):
if isinstance(update, L2BookSnapshot):
print(update)
elif isinstance(update, L2BookDiff):
print(update)
use architect_api::marketdata::L2BookUpdate;
use futures::StreamExt;
let mut stream = client.stream_l2_book_updates("BTC Crypto/USD", "COINBASE").await?;
while let Some(item) = stream.next().await {
let up = item?;
match up {
L2BookUpdate::Snapshot(snap) => {},
L2BookUpdate::Diff(diff) => {}
}
}
Applying diffs
For each diff message, a price level with non-zero quantity indicates that that price level should be updated to the stated quantity. A price level with a quantity of zero indicates that the price level should be removed from the book.
Sequence numbers
Sequence numbers are monotonically increasing integers that are assigned to each message. They can be used to detect gaps in the stream. From the first snapshot, each diff message should have a sequence number that is exactly one greater than the sequence number of the last received update.
Additionally, messages include a sequence ID field. Sequence IDs must be the same for all updates in a stream; if the sequence ID is observed to change, diff updates are no longer valid and the subscription should be restarted with a new snapshot.
Subscribe to L2 book
Subscribe to and maintain an L2 book for a given symbol and venue in a background task. The current state of the book is available anytime via the returned reference. Calling subscribe again for the same symbol and venue will return the same reference.
book = await client.subscribe_l2_book(
symbol="BTC Crypto/USD",
venue="COINBASE"
)
Stream trades
Stream the latest trades for a given symbol and venue.
async for trade in client.stream_trades(
symbol="BTC Crypto/USD",
venue="COINBASE"
):
print(trade)
use architect_api::marketdata::Trade;
use futures::StreamExt;
let mut stream = client.stream_trades(Some("BTC Crypto/USD"), "CME").await?;
while let Some(item) = stream.next().await {
let trade: Trade = item?;
}
{
"s": "BTC Crypto/USD", // symbol
"tn": 710661000, // timestamp (seconds since epoch)
"ts": 1747336563, // nanoseconds part of timestamp
"p": "3227.200000000", // price
"q": "3", // size
"d": "BUY" // trade direction or side
}
Stream candles (klines)
Candles are produced at different fixed periods and include the open, high, low, close, and volumes for that period. Not all exchange feeds produce all candle widths.
from architect_py import CandleWidth
stream = client.stream_candles(
symbol="BTC Crypto/USD",
venue="COINBASE",
candle_widths=[CandleWidth.OneSecond]
)
async for candle in stream:
print(candle)
use architect_api::marketdata::{Candle, CandleWidth};
use futures::StreamExt;
let mut stream = client.stream_candles(
"BTC Crypto/USD",
"COINBASE",
Some(&[CandleWidth::OneSecond])
).await?;
while let Some(item) = stream.next().await {
let candle: Candle = item?;
}
Streaming candles availability and request limits
Venue
Available candle widths for streaming
CME
1s, 1h, 15m, 1h, 1d
CFE
1s, 1h, 15m, 1h, 1d
US-EQUITIES
Get historical candles
Retrieve historical candles for a symbol and venue.
from architect_py import CandleWidth
from datetime import datetime, timedelta, timezone
candles = await client.get_historical_candles(
symbol="GC 20250428 CME Future/USD",
venue="CME",
candle_width=CandleWidth.OneHour,
start=datetime.now(timezone.utc) - timedelta(days=1),
end=datetime.now(timezone.utc)
# pass as_dataframe=True to return a pandas DataFrame
)
use architect_api::marketdata::{Candle, CandleWidth};
use chrono::{Utc, Duration};
let now = Utc::now();
let candles: Vec<Candle> = client.get_historical_candles(
"GC 20250428 CME Future/USD",
"CME",
CandleWidth::OneHour,
now - Duration::hours(12),
now
).await?;
{
"s": "GC 20250626 CME Future/USD", // symbol
"w": 3600, // width
"tn": 0, // timestamp (seconds since epoch)
"ts": 1747292400, // nanoseconds part of timestamp
"v": "14029", // volume
"av": "6767", // ask volume
"bv": "6748", // bid volume
"o": "3153.500000000", // open price
"h": "3155.500000000", // high price
"l": "3134.200000000", // low price
"c": "3145.400000000", // close price
"ao": "3153.500000000", // ask open price
"ah": "3155.600000000", // ask high price
"al": "3134.300000000", // ask low price
"ac": "3145.400000000", // ask close price
"bo": "3153.200000000", // bid open price
"bh": "3155.400000000", // bid high price
"bl": "3134.000000000", // bid low price
"bc": "3145.100000000", // bid close price
"mo": "3153.3500000000", // mid price
"mh": "3155.5000000000", // mid high price
"ml": "3134.1500000000", // mid low price
"mc": "3145.2500000000", // mid close price
}
Historical candles availability and request limits