Skip to main content

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 support
  • pyproject.toml - Modern Python packaging configuration
  • MANIFEST.in - Package file inclusion rules

Development Tools

  • compile_cython.py - Development script for compiling Cython extensions
  • debug.ipynb - Jupyter notebook for testing and development
  • uv.lock - Dependency lock file for reproducible builds

Configuration

  • .gitignore - Git ignore patterns
  • LICENSE - 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-indicator)
  3. Commit your changes (git commit -am 'Add new indicator')
  4. Push to the branch (git push origin feature/new-indicator)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tradelab-0.2.5.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tradelab-0.2.5-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86-64

File details

Details for the file tradelab-0.2.5.tar.gz.

File metadata

  • Download URL: tradelab-0.2.5.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for tradelab-0.2.5.tar.gz
Algorithm Hash digest
SHA256 3491c91b50e76c0e52aac0c509597280d7844639ada15c2cbdc707da7e8d5e2a
MD5 8eab28e513882e9e6de4cd03a4f4c9bb
BLAKE2b-256 5451b3d46116689ef7593f8c15745f133573bf73b570c83264c9bf2fa19131cf

See more details on using hashes here.

File details

Details for the file tradelab-0.2.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: tradelab-0.2.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.4 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

Hashes for tradelab-0.2.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 79f67ac3ba5e1a313faa3067128babbac469eba40ca43dab4cddc1efa0c62d21
MD5 041c1b12c35dbb2393863b1a044e1356
BLAKE2b-256 20c168bc6d10f8b93a1ac902b34e2f8e6e35d08ac3bb5974dc9a273bb07ddbb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page