#indicator #trading #moving-average #stock #charts #standard-deviation

m4rs

Trading indicator library supporting SMA, EMA, BolingerBand, MACD, RSI, Stochastics, Ichimoku, and more

11 breaking releases

new 0.12.0 Aug 31, 2024
0.10.0 Aug 17, 2024
0.7.0 Jul 27, 2024

#33 in Finance

Download history 276/week @ 2024-06-24 302/week @ 2024-07-01 129/week @ 2024-07-08 119/week @ 2024-07-15 119/week @ 2024-07-22 130/week @ 2024-07-29 118/week @ 2024-08-05 154/week @ 2024-08-12 143/week @ 2024-08-19 147/week @ 2024-08-26

585 downloads per month

MIT/Apache

76KB
1.5K SLoC

m4rs - Moving Average for Rust

crates.io

  • Trading indicator library
  • Small and simple implementation
  • No extra dependencies
  • Supports following indicators
    • ATR
    • Awesome Oscillator
    • Bolinger Band
    • CCI
    • DEMA
    • DMI/ADX
    • EMA
    • Envelope
    • Heikin Ashi
    • HMA
    • Ichimoku Kinko Hyo
    • MACD
    • Momentum
    • Parabolic SAR
    • RCI
    • RMA
    • RSI
    • SMA
    • Standard Deviation
    • Stochastics (Fast, Slow)
    • TEMA
    • VWMA
    • Williams Fractals
    • Williams %R
    • WMA
  • Call it "Mars"

Installation

cargo add m4rs

Examples

// Prepare candlesticks in some way such as by retrieving them from the exchange's API
// And make them into m4rs::Candlestick objects
let entries: Vec<m4rs::Candlestick> = vec![
    (1719400001, 100.0, 130.0, 90.0, 110.0, 1000.0),
    (1719400002, 110.0, 140.0, 100.0, 130.0, 1000.0),
    (1719400003, 130.0, 135.0, 120.0, 120.0, 1000.0),
    (1719400004, 120.0, 130.0, 80.0, 90.0, 1000.0),
    (1719400005, 90.0, 100.0, 70.0, 80.0, 1000.0),
    (1719400006, 80.0, 180.0, 60.0, 120.0, 1000.0),
    (1719400007, 120.0, 210.0, 110.0, 180.0, 1000.0),
    (1719400008, 180.0, 185.0, 170.0, 180.0, 1000.0),
    (1719400009, 180.0, 220.0, 140.0, 200.0, 1000.0),
]
.iter()
.map(|(at, o, h, l, c, v)| m4rs::Candlestick::new(*at, *o, *h, *l, *c, *v))
.collect();

// Get 3SMA calculation result
let result = m4rs::sma(&entries, 3).unwrap();

for x in &result {
    println!("{}: {:.1}", x.at, x.value);
}
// 1719400003: 120.0
// 1719400004: 113.3
// 1719400005: 96.7
// 1719400006: 96.7
// 1719400007: 126.7
// 1719400008: 160.0
// 1719400009: 186.7

API Reference

No runtime deps