Crates.io | kand |
lib.rs | kand |
version | 0.2.2 |
created_at | 2025-02-22 12:43:12.504708+00 |
updated_at | 2025-03-05 02:27:13.278635+00 |
description | Kand: A Pure Rust technical analysis library inspired by TA-Lib. |
homepage | |
repository | https://github.com/rust-ta/kand |
max_upload_size | |
id | 1565373 |
size | 775,470 |
Documentation: Rust - Python | Repository: GitHub
⚠️ Development Status: This project is under active development. APIs may change, and some features might not be fully implemented or tested yet. Contributions and feedback are welcome!
EMA calculation performance comparison across different implementations.
⚡ Unmatched Performance Built in Rust, delivering blazing speed and memory safety, rivaling TALib’s peak.
🔓 Multithreading Unleashed Breaks free from Python’s GIL, enabling seamless parallel processing beyond single-threaded limits.
⚙️ Real-Time Incremental Core O(1) complexity updates, redefining high-efficiency computation.
🚀 Native Zero-Copy Deeply integrated with NumPy, ensuring lossless data flow at maximum speed.
📊 Pioneering Indicators Features advanced tools like Vegas, VWAP, and Supertrend, pushing analysis frontiers.
📦 Lightweight & Effortless Ultra-compact package with one-line install—no bloat, no complex dependencies.
💻 Universal Compatibility Runs flawlessly across macOS, Linux, and Windows.
Dive deeper at our official documentation.
The Python interface of kand
leverages PyO3 for ultra-low latency bindings (~7ns overhead) to the Rust core, seamlessly integrating with NumPy for zero-copy operations and true thread-safe calculations. Below are examples for batch and incremental usage.
import numpy as np
from kand import ema
# Batch EMA computation with zero-copy NumPy integration
prices = np.array([10.0, 11.0, 12.0, 13.0, 14.0], dtype=np.float64)
ema_values = ema(prices, period=3)
# Incremental EMA update for streaming data
prev_ema = 13.5
new_price = 15.0
new_ema = ema_inc(new_price, prev_ema, period=3)
Key Features:
The Rust interface in kand
provides a high-performance, type-safe implementation of EMA with flexible parameter control. It supports both Vec and ndarray inputs for batch and incremental calculations, as shown below.
use kand::ohlcv::ema;
use ndarray::Array1;
// Batch EMA calculation over a price series
let prices = vec![10.0, 11.0, 12.0, 13.0, 14.0];
let mut ema_values = vec![0.0; prices.len()];
ema::ema(&prices, 3, None, &mut ema_values)?;
// Batch EMA with ndarray for scientific workflows
let prices = Array1::from_vec(vec![10.0, 11.0, 12.0, 13.0, 14.0]);
let mut ema_values = Array1::zeros(prices.len());
ema::ema(&prices, 3, None, &mut ema_values)?;
// Constant-time incremental EMA update
let prev_ema = 13.5;
let new_price = 15.0;
let new_ema = ema::ema_inc(new_price, prev_ema, 3, None)?;
Key Features:
&mut Vec<f64>
or &mut Array1<f64>
) to store results, slashing memory allocations.Result<(), KandError>
or Result<f64, KandError>
for reliable failure detection (e.g., invalid period, NaN inputs).Get started with Kand in one command - no extra configuration needed:
pip install kand
You can take latest release from crates.io
, or if you want to use the latest features / performance improvements point to the main
branch of this repo.
[dependencies]
kand = { git = "https://github.com/rust-ta/kand", rev = "<optional git tag>" }
Recommend Rust version >=1.80
.
We are passionate about supporting contributors of all levels of experience and would love to see you get involved in the project. See the contributing guide to get started.
This project is licensed under either of the following licenses, at your option:
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in kand by you, as defined in the Apache-2.0 license, shall be dually licensed as above, without any additional terms or conditions.