Crate velora_ta

Crate velora_ta 

Source
Expand description

§velora-ta

Technical Analysis indicators library for algorithmic trading.

This is a standalone technical analysis library that can be used independently or as part of the Velora HFT platform. It provides a comprehensive collection of technical indicators organized by category.

§Features

  • Trend Indicators: SMA, EMA, WMA, DEMA, TEMA, HMA
  • Momentum Indicators: RSI, MACD, Stochastic, ROC, CCI
  • Volatility Indicators: ATR, Bollinger Bands, Keltner Channels, StdDev
  • Volume Indicators: OBV, VWAP, ADL, MFI, CMF
  • Composite Tools: Indicator chains, crossovers, threshold detection

§Design Philosophy

  • Streaming-first: Process data one point at a time for real-time trading
  • Batch support: Calculate historical indicator values efficiently
  • Zero-copy: Efficient with slices and references where possible
  • Type-safe: Compile-time guarantees via Rust’s type system
  • Well-tested: Comprehensive test coverage with edge cases

§Quick Start

use velora_ta::{SMA, EMA, RSI, SingleIndicator};
use chrono::Utc;

// Create indicators
let mut sma = SMA::new(20)?;
let mut ema = EMA::new(10)?;
let mut rsi = RSI::new(14)?;

// Stream mode: process prices one at a time
for price in prices {
    let timestamp = Utc::now();

    if let Some(sma_val) = sma.update(price, timestamp)? {
        println!("SMA(20): {:.2}", sma_val);
    }

    if let Some(rsi_val) = rsi.update(price, timestamp)? {
        if rsi_val > 70.0 {
            println!("Overbought!");
        } else if rsi_val < 30.0 {
            println!("Oversold!");
        }
    }
}

// Or use batch mode for historical data
let sma = SMA::new(20)?;
let values = sma.calculate(&historical_prices)?;

§Indicator Categories

§Trend Indicators

Track the direction and strength of price trends:

  • SMA: Simple Moving Average - equal-weighted average
  • EMA: Exponential Moving Average - more weight on recent prices
  • WMA: Weighted Moving Average - linear weights (planned)
  • HMA: Hull Moving Average - very responsive (planned)

§Momentum Indicators

Measure the speed and magnitude of price changes:

  • RSI: Relative Strength Index - overbought/oversold detector
  • MACD: Moving Average Convergence Divergence - trend + momentum (in progress)
  • Stochastic: Oscillator comparing close to high-low range (planned)

§Volatility Indicators (Planned)

Measure price volatility and potential ranges:

  • ATR: Average True Range - for stop-loss placement
  • Bollinger Bands: Volatility bands around price
  • Keltner Channels: ATR-based channels

§Volume Indicators (Planned)

Analyze volume patterns:

  • OBV: On-Balance Volume - cumulative volume
  • VWAP: Volume-Weighted Average Price - intraday benchmark
  • MFI: Money Flow Index - RSI with volume

§Usage Patterns

§Streaming Mode (Real-time)

let mut indicator = SMA::new(20)?;

// Process live data
loop {
    let price = get_latest_price();
    let timestamp = Utc::now();

    if let Some(value) = indicator.update(price, timestamp)? {
        make_trading_decision(value);
    }
}

§Batch Mode (Historical)

let indicator = SMA::new(20)?;
let prices = load_historical_data();
let values = indicator.calculate(&prices)?;

for (i, value) in values.iter().enumerate() {
    if let Some(v) = value {
        println!("Price: {}, SMA: {}", prices[i], v);
    }
}

§Standalone Usage

This library can be used completely independently of the Velora platform:

[dependencies]
velora-ta = "0.1"

Re-exports§

pub use errors::IndicatorError;
pub use errors::IndicatorResult;
pub use traits::Indicator;
pub use traits::MultiIndicator;
pub use traits::SingleIndicator;
pub use traits::VolumeIndicator;
pub use types::IndicatorValue;
pub use types::MultiIndicatorValue;
pub use types::PriceType;
pub use utils::CircularBuffer;
pub use trend::Aroon;
pub use trend::ParabolicSAR;
pub use trend::SuperTrend;
pub use trend::Vortex;
pub use trend::ADX;
pub use trend::DEMA;
pub use trend::EMA;
pub use trend::HMA;
pub use trend::KAMA;
pub use trend::SMA;
pub use trend::SMMA;
pub use trend::TEMA;
pub use trend::VWMA;
pub use trend::WMA;
pub use momentum::Momentum;
pub use momentum::Stochastic;
pub use momentum::WilliamsR;
pub use momentum::CCI;
pub use momentum::MACD;
pub use momentum::ROC;
pub use momentum::RSI;
pub use momentum::TSI;
pub use volatility::BollingerBands;
pub use volatility::DonchianChannels;
pub use volatility::KeltnerChannels;
pub use volatility::StdDev;
pub use volatility::TrueRange;
pub use volatility::ATR;
pub use volume::ForceIndex;
pub use volume::AD;
pub use volume::CMF;
pub use volume::EMV;
pub use volume::MFI;
pub use volume::OBV;
pub use volume::VWAP;
pub use williams::Alligator;
pub use williams::AwesomeOscillator;
pub use williams::Fractals;
pub use statistical::Correlation;
pub use statistical::LinearRegression;
pub use statistical::ZScore;
pub use patterns::BearishEngulfing;
pub use patterns::BullishEngulfing;
pub use patterns::Doji;
pub use patterns::Hammer;
pub use patterns::PatternDetector;
pub use patterns::PatternSignal;
pub use patterns::ShootingStar;
pub use patterns::ThreeBlackCrows;
pub use patterns::ThreeWhiteSoldiers;
pub use types::OhlcBar;

Modules§

errors
Error types for technical indicators.
momentum
Momentum indicators for identifying trend strength and reversals.
patterns
Candlestick pattern recognition.
statistical
Statistical indicators
traits
Traits for technical indicators.
trend
Trend indicators for identifying market direction.
types
Common types used by technical indicators.
utils
Utility types and functions for technical indicators.
volatility
Volatility indicators for measuring price volatility and risk.
volume
Volume indicators for analyzing volume patterns and confirming price movements.
williams
Bill Williams indicators.