-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrsi_basic.rs
More file actions
32 lines (26 loc) · 1020 Bytes
/
rsi_basic.rs
File metadata and controls
32 lines (26 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use polars::prelude::*;
use rustalib::indicators::oscillators::calculate_rsi;
fn main() -> Result<(), PolarsError> {
// Create a simple price series with some movement
let close_prices = Series::new(
"close".into(),
&[
100.0, 102.0, 104.0, 103.0, 105.0, 107.0, 108.0, 107.0, 105.0, 103.0, 101.0, 99.0,
97.0, 95.0, 94.0,
],
);
// Create DataFrame with date and price data
let df = DataFrame::new(close_prices.len(), vec![close_prices.clone().into()])?;
// Calculate RSI with 5-period setting for this short example
let rsi = calculate_rsi(&df, 5, "close")?;
// Print the RSI values
println!("RSI values:");
println!("{}", rsi);
// Show how to interpret RSI values
println!("\nBasic RSI interpretation:");
println!("-------------------------");
println!("Values above 70: Overbought condition");
println!("Values below 30: Oversold condition");
println!("Values around 50: Neutral market");
Ok(())
}