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.md 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.
The library is ideal for backtesting trading strategies, real-time analysis, and research, with a focus on simplicity and extensibility.
Project Structure
The repository is organized as follows:
quantjourney_ti/
├── __init__.py # Package initialization and imports
├── _decorators.py # Decorators for timing and fallback mechanisms
├── _errors.py # Custom error classes for input validation
├── _indicator_kernels.py # Numba-optimized functions for indicator calculations
├── _legacy_/ # Legacy code (not actively maintained)
├── _utils.py # Utility functions for validation, plotting, and memory optimization
├── indicators.py # Main API class (TechnicalIndicators) with public methods
├── docs/ # Documentation
│ ├── INDICATORS.md # Explanation of each indicator
├── examples/ # Example scripts demonstrating usage
│ ├── example_basic.py # Basic indicator calculations
│ ├── example_indicators.py # Advanced usage with multiple indicators and plotting
├── tests/ # Unit and integration tests
│ ├── __init__.py
│ ├── _yf.py # yfinance test utilities
│ ├── test_all_indicators.py # Tests for all indicators
│ ├── test_basic.py # Basic functionality tests
│ ├── test_decorators.py # Decorator tests
│ ├── test_demo.py # Demo script tests
│ ├── test_indicators.py # Individual indicator tests
│ ├── test_integration_yf.py # Integration tests with yfinance
│ ├── test_utils.py # Utility function tests
├── quantjourney_ti.egg-info/ # Package metadata (generated, typically in .gitignore)
├── README.md # Project documentation (this file)
├── LICENSE.md # License details
├── setup.py # Package installation configuration
Note: The quantjourney_ti.egg-info directory is generated during package installation (e.g., pip install -e .). It can be safely removed if not using editable mode, and should be included in .gitignore to avoid version control.
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
-
Install the package in editable mode:
pip install -e .
Requirements:
- Python 3.8+
pandas,numpy,yfinance,numba,matplotlib
Usage
The library provides a TechnicalIndicators class for calculating indicators and saving plots. The examples/run_indicators.py script fetches PL data, calculates 20 popular indicators, and saves individual plots to an indicator_plots directory. Example:
from quantjourney_ti import TechnicalIndicators
from quantjourney_ti._utils import plot_indicators
import pandas as pd
import yfinance as yf
import os
# Fetch data
df = yf.download("PL", start="2024-01-01", end="2025-02-01")
df.columns = df.columns.str.lower().str.replace(' ', '_')
df["volume"] = df["volume"].replace(0, np.nan).ffill()
# Calculate indicators
ti = TechnicalIndicators()
indicators = [
("SMA", lambda: ti.SMA(df["close"], period=14)),
("EMA", lambda: ti.EMA(df["close"], period=14)),
# ... 18 more indicators
]
results = {name: func() for name, func in indicators}
# Save plots
os.makedirs("indicator_plots", exist_ok=True)
for name, result in results.items():
plot_indicators_dict = {name: result if isinstance(result, pd.Series) else result.iloc[:, 0]}
plot_indicators(df, plot_indicators_dict, title=f"{name} Indicator", save_path=f"indicator_plots/{name}_plot.png")
Run the example:
python examples/run_indicators.py
Output:
- Console: Last 5 and final values for each indicator.
- Files: PNG plots in
indicator_plots/(e.g.,SMA_plot.png).
📊 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:
pytest tests/
Cleaning: Remove generated files:
rm -rf quantjourney_ti.egg-info dist build
Future Work
- Add more indicators (e.g., PPO, Ichimoku Cloud).
- Enhance plotting with customizable layouts.
- Optimize Numba functions for additional edge cases.
- Support real-time data feeds.
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.2.0.tar.gz.
File metadata
- Download URL: quantjourney_ti-0.2.0.tar.gz
- Upload date:
- Size: 217.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef3800a4b6732ff8e73f986dae4475bf2c27bf72ae9971ff9699d5c6d9eec310
|
|
| MD5 |
026d18b5e17c301f04e0b8126bfa1d62
|
|
| BLAKE2b-256 |
f640ad2f9681238fee7d72f65184743232849fb83e26c85d8bd7682f35ff7077
|
File details
Details for the file quantjourney_ti-0.2.0-py3-none-any.whl.
File metadata
- Download URL: quantjourney_ti-0.2.0-py3-none-any.whl
- Upload date:
- Size: 58.0 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 |
957860daee53e87ce7885a126a8bcd39697a5f019b88a2109f97670bf6115617
|
|
| MD5 |
be46eaa17fac1f87979fb60d5455f062
|
|
| BLAKE2b-256 |
83db13403221da1a160d6cc06187c159ae7d9f83ecbef770244bf8d2d7040046
|