{"_id":"@bnn1/ta-tools","_rev":"2-5287250d1ae351402f96e266cd134fa3","name":"@bnn1/ta-tools","dist-tags":{"latest":"0.2.3"},"versions":{"0.1.1":{"name":"@bnn1/ta-tools","version":"0.1.1","keywords":["technical-analysis","trading","indicators","wasm","rust"],"author":{"name":"bnn1"},"license":"MIT","_id":"@bnn1/ta-tools@0.1.1","maintainers":[{"name":"bnn1","email":"boris.novikov95@gmail.com"}],"homepage":"https://github.com/bnn1/ta-tools#readme","bugs":{"url":"https://github.com/bnn1/ta-tools/issues"},"dist":{"shasum":"c7e39986f9d1ce4a1d0f55976e1e1510bdb92e08","tarball":"https://registry.npmjs.org/@bnn1/ta-tools/-/ta-tools-0.1.1.tgz","fileCount":8,"integrity":"sha512-WUTXUK22AV4ZgDW+ssRmw3+28JmxnVP4yJtS0e2YZSF/xhHHqsiNb7XWJUpE/mUZGikPL0UG6aQ73UG9opZGHQ==","signatures":[{"sig":"MEQCIG/EGWtIIkfGmSP3l7vWSpkoz6BuKt6VjFcEzIWBXVWtAiAqub1XdF9V0Pwz3aOfRwnvLxyfTRBZC9UOWUL6Fu6m5A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":449911},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"270ba0c7cca13958308213a3f2f5a38e72785d7f","scripts":{"test":"vitest run","bench":"vitest bench","build":"npm run build:wasm && npm run build:ts","build:ts":"tsc","build:wasm":"wasm-pack build crates/ta-core --target nodejs --out-dir ../../pkg","prepublishOnly":"npm run build && npm test"},"_npmUser":{"name":"bnn1","email":"boris.novikov95@gmail.com"},"repository":{"url":"git+https://github.com/bnn1/ta-tools.git","type":"git"},"_npmVersion":"11.6.2","description":"Blazing fast technical analysis indicators powered by Rust/WASM","directories":{},"_nodeVersion":"24.11.1","_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","typescript":"^5.7.2","indicatorts":"^2.2.2","trading-signals":"^7.1.1","fast-technical-indicators":"^1.1.4"},"_npmOperationalInternal":{"tmp":"tmp/ta-tools_0.1.1_1765305161309_0.8745262697417067","host":"s3://npm-registry-packages-npm-production"}},"0.2.3":{"name":"@bnn1/ta-tools","version":"0.2.3","description":"Blazing fast technical analysis indicators powered by Rust/WASM","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build:wasm":"wasm-pack build crates/ta-core --target nodejs --out-dir ../../pkg","build:ts":"tsc","build":"npm run build:wasm && npm run build:ts","test":"vitest run","bench":"vitest bench","prepublishOnly":"npm run build && npm test"},"repository":{"type":"git","url":"git+https://github.com/bnn1/ta-tools.git"},"homepage":"https://github.com/bnn1/ta-tools#readme","bugs":{"url":"https://github.com/bnn1/ta-tools/issues"},"author":{"name":"bnn1"},"engines":{"node":">=22.0.0"},"keywords":["technical-analysis","trading","indicators","wasm","rust"],"license":"MIT","devDependencies":{"fast-technical-indicators":"^1.1.4","indicatorts":"^2.2.2","trading-signals":"^7.1.1","typescript":"^5.7.2","vitest":"^2.1.8"},"gitHead":"d4a24fccf27e2b8638661134cf8519797eca24ed","_id":"@bnn1/ta-tools@0.2.3","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-DUivv72dbofNWzGh0hxxJ44TvIYvtByugeewhUMbl/wp7+67sTHvy4rNx6tRDaFoDyCVFcjqqjEo21jIxP800Q==","shasum":"379037e1e454ef4e84f9be905c9de3801fabc626","tarball":"https://registry.npmjs.org/@bnn1/ta-tools/-/ta-tools-0.2.3.tgz","fileCount":8,"unpackedSize":450731,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCofiqdNLz3V7a8TK5A9ogS70IWU1sJnKO4f2y/qWKZcAIgVO13Bjc0JDRjWNkh758Fj14L4ORhCZ/bKyYbdOQ4Je8="}]},"_npmUser":{"name":"bnn1","email":"boris.novikov95@gmail.com"},"directories":{},"maintainers":[{"name":"bnn1","email":"boris.novikov95@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ta-tools_0.2.3_1765342299501_0.6142851812859267"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-09T18:32:41.223Z","modified":"2025-12-10T04:51:39.835Z","0.1.1":"2025-12-09T18:32:41.488Z","0.2.3":"2025-12-10T04:51:39.671Z"},"bugs":{"url":"https://github.com/bnn1/ta-tools/issues"},"author":{"name":"bnn1"},"license":"MIT","homepage":"https://github.com/bnn1/ta-tools#readme","keywords":["technical-analysis","trading","indicators","wasm","rust"],"repository":{"type":"git","url":"git+https://github.com/bnn1/ta-tools.git"},"description":"Blazing fast technical analysis indicators powered by Rust/WASM","maintainers":[{"name":"bnn1","email":"boris.novikov95@gmail.com"}],"readme":"# ta-tools\n\nA high-performance Technical Analysis library written in **Rust** and compiled to **WebAssembly**.\n\n`ta-tools` provides near-native calculation speeds for technical indicators while remaining universally compatible across Node.js, Bun, Deno, and modern browsers.\n\n### Why?\n\nMost existing TA libraries fall into two categories:\n1.  **Pure JavaScript:** Easy to use but suffers from garbage collection overhead during heavy calculations.\n2.  **Native C++ Add-ons (e.g., `tulind`):** Fast, but require complex compile-chains (`node-gyp`) on installation and do not run in the browser.\n\n`ta-tools` solves this by using **WebAssembly**. It offers the performance of C++ with the portability of JavaScript.\n*   **Zero Compilation:** Users do not need a C++ compiler installed.\n*   **Universal:** The exact same package runs on the server and the client.\n*   **Type Safe:** Built with Rust for memory safety and correctness.\n\n---\n\n## Installation\n\n```bash\nnpm install ta-tools\n```\n\n---\n\n## Supported Indicators\n\n**Moving Averages:**\n- SMA (Simple Moving Average)\n- EMA (Exponential Moving Average)\n- WMA (Weighted Moving Average)\n- HMA (Hull Moving Average)\n\n**Oscillators & Momentum:**\n- RSI (Relative Strength Index)\n- MACD (Moving Average Convergence Divergence)\n- Stochastic Fast/Slow\n- Stochastic RSI\n\n**Volatility:**\n- Bollinger Bands\n- ATR (Average True Range)\n- Linear Regression\n\n**Trend & Volume:**\n- ADX (Average Directional Index)\n- Ichimoku Cloud\n- CVD (Cumulative Volume Delta)\n- MFI (Money Flow Index)\n\n**Volume Profile & VWAP:**\n- Fixed Range Volume Profile\n- Session VWAP\n- Rolling VWAP\n- Anchored VWAP\n\n**Support Levels:**\n- Pivot Points (Standard, Fibonacci, Woodie variants)\n\n---\n\n## Usage/API\n\n### Basic Usage - Batch Mode\n\nAll indicators accept either `number[]` or `Float64Array` and return results immediately:\n\n```typescript\nimport { sma, ema, rsi, bbands } from 'ta-tools';\n\nconst prices = [44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10];\n\n// Simple Moving Average\nconst sma14 = sma(prices, 14);\nconsole.log(sma14); // Float64Array\n\n// Exponential Moving Average\nconst ema12 = ema(prices, 12);\n\n// Relative Strength Index\nconst rsi14 = rsi(prices, 14);\n\n// Bollinger Bands (period, standard deviations)\nconst bands = bbands(prices, 20, 2);\nconsole.log(bands.upper);    // Upper band\nconsole.log(bands.middle);   // Middle band (SMA)\nconsole.log(bands.lower);    // Lower band\nconsole.log(bands.percentB); // %B indicator\n```\n\n### OHLCV Indicators - Candle Input\n\nOHLCV indicators accept `Candle[]` directly, eliminating positional arguments:\n\n```typescript\nimport { atr, adx, ichimoku, mfi } from 'ta-tools';\n\ninterface Candle {\n  open: number;\n  high: number;\n  low: number;\n  close: number;\n  volume?: number;\n  time?: number;\n}\n\nconst candles: Candle[] = [\n  { open: 100, high: 102, low: 99, close: 101, volume: 1000000 },\n  { open: 101, high: 103, low: 100, close: 102, volume: 1100000 },\n  // ... more candles\n];\n\n// Average True Range\nconst atrValues = atr(candles, 14);\n\n// Average Directional Index\nconst adxResult = adx(candles, 14);\nconsole.log(adxResult.adx);     // ADX line\nconsole.log(adxResult.plusDI);  // +DI\nconsole.log(adxResult.minusDI); // -DI\n\n// Ichimoku Cloud\nconst cloud = ichimoku(candles, 9, 26, 52);\nconsole.log(cloud.tenkan);   // Conversion line\nconsole.log(cloud.kijun);    // Base line\nconsole.log(cloud.senkouA);  // Leading Span A\nconsole.log(cloud.senkouB);  // Leading Span B\nconsole.log(cloud.chikou);   // Lagging Span\n\n// Money Flow Index\nconst mfiValues = mfi(candles, 14);\n```\n\n### Streaming Mode\n\nFor live data, use `.stream()` to maintain indicator state:\n\n```typescript\nimport { rsi, ema, macd } from 'ta-tools';\n\n// RSI streaming\nconst rsiStream = rsi.stream(14);\nrsiStream.init([44.34, 44.09, 44.15, 43.61]); // Initialize with historical data\nconst currentRsi = rsiStream.next(44.33);     // Add new candle\n\n// EMA streaming\nconst emaStream = ema.stream(12);\nemaStream.init(historicalPrices);\nconst currentEma = emaStream.next(newPrice);\n\n// MACD streaming\nconst macdStream = macd.stream(12, 26, 9);\nmacdStream.init(historicalPrices);\nconst { macd, signal, histogram } = macdStream.next(newPrice);\n```\n\n### Multi-Indicator Analysis\n\nUse `analyze()` to run multiple indicators on the same data:\n\n```typescript\nimport { analyze, sma, ema, rsi, bbands, macd } from 'ta-tools';\n\nconst results = analyze(prices, {\n  sma20: (d) => sma(d, 20),\n  sma50: (d) => sma(d, 50),\n  rsi14: (d) => rsi(d, 14),\n  bbands: (d) => bbands(d, 20, 2),\n  macd: (d) => macd(d, 12, 26, 9),\n});\n\nconsole.log(results.sma20);       // Float64Array\nconsole.log(results.rsi14);       // Float64Array\nconsole.log(results.bbands.upper); // Float64Array\nconsole.log(results.macd.histogram); // Float64Array\n```\n\n### Type Utilities\n\n```typescript\nimport { toFloat64Array, extractOHLCV } from 'ta-tools';\n\n// Convert number[] to Float64Array\nconst arr = toFloat64Array([1, 2, 3, 4, 5]); // Returns Float64Array\n\n// Extract OHLCV components from Candle[]\nconst { open, high, low, close, volume, time } = extractOHLCV(candles);\n```\n\n---\n\n## Performance Notes\n\n`ta-tools` is optimized to minimize boundary overhead between JavaScript and WebAssembly:\n\n*   **Zero-Copy Operations:** Arrays are passed directly to WASM without copying\n*   **Memory:** Uses flat `Float64Array` buffers to avoid object overhead\n*   **Precision:** All calculations use 64-bit floating-point precision (`f64`)\n*   **Compilation:** WASM is pre-compiled and optimized with `wasm-opt -Oz`\n\n### Benchmark Results\n\nBelow is a concise, exact summary of the [benchmarking results](benchmarks/2025-12-09-results.md).\nEach cell shows how ta-tools (WASM) performs relative to the other libraries for the indicated dataset size (values are \"times faster\" where >1 means ta-tools is faster than the compared library, and <1 means ta-tools is slower).\n\n| Indicator | Small (1k) | Big (10k) | Huge (100k) | Streaming (single next) |\n|---|---:|---:|---:|---:|\n| SMA | vs indicatorts: 0.58×<br>vs fast-technical-indicators: 1.82×<br>vs trading-signals: 8.51× | vs indicatorts: 0.69×<br>vs fast-technical-indicators: 2.63×<br>vs trading-signals: 14.14× | vs indicatorts: 1.46×<br>vs fast-technical-indicators: 4.95×<br>vs trading-signals: 13.41× | vs fast-technical-indicators: 0.99×<br>vs trading-signals: 1.16× |\n| EMA | vs indicatorts: 1.05×<br>vs fast-technical-indicators: 1.27×<br>vs trading-signals: 1.55× | vs indicatorts: 1.29×<br>vs fast-technical-indicators: 1.33×<br>vs trading-signals: 6.08× | vs indicatorts: 2.26×<br>vs fast-technical-indicators: 4.11×<br>vs trading-signals: 6.28× | vs fast-technical-indicators: 0.94× |\n| RSI | vs indicatorts: 2.52×<br>vs fast-technical-indicators: 16.79×<br>vs trading-signals: 19.71× | vs indicatorts: 2.81×<br>vs fast-technical-indicators: 16.47×<br>vs trading-signals: 19.69× | vs indicatorts: 4.10×<br>vs fast-technical-indicators: 15.71×<br>vs trading-signals: 15.36× | vs fast-technical-indicators: 1.18×<br>vs trading-signals: 1.18× |\n| WMA | vs fast-technical-indicators: 2.90×<br>vs trading-signals: 9.45× | vs fast-technical-indicators: 4.05×<br>vs trading-signals: 15.11× | vs fast-technical-indicators: 6.48×<br>vs trading-signals: 14.67× | vs fast-technical-indicators: 0.98× |\n| MACD | vs indicatorts: 0.99×<br>vs fast-technical-indicators: 2.26×<br>vs trading-signals: 4.06× | vs indicatorts: 1.23×<br>vs fast-technical-indicators: 2.65×<br>vs trading-signals: 5.79× | vs indicatorts: 1.45×<br>vs fast-technical-indicators: 4.10×<br>vs trading-signals: 3.64× | vs fast-technical-indicators: 0.81× |\n| Bollinger Bands | vs indicatorts: 1.08×<br>vs fast-technical-indicators: 6.91×<br>vs trading-signals: 11.52× | vs indicatorts: 1.33×<br>vs fast-technical-indicators: 10.09×<br>vs trading-signals: 16.47× | vs indicatorts: 1.66×<br>vs fast-technical-indicators: 10.69×<br>vs trading-signals: 10.80× | vs fast-technical-indicators: 1.05×<br>vs trading-signals: 1.03× |\n| ATR | vs indicatorts: 7.13×<br>vs fast-technical-indicators: 1.34×<br>vs trading-signals: 4.42× | vs indicatorts: 9.93×<br>vs fast-technical-indicators: 1.36×<br>vs trading-signals: 5.90× | vs indicatorts: 13.22×<br>vs fast-technical-indicators: 2.85×<br>vs trading-signals: 4.56× | vs fast-technical-indicators: 1.00×<br>vs trading-signals: 1.04× |\n| Stochastic Oscillator | vs indicatorts: 2.25×<br>vs fast-technical-indicators: 4.80×<br>vs trading-signals: 9.45× | vs indicatorts: 2.00×<br>vs fast-technical-indicators: 3.99×<br>vs trading-signals: 8.08× | vs indicatorts: 2.23×<br>vs fast-technical-indicators: 4.78×<br>vs trading-signals: 8.26× | vs fast-technical-indicators: 0.95×<br>vs trading-signals: 0.73× |\n| MFI | vs indicatorts: 4.55×<br>vs fast-technical-indicators: 13.57× | vs indicatorts: 6.93×<br>vs fast-technical-indicators: 20.02× | vs indicatorts: 7.53×<br>vs fast-technical-indicators: 14.15× | vs fast-technical-indicators: 1.12× |\n| ADX | vs fast-technical-indicators: 2.68×<br>vs trading-signals: 8.63× | vs fast-technical-indicators: 3.06×<br>vs trading-signals: 10.06× | vs fast-technical-indicators: 4.90×<br>vs trading-signals: 7.74× | vs fast-technical-indicators: 0.87×<br>vs trading-signals: 0.85× |\n| StochRSI | vs fast-technical-indicators: 3.25× | vs fast-technical-indicators: 3.54× | vs fast-technical-indicators: 4.30× | vs fast-technical-indicators: 1.10× |\n| Ichimoku Cloud | vs fast-technical-indicators: 1.79×<br>vs indicatorts: 16.90× | vs fast-technical-indicators: 2.04×<br>vs indicatorts: 98.41× | vs fast-technical-indicators: 1.80× | vs fast-technical-indicators: 1.19× |\n| VWAP (Session) | vs indicatorts: 0.83× | vs indicatorts: 1.33× | vs indicatorts: 1.31× | - |\n\n\n*Notes: the ATR rows in the original report list 'ta-tools (WASM) - ATR > Small dataset' as \"1.34x faster than fast-technical-indicators\" and \"7.13x faster than indicatorts\" etc. For readability this table shows ta-tools's reported multiplier against each library directly when available; where the report lists another library being faster than ta-tools the table displays the computed inverse (ta-tools relative to that library). Empty cells mean the report did not include a direct entry for that combination.\n\nFor full per-indicator, dataset, and streaming breakdowns see `benchmarks/2025-12-09-results.md`.\n\n---\n\n## Development\n\n### Prerequisites\n\n*   [Rust](https://www.rust-lang.org/tools/install) (1.56+)\n*   [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)\n*   Node.js 22+\n\n### Build\n\n```bash\n# Full build (WASM + TypeScript)\nnpm run build\n\n# WASM only\nnpm run build:wasm\n\n# TypeScript only\nnpm run build:ts\n```\n\n### Test\n\n```bash\nnpm test\nnpm run bench\n```\n\n### Project Structure\n\n```\n.\n├── crates/ta-core/           # Rust WASM library\n│   └── src/indicators/        # Indicator implementations\n├── js/                        # TypeScript wrapper\n│   └── index.ts              # High-level API\n├── dist/                     # Compiled TypeScript\n├── pkg/                      # Compiled WASM\n└── tests/                    # Integration tests\n```\n\n## Contributing\n\nContributions welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new indicators\n4. Ensure `npm run build && npm test` passes\n5. Open a pull request\n\n## Roadmap\n\n- [ ] Add more exotic indicators\n- [ ] Browser-specific optimizations\n- [ ] Binary persistence/deserialization\n- [ ] WebWorker utilities\n- [ ] Deno support\n\n## License\n\nMIT","readmeFilename":"README.md"}