numta 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- numta-0.1.0/LICENSE +21 -0
- numta-0.1.0/PKG-INFO +448 -0
- numta-0.1.0/README.md +414 -0
- numta-0.1.0/pyproject.toml +57 -0
- numta-0.1.0/setup.cfg +4 -0
- numta-0.1.0/src/numta/__init__.py +88 -0
- numta-0.1.0/src/numta/api/__init__.py +1 -0
- numta-0.1.0/src/numta/api/cycle_indicators.py +269 -0
- numta-0.1.0/src/numta/api/math_operators.py +412 -0
- numta-0.1.0/src/numta/api/momentum_indicators.py +2389 -0
- numta-0.1.0/src/numta/api/overlap.py +1252 -0
- numta-0.1.0/src/numta/api/pattern_recognition.py +3168 -0
- numta-0.1.0/src/numta/api/price_transform.py +553 -0
- numta-0.1.0/src/numta/api/statistic_functions.py +674 -0
- numta-0.1.0/src/numta/api/statistics.py +351 -0
- numta-0.1.0/src/numta/api/volatility_indicators.py +185 -0
- numta-0.1.0/src/numta/api/volume_indicators.py +329 -0
- numta-0.1.0/src/numta/backend.py +92 -0
- numta-0.1.0/src/numta/benchmark.py +294 -0
- numta-0.1.0/src/numta/cpu/__init__.py +1 -0
- numta-0.1.0/src/numta/cpu/cycle_indicators.py +408 -0
- numta-0.1.0/src/numta/cpu/math_operators.py +158 -0
- numta-0.1.0/src/numta/cpu/momentum_indicators.py +1600 -0
- numta-0.1.0/src/numta/cpu/overlap.py +655 -0
- numta-0.1.0/src/numta/cpu/pattern_recognition.py +3129 -0
- numta-0.1.0/src/numta/cpu/price_transform.py +103 -0
- numta-0.1.0/src/numta/cpu/statistic_functions.py +325 -0
- numta-0.1.0/src/numta/cpu/statistics.py +120 -0
- numta-0.1.0/src/numta/cpu/volatility_indicators.py +93 -0
- numta-0.1.0/src/numta/cpu/volume_indicators.py +158 -0
- numta-0.1.0/src/numta/optimized.py +213 -0
- numta-0.1.0/src/numta.egg-info/PKG-INFO +448 -0
- numta-0.1.0/src/numta.egg-info/SOURCES.txt +95 -0
- numta-0.1.0/src/numta.egg-info/dependency_links.txt +1 -0
- numta-0.1.0/src/numta.egg-info/requires.txt +12 -0
- numta-0.1.0/src/numta.egg-info/top_level.txt +1 -0
- numta-0.1.0/tests/test_benchmark.py +143 -0
- numta-0.1.0/tests/test_cdl_rickshawman.py +37 -0
- numta-0.1.0/tests/test_cdl_risefall3methods.py +55 -0
- numta-0.1.0/tests/test_cdl_separatinglines.py +54 -0
- numta-0.1.0/tests/test_cdl_shootingstar.py +36 -0
- numta-0.1.0/tests/test_cdl_shortline.py +53 -0
- numta-0.1.0/tests/test_cdl_spinningtop.py +53 -0
- numta-0.1.0/tests/test_cdl_stalledpattern.py +36 -0
- numta-0.1.0/tests/test_cdl_sticksandwich.py +36 -0
- numta-0.1.0/tests/test_cdl_takuri.py +36 -0
- numta-0.1.0/tests/test_cdl_tasukigap.py +54 -0
- numta-0.1.0/tests/test_cdl_thrusting.py +36 -0
- numta-0.1.0/tests/test_cdl_tristar.py +53 -0
- numta-0.1.0/tests/test_cdl_unique3river.py +36 -0
- numta-0.1.0/tests/test_cdl_upsidegap2crows.py +36 -0
- numta-0.1.0/tests/test_cdl_xsidegap3methods.py +54 -0
- numta-0.1.0/tests/test_correl.py +56 -0
- numta-0.1.0/tests/test_dema.py +58 -0
- numta-0.1.0/tests/test_ema.py +31 -0
- numta-0.1.0/tests/test_ht_dcperiod.py +38 -0
- numta-0.1.0/tests/test_ht_dcphase.py +32 -0
- numta-0.1.0/tests/test_ht_phasor.py +49 -0
- numta-0.1.0/tests/test_ht_sine.py +55 -0
- numta-0.1.0/tests/test_ht_trendline.py +49 -0
- numta-0.1.0/tests/test_ht_trendmode.py +46 -0
- numta-0.1.0/tests/test_kama.py +74 -0
- numta-0.1.0/tests/test_linearreg.py +67 -0
- numta-0.1.0/tests/test_linearreg_angle.py +96 -0
- numta-0.1.0/tests/test_linearreg_intercept.py +57 -0
- numta-0.1.0/tests/test_linearreg_slope.py +81 -0
- numta-0.1.0/tests/test_ma.py +115 -0
- numta-0.1.0/tests/test_mama.py +28 -0
- numta-0.1.0/tests/test_max.py +35 -0
- numta-0.1.0/tests/test_maxindex.py +36 -0
- numta-0.1.0/tests/test_medprice.py +38 -0
- numta-0.1.0/tests/test_midpoint.py +46 -0
- numta-0.1.0/tests/test_midprice.py +47 -0
- numta-0.1.0/tests/test_min.py +32 -0
- numta-0.1.0/tests/test_minindex.py +29 -0
- numta-0.1.0/tests/test_minmax.py +35 -0
- numta-0.1.0/tests/test_minmaxindex.py +32 -0
- numta-0.1.0/tests/test_natr.py +40 -0
- numta-0.1.0/tests/test_new_patterns.py +175 -0
- numta-0.1.0/tests/test_obv.py +54 -0
- numta-0.1.0/tests/test_optimized.py +209 -0
- numta-0.1.0/tests/test_sar.py +32 -0
- numta-0.1.0/tests/test_sarext.py +36 -0
- numta-0.1.0/tests/test_sma.py +28 -0
- numta-0.1.0/tests/test_stddev.py +40 -0
- numta-0.1.0/tests/test_stoch.py +57 -0
- numta-0.1.0/tests/test_stochf.py +44 -0
- numta-0.1.0/tests/test_sum.py +34 -0
- numta-0.1.0/tests/test_t3.py +33 -0
- numta-0.1.0/tests/test_tema.py +38 -0
- numta-0.1.0/tests/test_trange.py +38 -0
- numta-0.1.0/tests/test_trima.py +44 -0
- numta-0.1.0/tests/test_tsf.py +50 -0
- numta-0.1.0/tests/test_typprice.py +50 -0
- numta-0.1.0/tests/test_var.py +49 -0
- numta-0.1.0/tests/test_wclprice.py +56 -0
- numta-0.1.0/tests/test_wma.py +65 -0
numta-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Odyssée
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
numta-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: numta
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: NumPy-based Technical Analysis library with focus on performance
|
|
5
|
+
Author: numta contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/houseofai/numta
|
|
8
|
+
Project-URL: Repository, https://github.com/houseofai/numta
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.20.0
|
|
25
|
+
Requires-Dist: numba>=0.56.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
|
|
29
|
+
Provides-Extra: comparison
|
|
30
|
+
Requires-Dist: TA-Lib>=0.4.0; extra == "comparison"
|
|
31
|
+
Provides-Extra: numba
|
|
32
|
+
Requires-Dist: numba>=0.56.0; extra == "numba"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# numta
|
|
36
|
+
|
|
37
|
+
A pure Python implementation of TA-Lib (Technical Analysis Library) with a focus on performance and compatibility.
|
|
38
|
+
|
|
39
|
+
## Overview
|
|
40
|
+
|
|
41
|
+
`numta` (NumPy Technical Analysis) provides the same functionality as the popular TA-Lib library but implemented entirely in Python using NumPy and Numba for performance. This eliminates the need for complex C library dependencies while maintaining high performance through optimized NumPy operations and JIT compilation.
|
|
42
|
+
|
|
43
|
+
**Disclaimer**: This is an independent implementation inspired by TA-Lib. It is not affiliated with, endorsed by, or connected to the original TA-Lib project. The technical analysis algorithms implemented here are based on publicly available mathematical formulas and are compatible with TA-Lib's function signatures for ease of migration.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- **Pure Python implementation** (no C dependencies)
|
|
48
|
+
- **TA-Lib compatible** function signatures
|
|
49
|
+
- **Multiple performance backends:**
|
|
50
|
+
- Default NumPy implementation
|
|
51
|
+
- Optimized cumsum algorithm (3x faster, no dependencies)
|
|
52
|
+
- Numba JIT compilation (5-10x faster)
|
|
53
|
+
- **Automatic backend selection** for optimal performance
|
|
54
|
+
- **Easy installation** via pip
|
|
55
|
+
- **Comprehensive test suite** comparing outputs with original TA-Lib
|
|
56
|
+
- **Built-in performance benchmarking** tools
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
### Basic Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# From PyPI (when published)
|
|
64
|
+
pip install numta
|
|
65
|
+
|
|
66
|
+
# From source
|
|
67
|
+
git clone https://github.com/houseofai/numta.git
|
|
68
|
+
cd numta
|
|
69
|
+
pip install -e .
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Performance Optimizations (Recommended)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Install with Numba for 5-10x speedup
|
|
76
|
+
pip install "numta[numba]"
|
|
77
|
+
|
|
78
|
+
# Install development dependencies
|
|
79
|
+
pip install "numta[dev]"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Quick Start
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import numpy as np
|
|
86
|
+
from numta import SMA
|
|
87
|
+
|
|
88
|
+
# Create sample price data
|
|
89
|
+
close_prices = np.random.uniform(100, 200, 100)
|
|
90
|
+
|
|
91
|
+
# Calculate Simple Moving Average with default period (30)
|
|
92
|
+
sma = SMA(close_prices)
|
|
93
|
+
|
|
94
|
+
# Calculate SMA with custom period
|
|
95
|
+
sma_20 = SMA(close_prices, timeperiod=20)
|
|
96
|
+
|
|
97
|
+
print(f"SMA values: {sma[-5:]}") # Last 5 values
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Performance Optimization 🚀
|
|
101
|
+
|
|
102
|
+
numta can match or exceed TA-Lib's performance using optional optimization backends:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from numta import SMA_auto
|
|
106
|
+
|
|
107
|
+
# Automatic backend selection (recommended)
|
|
108
|
+
sma = SMA_auto(close_prices, timeperiod=30, backend='auto')
|
|
109
|
+
|
|
110
|
+
# Or choose specific backend
|
|
111
|
+
from numta import SMA_cumsum, SMA_numba
|
|
112
|
+
|
|
113
|
+
sma_fast = SMA_cumsum(close_prices, timeperiod=30) # 3x faster, no deps
|
|
114
|
+
sma_faster = SMA_numba(close_prices, timeperiod=30) # 5-10x faster
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Performance Comparison
|
|
118
|
+
|
|
119
|
+
| Implementation | Speed vs Original | Requirements |
|
|
120
|
+
|---------------------|-------------------|---------------------|
|
|
121
|
+
| **numpy (default)** | 1.0x (baseline) | None |
|
|
122
|
+
| **cumsum** | **3.14x faster** | None |
|
|
123
|
+
| **numba** | **5-10x faster** | `pip install numba` |
|
|
124
|
+
|
|
125
|
+
**Benchmark Results (10,000 points):**
|
|
126
|
+
- Original (numpy): 0.154ms
|
|
127
|
+
- Cumsum: 0.049ms (3.14x faster)
|
|
128
|
+
- **Numba: 0.028ms (5.52x faster)** ⭐
|
|
129
|
+
|
|
130
|
+
**See [PERFORMANCE.md](PERFORMANCE.md) for detailed performance analysis.**
|
|
131
|
+
|
|
132
|
+
## Implemented Indicators
|
|
133
|
+
|
|
134
|
+
This library implements a comprehensive set of technical analysis indicators across multiple categories:
|
|
135
|
+
|
|
136
|
+
### Overlap Studies
|
|
137
|
+
SMA, EMA, DEMA, TEMA, TRIMA, WMA, KAMA, MAMA, T3, BBANDS, MA, SAR, SAREXT
|
|
138
|
+
|
|
139
|
+
### Momentum Indicators
|
|
140
|
+
RSI, MACD, MACDEXT, MACDFIX, STOCH, STOCHF, STOCHRSI, ADX, ADXR, APO, AROON, AROONOSC, ATR, BOP, CCI, CMO, DX, MFI, MINUS_DI, MINUS_DM, MOM, PLUS_DI, PLUS_DM, PPO, ROC, ROCP, ROCR, ROCR100, TRIX, ULTOSC, WILLR
|
|
141
|
+
|
|
142
|
+
### Volume Indicators
|
|
143
|
+
AD, ADOSC, OBV
|
|
144
|
+
|
|
145
|
+
### Volatility Indicators
|
|
146
|
+
NATR, TRANGE
|
|
147
|
+
|
|
148
|
+
### Cycle Indicators
|
|
149
|
+
HT_DCPERIOD, HT_DCPHASE, HT_PHASOR, HT_SINE, HT_TRENDLINE, HT_TRENDMODE
|
|
150
|
+
|
|
151
|
+
### Statistical Functions
|
|
152
|
+
BETA, CORREL, LINEARREG, LINEARREG_ANGLE, LINEARREG_INTERCEPT, LINEARREG_SLOPE, STDDEV, TSF, VAR
|
|
153
|
+
|
|
154
|
+
### Math Operators
|
|
155
|
+
MAX, MAXINDEX, MIN, MININDEX, MINMAX, MINMAXINDEX, SUM
|
|
156
|
+
|
|
157
|
+
### Price Transform
|
|
158
|
+
MEDPRICE, MIDPOINT, MIDPRICE, TYPPRICE, WCLPRICE
|
|
159
|
+
|
|
160
|
+
### Pattern Recognition
|
|
161
|
+
60+ candlestick patterns including: Doji, Hammer, Engulfing, Morning Star, Evening Star, Three White Soldiers, and many more.
|
|
162
|
+
|
|
163
|
+
**See [FUNCTION_IMPLEMENTATIONS.md](FUNCTION_IMPLEMENTATIONS.md) for detailed implementation status.**
|
|
164
|
+
|
|
165
|
+
## Usage Examples
|
|
166
|
+
|
|
167
|
+
### Basic Usage
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
import numpy as np
|
|
171
|
+
from numta import SMA
|
|
172
|
+
|
|
173
|
+
# Generate sample data
|
|
174
|
+
close = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], dtype=np.float64)
|
|
175
|
+
|
|
176
|
+
# Calculate 3-period SMA
|
|
177
|
+
result = SMA(close, timeperiod=3)
|
|
178
|
+
|
|
179
|
+
# Output: [nan nan 2. 3. 4. 5. 6. 7. 8. 9.]
|
|
180
|
+
# First (timeperiod-1) values are NaN due to lookback period
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Working with Real Market Data
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
import numpy as np
|
|
187
|
+
from numta import SMA
|
|
188
|
+
|
|
189
|
+
# Example with stock prices
|
|
190
|
+
close_prices = np.array([
|
|
191
|
+
150.0, 151.5, 149.0, 153.0, 155.0,
|
|
192
|
+
154.0, 156.5, 158.0, 157.0, 159.5
|
|
193
|
+
])
|
|
194
|
+
|
|
195
|
+
# Calculate 5-period SMA
|
|
196
|
+
sma_5 = SMA(close_prices, timeperiod=5)
|
|
197
|
+
|
|
198
|
+
for i, (price, sma) in enumerate(zip(close_prices, sma_5)):
|
|
199
|
+
if not np.isnan(sma):
|
|
200
|
+
print(f"Day {i+1}: Price={price:.2f}, SMA(5)={sma:.2f}")
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Performance Benchmarking
|
|
204
|
+
|
|
205
|
+
`numta` includes a powerful benchmarking class to compare performance with the original TA-Lib:
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
import numpy as np
|
|
209
|
+
from numta import SMA as SMA_numta
|
|
210
|
+
from numta.benchmark import PerformanceMeasurement
|
|
211
|
+
import talib
|
|
212
|
+
|
|
213
|
+
# Create test data
|
|
214
|
+
data = np.random.uniform(100, 200, 10000)
|
|
215
|
+
|
|
216
|
+
# Setup benchmark
|
|
217
|
+
bench = PerformanceMeasurement()
|
|
218
|
+
bench.add_function("numta SMA", SMA_numta, data, timeperiod=30)
|
|
219
|
+
bench.add_function("TA-Lib SMA", talib.SMA, data, timeperiod=30)
|
|
220
|
+
|
|
221
|
+
# Run benchmark
|
|
222
|
+
results = bench.run(iterations=1000)
|
|
223
|
+
bench.print_results(results)
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Running the Benchmark Script
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
python examples/benchmark_sma.py
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Benchmark Features
|
|
233
|
+
|
|
234
|
+
The `PerformanceMeasurement` class provides:
|
|
235
|
+
|
|
236
|
+
- Measure execution time with configurable iterations and warmup
|
|
237
|
+
- Compare multiple functions side-by-side
|
|
238
|
+
- Calculate speedup ratios
|
|
239
|
+
- Test across different data sizes
|
|
240
|
+
- Statistical analysis (mean, median, std dev, min, max)
|
|
241
|
+
|
|
242
|
+
## Testing
|
|
243
|
+
|
|
244
|
+
The library includes comprehensive tests that compare outputs with the original TA-Lib:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Install test dependencies
|
|
248
|
+
pip install -e ".[dev]"
|
|
249
|
+
|
|
250
|
+
# Run all tests
|
|
251
|
+
pytest
|
|
252
|
+
|
|
253
|
+
# Optional: Install TA-Lib for comparison tests (requires TA-Lib C library)
|
|
254
|
+
pip install -e ".[comparison]"
|
|
255
|
+
|
|
256
|
+
# Run specific test file
|
|
257
|
+
pytest tests/test_sma.py
|
|
258
|
+
|
|
259
|
+
# Run with verbose output
|
|
260
|
+
pytest -v
|
|
261
|
+
|
|
262
|
+
# Run benchmark tests
|
|
263
|
+
pytest tests/test_benchmark.py
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Test Coverage
|
|
267
|
+
|
|
268
|
+
- **Comparison Tests**: Verify that outputs match TA-Lib exactly
|
|
269
|
+
- **Edge Cases**: Handle empty arrays, insufficient data, etc.
|
|
270
|
+
- **Input Validation**: Test error handling for invalid inputs
|
|
271
|
+
- **Data Types**: Support for both numpy arrays and Python lists
|
|
272
|
+
|
|
273
|
+
## API Compatibility
|
|
274
|
+
|
|
275
|
+
`numta` maintains full API compatibility with TA-Lib:
|
|
276
|
+
|
|
277
|
+
| Feature | TA-Lib | numta |
|
|
278
|
+
|---------------------|--------|-------|
|
|
279
|
+
| Function signatures | ✓ | ✓ |
|
|
280
|
+
| Return values | ✓ | ✓ |
|
|
281
|
+
| NaN handling | ✓ | ✓ |
|
|
282
|
+
| NumPy array support | ✓ | ✓ |
|
|
283
|
+
| List support | ✓ | ✓ |
|
|
284
|
+
| Default parameters | ✓ | ✓ |
|
|
285
|
+
|
|
286
|
+
## Development
|
|
287
|
+
|
|
288
|
+
### Project Structure
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
numta/
|
|
292
|
+
├── src/
|
|
293
|
+
│ └── numta/
|
|
294
|
+
│ ├── __init__.py # Main package exports
|
|
295
|
+
│ ├── backend.py # Backend selection logic
|
|
296
|
+
│ ├── benchmark.py # Performance measurement tools
|
|
297
|
+
│ ├── optimized.py # Optimized implementations
|
|
298
|
+
│ ├── api/ # Public API layer
|
|
299
|
+
│ │ ├── overlap.py # Overlap studies (SMA, EMA, etc.)
|
|
300
|
+
│ │ ├── momentum_indicators.py
|
|
301
|
+
│ │ ├── volume_indicators.py
|
|
302
|
+
│ │ └── ...
|
|
303
|
+
│ └── cpu/ # CPU/Numba implementations
|
|
304
|
+
│ ├── overlap.py # Numba-optimized overlap studies
|
|
305
|
+
│ ├── math_operators.py
|
|
306
|
+
│ └── ...
|
|
307
|
+
├── tests/ # Comprehensive test suite
|
|
308
|
+
│ ├── test_sma.py
|
|
309
|
+
│ ├── test_ema.py
|
|
310
|
+
│ └── test_benchmark.py
|
|
311
|
+
├── examples/ # Usage examples
|
|
312
|
+
│ ├── benchmark_sma.py
|
|
313
|
+
│ └── benchmark_optimized.py
|
|
314
|
+
├── development/ # Development tools
|
|
315
|
+
│ ├── accuracy_*.py # Accuracy comparison scripts
|
|
316
|
+
│ ├── benchmark_*.py # Benchmark scripts
|
|
317
|
+
│ └── ACCURACY.md # Accuracy test results
|
|
318
|
+
├── PERFORMANCE.md # Performance analysis
|
|
319
|
+
├── FUNCTION_IMPLEMENTATIONS.md # Implementation details
|
|
320
|
+
├── pyproject.toml
|
|
321
|
+
├── LICENSE
|
|
322
|
+
└── README.md
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Adding New Indicators
|
|
326
|
+
|
|
327
|
+
To add a new indicator:
|
|
328
|
+
|
|
329
|
+
1. Implement the function in the appropriate API module (e.g., `api/overlap.py` for overlap studies)
|
|
330
|
+
2. Optionally add optimized Numba implementation in the corresponding `cpu/` module
|
|
331
|
+
3. Ensure the signature matches TA-Lib exactly
|
|
332
|
+
4. Add comparison tests in `tests/`
|
|
333
|
+
5. Export the function in `__init__.py`
|
|
334
|
+
6. Add documentation and examples
|
|
335
|
+
|
|
336
|
+
Example:
|
|
337
|
+
|
|
338
|
+
```python
|
|
339
|
+
def EMA(close: Union[np.ndarray, list], timeperiod: int = 30) -> np.ndarray:
|
|
340
|
+
"""
|
|
341
|
+
Exponential Moving Average
|
|
342
|
+
|
|
343
|
+
Parameters
|
|
344
|
+
----------
|
|
345
|
+
close : array-like
|
|
346
|
+
Close prices
|
|
347
|
+
timeperiod : int, optional
|
|
348
|
+
Period for EMA (default: 30)
|
|
349
|
+
|
|
350
|
+
Returns
|
|
351
|
+
-------
|
|
352
|
+
np.ndarray
|
|
353
|
+
EMA values
|
|
354
|
+
"""
|
|
355
|
+
# Implementation here
|
|
356
|
+
pass
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Contributing
|
|
360
|
+
|
|
361
|
+
Contributions are welcome! Please:
|
|
362
|
+
|
|
363
|
+
1. Fork the repository
|
|
364
|
+
2. Create a feature branch
|
|
365
|
+
3. Implement your changes with tests
|
|
366
|
+
4. Ensure all tests pass
|
|
367
|
+
5. Submit a pull request
|
|
368
|
+
|
|
369
|
+
## Performance
|
|
370
|
+
|
|
371
|
+
`numta` uses NumPy's optimized functions and Numba JIT compilation to achieve performance competitive with the C-based TA-Lib. Benchmark results:
|
|
372
|
+
|
|
373
|
+
- **SMA**: Comparable performance to TA-Lib for large datasets
|
|
374
|
+
- **Lookback handling**: Efficient NaN placement
|
|
375
|
+
- **Memory usage**: Optimized array operations
|
|
376
|
+
|
|
377
|
+
Run `python examples/benchmark_sma.py` to see detailed benchmarks on your system.
|
|
378
|
+
|
|
379
|
+
## Requirements
|
|
380
|
+
|
|
381
|
+
- Python >= 3.8
|
|
382
|
+
- NumPy >= 1.20.0
|
|
383
|
+
|
|
384
|
+
### Optional Dependencies
|
|
385
|
+
|
|
386
|
+
- **Testing**: pytest >= 7.0.0, pytest-benchmark >= 4.0.0
|
|
387
|
+
- **Performance**: numba >= 0.56.0 (for JIT compilation, 5-10x speedup)
|
|
388
|
+
- **Comparison**: TA-Lib >= 0.4.0 (only for development/comparison scripts, requires C library)
|
|
389
|
+
|
|
390
|
+
## License
|
|
391
|
+
|
|
392
|
+
MIT License - see LICENSE file for details
|
|
393
|
+
|
|
394
|
+
## Acknowledgments
|
|
395
|
+
|
|
396
|
+
This project implements technical analysis algorithms that are publicly available mathematical formulas. We acknowledge and credit:
|
|
397
|
+
|
|
398
|
+
- **TA-Lib** - The original Technical Analysis Library (Copyright (c) 1999-2024, Mario Fortier)
|
|
399
|
+
- Website: https://ta-lib.org/
|
|
400
|
+
- Python wrapper: https://github.com/TA-Lib/ta-lib-python
|
|
401
|
+
- License: BSD 3-Clause
|
|
402
|
+
|
|
403
|
+
`numta` is an independent clean-room implementation and is not derived from TA-Lib's source code. All code in this repository is original work licensed under the MIT License (see LICENSE file).
|
|
404
|
+
|
|
405
|
+
## Roadmap
|
|
406
|
+
|
|
407
|
+
### Completed ✅
|
|
408
|
+
- [x] Core overlap studies (SMA, EMA, DEMA, TEMA, WMA, KAMA, etc.)
|
|
409
|
+
- [x] Momentum indicators (RSI, MACD, STOCH, ADX, etc.)
|
|
410
|
+
- [x] Volume indicators (OBV, AD, ADOSC)
|
|
411
|
+
- [x] Volatility indicators (NATR, TRANGE)
|
|
412
|
+
- [x] Pattern recognition (60+ candlestick patterns)
|
|
413
|
+
- [x] Cycle indicators (Hilbert Transform functions)
|
|
414
|
+
- [x] Statistical functions
|
|
415
|
+
- [x] Math operators
|
|
416
|
+
- [x] Price transforms
|
|
417
|
+
- [x] Comprehensive test framework
|
|
418
|
+
- [x] Performance benchmarking tools
|
|
419
|
+
- [x] Multiple backend support (NumPy, Numba)
|
|
420
|
+
|
|
421
|
+
### In Progress 🚧
|
|
422
|
+
- [ ] Additional performance optimizations
|
|
423
|
+
- [ ] Extended documentation and examples
|
|
424
|
+
- [ ] More comprehensive benchmarks
|
|
425
|
+
|
|
426
|
+
### Future Plans 📋
|
|
427
|
+
- [ ] Real-time streaming data support
|
|
428
|
+
- [ ] Integration with popular data providers
|
|
429
|
+
- [ ] Interactive visualization tools
|
|
430
|
+
- [ ] Additional optimization backends
|
|
431
|
+
|
|
432
|
+
## Support
|
|
433
|
+
|
|
434
|
+
For issues, questions, or contributions, please visit:
|
|
435
|
+
https://github.com/houseofai/numta/issues
|
|
436
|
+
|
|
437
|
+
## Citation
|
|
438
|
+
|
|
439
|
+
If you use this library in your research or project, please cite:
|
|
440
|
+
|
|
441
|
+
```
|
|
442
|
+
@software{numta,
|
|
443
|
+
title={numta: NumPy-based Technical Analysis Library},
|
|
444
|
+
author={numta contributors},
|
|
445
|
+
url={https://github.com/houseofai/numta},
|
|
446
|
+
year={2025}
|
|
447
|
+
}
|
|
448
|
+
```
|