lorentzian-classification-core
A bit-faithful Rust port of the Lorentzian Classification indicator by Justin Dehorty: an approximate-nearest-neighbors classifier over Lorentzian distance, with the full feature engineering, kernel regression, filter, signal, and trade-stats pipeline of the PineScript v6 reference.
The port is a statement-for-statement translation of the reference and is
parity-tested against committed TradingView gold exports: features and kernel
estimates agree within 1e-6, and predictions, directions, and entry/exit
signals match exactly. It is also bit-for-bit equal to the
Python port
of the same repository. One gold baseline is vendored into the crate, so
cargo test proves parity even from the extracted package.
Installation
Or in Cargo.toml:
[]
= "0.1"
Quick start with your own data
The core API is two types and one function: build a Vec<Bar>, pick
Settings, call calculate.
use ;
let bars: = my_feed
.iter
.map
.collect;
// price_scale quantizes ADX at the instrument's decimal precision
// (10^decimals); pass 0.0 to disable quantization.
let rows = calculate;
let last = rows.last.unwrap;
println!;
Series are forward-indexed (index 0 is the oldest bar) and missing values
are f64::NAN, exactly like Pine na.
Quick start with a TradingView CSV
With the default csv feature, exported TradingView data loads directly and
the price scale is derived from the data:
use ;
let = read_tradingview_csv?;
let rows = calculate;
# Ok::
Configuring settings
Settings::default() reproduces the TradingView defaults. Every field maps to
a named Pine input (documented field by field on
Settings),
so a chart configuration can be transcribed directly. Start from the default
and override what the chart changes:
use ;
let settings = Settings ;
Feature specs also parse from the KIND:paramA:paramB string form used by
the ports' command-line interfaces: FeatureSpec::parse("CCI:20:1").
Cargo features
| Feature | Default | Effect |
|---|---|---|
csv |
yes | read_tradingview_csv and the parity module for checking recomputations against Pine export CSVs, via the csv crate. |
With default-features = false the crate has zero dependencies: just the
numeric core, for consumers that feed Bar values from their own pipeline.
Validation
The parity contract, gold baselines, and cross-port equivalence (PineScript,
Python, Rust, Lean 4) are documented in the
repository validation notes.
The parity module exposes the same comparator used by the test suite, so
downstream integrations can verify their own exports.
Related crates
| Crate | Purpose |
|---|---|
lorentzian-classification |
Alias crate re-exporting this one under the canonical name. |
lorentzian-classification-cli |
Command-line interface (run, parity). |
Minimum supported Rust version
Rust 1.77. MSRV bumps are considered semver-minor and verified in CI with
the committed lockfile.
Safety and license
#![forbid(unsafe_code)], #![deny(missing_docs)], clippy pedantic clean.
Licensed under the MIT License.
This is analysis software, not investment advice; see the repository README for the project's scope and disclaimers.