A simple and powerful Python package for algorithmic trading and technical analysis. Calculate technical indicators and analyze market data with ease.
Project description
TradeLab
A high-performance Python package for algorithmic trading and technical analysis. TradeLab provides optimized Cython implementations of popular technical indicators and alternative candlestick patterns for fast market data analysis.
Features
- High Performance: Cython-optimized implementations for maximum speed
- Technical Indicators: Popular indicators including EMA, RSI, SuperTrend, ADX, ATR, and more
- Alternative Candles: Heikin-Ashi and Renko chart implementations
- Easy to Use: Clean, intuitive API with comprehensive documentation
- Type Safety: Full type hints and validation support
Installation
pip install tradelab
For Development
git clone https://github.com/husainchhil/TradeLab.git
cd TradeLab
pip install -e .
Quick Start
import pandas as pd
from tradelab.indicators import EMA, RSI, SuperTrend, ATR, ADX
from tradelab.candles import RENKO, HEIKINASHI
# Sample OHLCV data
data = pd.DataFrame({
'open': [100, 101, 102, 103, 104],
'high': [105, 106, 107, 108, 109],
'low': [99, 100, 101, 102, 103],
'close': [102, 103, 104, 105, 106],
'volume': [1000, 1100, 1200, 1300, 1400]
})
# Technical Indicators
ema_20 = EMA(data['close'], period=20)
rsi_14 = RSI(data['close'], period=14)
atr_14 = ATR(data['high'], data['low'], data['close'], period=14)
supertrend = SUPERTREND(data['high'], data['low'], data['close'])
# Alternative Candles
heikin_ashi = HEIKINASHI(data)
renko_chart = RENKO(data, brick_size=1.0, mode='wicks')
Available Indicators
Trend Indicators
- EMA - Exponential Moving Average
- SuperTrend - Trend-following indicator with dynamic support/resistance
- Normalized T3 - Triple exponential moving average with volume factor
Momentum Indicators
- RSI - Relative Strength Index (0-100 oscillator)
- ADX - Average Directional Index (trend strength)
Volatility Indicators
- ATR - Average True Range (market volatility)
Comparative Analysis
- Relative Strength - Compare performance between two securities
Alternative Candle Types
Heikin-Ashi
Smoothed candlesticks that filter market noise and highlight trends.
from tradelab.candles import HEIKINASHI
ha_candles = HEIKINASHI(ohlcv_data)
Renko Charts
Price-based charts that ignore time and focus on price movements.
from tradelab.candles import RENKO
renko_bricks = RENKO(ohlcv_data, brick_size=1.0, mode='wicks')
Data Utilities
OHLCV Resampling
TradeLab includes a powerful resampling function for converting OHLCV data to different timeframes.
from tradelab.utils import resample_ohlcv
# Resample to 1-hour bars starting at 9:15 AM
hourly_data = resample_ohlcv(data, freq="1H", anchor="09:15:00")
# Resample to 15-minute bars
intraday_data = resample_ohlcv(data, freq="15T", anchor="09:30:00")
# Resample to weekly bars starting on Monday
weekly_data = resample_ohlcv(data, freq="1W", anchor="MON")
Features:
- Flexible Timeframes: Support for any pandas frequency string (1H, 30T, 15min, 5S, 1W, etc.)
- Custom Anchoring: Align bars to specific times (intraday) or days (weekly)
- Proper OHLCV Aggregation: Open=first, High=max, Low=min, Close=last, Volume=sum
- Data Validation: Automatic column validation and cleaning
Performance
TradeLab uses Cython for performance-critical calculations, providing significant speed improvements over pure Python implementations:
- 2-10x faster than equivalent pandas/numpy operations
- Memory efficient with optimized data structures
- Type-safe with compile-time optimizations
Package Structure
tradelab/
├── indicators/ # Technical indicators
│ ├── ema/ # Exponential Moving Average
│ ├── rsi/ # Relative Strength Index
│ ├── supertrend/ # SuperTrend indicator
│ ├── adx/ # Average Directional Index
│ ├── normalized_t3/ # Normalized T3 Moving Average
│ ├── volatility/ # Volatility indicators (ATR)
│ └── relative_strength/ # Relative Strength analysis
├── candles/ # Alternative candle types
│ ├── heikinashi/ # Heikin-Ashi candles
│ └── renko/ # Renko charts
└── utils.py # Utility functions
Development Files
Build System
setup.py- Main build configuration with Cython supportpyproject.toml- Modern Python packaging configurationMANIFEST.in- Package file inclusion rules
Development Tools
compile_cython.py- Development script for compiling Cython extensionsdebug.ipynb- Jupyter notebook for testing and developmentuv.lock- Dependency lock file for reproducible builds
Configuration
.gitignore- Git ignore patternsLICENSE- MIT License.python-version- Python version specification
Building from Source
Prerequisites
pip install setuptools wheel Cython numpy pandas
Development Build
# Compile Cython extensions in-place
python setup.py build_ext --inplace
# Or use the development script
python compile_cython.py
Distribution Build
# Build wheel and source distribution
python -m build
# Install locally
pip install dist/tradelab-*.whl
Clean Build Artifacts
python compile_cython.py --clean
Requirements
- Python: ≥3.11
- NumPy: ≤2.2.0
- Pandas: ≤2.2.3
- Pydantic: ≥2.11.7
Build Requirements
- Cython: ≥3.0.0
- Setuptools: ≥64
- Wheel: Latest
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-indicator) - Commit your changes (
git commit -am 'Add new indicator') - Push to the branch (
git push origin feature/new-indicator) - Create a Pull Request
Support
- Issues: GitHub Issues
- Documentation: Available in code docstrings
Author
Husain Chhil - hychhil@gmail.com
Disclaimer
Important Notice: TradeLab is provided for educational and research purposes only. This software is not intended to provide financial advice or recommendations for actual trading decisions.
Risk Warning: Trading in financial markets involves substantial risk of loss and is not suitable for all investors. Past performance does not guarantee future results. The indicators and tools provided in this package should not be used as the sole basis for trading decisions.
No Warranty: This software is provided "as is" without any warranties, express or implied. The authors and contributors are not responsible for any financial losses or damages that may result from the use of this software.
Professional Advice: Always consult with qualified financial advisors before making investment decisions. Users are solely responsible for their trading decisions and any resulting profits or losses.
TradeLab - High-performance technical analysis for algorithmic trading
Project details
Release history Release notifications | RSS feed
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 tradelab-0.2.3.tar.gz.
File metadata
- Download URL: tradelab-0.2.3.tar.gz
- Upload date:
- Size: 766.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35549c8b066ed71fb7686328aa6504ecf4243d14e8a174b1cc394ac263a4b2b2
|
|
| MD5 |
16e7c751ee7c7e7202ec40dcb6ba33ef
|
|
| BLAKE2b-256 |
a922c315a62357b08e21056bed19dff66c2250d24e3a9f302b33c52cd3a252a5
|
File details
Details for the file tradelab-0.2.3-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: tradelab-0.2.3-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fa14e4f4c37011f404323f669135891b0b15525aa152abfefe30c3913ee77b5
|
|
| MD5 |
511c8c597a2b6086a78b0b4836e2468e
|
|
| BLAKE2b-256 |
a75722c2b30da28e1cd8bb97437d2dbde6aa7bde490a63f93b93e6136ed97855
|