alpaca-data
alpaca-data is an async Rust client for the Alpaca Market Data HTTP API.
Current Coverage
- stocks
- options
- crypto
- news
- corporate actions
Client Entry
use Client;
let client = builder
.credentials_from_env?
.build?;
# let _ = client;
# Ok::
Resource Accessors
client.stocks()client.options()client.crypto()client.news()client.corporate_actions()
Raw Cache Convenience
use CachedClient;
use Client;
let raw = builder
.credentials_from_env?
.build?;
let cache = new;
# let _ = cache;
# Ok::
alpaca_data::cache::CachedClient is an opt-in convenience facade for:
- cache-first stock snapshots
- cache-first raw option snapshots
- explicit stock bar subscriptions
- explicit refresh / clear operations
It does not own scheduling, business clocks, option-chain enrichment, or IV / Greeks calculations.
Stock and raw option snapshot caches share one requested-set reconciliation contract:
- provider errors are returned without changing cached values, unavailable keys, or the last successful refresh time
- successful full, partial, and empty responses reconcile only the keys captured for that request
- returned requested keys replace cached values and leave the unavailable set, while requested-but-omitted keys lose any old value and enter the unavailable set
- unexpected response keys are ignored, so an in-flight request cannot overwrite unrelated subscriptions
- a non-empty successful provider request advances the receive timestamp even when every requested key is omitted; an empty subscription set does not call the provider or advance time
CacheStats exposes subscribed, cached, unavailable, and last-success counts/timestamps so callers can distinguish complete, partial, empty, and failed refreshes.
Main API Surface
Stocks
bars/bars_allauctions/auctions_allquotes/quotes_alltrades/trades_alllatest_barslatest_quoteslatest_tradessnapshotscondition_codesexchange_codes
Options
bars/bars_alltrades/trades_alllatest_quoteslatest_tradessnapshots/snapshots_allchain/chain_allcondition_codesexchange_codes
Crypto
bars/bars_allquotes/quotes_alltrades/trades_alllatest_barslatest_quoteslatest_tradeslatest_orderbookssnapshots
News
listlist_all
Corporate Actions
listlist_all
Built-in Convenience Helpers
stocks::ordered_snapshots(...)options::ordered_snapshots(...)crypto::ordered_snapshots(...)crypto::preferred_location()crypto::Snapshot::{timestamp, price, last_price, bid_price, ask_price, mark_price}stocks::Snapshot::{timestamp, price, bid_price, ask_price, session_open, session_high, session_low, session_close, previous_close, session_volume}options::Snapshot::{timestamp, bid_price, ask_price, last_price, mark_price}options::underlying_symbol(...)symbols::display_stock_symbol(...)
Not Implemented
- crypto perpetual futures
- forex
- fixed income
- index
- logos
- screener
- websocket / stream APIs
Environment Variables
ALPACA_DATA_API_KEYALPACA_DATA_SECRET_KEY
See docs/reference/alpaca-data.md and https://docs.rs/alpaca-data for the full reference.