$npx -y skills add agiprolabs/claude-trading-skills --skill pandas-taTechnical analysis with 130+ indicators using pandas-ta for crypto market data
| 1 | # pandas-ta — Technical Analysis for Crypto Markets |
| 2 | |
| 3 | pandas-ta is a Python library that extends pandas DataFrames with 130+ technical analysis indicators accessible via `df.ta`. It covers trend, momentum, volatility, volume, and overlap indicator categories — all callable with a single method on any OHLCV DataFrame. |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```bash |
| 8 | uv pip install pandas-ta pandas httpx |
| 9 | ``` |
| 10 | |
| 11 | ## Quick Start |
| 12 | |
| 13 | ```python |
| 14 | import pandas as pd |
| 15 | import pandas_ta as ta |
| 16 | |
| 17 | # Assume df is a DataFrame with columns: open, high, low, close, volume |
| 18 | # All lowercase column names required |
| 19 | |
| 20 | # Single indicator |
| 21 | df["rsi"] = df.ta.rsi(length=14) |
| 22 | df["atr"] = df.ta.atr(length=14) |
| 23 | |
| 24 | # Multiple indicators via strategy |
| 25 | df.ta.strategy(ta.Strategy( |
| 26 | name="Quick Check", |
| 27 | ta=[ |
| 28 | {"kind": "rsi", "length": 14}, |
| 29 | {"kind": "macd", "fast": 12, "slow": 26, "signal": 9}, |
| 30 | {"kind": "bbands", "length": 20, "std": 2.0}, |
| 31 | ] |
| 32 | )) |
| 33 | ``` |
| 34 | |
| 35 | ## OHLCV DataFrame Format |
| 36 | |
| 37 | pandas-ta expects a DataFrame with lowercase column names: |
| 38 | |
| 39 | ```python |
| 40 | import pandas as pd |
| 41 | |
| 42 | df = pd.DataFrame({ |
| 43 | "open": [...], |
| 44 | "high": [...], |
| 45 | "low": [...], |
| 46 | "close": [...], |
| 47 | "volume": [...] |
| 48 | }, index=pd.DatetimeIndex([...])) |
| 49 | ``` |
| 50 | |
| 51 | **Important**: Set the index to a `DatetimeIndex` for time-aware indicators like VWAP. Column names must be lowercase (`close`, not `Close`). |
| 52 | |
| 53 | ### Handling Missing Data |
| 54 | |
| 55 | ```python |
| 56 | # Drop rows with NaN in OHLCV columns |
| 57 | df = df.dropna(subset=["open", "high", "low", "close", "volume"]) |
| 58 | |
| 59 | # Forward-fill small gaps (1-2 bars max) |
| 60 | df = df.ffill(limit=2) |
| 61 | |
| 62 | # Verify no zero-volume bars for volume indicators |
| 63 | df = df[df["volume"] > 0] |
| 64 | ``` |
| 65 | |
| 66 | ## Core Indicator Categories |
| 67 | |
| 68 | ### Trend Indicators |
| 69 | |
| 70 | Identify market direction and trend strength. |
| 71 | |
| 72 | | Indicator | Call | Key Signal | |
| 73 | |-----------|------|------------| |
| 74 | | SMA | `df.ta.sma(length=20)` | Price above = bullish | |
| 75 | | EMA | `df.ta.ema(length=20)` | Faster than SMA, less lag | |
| 76 | | SuperTrend | `df.ta.supertrend(length=10, multiplier=3)` | Direction column: 1=bull, -1=bear | |
| 77 | | Ichimoku | `df.ta.ichimoku()` | Returns tuple of (span, lines) DataFrames | |
| 78 | | VWMA | `df.ta.vwma(length=20)` | Volume-weighted price trend | |
| 79 | | HMA | `df.ta.hma(length=20)` | Minimal lag, smooth trend | |
| 80 | | ADX | `df.ta.adx(length=14)` | >25 = trending, <20 = ranging | |
| 81 | |
| 82 | ### Momentum Indicators |
| 83 | |
| 84 | Measure speed and magnitude of price changes. |
| 85 | |
| 86 | | Indicator | Call | Key Signal | |
| 87 | |-----------|------|------------| |
| 88 | | RSI | `df.ta.rsi(length=14)` | >70 overbought, <30 oversold | |
| 89 | | MACD | `df.ta.macd(fast=12, slow=26, signal=9)` | Histogram crossover = entry | |
| 90 | | Stochastic | `df.ta.stoch(k=14, d=3, smooth_k=3)` | >80 overbought, <20 oversold | |
| 91 | | CCI | `df.ta.cci(length=20)` | >100 overbought, <-100 oversold | |
| 92 | | Williams %R | `df.ta.willr(length=14)` | >-20 overbought, <-80 oversold | |
| 93 | | ROC | `df.ta.roc(length=10)` | Positive = upward momentum | |
| 94 | | MFI | `df.ta.mfi(length=14)` | Money flow version of RSI | |
| 95 | |
| 96 | ### Volatility Indicators |
| 97 | |
| 98 | Measure price dispersion and expected range. |
| 99 | |
| 100 | | Indicator | Call | Key Signal | |
| 101 | |-----------|------|------------| |
| 102 | | Bollinger Bands | `df.ta.bbands(length=20, std=2)` | Squeeze = breakout pending | |
| 103 | | ATR | `df.ta.atr(length=14)` | Position sizing, stop placement | |
| 104 | | Keltner Channels | `df.ta.kc(length=20, scalar=1.5)` | BB inside KC = squeeze | |
| 105 | | Donchian Channels | `df.ta.donchian(lower_length=20, upper_length=20)` | Breakout detection | |
| 106 | |
| 107 | ### Volume Indicators |
| 108 | |
| 109 | Confirm price moves with volume analysis. |
| 110 | |
| 111 | | Indicator | Call | Key Signal | |
| 112 | |-----------|------|------------| |
| 113 | | OBV | `df.ta.obv()` | Divergence from price = reversal | |
| 114 | | VWAP | `df.ta.vwap()` | Intraday fair value (needs DatetimeIndex) | |
| 115 | | CMF | `df.ta.cmf(length=20)` | >0 accumulation, <0 distribution | |
| 116 | | AD | `df.ta.ad()` | Accumulation/Distribution line | |
| 117 | |
| 118 | ## Strategy Class |
| 119 | |
| 120 | Run multiple indicators in a single call using `ta.Strategy`: |
| 121 | |
| 122 | ```python |
| 123 | import pandas_ta as ta |
| 124 | |
| 125 | # Built-in "All" strategy runs every indicator |
| 126 | df.ta.strategy(ta.AllStrategy) |
| 127 | |
| 128 | # Custom strategy |
| 129 | my_strategy = ta.Strategy( |
| 130 | name="Crypto Scalp", |
| 131 | description="Fast indicators for crypto scalping", |
| 132 | ta=[ |
| 133 | {"kind": "ema", "length": 9}, |
| 134 | {"kind": "ema", "length": 21}, |
| 135 | {"kind": "rsi", "length": 7}, |
| 136 | {"kind": "stoch", "k": 5, "d": 3, "smooth_k": 3}, |
| 137 | {"kind": "atr", "length": 7}, |
| 138 | {"kind": "bbands", "length": 10, "std": 2.0}, |
| 139 | {"kind": "obv"}, |
| 140 | ] |
| 141 | ) |
| 142 | df.ta.strategy(my_strategy) |
| 143 | ``` |
| 144 | |
| 145 | ### Named Strategy Patterns |
| 146 | |
| 147 | ```python |
| 148 | # Trend following |
| 149 | trend_strategy = ta.Strategy( |
| 150 | name="Trend", |
| 151 | ta=[ |
| 152 | {"kind": "ema", "length": 20}, |
| 153 | {"kind": "ema", "length": 50}, |
| 154 | {"kind": "adx", "length": 14}, |
| 155 | {"kind": "supertrend", "length": 10, "multiplier": 3}, |
| 156 | {"kind": "atr", "length": 14}, |
| 157 | ] |
| 158 | ) |
| 159 | |
| 160 | # Mean reversion |
| 161 | reversion_strategy = ta.Strategy( |
| 162 | name="Mean Reversion", |
| 163 | ta=[ |
| 164 | {"kind": "rsi |