indicator_math 0.6.7

เพิ่มการ analysis ให้เลือก ema,hma หรืออื่นๆ A technical analysis indicator library for Rust: SMA, EMA, WMA, HMA, EHMA, MACD and more.
Documentation
# Indicator Math


A Rust library for technical analysis indicators (SMA, EMA, WMA, HMA, MACD) and automated trend analysis.

## Usage


Add this to your `Cargo.toml`:

```toml
[dependencies]
indicator_math = "0.6.4"


Example: Getting Trading Actions
You can use the get_action_by_simple function to determine whether to Call or Put based on the EMA analysis results.

use indicator_math::{Candle, analyze_ema, get_action_by_simple};

fn main() {
    // 1. Prepare your candle data
    let candles = vec![
        Candle { time: 1735344000, open: 150.0, high: 155.0, low: 149.0, close: 152.0 },
        // ... add more candles (at least enough to satisfy your EMA period)
    ];

    // 2. Run the analysis (Short Period: 10, Long Period: 20)
    let analysis_results = analyze_ema(&candles, 10, 20);

    // 3. Get action for the latest data point
    if !analysis_results.is_empty() {
        let last_index = analysis_results.len() - 1;
        let action = get_action_by_simple(&analysis_results, last_index);

        match action {
            "call" => println!("🚀 Signal: CALL (Short EMA is above Long EMA)"),
            "put"  => println!("🔻 Signal: PUT (Long EMA is above Short EMA)"),
            "hold" => println!("↔️ Signal: HOLD (Neutral)"),
            _      => println!("No signal available"),
        }
    }
}