m4rs

Crates.iom4rs
lib.rsm4rs
version0.12.0
sourcesrc
created_at2024-06-27 03:59:28.312672
updated_at2024-08-31 10:27:27.081136
descriptionTrading indicator library supporting SMA, EMA, BolingerBand, MACD, RSI, Stochastics, Ichimoku, and more
homepagehttps://github.com/00x4/m4rs/
repositoryhttps://github.com/00x4/m4rs
max_upload_size
id1285076
size88,078
Yoshito Yamazaki (00x4)

documentation

README

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

Commit count: 33

cargo fmt