Skip to main content

Crate quant_primitives

Crate quant_primitives 

Source
Expand description

Pure trading primitives — cross-cutting value objects for quantitative finance.

Leaf crate: no internal dependencies. Only external: chrono, rust_decimal, serde, thiserror.

§Provided types

  • Candle — OHLCV bar with timestamp
  • Interval — time granularity (minute, hour, day, week)
  • Symbol — trading pair (e.g., BTC/USDT)
  • Ticker — universal asset identifier with venue/asset class metadata
  • Currency — currency code (e.g., USD, BTC)
  • PositionConfig — position sizing rules
  • precision_boundary — canonical Decimal ↔ f64 crossings with rich error enum

Re-exports§

pub use precision_boundary::decimal_to_f64_checked;
pub use precision_boundary::f64_to_decimal_checked;
pub use precision_boundary::NonFiniteKind;
pub use precision_boundary::PrecisionBoundaryError;
pub use taxonomy::AssetClass;
pub use taxonomy::AssetType;
pub use taxonomy::Derivative;
pub use taxonomy::Ticker;
pub use taxonomy::TickerError;
pub use taxonomy::Underlying;
pub use taxonomy::VenueType;

Modules§

crypto_classifier
Crypto classification heuristics — single source of truth.
precision_boundary
Precision boundary between FinancialValue (Decimal) and StatisticalValue (f64).
taxonomy
Ticker taxonomy - universal asset identification.

Structs§

Bps
A basis-points value validated to the range [0, 10000].
Candle
CandleRange
Time boundaries extracted from a candle slice.
Currency
A currency identifier (e.g., USD, EUR, BTC).
Fraction
A fraction value validated to the range [0, 1].
Percentage
A percentage value validated to the range [0, 100].
PositionConfig
Configuration for position sizing within a strategy.
Symbol
A trading symbol representing a base/quote currency pair.

Enums§

BpsError
Error for invalid basis-points construction.
CandleError
CandleQuality
Data quality flag for OHLCV candles.
FractionError
Error for invalid fraction construction.
Interval
Candle aggregation interval.
IntervalError
Errors from parsing an Interval from a string.
PercentageError
Error for invalid percentage construction.
PositionConfigError
Error for invalid PositionConfig construction.
SymbolError
Errors from parsing a Symbol from a string.
VolumeSource
Origin of the candle volume figure.

Functions§

interval_duration
Get duration for an interval.