Skip to main content
The Polaris Rust SDK is available on crates.io as polaris-data.

Install

If your project does not already use Tokio, add it as well:
The package name is polaris-data and the crate name is polaris_data. Or add it manually to Cargo.toml:
The SDK is async-first and is designed for Tokio-based services, backfills, and trading infrastructure.

Quickstart

Use events(...) when you want standardized historical rows in an async service or backfill job.

Create a client

If you omit api_key, the client reads POLARIS_API_KEY from the environment.
The main builder is:

Core methods

Use PolarisClient 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.
See Event envelope, Trades, and L2 snapshots and updates for v2 field and ordering changes.

Discover a market before you query it

Use catalog(...) to find the exact Polaris market ID for a venue.
If you want a high-level view of supported venues and example market IDs before you query the exact pair, start with Market Coverage.

Query events

Use events(...) 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.
See the Intents and RFQs guide for lifecycle reconstruction and the schema reference for fields.

Query option tickers

Use option_tickers(...) with an underlying market such as BTC. Set instrument: None for the whole option chain, or provide one exact venue-native contract.
Every option ticker event keeps 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

Use perpetual_tickers(...) to stream partial venue-published market state for a perpetual market.
The crate exports 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

Use ohlcv(...) when you want interval bars instead of individual trades.
Supported intervals are 100ms, 1s, 10s, 1m, 5m, 15m, and 1h.

Query order book snapshots

Use l2_snapshots(...) when you need order book depth data for microstructure analysis.
Use 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

Use funding_rates(...) to analyze perpetual funding rates and carry modeling.

Query mark prices

Use mark_prices(...) for basis analysis, mark tracking, and liquidation-related research.

Query volume profiles

Use volume(...) for volume profiling and participation analysis.

Query VWAP series

Use vwap(...) for execution benchmarking and price smoothing.

Query volatility series

Use volatility(...) for risk modeling and intraperiod volatility analysis.

Query best bid/offer

Use bbo(...) 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

Use depth_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/polaris or ~/.local/share/polaris
  • Windows: %APPDATA%\\polaris
Within that root, the SDK uses this layout:
Use dataset_root(...) on the builder to override the root explicitly.
  • POLARIS_ROOT overrides the shared root globally.
  • POLARIS_DATASET_DOWNLOAD_DIR is still accepted as a deprecated compatibility override.

Snapshot-first replay

Standardized historical methods—including replay(...), 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. Set allow_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 via POLARIS_API_KEY or configure it directly on the builder:
See Quickstart for the shared auth model.

Next steps