Skip to main content

Crate fin_stream

Crate fin_stream 

Source
Expand description

§fin-stream

Lock-free streaming primitives for real-time financial market data.

§Architecture

Tick Source
    |
    v
SPSC Ring Buffer  (lock-free, zero-allocation hot path)
    |
    v
OHLCV Aggregator  (streaming bar construction at any timeframe)
    |
    v
MinMax Normalizer (rolling-window coordinate normalization)
    |
    +---> Lorentz Transform  (spacetime boost for feature engineering)
    |
    v
Downstream (ML model, trade signal engine, order management)

§Performance

The SPSC ring buffer sustains 100 K+ ticks/second with no heap allocation on the fast path. All error paths return Result<_, StreamError> — the library never panics on the hot path. Construction functions validate their arguments and panic on misuse with a clear message (e.g. ring capacity of 0, normalizer window size of 0).

§Modules

ModuleResponsibility
bookOrder book delta streaming and crossed-book detection
errorTyped error hierarchy (StreamError)
healthFeed staleness detection and circuit-breaker
lorentzLorentz spacetime transforms for time-series features
normRolling min-max coordinate normalization
ohlcvOHLCV bar aggregation at arbitrary timeframes
ringSPSC lock-free ring buffer
sessionMarket session and trading-hours classification
tickRaw-to-normalized tick conversion for all exchanges
wsWebSocket connection management and reconnect policy

Re-exports§

pub use book::BookDelta;
pub use book::BookSide;
pub use book::OrderBook;
pub use book::PriceLevel;
pub use error::StreamError;
pub use health::FeedHealth;
pub use health::HealthMonitor;
pub use health::HealthStatus;
pub use lorentz::LorentzTransform;
pub use lorentz::SpacetimePoint;
pub use norm::MinMaxNormalizer;
pub use norm::ZScoreNormalizer;
pub use ohlcv::OhlcvAggregator;
pub use ohlcv::OhlcvBar;
pub use ohlcv::Timeframe;
pub use ring::SpscConsumer;
pub use ring::SpscProducer;
pub use ring::SpscRing;
pub use session::MarketSession;
pub use session::SessionAwareness;
pub use session::TradingStatus;
pub use tick::Exchange;
pub use tick::NormalizedTick;
pub use tick::RawTick;
pub use tick::TickNormalizer;
pub use ws::ConnectionConfig;
pub use ws::ReconnectPolicy;
pub use ws::WsManager;

Modules§

book
Order book — delta streaming with full reconstruction.
error
Typed error hierarchy for fin-stream.
health
Feed health monitoring — staleness detection and status tracking.
lorentz
Lorentz (special-relativistic) transforms applied to financial time series.
norm
Rolling-window coordinate normalization for financial time series.
ohlcv
Real-time tick-to-OHLCV aggregation at arbitrary timeframes.
ring
Lock-free single-producer / single-consumer (SPSC) ring buffer.
session
Market session awareness — trading hours, holidays, status transitions.
tick
Tick normalization — raw exchange messages → canonical NormalizedTick.
ws
WebSocket connection management — auto-reconnect and backpressure.