60 lines
2.3 KiB
Markdown
Executable File
60 lines
2.3 KiB
Markdown
Executable File
# CNN Fear & Greed Index Synthesis Algorithm
|
|
|
|
## Original CNN Fear & Greed Components (7 total):
|
|
1. Stock Price Momentum
|
|
2. Stock Price Strength
|
|
3. Stock Price Breadth
|
|
4. Put/Call Options Ratio
|
|
5. Junk Bond Demand
|
|
6. Market Volatility (VIX)
|
|
7. Safe Haven Demand
|
|
|
|
## Our Implementation (5 components, excluding options):
|
|
|
|
### 1. Stock Price Momentum
|
|
- **Data Source**: S&P 500 Index (^GSPC) from yfinance
|
|
- **Algorithm**: 125-day moving average vs current price
|
|
- **Calculation**: (Current Price - 125-day MA) / 125-day MA * 100
|
|
- **Normalization**: Scale to 0-100 where negative = fear, positive = greed
|
|
|
|
### 2. Stock Price Strength
|
|
- **Data Source**: NASDAQ 100 stocks new highs/lows
|
|
- **Algorithm**: 52-week new highs vs new lows ratio
|
|
- **Calculation**: Count stocks at 52w high / Total stocks * 100
|
|
- **Alternative**: Use RSI of major indices if individual stock data unavailable
|
|
|
|
### 3. Stock Price Breadth
|
|
- **Data Source**: NASDAQ 100 advancing vs declining stocks
|
|
- **Algorithm**: Advancing vs declining stocks ratio
|
|
- **Calculation**: Advancing stocks / Total stocks * 100
|
|
- **Implementation**: Use daily performance of our 96 QQQ constituents
|
|
|
|
### 4. Junk Bond Demand
|
|
- **Data Source**: HYG (High Yield Bond ETF) vs TLT (Treasury ETF)
|
|
- **Algorithm**: High yield bonds vs safe treasuries performance
|
|
- **Calculation**: (HYG 20-day return - TLT 20-day return) + offset
|
|
- **Normalization**: Scale where negative = fear (flight to safety)
|
|
|
|
### 5. Safe Haven Demand
|
|
- **Data Source**: GLD (Gold ETF) vs SPY (S&P 500 ETF)
|
|
- **Algorithm**: Gold vs equity performance comparison
|
|
- **Calculation**: (SPY 20-day return - GLD 20-day return) + offset
|
|
- **Normalization**: Scale where negative = fear (flight to gold)
|
|
|
|
## Final Synthesis Algorithm:
|
|
1. Calculate each component (0-100 scale)
|
|
2. Equal weight average: (Component1 + Component2 + Component3 + Component4 + Component5) / 5
|
|
3. Final scale: 0=Extreme Fear, 25=Fear, 50=Neutral, 75=Greed, 100=Extreme Greed
|
|
|
|
## Required Data Sources:
|
|
- ^GSPC: S&P 500 Index (yfinance)
|
|
- HYG: High Yield Bond ETF (yfinance)
|
|
- TLT: 20+ Year Treasury ETF (yfinance)
|
|
- GLD: Gold ETF (yfinance)
|
|
- SPY: S&P 500 ETF (yfinance)
|
|
- QQQ constituents: Individual stock data for breadth calculation
|
|
|
|
## Implementation Timeline:
|
|
- Historical synthesis: 2000-01-01 to present
|
|
- Daily frequency matching CNN's publication schedule
|
|
- Store in database table: fear_greed_index |