Skip to content

wrm3/fstrent_polars_ta

Repository files navigation

fstrent_polars_ta

High-Performance Technical Analysis Library for Python using Polars

Python 3.9+ License: MIT

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.

✨ Features

  • 🚀 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

📦 Installation

pip install fstrent_polars_ta

🚀 Quick Start

import 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())

📚 Indicator Categories

Momentum Indicators

RSI, MACD, Stochastic, ROC, MOM, CCI, Williams %R, CMO, TSI, and more

Overlap/Moving Averages

SMA, EMA, DEMA, TEMA, HMA, WMA, ZLEMA, VWMA, RMA, SMMA, ALMA, and more

Trend Indicators

ADX, DMI, Aroon, Vortex, PSAR, Supertrend, and more

Volatility Indicators

ATR, Bollinger Bands, Keltner Channels, Donchian Channels, True Range, and more

Volume Indicators

OBV, MFI, AD, ADOSC, CMF, EFI, PVT, VWAP, and more

Statistical Indicators

Standard Deviation, Z-Score, Variance, Kurtosis, Skew, Entropy, and more

Candle Patterns

Heikin Ashi, Doji, Inside Bar, Hammer, Shooting Star, Engulfing, and more

Custom Indicators (from production trading systems)

  • 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

🎯 Why fstrent_polars_ta?

Performance Comparison

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

From Pandas to Polars

# 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)

📖 Documentation

🧪 Development

# 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_ta

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

📄 License

MIT License - see LICENSE file for details

🙏 Credits

This library builds on the excellent work of:

Custom indicators are derived from production trading systems and various research sources.

⚠️ Disclaimer

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

About

High-performance technical analysis library using Polars - 5-10x faster than pandas_ta, 100+ indicators

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages