Show HN: Fin-primitives Zero-panic, decimal-precise trading types for Rust - https://entangled.cloud/117151040/show-hn-fin-primitives-zero-panic-decimal-precise-trading-types-for-rust??via=md
Show HN: Fin-primitives Zero-panic, decimal-precise trading types for Rust

I couldn't find a Rust crate that gave me validated financial types backed by decimal arithmetic. Everything I found either used f64 (unacceptable for order books), panicked on bad input, or was a thin wrapper around a single indicator.fin-primitives provides:- Price and Quantity newtypes over rust_decimal::Decimal, validated at construction — an invalid Price literally can't exist at runtime - L2 OrderBook with sequence validation and atomic rollback if a delta would produce an inverted spread - OHLCV aggregation from tick streams with bar invariants enforced on every push - Streaming SMA, EMA (SMA-seeded), and RSI (Wilder smoothing matching TradingView/Bloomberg) that return SignalValue::Unavailable until warm-up completes - Position ledger with VWAP average cost, realized/unrealized P&L net of commissions - Composable RiskRule trait — plug in your own rules, breaches returned as typed Vec, never swallowedNo unwrap, no expect, no panic in library code. cargo clippy denies all of them.This is part of a larger set of 11 crates I've published for LLM and trading infrastructure (https://crates.io/users/Mattbusel) but fin-primitives is the one I think fills the biggest gap in the Rust ecosystem right now.Happy to answer questions about the design decisions, especially the order book rollback mechanism and the indicator warm-up approach.

entangled dot cloud