Comprehensive technical indicators for financial data.
Project description
QuantJourney Technical Indicators
A high-performance Python library for calculating technical indicators, optimized with Numba for speed and designed for financial data analysis. This project is part of the Quantitative Infrastructure initiative by QuantJourney, providing robust tools for traders and researchers.
License: MIT License - see LICENSE for details.
Author: Jakub Polec (jakub@quantjourney.pro)
Repository: github.com/QuantJourneyOrg/qj_technical_indicators
Overview
The QuantJourney Technical Indicators library offers a comprehensive set of technical indicators for analyzing financial time series data. Key features include:
- Numba-Optimized Calculations: Fast, JIT-compiled functions for performance-critical computations.
- Flexible API: Supports both standalone functions and a
TechnicalIndicatorsclass for object-oriented usage. - Robust Error Handling: Validates inputs and handles edge cases like NaNs and empty data.
- Visualization: Generates individual plots for indicators, saved as PNG files in an
indicator_plotsdirectory. - Integration: Works seamlessly with
pandasDataFrames andyfinancefor data fetching.
Extras and Lazy Loading
-
Optional extras keep the core lightweight:
pip install .[yf]to enable yfinance-based examples/testspip install .[plot]to enable plotting with matplotlib
-
Lazy JIT compile: kernels compile on first use and are cached to disk. You can opt-in to eager compile for lower first-call latency:
from quantjourney_ti import TechnicalIndicators
ti = TechnicalIndicators(warmup=True) # pre-compiles a common subset of kernels
- Logging: queue logging is opt-in to avoid starting background threads on import:
from quantjourney_ti import start_logging_queue
start_logging_queue() # enable QueueHandler + background consumer thread
The library is ideal for backtesting trading strategies, real-time analysis, and research, with a focus on simplicity and extensibility.
Recent Improvements
- DataFrame inputs with only
adj_closeare now auto-normalized for indicators that require aclosecolumn. SMAgains a lightweight cache via@cached_indicatorto speed repeat calls on unchanged inputs.- Streaming buffers now respect the constructor’s
max_buffer_sizeargument. - Risk metrics correctly detect constant price series as prices (max drawdown = 0).
- Validation utilities and logging were streamlined to improve robustness in mixed environments.
Caching
Some indicators support lightweight caching to avoid repeated computation on identical inputs.
- The
@cached_indicator(ttl_seconds=3600)decorator enables memoization with a time‑to‑live. - Inputs are hashed by content (values + index) to detect duplicates safely.
- Example:
SMAuses caching out of the box.
Cache control utilities:
from quantjourney_ti import get_cache_stats, clear_indicator_cache
# View cache statistics
print(get_cache_stats())
# Clear all cached entries
clear_indicator_cache()
To add caching to your own wrappers, apply @cached_indicator above your method. Choose an appropriate TTL for your workload.
Project Structure
The repository is organized as follows (top-level view):
quantjourney_ti/ # Package code
├── __init__.py # Public exports and helpers
├── indicators.py # Main API class (TechnicalIndicators)
├── technical_indicators.py # Legacy compatibility wrapper(s)
├── _indicator_kernels.py # Numba-accelerated kernels
├── _decorators.py # timer / numba_fallback
├── _errors.py # Custom errors
├── _utils.py # Validation, plotting, memory helpers
├── _performance.py # Caching, profiling, perf stats
├── _risk_metrics.py # Risk metrics utilities
├── _streaming.py # Streaming indicators + datafeed
├── kernels/ # Organized numba kernels
│ ├── __init__.py
│ ├── trend_numba.py
│ ├── momentum_numba.py
│ ├── volatility_numba.py
│ └── volume_numba.py
└── _legacy_/ # Older APIs kept for reference
└── technical_indicators.py
tests/ # Unit and integration tests (pytest)
docs/ # Documentation
├── INDICATORS.md
└── USAGE.md
examples/ # Usage examples and scripts
notebooks/ # Jupyter notebooks
indicator_plots/ # Saved example plots
pyproject.toml # Build + project metadata
requirements.txt # Dev/test dependencies
CHANGELOG.md # Release notes
LICENSE # MIT License text
README.md # This file
Installation
-
Clone the repository:
git clone https://github.com/QuantJourneyOrg/qj_technical_indicators.git cd qj_technical_indicators
-
Install dependencies:
pip install -r requirements.txt # optional extras pip install .[yf] pip install .[plot]
-
Install the package in editable mode:
pip install -e .
Requirements:
- Python 3.11–3.14
pandas,numpy,yfinance,numba,matplotlib
Usage
The library provides a TechnicalIndicators class for calculating indicators and saving plots. See docs/USAGE.md for a compact guide and notebooks/ for interactive examples. Example:
import numpy as np
import pandas as pd
import yfinance as yf
from quantjourney_ti import TechnicalIndicators
from quantjourney_ti._utils import plot_indicators
# Fetch data (requires extra 'yf')
df = yf.download("AAPL", start="2024-01-01", end="2025-02-01", progress=False)
if isinstance(df.columns, pd.MultiIndex):
df.columns = df.columns.get_level_values(0).str.lower().str.replace(" ", "_")
else:
df.columns = df.columns.str.lower().str.replace(" ", "_")
df["volume"] = df["volume"].replace(0, np.nan).ffill()
ti = TechnicalIndicators()
ema = ti.EMA(df["close"], 20)
rsi = ti.RSI(df["close"], 14)
macd = ti.MACD(df["close"], 12, 26, 9)
Examples:
python examples/run_basic.py --ticker AAPL --period 6mo
python examples/run_channels.py --ticker AAPL --period 6mo
python examples/run_from_csv.py --csv path/to/ohlcv.csv --sep ,
Notebooks:
notebooks/01_basic_indicators.ipynbnotebooks/02_channels_and_bands.ipynbnotebooks/03_streaming_demo.ipynb
📊 Example Plot
Supported Indicators
The library supports 39 indicators (54 series):
- Single-Series Indicators (21):
- SMA (Simple Moving Average)
- EMA (Exponential Moving Average)
- RSI (Relative Strength Index)
- ATR (Average True Range)
- MFI (Money Flow Index)
- TRIX
- CCI (Commodity Channel Index)
- ROC (Rate of Change)
- WILLR (Williams %R)
- DEMA (Double Exponential Moving Average)
- KAMA (Kaufman Adaptive Moving Average)
- AO (Awesome Oscillator)
- ULTIMATE_OSCILLATOR
- CMO (Chande Momentum Oscillator)
- DPO (Detrended Price Oscillator)
- MASS_INDEX
- VWAP (Volume Weighted Average Price)
- AD (Accumulation/Distribution Line)
- HULL_MA (Hull Moving Average)
- OBV (On-Balance Volume)
- RVI (Relative Vigor Index)
- Multi-Series Indicators (18):
- MACD (MACD, Signal, Histogram)
- BB (Bollinger Bands: BB_Upper, BB_Middle, BB_Lower)
- STOCH (Stochastic Oscillator: K, D)
- ADX (Average Directional Index: ADX, +DI, -DI)
- ICHIMOKU (Tenkan-sen, Kijun-sen, Senkou Span A, Senkou Span B, Chikou Span)
- KELTNER (Keltner Channels: KC_Upper, KC_Middle, KC_Lower)
- DONCHIAN (Donchian Channels: DC_Upper, DC_Middle, DC_Lower)
- AROON (AROON_UP, AROON_DOWN, AROON_OSC)
- VOLUME_INDICATORS (Volume_SMA, Force_Index, VPT)
- PIVOT_POINTS (PP, R1, R2, S1, S2)
- RAINBOW (9 SMAs for periods 2-10)
- BETA
- DI (Directional Indicator: +DI, -DI)
- ADOSC (Chaikin A/D Oscillator)
- HEIKEN_ASHI (HA_Open, HA_High, HA_Low, HA_Close)
- BENFORD_LAW (Observed, Expected)
- MOMENTUM_INDEX (MomentumIndex, NegativeIndex)
- ELDER_RAY (BullPower, BearPower)
See indicators.py for the full list and parameters.
Development
To contribute:
- Fork the repository and create a branch.
- Add new indicators in
_indicator_kernels.pywith Numba optimization. - Define public methods in
indicators.py. - Update tests in
tests/. - Submit a pull request.
Testing:
# Core tests (no network):
pytest -m "not slow" # skips network-dependent tests
# Full suite including yfinance examples (requires network + optional extras):
pytest
- All tests live under
tests/. - Slow/optional tests are marked
@pytest.mark.slow. - Some tests require extras: install with
pip install .[yf]andpip install .[plot].
Contact
For issues or feedback, contact Jakub Polec at jakub@quantjourney.pro or open an issue on GitHub.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quantjourney_ti-0.3.2.tar.gz.
File metadata
- Download URL: quantjourney_ti-0.3.2.tar.gz
- Upload date:
- Size: 279.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8aa37a46f03a0567c030ee83ee05aaee5ad20d0eff9f93bb39bfbdbf39665637
|
|
| MD5 |
7b0c7dec1eed83f259dfb4d608cc85ef
|
|
| BLAKE2b-256 |
6861b48ca6c594a7f6ddb7b2decd230d8e1bb481c98ef1db5f504d801bb687f0
|
File details
Details for the file quantjourney_ti-0.3.2-py3-none-any.whl.
File metadata
- Download URL: quantjourney_ti-0.3.2-py3-none-any.whl
- Upload date:
- Size: 106.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cddc9b293b63247714656fbb04ef6c680d0979ede3774ce7839d388b2f396963
|
|
| MD5 |
f543da58ab0e0905d68ffaca806744a9
|
|
| BLAKE2b-256 |
de5aeb71e4e058f6648625632d530e4ae051e8562e48345eb56a9fb73d40e555
|