Expand description
Core domain types for the paft ecosystem.
This crate defines strongly-typed primitives for instruments, exchanges,
market sessions, security identifiers (Symbol, Figi, Isin), financial
periods, and lookback horizons used across the paft ecosystem. Types are
designed to be:
- Canonical and stable in string form (for serde, display, and storage)
- Liberal in what they accept when parsing (aliases, case-insensitivity), strict and consistent in emission
- Extensible via
Other(...)variants where providers use custom codes
§Quickstart
use paft_domain::{
AssetKind, CalendarPeriod, Exchange, Horizon, Instrument, ReportingPeriod, Symbol,
};
let symbol = Symbol::new("AAPL").unwrap();
let aapl = Instrument::from_symbol_and_exchange(
symbol.as_str(),
Exchange::NASDAQ,
AssetKind::Equity,
).unwrap();
assert_eq!(aapl.symbol.as_str(), "AAPL");
assert!(aapl.exchange.is_some());
let q4 = "2023-Q4".parse::<ReportingPeriod>().unwrap();
assert_eq!(q4.to_string(), "2023Q4");
let calendar_q4 = CalendarPeriod::quarterly(2023, 4).unwrap();
assert_eq!(calendar_q4.start_date().to_string(), "2023-10-01");
let horizon = "3mo".parse::<Horizon>().unwrap();
assert_eq!(horizon.to_string(), "3mo");§Serde
All domain types implement serde with stable string representations that match
their Display output. Unknown provider codes round-trip via Other where
applicable.
§Feature flags
tracing: enable lightweight instrumentation on constructors and validatorsdataframe: enablepaft-utilsDataFrametraits for convenient export
Re-exports§
pub use error::DomainError;pub use exchange::Exchange;pub use exchange::OtherExchange;pub use horizon::Horizon;pub use horizon::OtherHorizon;pub use identifiers::Figi;pub use identifiers::Isin;pub use identifiers::Symbol;pub use instrument::AssetKind;pub use instrument::Instrument;pub use instrument::OtherAssetKind;pub use market_state::MarketState;pub use market_state::OtherMarketState;pub use period::CalendarPeriod;pub use period::OtherPeriod;pub use period::PeriodDate;pub use period::PeriodYear;pub use period::QuarterOfYear;pub use period::ReportingPeriod;
Modules§
- error
- Domain-specific error types for
paft-domain. - exchange
- Exchange enumeration with major exchanges and extensible fallback.
- horizon
- Lookback horizon primitives.
- identifiers
- Identifier newtypes for the paft ecosystem.
- instrument
- Instrument identifier and asset classification domain types.
- market_
state - Market session state enumeration with helpers and serde support.
- period
- Financial period primitives.
Structs§
- Canonical
- Canonical string wrapper used for
Othervariants.
Enums§
- Canonical
Error - Errors that can occur when constructing canonical strings.
Constants§
- MAX_
CANONICAL_ TOKEN_ LEN - Maximum byte length of a canonical
Otherenum token.
Traits§
- String
Code - Trait for enums that have a canonical string code.
Functions§
- canonicalize
- Produces the canonical representation of an input string used across enums.