# **TA-Numba: Technical Analysis Library with Numba Acceleration**
**ta-numba** is a Python library for financial technical analysis that provides **dependency-free installation** and **high-performance computation** through Numba JIT compilation. It offers both **bulk processing** for historical analysis and **real-time streaming** for live trading applications.
## **π Key Features**
### **Dependency-Free Installation**
- **No C Compilation Required:** Pure Python implementation with NumPy and Numba dependencies only
- **Docker Compatible:** Reliable installation in containerized environments
- **Modern Python Support:** Compatible with NumPy 2.0 and recent Python versions
- **Simple Installation:** Standard `pip install` without system-level dependencies
### **Dual Processing Modes**
- **Bulk Processing:** Efficient vectorized calculations for historical analysis
- **Real-Time Streaming:** Constant-time updates for live market data processing
### **Performance Characteristics**
- **Numba JIT Compilation:** Near-native performance through just-in-time compilation
- **Warmup System:** Optional pre-compilation to eliminate first-call latency
- **API Compatibility:** Compatible with the ta library interface
- **Memory Efficiency:** Streaming mode uses constant memory regardless of data history
## **π Performance Comparison**
Based on comprehensive benchmarks with 100,000 data points across multiple technical analysis libraries:
| Aspect | TA-Lib | ta-numba | ta | pandas | cython |
| ----------------------- | ------------------- | ------------------ | ------------------- | ---------------- | -------------------- |
| **Installation** | C compiler required | pip install only | pip install only | pip install only | Compilation required |
| **Average Performance** | Fastest (baseline) | 4.3x slower | 857x slower | 94x slower | 2.5x slower |
| **Best Cases** | Fastest overall | MACD: 3.8x faster | All cases slower | All cases slower | Mixed results |
| **Worst Cases** | WMA, ADX fastest | WMA: 33x slower | PSAR: 8,837x slower | ATR: 13x slower | Variable performance |
| **Dependency Issues** | Frequent | None | None | Rare | Build-time only |
| **Streaming Support** | No | Yes (15.8x faster) | No | No | No |
### **Key Findings**
**Performance Trade-offs:**
- TA-Lib remains the fastest for raw computational speed
- ta-numba provides 4.3x slower performance on average, but eliminates installation complexity
- ta-numba significantly outperforms pure Python libraries (ta: 857x, pandas: 94x faster)
**Installation Reliability:**
- TA-Lib requires C compilation and system dependencies, causing frequent deployment issues
- ta-numba installs reliably across environments with standard Python packaging
**Real-Time Processing:**
- ta-numba's streaming mode provides 15.8x performance improvement over bulk recalculation approaches
- Constant memory usage vs. linear growth in traditional approaches
### **Installation Comparison**
```bash
# TA-Lib installation requirements:
# - C compiler (Visual Studio, GCC, or Clang)
# - System-level TA-Lib library
# - Compatible NumPy version
# - Platform-specific build tools
# ta-numba installation:
pip install ta-numba
# Dependencies: numpy, numba (automatically resolved)
```
## **π¦ Installation**
```bash
pip install ta-numba
```
Dependencies: `numpy`, `numba` (automatically installed)
## **π Quick Start**
### **Bulk Processing (Batch Calculations)**
Perfect for backtesting and historical analysis:
```python
import ta_numba.bulk as bulk
import numpy as np
# Your price data
close_prices = np.array([100, 102, 101, 103, 105, 104, 106])
# Calculate indicators on entire dataset
sma_20 = bulk.trend.sma(close_prices, window=20)
rsi_14 = bulk.momentum.rsi(close_prices, window=14)
macd_line, macd_signal, macd_hist = bulk.trend.macd(close_prices)
# Warm up JIT compilation for faster subsequent calls
import ta_numba.warmup
ta_numba.warmup.warmup_all() # Optional but recommended
```
### **Real-Time Streaming (Live Trading)**
Perfect for live market data and real-time trading:
```python
import ta_numba.stream as stream
# Create streaming indicators
sma = stream.SMA(window=20)
rsi = stream.RSI(window=14)
macd = stream.MACD(fast=12, slow=26, signal=9)
# Process live price updates
def on_new_price(price):
sma_value = sma.update(price)
rsi_value = rsi.update(price)
macd_values = macd.update(price)
if sma.is_ready:
print(f"SMA: {sma_value:.2f}")
if rsi.is_ready:
print(f"RSI: {rsi_value:.2f}")
if macd.is_ready:
print(f"MACD: {macd_values}")
# Simulate live data
for price in [100, 102, 101, 103, 105]:
on_new_price(price)
```
### **Legacy Compatibility (Direct Import)**
For existing ta library users:
```python
# Same as original ta library
import ta_numba.trend as trend
import ta_numba.momentum as momentum
sma_values = trend.sma(close_prices, window=20)
rsi_values = momentum.rsi(close_prices, window=14)
```
## **π Available Indicators**
### **π Streaming Indicators (New in v0.2.0)**
Real-time indicators with O(1) updates and constant memory usage:
**Trend Indicators (11)**
- `SMA`, `EMA`, `WMA` - Moving averages
- `MACD` - Moving Average Convergence Divergence
- `ADX` - Average Directional Index
- `TRIX` - Triple Exponential Average
- `CCI` - Commodity Channel Index
- `DPO` - Detrended Price Oscillator
- `Aroon` - Aroon Oscillator
- `ParabolicSAR` - Parabolic Stop and Reverse
- `VortexIndicator` - Vortex Indicator
**Momentum Indicators (10)**
- `RSI` - Relative Strength Index
- `Stochastic` - Stochastic Oscillator
- `StochasticRSI` - Stochastic RSI
- `WilliamsR` - Williams %R
- `TSI` - True Strength Index
- `UltimateOscillator` - Ultimate Oscillator
- `AwesomeOscillator` - Awesome Oscillator
- `KAMA` - Kaufman's Adaptive Moving Average
- `PPO` - Percentage Price Oscillator
- `ROC` - Rate of Change
**Volatility Indicators (9)**
- `ATR` - Average True Range
- `BollingerBands` - Bollinger Bands
- `KeltnerChannel` - Keltner Channel
- `DonchianChannel` - Donchian Channel
- `StandardDeviation` - Rolling Standard Deviation
- `Variance` - Rolling Variance
- `TrueRange` - True Range
- `HistoricalVolatility` - Historical Volatility
- `UlcerIndex` - Ulcer Index
**Volume Indicators (10)**
- `MoneyFlowIndex` - Money Flow Index
- `AccDistIndex` - Accumulation/Distribution Index
- `OnBalanceVolume` - On Balance Volume
- `ChaikinMoneyFlow` - Chaikin Money Flow
- `ForceIndex` - Force Index
- `EaseOfMovement` - Ease of Movement
- `VolumePriceTrend` - Volume Price Trend
- `NegativeVolumeIndex` - Negative Volume Index
- `VWAP` - Volume Weighted Average Price
- `VWEMA` - Volume Weighted Exponential Moving Average
### **π Bulk Processing Indicators**
All functions accept NumPy arrays for maximum performance.
<details>
<summary><strong>Volume Indicators (10)</strong></summary>
- `ta_numba.volume.money_flow_index`
- `ta_numba.volume.acc_dist_index`
- `ta_numba.volume.on_balance_volume`
- `ta_numba.volume.chaikin_money_flow`
- `ta_numba.volume.force_index`
- `ta_numba.volume.ease_of_movement`
- `ta_numba.volume.volume_price_trend`
- `ta_numba.volume.negative_volume_index`
- `ta_numba.volume.volume_weighted_average_price`
- `ta_numba.volume.volume_weighted_exponential_moving_average`
</details>
<details>
<summary><strong>Volatility Indicators (5)</strong></summary>
- `ta_numba.volatility.average_true_range`
- `ta_numba.volatility.bollinger_bands`
- `ta_numba.volatility.keltner_channel`
- `ta_numba.volatility.donchian_channel`
- `ta_numba.volatility.ulcer_index`
</details>
<details>
<summary><strong>Trend Indicators (15)</strong></summary>
- `ta_numba.trend.sma`
- `ta_numba.trend.ema`
- `ta_numba.trend.wma`
- `ta_numba.trend.macd`
- `ta_numba.trend.adx`
- `ta_numba.trend.vortex_indicator`
- `ta_numba.trend.trix`
- `ta_numba.trend.mass_index`
- `ta_numba.trend.cci`
- `ta_numba.trend.dpo`
- `ta_numba.trend.kst`
- `ta_numba.trend.ichimoku`
- `ta_numba.trend.parabolic_sar`
- `ta_numba.trend.schaff_trend_cycle`
- `ta_numba.trend.aroon`
</details>
<details>
<summary><strong>Momentum Indicators (11)</strong></summary>
- `ta_numba.momentum.rsi`
- `ta_numba.momentum.stochrsi`
- `ta_numba.momentum.tsi`
- `ta_numba.momentum.ultimate_oscillator`
- `ta_numba.momentum.stoch`
- `ta_numba.momentum.williams_r`
- `ta_numba.momentum.awesome_oscillator`
- `ta_numba.momentum.kama`
- `ta_numba.momentum.roc`
- `ta_numba.momentum.ppo`
- `ta_numba.momentum.pvo`
</details>
<details>
<summary><strong>Other Indicators (4)</strong></summary>
- `ta_numba.others.daily_return`
- `ta_numba.others.daily_log_return`
- `ta_numba.others.cumulative_return`
- `ta_numba.others.compound_log_return`
</details>
## **β‘ Performance & Benchmarks**
### **π Benchmark Methodology**
**Test Environment:**
- Data Size: 100,000 price points
- Iterations: 3 runs per indicator per library
- Hardware: Standard development machine
- Libraries: ta-numba, ta-lib, ta, pandas, cython, NautilusTrader
**Performance Analysis:**
- **ta-numba delivers substantial performance improvements over pure Python libraries**
- **TA-Lib maintains performance leadership in bulk processing**
- **ta-numba provides unique advantages in streaming scenarios**
- **Installation reliability varies significantly between libraries**
### **π Comprehensive Benchmark Results (100K data points)**
**Complete Library Comparison:**
```text
Performance Comparison (Average Time per Run):
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Indicator | ta | ta-numba | ta-lib | pandas | cython | nautilus | Speedup vs ta | Speedup vs talib | Speedup vs pandas | Speedup vs cython | Speedup vs nautilus
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SMA | 0.001196s | 0.001082s | 0.000087s | 0.000713s | 0.000058s | 0.105247s | 1.11x | 0.08x | 0.66x | 0.05x | 97.29x
EMA | 0.000577s | 0.000112s | 0.000332s | 0.000493s | 0.000168s | 0.011398s | 5.16x | 2.97x | 4.41x | 1.50x | 101.92x
RSI | 0.002789s | 0.001355s | 0.000433s | 0.002412s | 0.001946s | 0.062416s | 2.06x | 0.32x | 1.78x | 1.44x | 46.06x
MACD | 0.001635s | 0.000642s | 0.002456s | 0.001860s | 0.000666s | 0.012047s | 2.55x | 3.83x | 2.90x | 1.04x | 18.77x
ATR | 0.205986s | 0.000672s | 0.002262s | 0.008719s | 0.001687s | 0.018718s | 306.60x | 3.37x | 12.98x | 2.51x | 27.86x
Bollinger Upper | 0.002052s | 0.001432s | 0.000341s | 0.002129s | 0.006004s | 0.214716s | 1.43x | 0.24x | 1.49x | 4.19x | 149.92x
OBV | 0.000685s | 0.000066s | 0.000224s | N/A | 0.000275s | 14.146200s | 10.43x | 3.42x | N/A | 4.19x | 215376.26x
MFI | 0.482099s | 0.002581s | 0.002374s | 0.003096s | 0.006168s | 0.021110s | 186.77x | 0.92x | 1.20x | 2.39x | 8.18x
WMA | 2.456998s | 0.003013s | 0.000092s | 0.126318s | 0.002411s | 0.339517s | 815.56x | 0.03x | 41.93x | 0.80x | 112.70x
VWEMA | 0.000908s | 0.000822s | 0.029710s | 0.002095s | 0.004002s | 0.058675s | 1.10x | 36.13x | 2.55x | 4.87x | 71.35x
ADX | 0.407531s | 0.003533s | 0.000643s | 0.012459s | 0.009984s | 0.002930s | 115.34x | 0.18x | 3.53x | 2.83x | 0.83x
PSAR | 4.123320s | 0.000467s | 0.000346s | 0.449931s | 0.001659s | 0.007989s | 8837.04x | 0.74x | 964.29x | 3.56x | 17.12x
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Summary Statistics:
Average speedup vs ta: 857.10x
Average speedup vs ta-lib: 4.35x
Average speedup vs pandas: 94.34x
Average speedup vs cython: 2.45x
Average speedup vs nautilus: 18002.35x
Identical results vs ta: 11/12
Identical results vs ta-lib: 4/12
Identical results vs cython: 5/12
Identical results vs nautilus: 3/12
```
### **π Performance Summary**
**Benchmark Results Analysis:**
**vs Pure Python Libraries:**
- ta library: 857x average speedup (range: 1.1x to 8,837x)
- pandas: 94x average speedup (range: 0.66x to 964x)
- Consistent performance advantage across most indicators
**vs Compiled Libraries:**
- TA-Lib: 0.23x average performance (ta-numba is 4.3x slower on average)
- cython: 2.5x average speedup (mixed results depending on indicator)
- Performance varies significantly by indicator complexity
**Streaming Performance:**
- 15.8x faster than bulk recalculation methods
- Constant O(1) memory usage vs. O(n) growth
- Microsecond-level latency for real-time applications
**Library Selection Criteria:**
- **Choose TA-Lib for**: Maximum performance, stable environment, C compilation acceptable
- **Choose ta-numba for**: Reliable deployment, streaming requirements, Python-only environments
- **Choose ta/pandas for**: Simplicity, small datasets, existing pandas workflows
**Real-Time Streaming Performance (per tick):**
```text
π REAL-TIME STREAMING COMPARISON
============================================================
Simulating live market data feed with continuous price updates...
π Generating 100 warmup ticks...
π₯ Warming up JIT compilation...
π Initializing streaming indicators...
π― SIMULATING 10,000 LIVE MARKET TICKS...
------------------------------------------------------------
Progress: 10% | Avg Bulk: 0.039ms | Avg Streaming: 0.017ms | Speedup: 2.3x
Progress: 20% | Avg Bulk: 0.103ms | Avg Streaming: 0.018ms | Speedup: 5.8x
Progress: 30% | Avg Bulk: 0.174ms | Avg Streaming: 0.019ms | Speedup: 9.0x
Progress: 40% | Avg Bulk: 0.244ms | Avg Streaming: 0.021ms | Speedup: 11.6x
Progress: 50% | Avg Bulk: 0.313ms | Avg Streaming: 0.023ms | Speedup: 13.5x
Progress: 60% | Avg Bulk: 0.378ms | Avg Streaming: 0.023ms | Speedup: 16.2x
Progress: 70% | Avg Bulk: 0.447ms | Avg Streaming: 0.024ms | Speedup: 18.7x
Progress: 80% | Avg Bulk: 0.516ms | Avg Streaming: 0.024ms | Speedup: 21.7x
Progress: 90% | Avg Bulk: 0.589ms | Avg Streaming: 0.024ms | Speedup: 24.3x
Progress: 100% | Avg Bulk: 0.671ms | Avg Streaming: 0.026ms | Speedup: 26.1x
π FINAL RESULTS
============================================================
Total ticks processed: 10,000
Lookback window size: 10000
β±οΈ TIMING STATISTICS (per tick):
Method Mean Median 95%ile 99%ile
-------------------------------------------------------
Bulk 0.347ms 0.346ms 0.673ms 0.699ms
Streaming 0.022ms 0.022ms 0.028ms 0.039ms
π PERFORMANCE IMPROVEMENT:
Average speedup: 15.8x faster
Median speedup: 15.9x faster
πΎ MEMORY USAGE COMPARISON:
Bulk approach: O(n) = 10000 * 8 bytes * 7 indicators = 546.9 KB
Streaming approach: O(1) = ~1 KB total (constant)
Memory efficiency: 547x less memory
β‘ LATENCY ANALYSIS:
Bulk 99th percentile: 0.699ms
Streaming 99th percentile: 0.039ms
For HFT (<1ms requirement): β
Bulk passes, β
Streaming passes
```
### **βοΈ Library Selection Guide**
**Choose TA-Lib when:**
- Maximum computational performance is critical
- Working in controlled environments with stable dependencies
- C compilation infrastructure is available and maintained
- Academic or research work with consistent setup
**Choose ta-numba when:**
- Deploying in diverse environments (Docker, cloud, etc.)
- Requiring real-time streaming capabilities
- Building production systems with reliability requirements
- Working with modern Python/NumPy ecosystems
**Choose ta/pandas when:**
- Working with small to medium datasets
- Prototyping or exploratory analysis
- Integration with existing pandas workflows is important
- Performance requirements are modest
### **π Real-Time Performance Advantage**
```python
# Traditional approach (recalculates entire array each time)
def update_traditional(new_price, history, window=20):
history.append(new_price)
return talib.SMA(np.array(history), window)[-1] # 0.347ms per update
# ta-numba streaming (O(1) update)
sma = stream.SMA(window=20)
def update_streaming(new_price):
return sma.update(new_price) # 0.022ms per update - 15.8x faster!
```
````
Generating sample data of size 200000 with seed None...
Sample data generated.
--- Warming up Numba functions (JIT Compilation) ---
Warm-up complete.
--- Running Benchmarks (5 loops each) ---
Discrepancy for TRIX:
Mean Absolute Difference: 0.007569
Zero Status: Normal
First 5 differing values (Index, TA, Numba):
43, -0.035422, -0.054566
44, -0.021285, -0.035508
45, 0.001522, -0.006502
46, 0.002349, -0.005051
47, 0.012865, 0.008175
Discrepancy for MI:
Mean Absolute Difference: 6.323e-06
Zero Status: Normal
First 5 differing values (Index, TA, Numba):
40, 24.923410, 25.163110
41, 25.099305, 25.298424
42, 25.092817, 25.256278
43, 25.031762, 25.163705
44, 25.043005, 25.150111
Discrepancy for STC:
Mean Absolute Difference: 4.276e-06
Zero Status: Normal
First 5 differing values (Index, TA, Numba):
71, 16.939844, 17.313568
72, 8.469922, 8.656784
73, 4.234961, 4.328392
74, 15.217372, 15.289315
75, 28.028082, 28.091572
Discrepancy for TSI:
Mean Absolute Difference: 0.0004937
Zero Status: Normal
First 5 differing values (Index, TA, Numba):
37, 8.232642, 1.088498
38, 7.628686, 0.899511
39, 6.338255, -0.030883
40, 6.326458, 0.355236
41, 3.863873, -1.721345
--- Benchmark Results (Average Time per Run) ---
-----------------------------------------------------------
Indicator | `ta` Library | Numba Version | Speedup
-----------------------------------------------------------
MFI | 1.187933s | 0.005150s | 230.65x
ADI | 0.001475s | 0.000434s | 3.40x
OBV | 0.001602s | 0.000122s | 13.08x
CMF | 0.004253s | 0.001713s | 2.48x
FI | 0.001479s | 0.000609s | 2.43x
EOM | 0.001648s | 0.000172s | 9.58x
VPT | 0.002104s | 0.000451s | 4.66x
NVI | 3.244231s | 0.001093s | 2967.43x
VWAP | 0.003858s | 0.001392s | 2.77x
VWEMA | 0.005218s | 0.002011s | 2.60x
ATR | 0.419494s | 0.001130s | 371.32x
BB | 0.004472s | 0.003196s | 1.40x
KC | 0.005683s | 0.007647s | 0.74x
DC | 0.006115s | 0.009956s | 0.61x
UI | 0.398492s | 0.007430s | 53.63x
SMA | 0.001696s | 0.002453s | 0.69x
EMA | 0.001192s | 0.000444s | 2.69x
WMA | 5.459586s | 0.006479s | 842.68x
MACD | 0.003275s | 0.001290s | 2.54x
ADX | 0.883612s | 0.007472s | 118.25x
Vortex | 0.016811s | 0.007960s | 2.11x
TRIX | 0.004868s | 0.001166s | 4.18x
MI | 0.003594s | 0.008942s | 0.40x
CCI | 1.055140s | 0.007558s | 139.60x
DPO | 0.001935s | 0.002446s | 0.79x
KST | 0.011884s | 0.031931s | 0.37x
Ichimoku | 0.013384s | 0.027892s | 0.48x
PSAR | 9.464796s | 0.001216s | 7783.20x
STC | 0.018517s | 0.019506s | 0.95x
Aroon | 0.402076s | 0.005702s | 70.52x
RSI | 0.004719s | 0.002710s | 1.74x
StochRSI | 0.012424s | 0.014490s | 0.86x
TSI | 0.004547s | 0.001771s | 2.57x
UO | 0.034889s | 0.014549s | 2.40x
Stoch | 0.006982s | 0.011224s | 0.62x
WR | 0.006880s | 0.009031s | 0.76x
AO | 0.003143s | 0.004481s | 0.70x
KAMA | 0.130242s | 0.001560s | 83.47x
ROC | 0.000777s | 0.000344s | 2.26x
PPO | 0.003494s | 0.001294s | 2.70x
PVO | 0.003904s | 0.001216s | 3.21x
DR | 0.000662s | 0.000300s | 2.21x
DLR | 0.000803s | 0.001611s | 0.50x
CR | 0.000388s | 0.000184s | 2.11x
CLR | 11.993333s | 1.936194s | 6.19x
```
-----------------------------------------------------------
--- Zero Value Status for All Indicators ---
Normal (non-zero values): 44 indicators
MFI, ADI, OBV, CMF, FI, EOM, VPT, NVI, VWAP, VWEMA,
ATR, BB, KC, DC, UI, ... and 29 more
All 44 indicators have normal non-zero values!
--- Discrepancy Report ---
Indicator Status MAD Zero Status
TRIX Different 0.007569 Normal
MI Different 6.323000e-06 Normal
STC Different 4.276000e-06 Normal
TSI Different 4.937000e-04 Normal
-----------------------------------------------------------
````
## **π What's New in v0.2.0**
### **π Streaming Indicators**
- **Real-time processing**: O(1) per-update performance
- **Memory efficient**: Constant memory usage regardless of data size
- **Production ready**: Designed for live trading systems
- **Clean API**: Simplified class names (`SMA`, `EMA`, `RSI` vs `SMAStreaming`)
### **β‘ JIT Warmup System**
- **Fast startup**: Eliminate JIT compilation delays in production
- **Bulk warmup**: `ta_numba.warmup.warmup_all()` for all indicators
- **Selective warmup**: Individual indicator warmup available
- **Docker friendly**: Persistent compilation across container restarts
### **π― Improved API Design**
- **Dual namespaces**: `ta_numba.bulk` and `ta_numba.stream` for clarity
- **Legacy compatibility**: Existing imports continue to work
- **Better ergonomics**: Cleaner function calls for real-world usage
## **π Migration Guide**
### **From v0.1.0 to v0.2.0**
```python
# Old way (still supported)
import ta_numba.trend as trend
sma_values = trend.sma(prices, window=20)
# New recommended way - Bulk processing
import ta_numba.bulk as bulk
sma_values = bulk.trend.sma(prices, window=20)
# New feature - Streaming
import ta_numba.stream as stream
sma = stream.SMA(window=20)
for price in live_prices:
current_sma = sma.update(price)
```
### **From Other Libraries**
```python
# From pandas
df['sma'] = df['close'].rolling(20).mean()
# To ta-numba bulk
sma_values = bulk.trend.sma(df['close'].values, window=20)
# From ta-lib streaming simulation
# (multiple function calls for updates)
# To ta-numba streaming
sma = stream.SMA(window=20)
current_value = sma.update(new_price)
```
## **π οΈ Advanced Usage**
### **Production Deployment**
```python
# Recommended startup sequence for production
import ta_numba.warmup
import ta_numba.bulk as bulk
import ta_numba.stream as stream
# Warm up all indicators (do this once at startup)
ta_numba.warmup.warmup_all()
# Now all subsequent calls are fast
def process_historical_data(prices):
return bulk.trend.sma(prices, window=20)
def process_live_data():
sma = stream.SMA(window=20)
for price in live_feed:
yield sma.update(price)
```
### **Docker Integration**
```dockerfile
# Dockerfile optimization
FROM python:3.11
RUN pip install ta-numba
# Pre-compile indicators at build time
RUN python -c "import ta_numba.warmup; ta_numba.warmup.warmup_all()"
# Your application will start faster
COPY . .
CMD ["python", "your_trading_app.py"]
```
## **π Real-World Performance Examples**
### **Backtesting (Bulk Processing)**
```python
import ta_numba.bulk as bulk
import time
# Process 1M price points
prices = np.random.randn(1_000_000).cumsum() + 100
start = time.time()
sma_values = bulk.trend.sma(prices, window=50)
rsi_values = bulk.momentum.rsi(prices, window=14)
macd_line, macd_signal, macd_hist = bulk.trend.macd(prices)
elapsed = time.time() - start
print(f"Processed 1M points in {elapsed:.3f}s")
# Output: Processed 1M points in 0.045s
```
### **Live Trading (Streaming)**
```python
import ta_numba.stream as stream
# Set up indicators
indicators = {
'sma_20': stream.SMA(window=20),
'sma_50': stream.SMA(window=50),
'rsi': stream.RSI(window=14),
'macd': stream.MACD()
}
def on_price_update(price):
signals = {}
for name, indicator in indicators.items():
signals[name] = indicator.update(price)
# Generate trading signals
if all(ind.is_ready for ind in indicators.values()):
if signals['sma_20'] > signals['sma_50']:
return "BUY_SIGNAL"
elif signals['rsi'] > 70:
return "SELL_SIGNAL"
return "HOLD"
# Process live feed (microsecond latency)
for price in live_price_feed:
signal = on_price_update(price) # ~2-5 microseconds
## **Acknowledgements**
## **π Acknowledgements**
This library builds upon the excellent work of several projects:
- **[Technical Analysis Library (ta)](https://github.com/bukosabino/ta)** by DarΓo LΓ³pez Padial - API design and calculation logic foundation
- **[Numba](https://numba.pydata.org/)** - JIT compilation technology that makes the performance possible
- **[NumPy](https://numpy.org/)** - Fundamental array operations and mathematical functions
ta-numba extends the original ta library with high-performance Numba compilation and adds real-time streaming capabilities while maintaining mathematical accuracy and API compatibility.
## **π Mathematical Documentation**
All indicator implementations are based on established formulas documented in: [`ta-numba.pdf`](ta-numba.pdf)
This document provides:
- Precise mathematical definitions for all indicators
- Implementation details and edge case handling
- Verification against reference implementations
- Performance optimization techniques used
## **π€ Contributing**
We welcome contributions! Whether it's:
- π Bug reports and fixes
- π New indicator implementations
- β‘ Performance optimizations
- π Documentation improvements
- π§ͺ Test coverage expansion
Please see our [contributing guidelines](CONTRIBUTING.md) for details.
## **π License**
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
**β If ta-numba helps your trading or research, please give us a star on GitHub!**
```
Raw data
{
"_id": null,
"home_page": null,
"name": "ta-numba",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "technical-analysis, quantitative-analysis, financial-engineering, trading, indicators, numba, performance, streaming, real-time, jit-compilation",
"author": null,
"author_email": "Beomgyu Joeng <jaden.b.jeong@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/02/92/5b3b66ba407917362b1f72ae64954a997934feb8c34b5bc02ca968e25aa5/ta_numba-0.2.2.tar.gz",
"platform": null,
"description": "# **TA-Numba: Technical Analysis Library with Numba Acceleration**\n\n**ta-numba** is a Python library for financial technical analysis that provides **dependency-free installation** and **high-performance computation** through Numba JIT compilation. It offers both **bulk processing** for historical analysis and **real-time streaming** for live trading applications.\n\n## **\ud83d\ude80 Key Features**\n\n### **Dependency-Free Installation**\n\n- **No C Compilation Required:** Pure Python implementation with NumPy and Numba dependencies only\n- **Docker Compatible:** Reliable installation in containerized environments\n- **Modern Python Support:** Compatible with NumPy 2.0 and recent Python versions\n- **Simple Installation:** Standard `pip install` without system-level dependencies\n\n### **Dual Processing Modes**\n\n- **Bulk Processing:** Efficient vectorized calculations for historical analysis\n- **Real-Time Streaming:** Constant-time updates for live market data processing\n\n### **Performance Characteristics**\n\n- **Numba JIT Compilation:** Near-native performance through just-in-time compilation\n- **Warmup System:** Optional pre-compilation to eliminate first-call latency\n- **API Compatibility:** Compatible with the ta library interface\n- **Memory Efficiency:** Streaming mode uses constant memory regardless of data history\n\n## **\ud83d\udcca Performance Comparison**\n\nBased on comprehensive benchmarks with 100,000 data points across multiple technical analysis libraries:\n\n| Aspect | TA-Lib | ta-numba | ta | pandas | cython |\n| ----------------------- | ------------------- | ------------------ | ------------------- | ---------------- | -------------------- |\n| **Installation** | C compiler required | pip install only | pip install only | pip install only | Compilation required |\n| **Average Performance** | Fastest (baseline) | 4.3x slower | 857x slower | 94x slower | 2.5x slower |\n| **Best Cases** | Fastest overall | MACD: 3.8x faster | All cases slower | All cases slower | Mixed results |\n| **Worst Cases** | WMA, ADX fastest | WMA: 33x slower | PSAR: 8,837x slower | ATR: 13x slower | Variable performance |\n| **Dependency Issues** | Frequent | None | None | Rare | Build-time only |\n| **Streaming Support** | No | Yes (15.8x faster) | No | No | No |\n\n### **Key Findings**\n\n**Performance Trade-offs:**\n\n- TA-Lib remains the fastest for raw computational speed\n- ta-numba provides 4.3x slower performance on average, but eliminates installation complexity\n- ta-numba significantly outperforms pure Python libraries (ta: 857x, pandas: 94x faster)\n\n**Installation Reliability:**\n\n- TA-Lib requires C compilation and system dependencies, causing frequent deployment issues\n- ta-numba installs reliably across environments with standard Python packaging\n\n**Real-Time Processing:**\n\n- ta-numba's streaming mode provides 15.8x performance improvement over bulk recalculation approaches\n- Constant memory usage vs. linear growth in traditional approaches\n\n### **Installation Comparison**\n\n```bash\n# TA-Lib installation requirements:\n# - C compiler (Visual Studio, GCC, or Clang)\n# - System-level TA-Lib library\n# - Compatible NumPy version\n# - Platform-specific build tools\n\n# ta-numba installation:\npip install ta-numba\n# Dependencies: numpy, numba (automatically resolved)\n```\n\n## **\ud83d\udce6 Installation**\n\n```bash\npip install ta-numba\n```\n\nDependencies: `numpy`, `numba` (automatically installed)\n\n## **\ud83d\ude80 Quick Start**\n\n### **Bulk Processing (Batch Calculations)**\n\nPerfect for backtesting and historical analysis:\n\n```python\nimport ta_numba.bulk as bulk\nimport numpy as np\n\n# Your price data\nclose_prices = np.array([100, 102, 101, 103, 105, 104, 106])\n\n# Calculate indicators on entire dataset\nsma_20 = bulk.trend.sma(close_prices, window=20)\nrsi_14 = bulk.momentum.rsi(close_prices, window=14)\nmacd_line, macd_signal, macd_hist = bulk.trend.macd(close_prices)\n\n# Warm up JIT compilation for faster subsequent calls\nimport ta_numba.warmup\nta_numba.warmup.warmup_all() # Optional but recommended\n```\n\n### **Real-Time Streaming (Live Trading)**\n\nPerfect for live market data and real-time trading:\n\n```python\nimport ta_numba.stream as stream\n\n# Create streaming indicators\nsma = stream.SMA(window=20)\nrsi = stream.RSI(window=14)\nmacd = stream.MACD(fast=12, slow=26, signal=9)\n\n# Process live price updates\ndef on_new_price(price):\n sma_value = sma.update(price)\n rsi_value = rsi.update(price)\n macd_values = macd.update(price)\n\n if sma.is_ready:\n print(f\"SMA: {sma_value:.2f}\")\n if rsi.is_ready:\n print(f\"RSI: {rsi_value:.2f}\")\n if macd.is_ready:\n print(f\"MACD: {macd_values}\")\n\n# Simulate live data\nfor price in [100, 102, 101, 103, 105]:\n on_new_price(price)\n```\n\n### **Legacy Compatibility (Direct Import)**\n\nFor existing ta library users:\n\n```python\n# Same as original ta library\nimport ta_numba.trend as trend\nimport ta_numba.momentum as momentum\n\nsma_values = trend.sma(close_prices, window=20)\nrsi_values = momentum.rsi(close_prices, window=14)\n```\n\n## **\ud83d\udccb Available Indicators**\n\n### **\ud83d\udd04 Streaming Indicators (New in v0.2.0)**\n\nReal-time indicators with O(1) updates and constant memory usage:\n\n**Trend Indicators (11)**\n\n- `SMA`, `EMA`, `WMA` - Moving averages\n- `MACD` - Moving Average Convergence Divergence\n- `ADX` - Average Directional Index\n- `TRIX` - Triple Exponential Average\n- `CCI` - Commodity Channel Index\n- `DPO` - Detrended Price Oscillator\n- `Aroon` - Aroon Oscillator\n- `ParabolicSAR` - Parabolic Stop and Reverse\n- `VortexIndicator` - Vortex Indicator\n\n**Momentum Indicators (10)**\n\n- `RSI` - Relative Strength Index\n- `Stochastic` - Stochastic Oscillator\n- `StochasticRSI` - Stochastic RSI\n- `WilliamsR` - Williams %R\n- `TSI` - True Strength Index\n- `UltimateOscillator` - Ultimate Oscillator\n- `AwesomeOscillator` - Awesome Oscillator\n- `KAMA` - Kaufman's Adaptive Moving Average\n- `PPO` - Percentage Price Oscillator\n- `ROC` - Rate of Change\n\n**Volatility Indicators (9)**\n\n- `ATR` - Average True Range\n- `BollingerBands` - Bollinger Bands\n- `KeltnerChannel` - Keltner Channel\n- `DonchianChannel` - Donchian Channel\n- `StandardDeviation` - Rolling Standard Deviation\n- `Variance` - Rolling Variance\n- `TrueRange` - True Range\n- `HistoricalVolatility` - Historical Volatility\n- `UlcerIndex` - Ulcer Index\n\n**Volume Indicators (10)**\n\n- `MoneyFlowIndex` - Money Flow Index\n- `AccDistIndex` - Accumulation/Distribution Index\n- `OnBalanceVolume` - On Balance Volume\n- `ChaikinMoneyFlow` - Chaikin Money Flow\n- `ForceIndex` - Force Index\n- `EaseOfMovement` - Ease of Movement\n- `VolumePriceTrend` - Volume Price Trend\n- `NegativeVolumeIndex` - Negative Volume Index\n- `VWAP` - Volume Weighted Average Price\n- `VWEMA` - Volume Weighted Exponential Moving Average\n\n### **\ud83d\udcca Bulk Processing Indicators**\n\nAll functions accept NumPy arrays for maximum performance.\n\n<details>\n<summary><strong>Volume Indicators (10)</strong></summary>\n\n- `ta_numba.volume.money_flow_index`\n- `ta_numba.volume.acc_dist_index`\n- `ta_numba.volume.on_balance_volume`\n- `ta_numba.volume.chaikin_money_flow`\n- `ta_numba.volume.force_index`\n- `ta_numba.volume.ease_of_movement`\n- `ta_numba.volume.volume_price_trend`\n- `ta_numba.volume.negative_volume_index`\n- `ta_numba.volume.volume_weighted_average_price`\n- `ta_numba.volume.volume_weighted_exponential_moving_average`\n\n</details>\n\n<details>\n<summary><strong>Volatility Indicators (5)</strong></summary>\n\n- `ta_numba.volatility.average_true_range`\n- `ta_numba.volatility.bollinger_bands`\n- `ta_numba.volatility.keltner_channel`\n- `ta_numba.volatility.donchian_channel`\n- `ta_numba.volatility.ulcer_index`\n\n</details>\n\n<details>\n<summary><strong>Trend Indicators (15)</strong></summary>\n\n- `ta_numba.trend.sma`\n- `ta_numba.trend.ema`\n- `ta_numba.trend.wma`\n- `ta_numba.trend.macd`\n- `ta_numba.trend.adx`\n- `ta_numba.trend.vortex_indicator`\n- `ta_numba.trend.trix`\n- `ta_numba.trend.mass_index`\n- `ta_numba.trend.cci`\n- `ta_numba.trend.dpo`\n- `ta_numba.trend.kst`\n- `ta_numba.trend.ichimoku`\n- `ta_numba.trend.parabolic_sar`\n- `ta_numba.trend.schaff_trend_cycle`\n- `ta_numba.trend.aroon`\n\n</details>\n\n<details>\n<summary><strong>Momentum Indicators (11)</strong></summary>\n\n- `ta_numba.momentum.rsi`\n- `ta_numba.momentum.stochrsi`\n- `ta_numba.momentum.tsi`\n- `ta_numba.momentum.ultimate_oscillator`\n- `ta_numba.momentum.stoch`\n- `ta_numba.momentum.williams_r`\n- `ta_numba.momentum.awesome_oscillator`\n- `ta_numba.momentum.kama`\n- `ta_numba.momentum.roc`\n- `ta_numba.momentum.ppo`\n- `ta_numba.momentum.pvo`\n\n</details>\n\n<details>\n<summary><strong>Other Indicators (4)</strong></summary>\n\n- `ta_numba.others.daily_return`\n- `ta_numba.others.daily_log_return`\n- `ta_numba.others.cumulative_return`\n- `ta_numba.others.compound_log_return`\n\n</details>\n\n## **\u26a1 Performance & Benchmarks**\n\n### **\ud83d\udcca Benchmark Methodology**\n\n**Test Environment:**\n\n- Data Size: 100,000 price points\n- Iterations: 3 runs per indicator per library\n- Hardware: Standard development machine\n- Libraries: ta-numba, ta-lib, ta, pandas, cython, NautilusTrader\n\n**Performance Analysis:**\n\n- **ta-numba delivers substantial performance improvements over pure Python libraries**\n- **TA-Lib maintains performance leadership in bulk processing**\n- **ta-numba provides unique advantages in streaming scenarios**\n- **Installation reliability varies significantly between libraries**\n\n### **\ud83d\udcca Comprehensive Benchmark Results (100K data points)**\n\n**Complete Library Comparison:**\n\n```text\nPerformance Comparison (Average Time per Run):\n----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\nIndicator | ta | ta-numba | ta-lib | pandas | cython | nautilus | Speedup vs ta | Speedup vs talib | Speedup vs pandas | Speedup vs cython | Speedup vs nautilus\n----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\nSMA | 0.001196s | 0.001082s | 0.000087s | 0.000713s | 0.000058s | 0.105247s | 1.11x | 0.08x | 0.66x | 0.05x | 97.29x\nEMA | 0.000577s | 0.000112s | 0.000332s | 0.000493s | 0.000168s | 0.011398s | 5.16x | 2.97x | 4.41x | 1.50x | 101.92x\nRSI | 0.002789s | 0.001355s | 0.000433s | 0.002412s | 0.001946s | 0.062416s | 2.06x | 0.32x | 1.78x | 1.44x | 46.06x\nMACD | 0.001635s | 0.000642s | 0.002456s | 0.001860s | 0.000666s | 0.012047s | 2.55x | 3.83x | 2.90x | 1.04x | 18.77x\nATR | 0.205986s | 0.000672s | 0.002262s | 0.008719s | 0.001687s | 0.018718s | 306.60x | 3.37x | 12.98x | 2.51x | 27.86x\nBollinger Upper | 0.002052s | 0.001432s | 0.000341s | 0.002129s | 0.006004s | 0.214716s | 1.43x | 0.24x | 1.49x | 4.19x | 149.92x\nOBV | 0.000685s | 0.000066s | 0.000224s | N/A | 0.000275s | 14.146200s | 10.43x | 3.42x | N/A | 4.19x | 215376.26x\nMFI | 0.482099s | 0.002581s | 0.002374s | 0.003096s | 0.006168s | 0.021110s | 186.77x | 0.92x | 1.20x | 2.39x | 8.18x\nWMA | 2.456998s | 0.003013s | 0.000092s | 0.126318s | 0.002411s | 0.339517s | 815.56x | 0.03x | 41.93x | 0.80x | 112.70x\nVWEMA | 0.000908s | 0.000822s | 0.029710s | 0.002095s | 0.004002s | 0.058675s | 1.10x | 36.13x | 2.55x | 4.87x | 71.35x\nADX | 0.407531s | 0.003533s | 0.000643s | 0.012459s | 0.009984s | 0.002930s | 115.34x | 0.18x | 3.53x | 2.83x | 0.83x\nPSAR | 4.123320s | 0.000467s | 0.000346s | 0.449931s | 0.001659s | 0.007989s | 8837.04x | 0.74x | 964.29x | 3.56x | 17.12x\n----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\nSummary Statistics:\nAverage speedup vs ta: 857.10x\nAverage speedup vs ta-lib: 4.35x\nAverage speedup vs pandas: 94.34x\nAverage speedup vs cython: 2.45x\nAverage speedup vs nautilus: 18002.35x\nIdentical results vs ta: 11/12\nIdentical results vs ta-lib: 4/12\nIdentical results vs cython: 5/12\nIdentical results vs nautilus: 3/12\n```\n\n### **\ud83d\udcc8 Performance Summary**\n\n**Benchmark Results Analysis:**\n\n**vs Pure Python Libraries:**\n\n- ta library: 857x average speedup (range: 1.1x to 8,837x)\n- pandas: 94x average speedup (range: 0.66x to 964x)\n- Consistent performance advantage across most indicators\n\n**vs Compiled Libraries:**\n\n- TA-Lib: 0.23x average performance (ta-numba is 4.3x slower on average)\n- cython: 2.5x average speedup (mixed results depending on indicator)\n- Performance varies significantly by indicator complexity\n\n**Streaming Performance:**\n\n- 15.8x faster than bulk recalculation methods\n- Constant O(1) memory usage vs. O(n) growth\n- Microsecond-level latency for real-time applications\n\n**Library Selection Criteria:**\n\n- **Choose TA-Lib for**: Maximum performance, stable environment, C compilation acceptable\n- **Choose ta-numba for**: Reliable deployment, streaming requirements, Python-only environments\n- **Choose ta/pandas for**: Simplicity, small datasets, existing pandas workflows\n\n**Real-Time Streaming Performance (per tick):**\n\n```text\n\ud83d\ude80 REAL-TIME STREAMING COMPARISON\n============================================================\nSimulating live market data feed with continuous price updates...\n\n\ud83d\udcca Generating 100 warmup ticks...\n\ud83d\udd25 Warming up JIT compilation...\n\ud83d\udcc8 Initializing streaming indicators...\n\n\ud83c\udfaf SIMULATING 10,000 LIVE MARKET TICKS...\n------------------------------------------------------------\nProgress: 10% | Avg Bulk: 0.039ms | Avg Streaming: 0.017ms | Speedup: 2.3x\nProgress: 20% | Avg Bulk: 0.103ms | Avg Streaming: 0.018ms | Speedup: 5.8x\nProgress: 30% | Avg Bulk: 0.174ms | Avg Streaming: 0.019ms | Speedup: 9.0x\nProgress: 40% | Avg Bulk: 0.244ms | Avg Streaming: 0.021ms | Speedup: 11.6x\nProgress: 50% | Avg Bulk: 0.313ms | Avg Streaming: 0.023ms | Speedup: 13.5x\nProgress: 60% | Avg Bulk: 0.378ms | Avg Streaming: 0.023ms | Speedup: 16.2x\nProgress: 70% | Avg Bulk: 0.447ms | Avg Streaming: 0.024ms | Speedup: 18.7x\nProgress: 80% | Avg Bulk: 0.516ms | Avg Streaming: 0.024ms | Speedup: 21.7x\nProgress: 90% | Avg Bulk: 0.589ms | Avg Streaming: 0.024ms | Speedup: 24.3x\nProgress: 100% | Avg Bulk: 0.671ms | Avg Streaming: 0.026ms | Speedup: 26.1x\n\n\ud83d\udcca FINAL RESULTS\n============================================================\nTotal ticks processed: 10,000\nLookback window size: 10000\n\n\u23f1\ufe0f TIMING STATISTICS (per tick):\nMethod Mean Median 95%ile 99%ile\n-------------------------------------------------------\nBulk 0.347ms 0.346ms 0.673ms 0.699ms\nStreaming 0.022ms 0.022ms 0.028ms 0.039ms\n\n\ud83d\ude80 PERFORMANCE IMPROVEMENT:\nAverage speedup: 15.8x faster\nMedian speedup: 15.9x faster\n\n\ud83d\udcbe MEMORY USAGE COMPARISON:\nBulk approach: O(n) = 10000 * 8 bytes * 7 indicators = 546.9 KB\nStreaming approach: O(1) = ~1 KB total (constant)\nMemory efficiency: 547x less memory\n\n\u26a1 LATENCY ANALYSIS:\nBulk 99th percentile: 0.699ms\nStreaming 99th percentile: 0.039ms\nFor HFT (<1ms requirement): \u2705 Bulk passes, \u2705 Streaming passes\n```\n\n### **\u2696\ufe0f Library Selection Guide**\n\n**Choose TA-Lib when:**\n\n- Maximum computational performance is critical\n- Working in controlled environments with stable dependencies\n- C compilation infrastructure is available and maintained\n- Academic or research work with consistent setup\n\n**Choose ta-numba when:**\n\n- Deploying in diverse environments (Docker, cloud, etc.)\n- Requiring real-time streaming capabilities\n- Building production systems with reliability requirements\n- Working with modern Python/NumPy ecosystems\n\n**Choose ta/pandas when:**\n\n- Working with small to medium datasets\n- Prototyping or exploratory analysis\n- Integration with existing pandas workflows is important\n- Performance requirements are modest\n\n### **\ud83d\ude80 Real-Time Performance Advantage**\n\n```python\n# Traditional approach (recalculates entire array each time)\ndef update_traditional(new_price, history, window=20):\n history.append(new_price)\n return talib.SMA(np.array(history), window)[-1] # 0.347ms per update\n\n# ta-numba streaming (O(1) update)\nsma = stream.SMA(window=20)\ndef update_streaming(new_price):\n return sma.update(new_price) # 0.022ms per update - 15.8x faster!\n```\n\n````\n\n Generating sample data of size 200000 with seed None...\n Sample data generated.\n\n --- Warming up Numba functions (JIT Compilation) ---\n Warm-up complete.\n\n --- Running Benchmarks (5 loops each) ---\n\n Discrepancy for TRIX:\n Mean Absolute Difference: 0.007569\n Zero Status: Normal\n\n First 5 differing values (Index, TA, Numba):\n 43, -0.035422, -0.054566\n 44, -0.021285, -0.035508\n 45, 0.001522, -0.006502\n 46, 0.002349, -0.005051\n 47, 0.012865, 0.008175\n\n Discrepancy for MI:\n Mean Absolute Difference: 6.323e-06\n Zero Status: Normal\n\n First 5 differing values (Index, TA, Numba):\n 40, 24.923410, 25.163110\n 41, 25.099305, 25.298424\n 42, 25.092817, 25.256278\n 43, 25.031762, 25.163705\n 44, 25.043005, 25.150111\n\n Discrepancy for STC:\n Mean Absolute Difference: 4.276e-06\n Zero Status: Normal\n\n First 5 differing values (Index, TA, Numba):\n 71, 16.939844, 17.313568\n 72, 8.469922, 8.656784\n 73, 4.234961, 4.328392\n 74, 15.217372, 15.289315\n 75, 28.028082, 28.091572\n\n Discrepancy for TSI:\n Mean Absolute Difference: 0.0004937\n Zero Status: Normal\n\n First 5 differing values (Index, TA, Numba):\n 37, 8.232642, 1.088498\n 38, 7.628686, 0.899511\n 39, 6.338255, -0.030883\n 40, 6.326458, 0.355236\n 41, 3.863873, -1.721345\n\n --- Benchmark Results (Average Time per Run) ---\n\n -----------------------------------------------------------\n Indicator | `ta` Library | Numba Version | Speedup\n -----------------------------------------------------------\n MFI | 1.187933s | 0.005150s | 230.65x\n ADI | 0.001475s | 0.000434s | 3.40x\n OBV | 0.001602s | 0.000122s | 13.08x\n CMF | 0.004253s | 0.001713s | 2.48x\n FI | 0.001479s | 0.000609s | 2.43x\n EOM | 0.001648s | 0.000172s | 9.58x\n VPT | 0.002104s | 0.000451s | 4.66x\n NVI | 3.244231s | 0.001093s | 2967.43x\n VWAP | 0.003858s | 0.001392s | 2.77x\n VWEMA | 0.005218s | 0.002011s | 2.60x\n ATR | 0.419494s | 0.001130s | 371.32x\n BB | 0.004472s | 0.003196s | 1.40x\n KC | 0.005683s | 0.007647s | 0.74x\n DC | 0.006115s | 0.009956s | 0.61x\n UI | 0.398492s | 0.007430s | 53.63x\n SMA | 0.001696s | 0.002453s | 0.69x\n EMA | 0.001192s | 0.000444s | 2.69x\n WMA | 5.459586s | 0.006479s | 842.68x\n MACD | 0.003275s | 0.001290s | 2.54x\n ADX | 0.883612s | 0.007472s | 118.25x\n Vortex | 0.016811s | 0.007960s | 2.11x\n TRIX | 0.004868s | 0.001166s | 4.18x\n MI | 0.003594s | 0.008942s | 0.40x\n CCI | 1.055140s | 0.007558s | 139.60x\n DPO | 0.001935s | 0.002446s | 0.79x\n KST | 0.011884s | 0.031931s | 0.37x\n Ichimoku | 0.013384s | 0.027892s | 0.48x\n PSAR | 9.464796s | 0.001216s | 7783.20x\n STC | 0.018517s | 0.019506s | 0.95x\n Aroon | 0.402076s | 0.005702s | 70.52x\n RSI | 0.004719s | 0.002710s | 1.74x\n StochRSI | 0.012424s | 0.014490s | 0.86x\n TSI | 0.004547s | 0.001771s | 2.57x\n UO | 0.034889s | 0.014549s | 2.40x\n Stoch | 0.006982s | 0.011224s | 0.62x\n WR | 0.006880s | 0.009031s | 0.76x\n AO | 0.003143s | 0.004481s | 0.70x\n KAMA | 0.130242s | 0.001560s | 83.47x\n ROC | 0.000777s | 0.000344s | 2.26x\n PPO | 0.003494s | 0.001294s | 2.70x\n PVO | 0.003904s | 0.001216s | 3.21x\n DR | 0.000662s | 0.000300s | 2.21x\n DLR | 0.000803s | 0.001611s | 0.50x\n CR | 0.000388s | 0.000184s | 2.11x\n CLR | 11.993333s | 1.936194s | 6.19x\n ```\n\n -----------------------------------------------------------\n\n --- Zero Value Status for All Indicators ---\n\n Normal (non-zero values): 44 indicators\n MFI, ADI, OBV, CMF, FI, EOM, VPT, NVI, VWAP, VWEMA,\n ATR, BB, KC, DC, UI, ... and 29 more\n\n All 44 indicators have normal non-zero values!\n\n --- Discrepancy Report ---\n\n Indicator Status MAD Zero Status\n TRIX Different 0.007569 Normal\n MI Different 6.323000e-06 Normal\n STC Different 4.276000e-06 Normal\n TSI Different 4.937000e-04 Normal\n -----------------------------------------------------------\n\n````\n\n## **\ud83c\udd95 What's New in v0.2.0**\n\n### **\ud83d\udd04 Streaming Indicators**\n\n- **Real-time processing**: O(1) per-update performance\n- **Memory efficient**: Constant memory usage regardless of data size\n- **Production ready**: Designed for live trading systems\n- **Clean API**: Simplified class names (`SMA`, `EMA`, `RSI` vs `SMAStreaming`)\n\n### **\u26a1 JIT Warmup System**\n\n- **Fast startup**: Eliminate JIT compilation delays in production\n- **Bulk warmup**: `ta_numba.warmup.warmup_all()` for all indicators\n- **Selective warmup**: Individual indicator warmup available\n- **Docker friendly**: Persistent compilation across container restarts\n\n### **\ud83c\udfaf Improved API Design**\n\n- **Dual namespaces**: `ta_numba.bulk` and `ta_numba.stream` for clarity\n- **Legacy compatibility**: Existing imports continue to work\n- **Better ergonomics**: Cleaner function calls for real-world usage\n\n## **\ud83d\udd04 Migration Guide**\n\n### **From v0.1.0 to v0.2.0**\n\n```python\n# Old way (still supported)\nimport ta_numba.trend as trend\nsma_values = trend.sma(prices, window=20)\n\n# New recommended way - Bulk processing\nimport ta_numba.bulk as bulk\nsma_values = bulk.trend.sma(prices, window=20)\n\n# New feature - Streaming\nimport ta_numba.stream as stream\nsma = stream.SMA(window=20)\nfor price in live_prices:\n current_sma = sma.update(price)\n```\n\n### **From Other Libraries**\n\n```python\n# From pandas\ndf['sma'] = df['close'].rolling(20).mean()\n# To ta-numba bulk\nsma_values = bulk.trend.sma(df['close'].values, window=20)\n\n# From ta-lib streaming simulation\n# (multiple function calls for updates)\n# To ta-numba streaming\nsma = stream.SMA(window=20)\ncurrent_value = sma.update(new_price)\n```\n\n## **\ud83d\udee0\ufe0f Advanced Usage**\n\n### **Production Deployment**\n\n```python\n# Recommended startup sequence for production\nimport ta_numba.warmup\nimport ta_numba.bulk as bulk\nimport ta_numba.stream as stream\n\n# Warm up all indicators (do this once at startup)\nta_numba.warmup.warmup_all()\n\n# Now all subsequent calls are fast\ndef process_historical_data(prices):\n return bulk.trend.sma(prices, window=20)\n\ndef process_live_data():\n sma = stream.SMA(window=20)\n for price in live_feed:\n yield sma.update(price)\n```\n\n### **Docker Integration**\n\n```dockerfile\n# Dockerfile optimization\nFROM python:3.11\nRUN pip install ta-numba\n\n# Pre-compile indicators at build time\nRUN python -c \"import ta_numba.warmup; ta_numba.warmup.warmup_all()\"\n\n# Your application will start faster\nCOPY . .\nCMD [\"python\", \"your_trading_app.py\"]\n```\n\n## **\ud83d\udcc8 Real-World Performance Examples**\n\n### **Backtesting (Bulk Processing)**\n\n```python\nimport ta_numba.bulk as bulk\nimport time\n\n# Process 1M price points\nprices = np.random.randn(1_000_000).cumsum() + 100\n\nstart = time.time()\nsma_values = bulk.trend.sma(prices, window=50)\nrsi_values = bulk.momentum.rsi(prices, window=14)\nmacd_line, macd_signal, macd_hist = bulk.trend.macd(prices)\nelapsed = time.time() - start\n\nprint(f\"Processed 1M points in {elapsed:.3f}s\")\n# Output: Processed 1M points in 0.045s\n```\n\n### **Live Trading (Streaming)**\n\n```python\nimport ta_numba.stream as stream\n\n# Set up indicators\nindicators = {\n 'sma_20': stream.SMA(window=20),\n 'sma_50': stream.SMA(window=50),\n 'rsi': stream.RSI(window=14),\n 'macd': stream.MACD()\n}\n\ndef on_price_update(price):\n signals = {}\n for name, indicator in indicators.items():\n signals[name] = indicator.update(price)\n\n # Generate trading signals\n if all(ind.is_ready for ind in indicators.values()):\n if signals['sma_20'] > signals['sma_50']:\n return \"BUY_SIGNAL\"\n elif signals['rsi'] > 70:\n return \"SELL_SIGNAL\"\n\n return \"HOLD\"\n\n# Process live feed (microsecond latency)\nfor price in live_price_feed:\n signal = on_price_update(price) # ~2-5 microseconds\n\n\n## **Acknowledgements**\n\n## **\ud83d\ude4f Acknowledgements**\n\nThis library builds upon the excellent work of several projects:\n\n- **[Technical Analysis Library (ta)](https://github.com/bukosabino/ta)** by Dar\u00edo L\u00f3pez Padial - API design and calculation logic foundation\n- **[Numba](https://numba.pydata.org/)** - JIT compilation technology that makes the performance possible\n- **[NumPy](https://numpy.org/)** - Fundamental array operations and mathematical functions\n\nta-numba extends the original ta library with high-performance Numba compilation and adds real-time streaming capabilities while maintaining mathematical accuracy and API compatibility.\n\n## **\ud83d\udcca Mathematical Documentation**\n\nAll indicator implementations are based on established formulas documented in: [`ta-numba.pdf`](ta-numba.pdf)\n\nThis document provides:\n- Precise mathematical definitions for all indicators\n- Implementation details and edge case handling\n- Verification against reference implementations\n- Performance optimization techniques used\n\n## **\ud83e\udd1d Contributing**\n\nWe welcome contributions! Whether it's:\n- \ud83d\udc1b Bug reports and fixes\n- \ud83d\udcc8 New indicator implementations\n- \u26a1 Performance optimizations\n- \ud83d\udcda Documentation improvements\n- \ud83e\uddea Test coverage expansion\n\nPlease see our [contributing guidelines](CONTRIBUTING.md) for details.\n\n## **\ud83d\udcdd License**\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\n**\u2b50 If ta-numba helps your trading or research, please give us a star on GitHub!**\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A high-performance technical analysis library with JIT compilation and streaming capabilities for real-time trading.",
"version": "0.2.2",
"project_urls": {
"Documentation": "https://github.com/JadenJ09/ta-numba#readme",
"Homepage": "https://github.com/JadenJ09/ta-numba",
"Issues": "https://github.com/JadenJ09/ta-numba/issues",
"Repository": "https://github.com/JadenJ09/ta-numba"
},
"split_keywords": [
"technical-analysis",
" quantitative-analysis",
" financial-engineering",
" trading",
" indicators",
" numba",
" performance",
" streaming",
" real-time",
" jit-compilation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e464c12f99f005138b784b8c450f6843b345a8dc6405b59f38c53f9b7a51f392",
"md5": "1f8ce95f95ca0798c397cca67903239a",
"sha256": "eb3539d200875b0a0566a7fd5dd29fd964d600909afa2def7a643206c32b3602"
},
"downloads": -1,
"filename": "ta_numba-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1f8ce95f95ca0798c397cca67903239a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 47042,
"upload_time": "2025-07-17T02:23:47",
"upload_time_iso_8601": "2025-07-17T02:23:47.603527Z",
"url": "https://files.pythonhosted.org/packages/e4/64/c12f99f005138b784b8c450f6843b345a8dc6405b59f38c53f9b7a51f392/ta_numba-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "02925b3b66ba407917362b1f72ae64954a997934feb8c34b5bc02ca968e25aa5",
"md5": "c02ef4932b2774072bc41bf767407f79",
"sha256": "f3b06db354ed0e31651590e433a88f6f163ec6ff3fda12380f464bf100e5604c"
},
"downloads": -1,
"filename": "ta_numba-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "c02ef4932b2774072bc41bf767407f79",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 412073,
"upload_time": "2025-07-17T02:23:48",
"upload_time_iso_8601": "2025-07-17T02:23:48.993274Z",
"url": "https://files.pythonhosted.org/packages/02/92/5b3b66ba407917362b1f72ae64954a997934feb8c34b5bc02ca968e25aa5/ta_numba-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-17 02:23:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "JadenJ09",
"github_project": "ta-numba#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ta-numba"
}