pub struct Rsi { /* private fields */ }Expand description
Relative Strength Index indicator.
Measures the magnitude of recent price changes to evaluate overbought or oversold conditions. Values range from 0 to 100.
§Formula
RSI = 100 - (100 / (1 + RS)) RS = Average Gain / Average Loss
Traditional interpretation:
- RSI > 70: Overbought
- RSI < 30: Oversold
§Example
use quant_indicators::{Indicator, Rsi};
use quant_primitives::Candle;
use chrono::Utc;
use rust_decimal_macros::dec;
let ts = Utc::now();
let candles: Vec<Candle> = (0..20).map(|i| {
Candle::new(dec!(100), dec!(110), dec!(90), dec!(100) + rust_decimal::Decimal::from(i), dec!(1000), ts).unwrap()
}).collect();
let rsi = Rsi::new(14).unwrap();
let series = rsi.compute(&candles).unwrap();Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Rsi
impl RefUnwindSafe for Rsi
impl Send for Rsi
impl Sync for Rsi
impl Unpin for Rsi
impl UnsafeUnpin for Rsi
impl UnwindSafe for Rsi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more