| Crates.io | oxi-talib |
| lib.rs | oxi-talib |
| version | 0.1.1 |
| created_at | 2025-10-03 21:05:17.495354+00 |
| updated_at | 2025-10-04 04:02:50.148872+00 |
| description | A Rust library for candlestick pattern recognition. |
| homepage | |
| repository | https://github.com/sbooker/oxi-talib |
| max_upload_size | |
| id | 1867197 |
| size | 64,497 |
oxi-talib is a Rust library for candlestick pattern recognition.
Vec, Result, Option).unsafe code required for C library interaction is encapsulated.The library depends on the C library TA-Lib, which must be installed on the system.
Linux / macOS Build from source:
sudo apt-get update && sudo apt-get install build-essential libclang-dev
Other Systems:
Install the equivalent packages (e.g., base-devel and clang on Arch Linux, "Build Tools for Visual Studio" and LLVM on Windows, or Xcode Command Line Tools on macOS).
Cargo.toml[dependencies]
oxi-talib = "0.1.0"
use oxi_talib::{cdl, Pattern, SimpleCandle, Error};
fn main() -> Result<(), Error> {
// 1. Data for analysis.
let candles: Vec<SimpleCandle> = vec![
SimpleCandle::try_new(100.0, 105.0, 106.0, 98.0)?,
SimpleCandle::try_new(105.0, 102.0, 107.0, 101.0)?,
// A candle corresponding to the "Hammer" pattern
SimpleCandle::try_new(102.0, 103.0, 104.0, 95.0)?,
SimpleCandle::try_new(103.0, 108.0, 109.0, 102.0)?,
];
// 2. Perform the analysis for the "Hammer" pattern.
let signals = cdl().pattern(Pattern::Hammer, &candles)?;
// 3. Process the results.
assert_eq!(signals.len(), candles.len());
for (i, signal) in signals.iter().enumerate() {
if let Some(s) = signal {
println!(
"Hammer pattern found at candle #{} with quality {}!",
i, s.quality.value()
);
}
}
Ok(())
}
Candle TraitTo work with your own data structures, you need to implement the Candle trait.
use oxi_talib::{Candle, Pattern, cdl};
#[derive(Clone)]
struct MyData {
open_price: f64,
high_price: f64,
low_price: f64,
close_price: f64,
}
impl Candle for MyData {
type Price = f64;
fn open(&self) -> Self::Price { self.open_price }
fn high(&self) -> Self::Price { self.high_price }
fn low(&self) -> Self::Price { self.low_price }
fn close(&self) -> Self::Price { self.close_price }
}
let my_data: Vec<MyData> = // ...
let signals = cdl().pattern(Pattern::Doji, &my_data);
Recognition parameters can be changed via the configure function. It should be called once at application startup in a single-threaded context.
use oxi_talib::cdl::engines::talib::engine::configure;
use oxi_talib::Settings;
// Executed once in the main function.
let mut settings = Settings::default();
settings.body_doji_factor = 0.2; // Example of changing a parameter
configure(settings).expect("Configuration should not be called more than once");
// All subsequent calls to `cdl()` will use these settings.
Stage 1: TA-Lib API Coverage
CDL).Stage 2: Native Rust Implementation
Stage 3: Advanced Analysis
Quality (shape correctness) and Strength (contextual significance) scoring system after transitioning to a native implementation.