Skip to main content

Module data

Module data 

Source
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§

AccountQuery
Key type used when reading the current trading account snapshot.
InMemoryStore
Simple in-memory store suitable for tests and local process caches.
OptionChainQuery
Key type used when reading the current option chain for an underlying symbol.
OrderByClientIdQuery
Key type used when reading one order by client order id.
OrderByIdQuery
Key type used when reading one order by exchange order id.
Repository
Cache-first facade that composes a source with a store.

Traits§

DataApi
Exchange data query surface covering account snapshots, order lookups, and market data.
Source
Authoritative read source such as an exchange REST adapter.
Store
Cache or sink abstraction for persisted query results.