technical-analysis

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Technical Analysis

技术分析

Compute technical indicators using pandas-ta. Supports multi-symbol analysis and earnings data.
使用pandas-ta计算技术指标,支持多标的分析和收益数据处理。

Instructions

操作说明

Note: If
uv
is not installed or
pyproject.toml
is not found, replace
uv run python
with
python
in all commands below.
bash
uv run python scripts/technicals.py SYMBOL [--period PERIOD] [--indicators INDICATORS] [--earnings]
注意: 若未安装
uv
或未找到
pyproject.toml
,请将以下所有命令中的
uv run python
替换为
python
bash
uv run python scripts/technicals.py SYMBOL [--period PERIOD] [--indicators INDICATORS] [--earnings]

Arguments

参数说明

  • SYMBOL
    - Ticker symbol or comma-separated list (e.g.,
    AAPL
    or
    AAPL,MSFT,GOOGL
    )
  • --period
    - Historical period: 1mo, 3mo, 6mo, 1y (default: 3mo)
  • --indicators
    - Comma-separated list: rsi,macd,bb,sma,ema,atr,adx (default: all)
  • --earnings
    - Include earnings data (upcoming date + history)
  • SYMBOL
    - 股票代码或逗号分隔的代码列表(例如:
    AAPL
    AAPL,MSFT,GOOGL
  • --period
    - 历史数据周期:1mo、3mo、6mo、1y(默认值:3mo)
  • --indicators
    - 逗号分隔的指标列表:rsi、macd、bb、sma、ema、atr、adx(默认值:全部)
  • --earnings
    - 包含收益数据(即将到来的日期+历史数据)

Output

输出结果

Single symbol returns:
  • price
    - Current price and recent change
  • indicators
    - Computed values for each indicator
  • risk_metrics
    - Volatility (annualized %) and Sharpe ratio
  • signals
    - Buy/sell signals based on indicator levels
  • earnings
    - Upcoming date and EPS history (if
    --earnings
    )
Multiple symbols returns:
  • results
    - Array of individual symbol results
单标的返回内容:
  • price
    - 当前价格及近期涨跌幅
  • indicators
    - 各指标的计算值
  • risk_metrics
    - 波动率(年化百分比)和夏普比率
  • signals
    - 基于指标水平生成的买卖信号
  • earnings
    - 即将到来的收益日期及EPS历史数据(若使用
    --earnings
    参数)
多标的返回内容:
  • results
    - 单个标的结果的数组

Interpretation

指标解读

  • RSI > 70 = overbought, RSI < 30 = oversold
  • MACD crossover = momentum shift
  • Price near Bollinger Band = potential reversal
  • Golden cross (SMA20 > SMA50) = bullish
  • ADX > 25 = strong trend
  • Sharpe ratio > 1 = good risk-adjusted returns, > 2 = excellent
  • Volatility (annualized) = standard deviation of returns scaled to annual basis
  • RSI > 70 = 超买,RSI < 30 = 超卖
  • MACD交叉 = 动量转变
  • 价格接近布林带 = 潜在反转信号
  • 黄金交叉(SMA20 > SMA50)= 看涨信号
  • ADX > 25 = 趋势强劲
  • 夏普比率 > 1 = 风险调整后收益良好,>2 = 收益极佳
  • 波动率(年化)= 收益标准差按年度缩放后的数值

Examples

示例

bash
undefined
bash
undefined

Single symbol with all indicators

单标的计算所有指标

uv run python scripts/technicals.py AAPL
uv run python scripts/technicals.py AAPL

Multiple symbols

多标的分析

uv run python scripts/technicals.py AAPL,MSFT,GOOGL
uv run python scripts/technicals.py AAPL,MSFT,GOOGL

With earnings data

包含收益数据

uv run python scripts/technicals.py NVDA --earnings
uv run python scripts/technicals.py NVDA --earnings

Specific indicators only

仅计算指定指标

uv run python scripts/technicals.py TSLA --indicators rsi,macd

---
uv run python scripts/technicals.py TSLA --indicators rsi,macd

---

Correlation Analysis

相关性分析

Compute price correlation matrix between multiple symbols for diversification analysis.
计算多个标的之间的价格相关矩阵,用于多元化投资分析。

Instructions

操作说明

bash
uv run python scripts/correlation.py SYMBOLS [--period PERIOD]
bash
uv run python scripts/correlation.py SYMBOLS [--period PERIOD]

Arguments

参数说明

  • SYMBOLS
    - Comma-separated ticker symbols (minimum 2)
  • --period
    - Historical period: 1mo, 3mo, 6mo, 1y (default: 3mo)
  • SYMBOLS
    - 逗号分隔的股票代码(至少2个)
  • --period
    - 历史数据周期:1mo、3mo、6mo、1y(默认值:3mo)

Output

输出结果

  • symbols
    - List of symbols analyzed
  • period
    - Time period used
  • correlation_matrix
    - Nested dict with correlation values between all pairs
  • symbols
    - 分析的标的列表
  • period
    - 使用的时间周期
  • correlation_matrix
    - 包含所有标的对相关值的嵌套字典

Interpretation

结果解读

  • Correlation near 1.0 = highly correlated (move together)
  • Correlation near -1.0 = negatively correlated (move opposite)
  • Correlation near 0 = uncorrelated (independent movement)
  • For diversification, prefer low/negative correlations
  • 相关性接近1.0 = 高度相关(同涨同跌)
  • 相关性接近-1.0 = 负相关(反向波动)
  • 相关性接近0 = 不相关(独立波动)
  • 多元化投资偏好低/负相关性的标的

Examples

示例

bash
undefined
bash
undefined

Portfolio correlation

投资组合相关性分析

uv run python scripts/correlation.py AAPL,MSFT,GOOGL,AMZN
uv run python scripts/correlation.py AAPL,MSFT,GOOGL,AMZN

Sector comparison

板块对比分析

uv run python scripts/correlation.py XLF,XLK,XLE,XLV --period 6mo
uv run python scripts/correlation.py XLF,XLK,XLE,XLV --period 6mo

Check hedge effectiveness

对冲有效性验证

uv run python scripts/correlation.py SPY,GLD,TLT
undefined
uv run python scripts/correlation.py SPY,GLD,TLT
undefined

Dependencies

依赖库

  • numpy
  • pandas
  • pandas-ta
  • yfinance
  • numpy
  • pandas
  • pandas-ta
  • yfinance