High-Performance Technical Analysis Library for Python using Polars
fstrent_polars_ta is a blazingly fast technical analysis library that leverages Polars for 5-10x performance improvements over pandas-based alternatives. It consolidates the best indicators from finta and pandas_ta, adds custom production-proven indicators, and provides a clean, consistent API.
- 🚀 Lightning Fast: 5-10x faster than pandas_ta by using Polars' columnar memory layout and parallel execution
- 📊 Comprehensive: 100+ technical indicators across all categories
- 🎯 Production-Ready: Includes custom indicators proven in live trading systems
- 🧪 Well-Tested: >90% test coverage with validation against reference implementations
- 🔧 Easy to Use: Clean, consistent API - pass a DataFrame, get a DataFrame back
- ⚡ Memory Efficient: 30%+ less memory usage than pandas equivalents
pip install fstrent_polars_taimport polars as pl
import fstrent_polars_ta as fpta
# Load your OHLCV data into a Polars DataFrame
df = pl.read_csv('ohlcv_data.csv')
# Calculate RSI
df = df.with_columns(
fpta.rsi(pl.col('close'), length=14).alias('rsi')
)
# Calculate MACD
macd_df = fpta.macd(df['close'], fast=12, slow=26, signal=9)
df = df.hstack(macd_df)
# Calculate Bollinger Bands
bbands_df = fpta.bbands(df['close'], length=20, std=2.0)
df = df.hstack(bbands_df)
print(df.tail())RSI, MACD, Stochastic, ROC, MOM, CCI, Williams %R, CMO, TSI, and more
SMA, EMA, DEMA, TEMA, HMA, WMA, ZLEMA, VWMA, RMA, SMMA, ALMA, and more
ADX, DMI, Aroon, Vortex, PSAR, Supertrend, and more
ATR, Bollinger Bands, Keltner Channels, Donchian Channels, True Range, and more
OBV, MFI, AD, ADOSC, CMF, EFI, PVT, VWAP, and more
Standard Deviation, Z-Score, Variance, Kurtosis, Skew, Entropy, and more
Heikin Ashi, Doji, Inside Bar, Hammer, Shooting Star, Engulfing, and more
- Smoothed Heikin Ashi (SHA): Advanced candle smoothing with trend detection
- Impulse MACD: MACD variant with momentum filtering for stronger signals
- Nadaraya-Watson Envelope (NWE): Gaussian-smoothed trend following with reversal and envelope breach detection
- Custom Bollinger Bands: Enhanced BB with expansion/contraction detection
| Operation | pandas_ta | fstrent_polars_ta | Speedup |
|---|---|---|---|
| RSI (100K candles) | 145ms | 18ms | 8.1x |
| MACD (100K candles) | 89ms | 12ms | 7.4x |
| Bollinger Bands (100K candles) | 156ms | 22ms | 7.1x |
| 10 indicators on 50 pairs | 8.2s | 1.1s | 7.5x |
Benchmarks run on AMD Ryzen 9 5900X, 32GB RAM
# pandas_ta (old way)
import pandas as pd
import pandas_ta as ta
df['rsi'] = ta.rsi(df['close'], length=14)
df.ta.macd(append=True) # Modifies df in place
# fstrent_polars_ta (new way)
import polars as pl
import fstrent_polars_ta as fpta
df = df.with_columns(
fpta.rsi(pl.col('close'), length=14).alias('rsi')
)
macd_df = fpta.macd(df['close'])
df = df.hstack(macd_df)- Full API Reference
- Migration Guide from pandas_ta
- Custom Indicators Guide
- Examples
- Performance Benchmarks
# Clone the repository
git clone https://github.com/fstrent/fstrent_polars_ta.git
cd fstrent_polars_ta
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest
# Run tests with coverage
pytest --cov=fstrent_polars_ta --cov-report=html
# Format code
black .
# Lint code
ruff check .
# Type check
mypy fstrent_polars_taContributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT License - see LICENSE file for details
This library builds on the excellent work of:
Custom indicators are derived from production trading systems and various research sources.
This library is for educational and research purposes. Trading cryptocurrencies and other financial instruments carries risk. Always do your own research and never trade with money you can't afford to lose.
Built with ❤️ for algorithmic traders and quantitative researchers