A comprehensive Python library for technical analysis indicators used in algorithmic trading. Built with performance and extensibility in mind, this library provides a suite of technical indicators with a clean, consistent API for analyzing market data and generating buy/sell signals.
- Modular Architecture: Built around an abstract
Indicator
base class for consistency and extensibility - Performance Optimized: Efficient calculations using pandas and numpy
- Complete Indicator Suite: RSI, VIX, Candlestick patterns, Price drops, and more
- Easy Integration: Simple API for incorporating indicators into trading strategies
- Type Safety: Full type hints for better development experience
- Extensible: Easy to add custom indicators following the established patterns
pip install Python.Trading.Indicators
For development installation:
git clone https://github.com/venantvr/Python.Trading.Indicators.git
cd Python.Trading.Indicators
pip install -e .
import pandas as pd
from python_trading_indicators.rsi import RSIIndicator
from python_trading_indicators.candlestick import CandlestickIndicator
# Sample market data
data = {
'close': [100, 102, 105, 103, 108, 115, 110, 109, 107, 102, 95],
'open': [98, 100, 102, 105, 103, 108, 115, 110, 109, 107, 102],
'volume': [1000, 1100, 1200, 900, 1500, 2500, 1800, 1000, 1100, 2200, 3000]
}
candles = pd.DataFrame(data)
# RSI Indicator
rsi = RSIIndicator(period=14, buy_threshold=30, sell_threshold=70)
rsi.calculate(candles)
if rsi.check_buy_condition():
print("π’ RSI Buy signal detected")
if rsi.check_sell_condition():
print("π΄ RSI Sell signal detected")
# Candlestick Pattern Analysis
candlestick = CandlestickIndicator(lookback_period=3)
candlestick.calculate(candles)
if candlestick.check_buy_condition():
print("π’ Bullish candlestick pattern with volume confirmation")
Identifies overbought and oversold conditions in the market.
from python_trading_indicators.rsi import RSIIndicator
rsi = RSIIndicator(
period=14, # Calculation period
buy_threshold=30, # Oversold threshold
sell_threshold=70 # Overbought threshold
)
Analyzes recent candlestick patterns to determine bullish/bearish trends with volume confirmation.
from python_trading_indicators.candlestick import CandlestickIndicator
candlestick = CandlestickIndicator(
lookback_period=3, # Number of candles to analyze
volume_threshold=1.2 # Volume confirmation multiplier
)
Detects significant price drops that might indicate selling opportunities or rebounds.
from python_trading_indicators.drop import SuddenPriceDropIndicator
drop_detector = SuddenPriceDropIndicator(
drop_percentage=10, # Minimum drop percentage
lookback_period=20 # Period to check for highest price
)
Measures market volatility and identifies panic conditions.
from python_trading_indicators.vix import VIXIndicator
vix = VIXIndicator(
period=20, # Calculation period
panic_threshold=25 # Volatility panic threshold
)
A utility indicator for testing or temporarily disabling indicator logic.
from python_trading_indicators.passthrough import PassThroughIndicator
passthrough = PassThroughIndicator(enabled=False)
All indicators inherit from the abstract Indicator
base class, ensuring a consistent interface:
from abc import ABC, abstractmethod
from pandas import DataFrame
class Indicator(ABC):
def __init__(self, enabled: bool = True):
self.is_enabled = enabled
@abstractmethod
def compute_indicator(self, candles: DataFrame):
"""Compute the indicator based on the provided candles."""
pass
@abstractmethod
def evaluate_buy_condition(self) -> bool:
"""Evaluate if buy conditions are met."""
pass
@abstractmethod
def evaluate_sell_condition(self) -> bool:
"""Evaluate if sell conditions are met."""
pass
Run the complete test suite:
make test
Install dependencies for development:
make install
Update dependencies:
make update
Code formatting:
make format
Format and check code:
make format
Run all quality checks:
make check
- All indicators are optimized for pandas DataFrame operations
- Calculations are vectorized where possible for better performance
- Memory usage is minimized through efficient data handling
- Suitable for both real-time and batch processing scenarios
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please file an issue on the GitHub repository.
- Repository: https://github.com/venantvr/Python.Trading.Indicators
- PyPI Package: https://pypi.org/project/Python.Trading.Indicators/
- Documentation: https://Python.Trading.Indicators.readthedocs.io/
Disclaimer: This library is for educational and research purposes. Always do your own research before making any trading decisions. Past performance is not indicative of future results.