Expand description
Bit-faithful Rust port of the Lorentzian Classification indicator.
This crate is a direct, forward-indexed port of the PineScript v6 reference
(and the parity-tested Python port under ports/python). Series use index
0 as the oldest bar, and missing Pine na values are represented as
f64::NAN (MISSING).
The implementation is deliberately allocation-simple and dependency-light so
it stays easy to audit against the reference. Floating-point operations
mirror the Python port’s accumulation order and rounding (banker’s rounding
via f64::round_ties_even, libm powf/exp), which makes the two ports
bit-for-bit equal and keeps the crate within 1e-6 of the TradingView gold
baselines.
§Cargo features
csv(default): TradingView CSV input (read_tradingview_csv) and Pine-export parity checking (theparitymodule), via the establishedcsvcrate so valid quoted CSV behaves like Python’s standardcsvparser. Disable it (default-features = false) for a zero-dependency numeric core when you feedBarvalues from your own data pipeline.
§Example
use lorentzian_classification_core::{calculate, Bar, Settings};
let bars: Vec<Bar> = (0..32)
.map(|i| {
let c = 100.0 + f64::from(i);
Bar { time: i.to_string(), open: c, high: c + 1.0, low: c - 1.0, close: c }
})
.collect();
let rows = calculate(&bars, &Settings::default(), 0.0);
assert_eq!(rows.len(), bars.len());Re-exports§
pub use ann::AnnState;pub use csv_io::detect_price_scale;pub use csv_io::read_tradingview_csv;pub use csv_io::CsvError;pub use engine::calculate;pub use engine::select_source;pub use parity::parity_summary;pub use parity::read_pine_export;pub use parity::ExpectedRow;pub use parity::Mismatch;pub use parity::ParitySummary;pub use types::is_missing;pub use types::nz;pub use types::Bar;pub use types::FeatureKind;pub use types::FeatureSpec;pub use types::ParseError;pub use types::ResultRow;pub use types::Settings;pub use types::Source;pub use types::MISSING;pub use types::RESULT_FIELDNAMES;
Modules§
- ann
- Approximate Nearest Neighbors classifier over the Lorentzian distance.
- csv_io
- Minimal TradingView/Pine OHLC CSV reader.
- display
- Pine-style color encoding for display outputs.
- engine
- The per-bar classification engine: features, kernels, kNN prediction, filters, entries/exits, and trade statistics.
- filters
- Market-regime filter (the KLMF-based normalized-slope detector).
- indicators
- Moving averages, oscillators, and normalized features.
- kernels
- Nadaraya-Watson kernel regression estimators (Rational Quadratic, Gaussian).
- parity
- Parity comparison against TradingView/Pine export CSVs.
- types
- Core data types: bars, settings, feature specifications, and result rows.