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.2.tar.gz (766.2 kB 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.2-cp313-cp313-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.13Windows x86-64

File details

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

File metadata

  • Download URL: tradelab-0.2.2.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

Hashes for tradelab-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e3ce4ebbceb4f6898b57e3c719a61e33694114124ddcb2ffeeb33aabf81534f6
MD5 514629825008ae6cf915e216c51ce615
BLAKE2b-256 802fc2adae93713dccde3298775913e51add8524ece6a8a3cc92a3e3ca1f2027

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tradelab-0.2.2-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

Hashes for tradelab-0.2.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e4e1a1903d29c7edbca7d03898f18b85ae818c582adcca5e1351359cf85e678e
MD5 82e0c3dbf9113b83edc54a76242baa03
BLAKE2b-256 487d9b14dd658f65655429be4cd3cce2b5f81acda6183125160336fe0d8de244

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