polaris-data.
Install
polaris-data and the crate name is polaris_data.
Or add it manually to Cargo.toml:
Quickstart
Useevents(...) when you want standardized historical rows in an async service or backfill job.
Create a client
If you omitapi_key, the client reads POLARIS_API_KEY from the environment.
Core methods
UsePolarisClient for discovery and snapshot-backed historical queries.
from and to accept ISO 8601 strings, chrono::DateTime<Utc>, or Unix epoch milliseconds as i64 or u64. If you omit one or both bounds, the SDK infers a bounded historical range from catalog metadata, using the latest 7 days by default and applying public cutoff rules for preview datasets when no API key is present.
Set materialize_orderbooks: true on HistoricalQuery, ReplayQuery, and
StreamQuery for the default reconstruction behavior. Snapshots replace the
complete state, deltas update listed prices, and zero quantity deletes a price.
Books clear across gaps and reconnects, with deltas skipped until a new snapshot.
Use l2_updates(...) for raw snapshots and deltas, then feed selected updates
into the exported OrderbookBuilder for application-managed books.
Match event schema versions
StandardEvent is an untagged wire-compatible enum. Match
StandardEvent::Legacy or StandardEvent::V2 when you need the stored
envelope. The shared event.timestamp() accessor returns legacy timestamp or
v2 collector_timestamp; it does not add a timestamp field to v2 rows.
Discover a market before you query it
Usecatalog(...) to find the exact Polaris market ID for a venue.
Query events
Useevents(...) when you want standardized historical event rows beyond trades alone.
Query trades
trades(...) returns normalized trade events. The SDK loads standardized snapshot data locally and filters trade rows for you.
Query intents and RFQs
intents(...) returns typed RFQ, quote, executable-intent, and settlement
observations in stored order. Use market: "intents" and correlate rows by their
captured rfq_id or intent_id.
Query option tickers
Useoption_tickers(...) with an underlying market such as BTC. Set
instrument: None for the whole option chain, or provide one exact
venue-native contract.
source, the normalized underlying market,
and the non-empty exact instrument separate. See
Option tickers for the payload fields and realtime
filtering behavior.
Query perpetual tickers
Useperpetual_tickers(...) to stream partial venue-published market state for
a perpetual market.
PerpetualTickerData, LegacyPerpetualTickerEvent,
PerpetualTickerEventV2, and their PerpetualTickerEvent enum. Its
timestamp(), source(), market(), and data() accessors work across both
event versions. The blocking client exposes the equivalent method, and
PreparedHistoricalReplay::perpetual_tickers() can filter already resolved
local files without another coverage or download request. Generic events,
replay, and realtime stream methods include these events automatically. See
Perpetual tickers for all payload fields and
validation rules.
Query OHLCV bars
Useohlcv(...) when you want interval bars instead of individual trades.
100ms, 1s, 10s, 1m, 5m, 15m, and 1h.
Query order book snapshots
Usel2_snapshots(...) when you need order book depth data for microstructure analysis.
l2_updates(...) when you want to manage reconstruction in your
application. It returns raw StandardEvent snapshots and deltas that can be
passed directly to OrderbookBuilder::update, regardless of the query’s
materialize_orderbooks field. Call OrderbookBuilder::snapshot only when you
need a complete sorted book; apply retains the previous combined behavior.
Query funding rates
Usefunding_rates(...) to analyze perpetual funding rates and carry modeling.
Query mark prices
Usemark_prices(...) for basis analysis, mark tracking, and liquidation-related research.
Query volume profiles
Usevolume(...) for volume profiling and participation analysis.
Query VWAP series
Usevwap(...) for execution benchmarking and price smoothing.
Query volatility series
Usevolatility(...) for risk modeling and intraperiod volatility analysis.
Query best bid/offer
Usebbo(...) for spread tracking, quote analytics, and top-of-book monitoring.
Use bbo_changes(...) with the same query when only actual best-price or
best-quantity changes should be emitted.
Query depth metrics
Usedepth_metrics(...) for liquidity analysis and market impact estimation.
Local dataset storage
The SDK stores standardized snapshots and local cache data under the shared Polaris app-data root so the Rust SDK and other Polaris tools can reuse the same files. Default roots:- macOS:
~/Library/Application Support/polaris - Linux:
$XDG_DATA_HOME/polarisor~/.local/share/polaris - Windows:
%APPDATA%\\polaris
dataset_root(...) on the builder to override the root explicitly.
POLARIS_ROOToverrides the shared root globally.POLARIS_DATASET_DOWNLOAD_DIRis still accepted as a deprecated compatibility override.
Snapshot-first replay
Standardized historical methods—includingreplay(...), events(...),
trades(...), option_tickers(...), perpetual_tickers(...), and
ohlcv(...)—use snapshot-first replay. See Snapshots
for the full flow.
Gap handling
By default, snapshot-backed methods fail if the requested range is not fully covered by available standardized snapshots. Setallow_gaps: true when you want the SDK to:
- return only covered rows
- skip missing intervals
- emit a
log::warn!entry describing the gaps
Authentication
Public sources work without an API key. For premium sources or extended history, set your key viaPOLARIS_API_KEY or configure it directly on the builder:
Next steps
- Read Quickstart if you want the shared auth model behind the SDK.
- Read Snapshots if your Rust workflow starts from historical files.
- Read Trades, Perpetual tickers, Events, or OHLCV for detailed method documentation.