Skip to main content

PythonPine v2.0 - High-Performance Technical Indicators

Vectorized Pine Script indicators for machine learning and algorithmic trading. 10-100x faster than loop-based implementations.

Features

  • ⚡ NumPy/Pandas Vectorization - Millions of bars in seconds
  • 🧠 ML Alpha Module - Z-score, percentile rank, fractional differentiation
  • 📊 50+ Indicators - RSI, MACD, ATR, Bollinger, SuperTrend, Ichimoku...
  • 🔄 Pine Script Parity - Same signatures, same math
  • 📈 Price Action - Vectorized pattern detection

Installation

pip install pythonpine

Quick Start

import numpy as np
from pythonpine import rsi, macd, atr, zscore

# Your price data
close = np.random.randn(10000).cumsum() + 100
high = close + np.abs(np.random.randn(10000)) * 0.5
low = close - np.abs(np.random.randn(10000)) * 0.5

# Calculate indicators (returns NumPy arrays)
rsi_values = rsi(close, 14)
macd_line, signal, hist = macd(close)
atr_values = atr(high, low, close, 14)

# ML preprocessing
rsi_zscore = zscore(rsi_values, 20)  # Normalized for ML

ML Alpha Module

from pythonpine import zscore, percentile_rank, log_returns, fractional_diff

# Stationarity transforms
returns = log_returns(close)
frac_diff = fractional_diff(close, d=0.4)  # López de Prado method

# Feature engineering
rsi_z = zscore(rsi(close), 50)  # Z-score normalized RSI
rsi_rank = percentile_rank(rsi(close), 100)  # Percentile rank

Benchmarks

Indicator Legacy (loop) V2 (vectorized) Speedup
RSI 1.2s 0.01s 120x
MACD 0.8s 0.008s 100x
ATR 0.5s 0.005s 100x
Bollinger 0.9s 0.007s 130x

Tested on 1M bars

Indicator Reference

Momentum

  • rsi(close, 14) - Relative Strength Index
  • macd(close, 12, 26, 9) - MACD line, signal, histogram
  • stochastic(close, high, low) - Stochastic Oscillator
  • adx(high, low, close) - Average Directional Index
  • cci(close, high, low) - Commodity Channel Index

Volatility

  • atr(high, low, close, 14) - Average True Range
  • bollinger_bands(close, 20, 2) - Upper, lower, middle
  • keltner_channel(high, low, close) - Keltner bands
  • historical_volatility(close, 20) - HV annualized

Trend

  • sma(close, 20) - Simple Moving Average
  • ema(close, 20) - Exponential MA
  • supertrend(high, low, close) - Trend direction + line
  • ichimoku(high, low, close) - Full cloud

Price Action

  • engulfing(o, h, l, c) - Returns +1 (bullish), -1 (bearish), 0
  • doji(o, h, l, c) - Doji detection
  • support_resistance_zones(h, l, c, v) - Volume-based S/R

License

MIT

Metadata

Release files for pythonpine 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pythonpine 2.0.1
File Size Uploaded
pythonpine-2.0.1.tar.gz 38.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pythonpine 2.0.1
File Interpreter ABI Platform
pythonpine-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 82.2 kB

Release files / pythonpine-2.0.1.tar.gz

Download URL pythonpine-2.0.1.tar.gz
Size 38.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9f3ed454c3651e765e31357821ffdf6b550c6060f54c213abd2cf7111f659bed
BLAKE2b-256 checksum
How to use checksums
5e99cf4df3f6731e341eaad140e6dae4038234d57a4a70f20662addc27587cee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / pythonpine-2.0.1-py3-none-any.whl

Download URL pythonpine-2.0.1-py3-none-any.whl
Size 43.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
262c436d4854dcc381307fa018cf39493561abcf3a12e1af996fbd4b9f941ed0
BLAKE2b-256 checksum
How to use checksums
eee9e8f6e3454b6326b9a532a538d8992c4cdf9bd6524c1530b4be77df53dfc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page