Expand description
Data access abstractions that separate direct exchange reads from cached reads.
§Design
Source<Q, T>fetches authoritative data from an exchange or upstream service.Store<Q, T>persists previously fetched data in memory or another sink.Repository<S, C>composes a source and a store into a cache-first read facade.
This layer is intentionally read-focused. Command-style operations such as order submission
remain in trading::TradingApi and should invalidate or bypass caches at the call site.
§Examples
Direct read from the exchange adapter via DataApi:
use tradingkit::data::DataApi;
use tradingkit::exchange::alpaca::{Alpaca, AlpacaCredentials};
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let alpaca = Alpaca::paper(AlpacaCredentials::new(
"your-key".to_string(),
"your-secret".to_string(),
));
let account = alpaca.get_account().await?;
let _status = account.status;
Ok(())
}Structs§
- Account
Query - Key type used when reading the current trading account snapshot.
- InMemory
Store - Simple in-memory store suitable for tests and local process caches.
- Option
Chain Query - Key type used when reading the current option chain for an underlying symbol.
- Order
ByClient IdQuery - Key type used when reading one order by client order id.
- Order
ById Query - Key type used when reading one order by exchange order id.
- Repository
- Cache-first facade that composes a source with a store.