Crates.io | rustalib |
lib.rs | rustalib |
version | 1.0.9 |
created_at | 2025-05-13 21:23:52.753824+00 |
updated_at | 2025-07-04 21:18:57.760964+00 |
description | A library of technical indicators for financial analysis, similar to TA-Lib |
homepage | https://github.com/rustic-ml/RusTaLib |
repository | https://github.com/rustic-ml/RusTaLib |
max_upload_size | |
id | 1672539 |
size | 789,849 |
Meet Rustalib, your steadfast crustacean companion for navigating the currents of financial markets! This comprehensive Rust library, rustalib
, provides a powerful toolkit for calculating technical indicators, all powered by the high-performance Polars DataFrame library.
Whether you're charting, backtesting, or building live trading systems, Rustalib is here to help you process market data with speed and precision.
rustalib provides a robust, extensible, and efficient toolkit for quantitative finance, algorithmic trading, and data science in Rust. The library is designed for:
Whether you are backtesting, researching, or building production trading systems, this crate offers a solid foundation for technical analysis in Rust.
Add to your Cargo.toml
:
[dependencies]
rustalib = "*" # Or specify a version
polars = { version = "0.46", features = ["lazy", "dtype-full"] }
use polars::prelude::*;
use ta_lib_in_rust::indicators::moving_averages::calculate_sma;
fn main() -> PolarsResult<()> {
let close = Series::new("close", &[10.0, 11.0, 12.0, 11.5, 12.5]);
let mut df = DataFrame::new(vec![close.into()])?;
let sma_3 = calculate_sma(&df, "close", 3)?;
df.with_column(sma_3)?;
println!("{}", df);
Ok(())
}
use polars::prelude::*;
use ta_lib_in_rust::indicators::{
moving_averages::calculate_ema,
oscillators::calculate_rsi,
volatility::calculate_bollinger_bands,
};
fn main() -> PolarsResult<()> {
let close = Series::new("close", &[100.0, 102.0, 104.0, 103.0, 105.0]);
let mut df = DataFrame::new(vec![close.clone().into()])?;
let ema_3 = calculate_ema(&df, "close", 3)?;
let rsi_3 = calculate_rsi(&df, 3, "close")?;
let (bb_mid, bb_up, bb_low) = calculate_bollinger_bands(&df, 3, 2.0, "close")?;
df = df.with_columns([ema_3, rsi_3, bb_mid, bb_up, bb_low])?;
println!("{}", df);
Ok(())
}
let df = CsvReadOptions::default()
.with_has_header(true)
.try_into_reader_with_file_path(Some("data.csv".into()))?
.finish()?;
// Important: Ensure column names are lowercase for compatibility with indicators
let mut df = df.lazy()
.select([
col("Symbol").alias("symbol"),
col("Timestamp").alias("timestamp"),
col("Open").alias("open"),
col("High").alias("high"),
col("Low").alias("low"),
col("Close").alias("close"),
col("Volume").cast(DataType::Float64).alias("volume"),
])
.collect()?;
// ... apply indicators ...
CsvWriter::new(std::io::BufWriter::new(std::fs::File::create("results.csv")?))
.finish(&mut df)?;
See the examples/
directory for:
This library expects lowercase column names (open
, high
, low
, close
, volume
) in DataFrames. When working with CSVs that might have different case formats (e.g., Open
, High
, etc.), make sure to rename the columns using Polars' selection and aliasing capabilities as shown in the examples above.
Contributions are welcome! Please:
MIT License. See LICENSE for details.