Crate paft_domain

Crate paft_domain 

Source
Expand description

Core domain types for the paft ecosystem.

This crate defines strongly-typed primitives for instruments, exchanges, market sessions, identifiers (including an opaque Symbol), and financial periods 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, Exchange, Instrument, Period, Symbol};

// Create an instrument from a symbol and kind
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(), symbol.as_str());
assert!(aapl.exchange().is_some());

// Parse financial periods from flexible inputs and get canonical form
let q4 = "2023-Q4".parse::<Period>().unwrap();
assert_eq!(q4.to_string(), "2023Q4");
let next = q4.next_quarter().unwrap();
assert_eq!(next.to_string(), "2024Q1");

§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

  • rust-decimal (default): use paft-money with rust-decimal
  • bigdecimal: use paft-money with bigdecimal
  • dataframe: enable paft-utils dataframe traits for convenient export

Re-exports§

pub use error::DomainError;
pub use exchange::Exchange;
pub use identifiers::Figi;
pub use identifiers::Isin;
pub use identifiers::Symbol;
pub use instrument::AssetKind;
pub use instrument::Instrument;
pub use market_state::MarketState;
pub use period::Period;

Modules§

error
Domain-specific error types for paft-domain.
exchange
Exchange enumeration with major exchanges and extensible fallback.
identifiers
Identifier newtypes for instrument codes (ISIN, FIGI, Symbol).
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 Other variants.

Enums§

CanonicalError
Errors that can occur when constructing canonical strings.

Traits§

StringCode
Trait for enums that have a canonical string code.

Functions§

canonicalize
Produces the canonical representation of an input string used across enums.