Skip to main content

Crate wickra_core

Crate wickra_core 

Source
Expand description

wickra-core: streaming-first technical indicators.

The core engine of Wickra. Every indicator is implemented as a state machine that consumes inputs one at a time via Indicator::update in constant time. Batch evaluation is provided as a blanket extension trait so the same code path serves both online (tick-by-tick) and offline (historical) workloads.

§Design

  • Streaming-first. State is held by the indicator instance, so a new value only re-computes deltas, not the whole series.
  • Batch is free. BatchExt::batch is a blanket implementation that simply replays update over a slice. Writing one implementation gives both APIs.
  • Composable. Indicators implement Indicator<Input = f64, Output = f64> wherever they conceptually take a price, so they can be chained via Chain.
  • No unsafe. The crate forbids unsafe_code in the workspace lints.

§Quick start

use wickra_core::{BatchExt, Indicator, Sma};

// Streaming:
let mut sma = Sma::new(3).unwrap();
assert_eq!(sma.update(1.0), None);
assert_eq!(sma.update(2.0), None);
assert_eq!(sma.update(3.0), Some(2.0));

// Batch (replays `update` internally):
let mut sma = Sma::new(3).unwrap();
let out = sma.batch(&[1.0, 2.0, 3.0, 4.0]);
assert_eq!(out, vec![None, None, Some(2.0), Some(3.0)]);

Re-exports§

pub use indicators::AcceleratorOscillator;
pub use indicators::Adl;
pub use indicators::Adx;
pub use indicators::AdxOutput;
pub use indicators::Aroon;
pub use indicators::AroonOscillator;
pub use indicators::AroonOutput;
pub use indicators::Atr;
pub use indicators::AtrTrailingStop;
pub use indicators::AwesomeOscillator;
pub use indicators::BalanceOfPower;
pub use indicators::BollingerBands;
pub use indicators::BollingerBandwidth;
pub use indicators::BollingerOutput;
pub use indicators::Cci;
pub use indicators::ChaikinMoneyFlow;
pub use indicators::ChaikinOscillator;
pub use indicators::ChaikinVolatility;
pub use indicators::ChandeKrollStop;
pub use indicators::ChandeKrollStopOutput;
pub use indicators::ChandelierExit;
pub use indicators::ChandelierExitOutput;
pub use indicators::ChoppinessIndex;
pub use indicators::Cmo;
pub use indicators::Coppock;
pub use indicators::Dema;
pub use indicators::Donchian;
pub use indicators::DonchianOutput;
pub use indicators::Dpo;
pub use indicators::EaseOfMovement;
pub use indicators::Ema;
pub use indicators::ForceIndex;
pub use indicators::HistoricalVolatility;
pub use indicators::Hma;
pub use indicators::Kama;
pub use indicators::Keltner;
pub use indicators::KeltnerOutput;
pub use indicators::LinRegAngle;
pub use indicators::LinRegSlope;
pub use indicators::LinearRegression;
pub use indicators::MacdIndicator;
pub use indicators::MacdOutput;
pub use indicators::MassIndex;
pub use indicators::MedianPrice;
pub use indicators::Mfi;
pub use indicators::Mom;
pub use indicators::Natr;
pub use indicators::Obv;
pub use indicators::PercentB;
pub use indicators::Pmo;
pub use indicators::Ppo;
pub use indicators::Psar;
pub use indicators::Roc;
pub use indicators::RollingVwap;
pub use indicators::Rsi;
pub use indicators::Sma;
pub use indicators::Smma;
pub use indicators::StdDev;
pub use indicators::StochRsi;
pub use indicators::Stochastic;
pub use indicators::StochasticOutput;
pub use indicators::SuperTrend;
pub use indicators::SuperTrendOutput;
pub use indicators::Tema;
pub use indicators::Trima;
pub use indicators::Trix;
pub use indicators::TrueRange;
pub use indicators::Tsi;
pub use indicators::TypicalPrice;
pub use indicators::UlcerIndex;
pub use indicators::UltimateOscillator;
pub use indicators::VerticalHorizontalFilter;
pub use indicators::VolumePriceTrend;
pub use indicators::Vortex;
pub use indicators::VortexOutput;
pub use indicators::Vwap;
pub use indicators::Vwma;
pub use indicators::WeightedClose;
pub use indicators::WilliamsR;
pub use indicators::Wma;
pub use indicators::ZScore;
pub use indicators::Zlema;
pub use indicators::T3;

Modules§

indicators
Built-in indicators. Every indicator implements crate::Indicator.

Structs§

Candle
A single OHLCV bar.
Chain
Chain two indicators so the output of the first becomes the input of the second.
Tick
A single trade tick.

Enums§

Error
Errors that can occur when constructing or operating on an indicator.

Traits§

BatchExt
Blanket extension that adds batch evaluation to every Indicator.
Indicator
A streaming technical indicator.

Type Aliases§

Result
Convenience alias for Result<T, wickra_core::Error>.