Module main

Source
Expand description

A Relative Strength Index (RSI) calculator module.

This module provides an implementation for calculating the Relative Strength Index (RSI) over a configurable period with customizable overbought and oversold thresholds.

The RSI is a momentum oscillator that measures the speed and change of price movements. It is used to indicate overbought or oversold market conditions.

§Examples

Using the default thresholds (70 for overbought, 30 for oversold):

use indexes_rs::v1::rsi::main::RSI;
use indexes_rs::v1::sma::main::SMAError;
use indexes_rs::v1::rsi::types::RSIResult;
use indexes_rs::v1::types::TrendDirection;

let mut rsi = RSI::new(14, None, None);
let prices = vec![44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10, 45.42];

for price in prices {
    if let Some(result) = rsi.calculate(price) {
        println!("RSI: {:.2}, Condition: {:?}", result.value, result.condition);
    }
}

Using custom thresholds (e.g., 80 for overbought and 20 for oversold):

use indexes_rs::v1::rsi::main::RSI;
let mut rsi = RSI::new(14, Some(80.0), Some(20.0));

Structs§

RSI
A struct for calculating the Relative Strength Index (RSI) with customizable thresholds.