{"id":26729704,"url":"https://github.com/rust-ta/kand","last_synced_at":"2025-03-27T23:01:19.849Z","repository":{"id":279051058,"uuid":"937135022","full_name":"rust-ta/kand","owner":"rust-ta","description":"A Blazingly Fast Technical Analysis Library in Rust and Python.","archived":false,"fork":false,"pushed_at":"2025-03-14T11:11:23.000Z","size":6980,"stargazers_count":77,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-14T12:23:51.178Z","etag":null,"topics":["finance","financial","indicator","quant","series-analysis","stocks","ta-lib","technical-analysis"],"latest_commit_sha":null,"homepage":"https://rust-ta.github.io/kand/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-ta.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-22T12:23:12.000Z","updated_at":"2025-03-14T11:10:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"2aa685ad-c7e6-4315-bddd-d058892c2efa","html_url":"https://github.com/rust-ta/kand","commit_stats":null,"previous_names":["rust-ta/kand"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-ta%2Fkand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-ta%2Fkand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-ta%2Fkand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-ta%2Fkand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-ta","download_url":"https://codeload.github.com/rust-ta/kand/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245938000,"owners_count":20696992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["finance","financial","indicator","quant","series-analysis","stocks","ta-lib","technical-analysis"],"created_at":"2025-03-27T23:00:45.850Z","updated_at":"2025-03-27T23:01:19.801Z","avatar_url":"https://github.com/rust-ta.png","language":"Rust","funding_links":[],"categories":["Analytic tools"],"sub_categories":["Indicators"],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cimg src=\"docs/assets/logo.png\" alt=\"Kand Logo\" width=\"250\"\u003e\n\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://crates.io/crates/kand\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/kand.svg\" alt=\"Crates.io\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://docs.rs/kand\"\u003e\n    \u003cimg src=\"https://docs.rs/kand/badge.svg\" alt=\"Docs.rs\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.python.org/pypi/kand\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/kand.svg\" alt=\"PyPI Version\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.python.org/pypi/kand\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/kand.svg\" alt=\"Python Versions\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/rust-ta/kand/actions/workflows/CI.yml\"\u003e\n    \u003cimg src=\"https://github.com/rust-ta/kand/actions/workflows/CI.yml/badge.svg\" alt=\"CI Status\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.python.org/pypi/kand\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/l/kand.svg\" alt=\"License\"/\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eDocumentation\u003c/b\u003e:\n  \u003ca href=\"https://docs.rs/kand\"\u003eRust\u003c/a\u003e\n  -\n  \u003ca href=\"https://rust-ta.github.io/kand/\"\u003ePython\u003c/a\u003e\n  |\n  \u003cb\u003eRepository\u003c/b\u003e:\n  \u003ca href=\"https://github.com/rust-ta/kand\"\u003eGitHub\u003c/a\u003e\n\u003c/p\u003e\n\u003ch2 align=\"center\"\u003e\n  \u003cb\u003eKand: A Blazingly Fast Technical Analysis Library, written in Rust.\u003c/b\u003e\n\u003c/h2\u003e\n\n\u003e ⚠️ **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!\n\n\u003cp align=\"center\"\u003e\n  \u003cpicture align=\"center\"\u003e\n    \u003cimg alt=\"EMA Performance Comparison\" src=\"docs/assets/bench_ema.png\" width=\"600\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ci\u003eEMA calculation performance comparison across different implementations.\u003c/i\u003e\n\u003c/p\u003e\n\n## Why Kand?\n\n- **⚡ Unmatched Performance**\n  Built in Rust, delivering blazing speed and memory safety, rivaling TALib’s peak.\n\n- **🔓 Multithreading Unleashed**\n  Breaks free from Python’s GIL, enabling seamless parallel processing beyond single-threaded limits.\n\n- **⚙️ Real-Time Incremental Core**\n  O(1) complexity updates, redefining high-efficiency computation.\n\n- **🚀 Native Zero-Copy**\n  Deeply integrated with NumPy, ensuring lossless data flow at maximum speed.\n\n- **📊 Pioneering Indicators**\n  Features advanced tools like Vegas, VWAP, and Supertrend, pushing analysis frontiers.\n\n- **📦 Lightweight \u0026 Effortless**\n  Ultra-compact package with one-line install—no bloat, no complex dependencies.\n\n- **💻 Universal Compatibility**\n  Runs flawlessly across macOS, Linux, and Windows.\n\nDive deeper at our [official documentation](https://rust-ta.github.io/kand/about).\n\n#### Python API\n\nThe 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.\n\n```python\nimport numpy as np\nfrom kand import ema\n\n# Batch EMA computation with zero-copy NumPy integration\nprices = np.array([10.0, 11.0, 12.0, 13.0, 14.0], dtype=np.float64)\nema_values = ema(prices, period=3)\n\n# Incremental EMA update for streaming data\nprev_ema = 13.5\nnew_price = 15.0\nnew_ema = ema_inc(new_price, prev_ema, period=3)\n```\n\n**Key Features:**\n\n- **Zero-Copy**: Operates directly on NumPy arrays, avoiding memory duplication.\n- **GIL-Free**: Rust backend releases the Python GIL, enabling parallel execution.\n- **Incremental Updates**: O(1) complexity for real-time applications.\n\n---\n\n#### Rust API\n\nThe 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.\n\n```rust\nuse kand::ohlcv::ema;\nuse ndarray::Array1;\n\n// Batch EMA calculation over a price series\nlet prices = vec![10.0, 11.0, 12.0, 13.0, 14.0];\nlet mut ema_values = vec![0.0; prices.len()];\nema::ema(\u0026prices, 3, None, \u0026mut ema_values)?;\n\n// Batch EMA with ndarray for scientific workflows\nlet prices = Array1::from_vec(vec![10.0, 11.0, 12.0, 13.0, 14.0]);\nlet mut ema_values = Array1::zeros(prices.len());\nema::ema(\u0026prices, 3, None, \u0026mut ema_values)?;\n\n// Constant-time incremental EMA update\nlet prev_ema = 13.5;\nlet new_price = 15.0;\nlet new_ema = ema::ema_inc(new_price, prev_ema, 3, None)?;\n```\n\n**Key Features:**\n\n- **Memory Efficiency**: Leverages mutable buffers (`\u0026mut Vec\u003cf64\u003e` or `\u0026mut Array1\u003cf64\u003e`) to store results, slashing memory allocations.\n- **Error Handling**: Returns `Result\u003c(), KandError\u003e` or `Result\u003cf64, KandError\u003e` for reliable failure detection (e.g., invalid period, NaN inputs).\n- **Incremental Design**: O(1) updates tailored for real-time systems.\n\n---\n\n## Setup\n\n### Python\n\nGet started with Kand in one command - no extra configuration needed:\n\n```bash\npip install kand\n```\n\n### Rust\n\nYou can take latest release from [`crates.io`](https://crates.io/crates/kand), or if you want to use the latest features / performance improvements point to the `main` branch of this repo.\n\n```toml\n[dependencies]\nkand = { git = \"https://github.com/rust-ta/kand\", rev = \"\u003coptional git tag\u003e\" }\n```\n\nRecommend Rust version `\u003e=1.80`.\n\n## Functions List\n\n### OHLCV Based\n\n- [x] **AD** - Chaikin A/D Line\n- [x] **ADOSC** - Chaikin A/D Oscillator\n- [x] **ADR** - Average Daily Range\n- [x] **ADX** - Average Directional Movement Index\n- [x] **ADXR** - Average Directional Movement Index Rating\n- [ ] **APO** - Absolute Price Oscillator\n- [x] **AROON** - Aroon\n- [x] **AROONOSC** - Aroon Oscillator\n- [x] **ATR** - Average True Range\n- [x] **BBANDS** - Bollinger Bands\n- [x] **BOP** - Balance Of Power\n- [x] **CCI** - Commodity Channel Index\n- [x] **CDL_DOJI** - Doji\n- [x] **CDL_DRAGONFLY_DOJI** - Dragonfly Doji\n- [x] **CDL_GRAVESTONE_DOJI** - Gravestone Doji\n- [x] **CDL_HAMMER** - Hammer\n- [x] **CDL_INVERTED_HAMMER** - Inverted Hammer\n- [x] **CDL_LONG_LOWER_SHADOW** - Long Lower Shadow\n- [x] **CDL_LONG_UPPER_SHADOW** - Long Upper Shadow\n- [x] **CDL_MARUBOZU** - Marubozu\n- [ ] **CMO** - Chande Momentum Oscillator\n- [x] **DEMA** - Double Exponential Moving Average\n- [x] **DX** - Directional Movement Index\n- [x] **EMA** - Exponential Moving Average\n- [x] **ECL** - Expanded Camarilla Levels **[Untested]**\n- [x] **HA** - Heikin Ashi Chart\n- [ ] **HT_DCPERIOD** - Hilbert Transform - Dominant Cycle Period\n- [ ] **HT_DCPHASE** - Hilbert Transform - Dominant Cycle Phase\n- [ ] **HT_PHASOR** - Hilbert Transform - Phasor Components\n- [ ] **HT_SINE** - Hilbert Transform - SineWave\n- [ ] **HT_TRENDLINE** - Hilbert Transform - Instantaneous Trendline\n- [ ] **HT_TRENDMODE** - Hilbert Transform - Trend vs Cycle Mode\n- [ ] **KAMA** - Kaufman Adaptive Moving Average\n- [ ] **LINEARREG** - Linear Regression\n- [ ] **LINEARREG_ANGLE** - Linear Regression Angle\n- [ ] **LINEARREG_INTERCEPT** - Linear Regression Intercept\n- [ ] **LINEARREG_SLOPE** - Linear Regression Slope\n- [x] **MACD** - Moving Average Convergence/Divergence **[Unstable]**\n- [ ] **MACDEXT** - MACD with controllable MA type\n- [ ] **MAMA** - MESA Adaptive Moving Average\n- [x] **MEDPRICE** - Median Price\n- [x] **MFI** - Money Flow Index **[No Incremental]**\n- [x] **MIDPOINT** - MidPoint over period\n- [x] **MIDPRICE** - Midpoint Price over period\n- [x] **MINUS_DI** - Minus Directional Indicator\n- [x] **MINUS_DM** - Minus Directional Movement\n- [x] **MOM** - Momentum\n- [x] **NATR** - Normalized Average True Range\n- [x] **OBV** - On Balance Volume\n- [x] **PLUS_DI** - Plus Directional Indicator\n- [x] **PLUS_DM** - Plus Directional Movement\n- [ ] **PPO** - Percentage Price Oscillator\n- [ ] **RENKO** - Renko Chart\n- [x] **RMA** - Rolling Moving Average\n- [x] **ROC** - Rate of change : ((price/prevPrice)-1)*100\n- [x] **ROCP** - Rate of change Percentage: (price-prevPrice)/prevPrice\n- [x] **ROCR** - Rate of change ratio: (price/prevPrice)\n- [x] **ROCR100** - Rate of change ratio 100 scale: (price/prevPrice)*100\n- [x] **RSI** - Relative Strength Index\n- [x] **SAR** - Parabolic SAR\n- [ ] **SAREXT** - Parabolic SAR - Extended\n- [x] **SMA** - Simple Moving Average\n- [x] **STOCH** - Stochastic **[No Incremental]**\n- [ ] **STOCHF** - Stochastic Fast\n- [ ] **STOCHRSI** - Stochastic Relative Strength Index\n- [x] **SUPERTREND** - Super Trend Indicator\n- [x] **T3** - Triple Exponential Moving Average (T3)\n- [x] **TEMA** - Triple Exponential Moving Average\n- [x] **TRANGE** - True Range\n- [x] **TRIMA** - Triangular Moving Average\n- [x] **TRIX** - 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA\n- [ ] **TSF** - Time Series Forecast\n- [x] **TYPPRICE** - Typical Price\n- [ ] **ULTOSC** - Ultimate Oscillator\n- [x] **VEGAS** - VEGAS Channel and Trend Boundary EMAs **[Untested]**\n- [x] **VWAP** - Volume Weighted Average Price\n- [x] **WCLPRICE** - Weighted Close Price\n- [x] **WILLR** - Williams' %R\n- [x] **WMA** - Weighted Moving Average\n\n### Statistical Analysis\n\n- [ ] **ALPHA** - Alpha: Measures excess returns over market\n- [ ] **BETA** - Beta: Measures sensitivity to market volatility\n- [ ] **CALMAR** - Calmar Ratio: Annual return to maximum drawdown ratio\n- [ ] **CORREL** - Pearson's Correlation Coefficient\n- [ ] **DRAWDOWN** - Maximum Drawdown: Maximum potential loss\n- [ ] **KELLY** - Kelly Criterion: Optimal position sizing\n- [x] **MAX** - Highest value over a specified period\n- [x] **MIN** - Lowest value over a specified period\n- [ ] **SHARPE** - Sharpe Ratio: Risk-adjusted return measure\n- [ ] **SORTINO** - Sortino Ratio: Downside risk-adjusted returns\n- [x] **STDDEV** - Standard Deviation\n- [x] **SUM** - Summation\n- [x] **VAR** - Variance\n- [ ] **WINRATE** - Win Rate: Strategy success probability\n\n## Contributing\n\nWe are passionate about supporting contributors of all levels of experience and would love to see\nyou get involved in the project. See the\n[contributing guide](https://github.com/rust-ta/kand/blob/main/CONTRIBUTING.md) to get started.\n\n\n## License\n\nThis project is licensed under either of the following licenses, at your option:\n- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n  \u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttps://opensource.org/licenses/MIT\u003e)\n\nUnless 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-ta%2Fkand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-ta%2Fkand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-ta%2Fkand/lists"}