38 — Python Power Tools

pandas-ta & yfinance#

Python✓ Mathematical
◆ The PatternTechnical indicators + market data in one-liners

yfinance downloads free historical market data from Yahoo Finance. pandas-ta computes 130+ technical indicators as DataFrame operations. Together, they're the fastest way to go from idea to analysis for any market strategy.

// Price data with technical indicators
# pandas-ta + yfinance — quick market analysis
import yfinance as yf
import pandas_ta as ta

# Download data
df = yf.download('AAPL', start='2023-01-01')

# Add indicators as columns
df.ta.sma(length=20, append=True)
df.ta.rsi(length=14, append=True)
df.ta.macd(append=True)
df.ta.bbands(length=20, append=True)

# Or run a full strategy
df.ta.strategy('all')  # adds 130+ indicators

# Quick signal
df['signal'] = (df['RSI_14'] < 30).astype(int)
print(df[['Close', 'SMA_20', 'RSI_14']].tail())
CategoryIndicatorspandas-ta function
TrendSMA, EMA, MACDta.sma(), ta.ema(), ta.macd()
MomentumRSI, Stochastic, CCIta.rsi(), ta.stoch(), ta.cci()
VolatilityBollinger, ATR, Keltnerta.bbands(), ta.atr()
VolumeOBV, VWAP, MFIta.obv(), ta.vwap(), ta.mfi()
Pattern bridge: These are the same indicators explored in the Markets → Indicators collection — but here you can compute them yourself in Python and feed them into ML models as features.
← Previous
Optuna
Open in the full reader, with the topic sidebar →