Skip to main content

Crate paft_market

Crate paft_market 

Source
Expand description

Market data types, requests, and responses for paft.

This crate provides strongly-typed market data models (quotes, options, news), request builders (search, history), and response types that are consistent across providers. It aims to:

  • Offer validated builders to avoid invalid request states
  • Encode canonical, serde-stable string forms for interop
  • Integrate with paft-domain and paft-money for identifiers and values

§Quickstart

use paft_market::{HistoryRequest, Interval, Range, SearchRequest};

// Build a history request for 1 month of daily candles
let req = HistoryRequest::try_from_range(Range::M1, Interval::D1).unwrap();
assert_eq!(req.interval(), Interval::D1);

// Build a validated search request
let search = SearchRequest::new("AAPL").unwrap();
assert_eq!(search.query(), "AAPL");

§Feature flags

The default money backend is rust_decimal.

  • bigdecimal: switch paft-money to the bigdecimal backend
  • dataframe: enable polars/df-derive-macros integration for dataframe export

§Serde

All models serialize with stable, human-readable representations suitable for storage and transport. Dataframe support emits string codes for enums.

Request and semantic metadata wire shapes deserialize strictly when silently dropping fields could change meaning. A kind discriminator alone does not make a data payload strict. Provider/data payload models are forward-compatible by default and ignore unmodeled JSON fields unless validation requires rejection. Generic provider metadata is serde-flattened into the owning JSON object, so colliding JSON field names are unsupported; dataframe export keeps provider metadata under provider.* columns.

Re-exports§

pub use error::MarketError;
pub use market::action::Action;
pub use market::news::GenericNewsArticle;
pub use market::news::NewsArticle;
pub use market::options::GenericOptionChain;
pub use market::options::GenericOptionContract;
pub use market::options::GenericOptionUpdate;
pub use market::options::OptionChain;
pub use market::options::OptionContract;
pub use market::options::OptionContractKey;
pub use market::options::OptionGreeks;
pub use market::options::OptionSide;
pub use market::options::OptionUpdate;
pub use market::orderbook::BookLevel;
pub use market::orderbook::GenericBookLevel;
pub use market::orderbook::GenericOrderBook;
pub use market::orderbook::OrderBook;
pub use market::quote::GenericQuote;
pub use market::quote::GenericQuoteUpdate;
pub use market::quote::Quote;
pub use market::quote::QuoteUpdate;
pub use requests::history::HistoryFlags;
pub use requests::history::HistoryRequest;
pub use requests::history::HistoryRequestBuilder;
pub use requests::history::Interval;
pub use requests::history::Range;
pub use requests::history::TimeSpec;
pub use requests::news::NewsRequest;
pub use requests::news::NewsTab;
pub use requests::options::OptionChainRequest;
pub use requests::options::OptionExpirationsRequest;
pub use requests::search::SearchRequest;
pub use requests::search::SearchRequestBuilder;
pub use responses::download::DownloadEntry;
pub use responses::download::DownloadResponse;
pub use responses::download::GenericDownloadEntry;
pub use responses::download::GenericDownloadResponse;
pub use responses::history::AdjustmentAnchor;
pub use responses::history::AdjustmentMethod;
pub use responses::history::Candle;
pub use responses::history::CandleUpdate;
pub use responses::history::CorporateActionAdjustmentCause;
pub use responses::history::CorporateActionAdjustmentCauses;
pub use responses::history::GenericCandle;
pub use responses::history::GenericCandleUpdate;
pub use responses::history::GenericHistoryResponse;
pub use responses::history::HistoryMeta;
pub use responses::history::HistoryResponse;
pub use responses::history::HistoryValidationError;
pub use responses::history::Ohlc;
pub use responses::history::OhlcPriceBasis;
pub use responses::history::PriceBasis;
pub use responses::options::OptionExpirationsResponse;
pub use responses::search::GenericSearchResponse;
pub use responses::search::GenericSearchResult;
pub use responses::search::SearchResponse;
pub use responses::search::SearchResult;

Modules§

error
Error types specific to paft-market request validation.
market
Market-related primitives.
requests
Request namespaces consolidating request builders and parameters.
responses
Market response modules.