📈 US Stock Analyzer - Three-Factor Buy Signal System
A comprehensive stock analysis system that combines Value Investing (DCF), Trend Trading (Livermore Rules), and Market Sentiment (VIX) to generate buy signals only when all three factors align.
Quick Start
CODEBLOCK0
Three-Factor Framework
1️⃣ Value Factor (DCF) - 40% Weight
- - Buy Condition: Price < Intrinsic Value × (1 - Margin of Safety)
- Key Metrics: Free Cash Flow, WACC, growth rates, ROE, debt levels
- Output: Value score 0-100, fair value estimate
2️⃣ Trend Factor (Livermore) - 35% Weight
- Break above resistance with volume confirmation (1.5x avg)
- Sector alignment (ETF in uptrend)
- Price > MA20 > MA60
- - Output: Trend score 0-100, key support/resistance levels
3️⃣ Sentiment Factor (VIX) - 25% Weight
- VIX < 25 (non-panic)
- VIX percentile < 70% (not expensive)
- Market breadth positive (SPY uptrend)
- - Output: Sentiment score 0-100, market regime
Final Buy Signal
CODEBLOCK1
Usage
Basic Analysis
CODEBLOCK2
With Chart Output
CODEBLOCK3
Data Sources
| Data | Source | Required |
|---|
| Price/Volume | Yahoo Finance (yfinance) | Free |
| Financials |
FMP API | Optional (free tier) |
| VIX | CBOE via Yahoo | Free |
| Sector ETFs | Yahoo Finance | Free |
Configuration
Edit config.yaml to customize:
- - DCF discount rate (default: 10%)
- Margin of safety threshold (default: 20%)
- VIX panic threshold (default: 30)
- Factor weights
- Position sizing rules
Output
The system generates a formatted report including:
- - Executive summary with composite score
- Individual factor scores with visual bars
- Buy/hold signal with confidence level
- Position sizing recommendation
- Target price and stop loss levels
- Risk assessment
File Structure
CODEBLOCK4
Methodology
See references/methodology.md for:
- - Detailed DCF calculation methodology
- Livermore trading rules implementation
- VIX sentiment scoring algorithm
- Position sizing formulas
Disclaimer
This tool is for informational purposes only and does not constitute investment advice. Always conduct your own research and consider consulting a financial advisor before making investment decisions.
License
MIT-0 (Public Domain)
📈 美股分析器 - 三因子买入信号系统
一套综合性的股票分析系统,结合了价值投资(DCF)、趋势交易(利弗莫尔规则)和市场情绪(VIX),仅当三个因子同时满足条件时生成买入信号。
快速开始
bash
安装依赖
pip3 install yfinance pandas numpy matplotlib pyyaml requests
设置API密钥(可选,用于增强金融数据)
export FMP
APIKEY=your
keyhere
运行分析
python3 scripts/decision_engine.py AAPL
三因子框架
1️⃣ 价值因子(DCF)- 权重40%
- - 买入条件:价格 < 内在价值 × (1 - 安全边际)
- 关键指标:自由现金流、加权平均资本成本、增长率、净资产收益率、负债水平
- 输出:价值评分0-100,公允价值估算
2️⃣ 趋势因子(利弗莫尔)- 权重35%
- 突破阻力位且成交量确认(1.5倍均值)
- 行业板块一致(ETF处于上升趋势)
- 价格 > 20日均线 > 60日均线
3️⃣ 情绪因子(VIX)- 权重25%
- VIX < 25(非恐慌状态)
- VIX百分位 < 70%(未处于高位)
- 市场广度正面(SPY处于上升趋势)
最终买入信号
买入 = 价值 ≥ 60 且 趋势 ≥ 60 且 情绪 ≥ 60 且 综合评分 ≥ 70
使用方法
基础分析
python
from scripts.decision_engine import StockAnalyzer
analyzer = StockAnalyzer(config_path=config.yaml)
result = analyzer.analyze(TSLA)
print(result[report])
生成图表
python
analyzer.plot
analysis(result[result], savepath=tsla_analysis.png)
数据来源
| 数据 | 来源 | 要求 |
|---|
| 价格/成交量 | 雅虎财经(yfinance) | 免费 |
| 财务数据 |
FMP API | 可选(免费层级) |
| VIX | 芝加哥期权交易所(通过雅虎) | 免费 |
| 行业ETF | 雅虎财经 | 免费 |
配置说明
编辑config.yaml以自定义:
- - DCF折现率(默认:10%)
- 安全边际阈值(默认:20%)
- VIX恐慌阈值(默认:30)
- 因子权重
- 仓位管理规则
输出内容
系统生成格式化的报告,包括:
- - 综合评分执行摘要
- 各因子评分及可视化柱状图
- 买入/持有信号及置信度
- 仓位管理建议
- 目标价和止损位
- 风险评估
文件结构
us-stock-analyzer/
├── SKILL.md # 本文件
├── config.yaml # 配置文件
├── requirements.txt # Python依赖
├── scripts/
│ ├── data_fetcher.py # 数据获取
│ ├── dcf_analyzer.py # DCF估值
│ ├── trend_analyzer.py # 利弗莫尔趋势分析
│ ├── sentiment_analyzer.py # VIX情绪分析
│ └── decision_engine.py # 三因子引擎
├── references/
│ └── methodology.md # 详细方法论
└── examples/
└── sample_report.md # 示例输出
方法论
详见 references/methodology.md:
- - DCF计算详细方法
- 利弗莫尔交易规则实现
- VIX情绪评分算法
- 仓位计算公式
免责声明
本工具仅供信息参考,不构成投资建议。在做出投资决策前,请务必进行独立研究并考虑咨询财务顾问。
许可证
MIT-0(公共领域)