fin_stream/lib.rs
1// SPDX-License-Identifier: MIT
2#![deny(missing_docs)]
3//! # fin-stream
4//!
5//! Lock-free streaming primitives for real-time financial market data.
6//!
7//! ## Architecture
8//!
9//! ```text
10//! Tick Source
11//! |
12//! v
13//! SPSC Ring Buffer (lock-free, zero-allocation hot path)
14//! |
15//! v
16//! OHLCV Aggregator (streaming bar construction at any timeframe)
17//! |
18//! v
19//! MinMax Normalizer (rolling-window coordinate normalization)
20//! |
21//! +---> Lorentz Transform (spacetime boost for feature engineering)
22//! |
23//! v
24//! Downstream (ML model, trade signal engine, order management)
25//! ```
26//!
27//! ## Performance
28//!
29//! The SPSC ring buffer sustains 100 K+ ticks/second with no heap allocation
30//! on the fast path. All error paths return `Result<_, StreamError>` — the
31//! library never panics on the hot path. Construction functions validate their
32//! arguments and panic on misuse with a clear message (e.g. ring capacity of 0,
33//! normalizer window size of 0).
34//!
35//! ## Modules
36//!
37//! | Module | Responsibility |
38//! |--------|----------------|
39//! [`book`] | Order book delta streaming and crossed-book detection |
40//! [`error`] | Typed error hierarchy (`StreamError`) |
41//! [`health`] | Feed staleness detection and circuit-breaker |
42//! [`lorentz`] | Lorentz spacetime transforms for time-series features |
43//! [`norm`] | Rolling min-max coordinate normalization |
44//! [`ohlcv`] | OHLCV bar aggregation at arbitrary timeframes |
45//! [`ring`] | SPSC lock-free ring buffer |
46//! [`session`] | Market session and trading-hours classification |
47//! [`tick`] | Raw-to-normalized tick conversion for all exchanges |
48//! [`ws`] | WebSocket connection management and reconnect policy |
49
50pub mod book;
51pub mod error;
52pub mod health;
53pub mod lorentz;
54pub mod norm;
55pub mod ohlcv;
56pub mod ring;
57pub mod session;
58pub mod tick;
59pub mod ws;
60
61pub use book::{BookDelta, BookSide, OrderBook, PriceLevel};
62pub use error::StreamError;
63pub use health::{FeedHealth, HealthMonitor, HealthStatus};
64pub use lorentz::{LorentzTransform, SpacetimePoint};
65pub use norm::{MinMaxNormalizer, ZScoreNormalizer};
66pub use ohlcv::{OhlcvAggregator, OhlcvBar, Timeframe};
67pub use ring::{SpscConsumer, SpscProducer, SpscRing};
68pub use session::{MarketSession, SessionAwareness, TradingStatus};
69pub use tick::{Exchange, NormalizedTick, RawTick, TickNormalizer};
70pub use ws::{ConnectionConfig, ReconnectPolicy, WsManager};