Methodology & Analysis Framework
Comprehensive documentation of all analysis modules, formulas, and ML models used in StockViz
Overview
StockViz employs a multi-layered analysis framework combining:
- 19+ Analysis Modules covering technical, fundamental, and alternative data
- 100+ Indicators & Metrics for comprehensive stock evaluation
- Advanced ML Models including XGBoost, LSTM, and Transformers
- Risk Management Tools with VaR, Sharpe Ratio, and stress testing
- Sentiment Analysis from news, social media, and analyst reports
Analysis Workflow
- Data Collection: Historical prices, financials, news, options data
- Feature Engineering: Calculate 100+ technical & fundamental indicators
- Multi-Module Analysis: Run all analysis modules in parallel
- Score Aggregation: Combine scores with weighted averaging
- Recommendation Generation: Generate buy/sell/hold recommendation
Analysis Modules (19+)
1. Technical Analysis
50+ IndicatorsRSI, MACD, Bollinger Bands, Moving Averages, Stochastic Oscillators, ADX, ATR, and more
2. Fundamental Analysis
30+ RatiosP/E, P/B, ROE, ROA, Debt Ratios, Margins, Growth Rates, Liquidity Metrics
3. DCF Valuation
3 ScenariosDiscounted Cash Flow with Pessimistic, Base, and Optimistic projections
4. Sentiment Analysis
Fear & GreedNews sentiment, social media, analyst ratings, market psychology
5. Sector Analysis
11 SectorsRelative performance vs sector ETFs, sector rotation analysis
6. Earnings Analysis
SurprisesEPS trends, earnings surprises, revenue growth, guidance
7. Options Analysis
GreeksImplied volatility, put/call ratio, Greeks (Delta, Gamma, Theta, Vega)
8. Alternative Data
ESGESG scores, web traffic, job postings, satellite data
9. Risk Management
VaRValue at Risk, Sharpe Ratio, Maximum Drawdown, Beta, stress tests
10. Market Timing
HMMMarket regime detection, breadth analysis, volatility patterns
11. ML Predictions
6+ ModelsXGBoost, LSTM, CNN-LSTM, Transformer, VAE, TCN ensemble
Technical Analysis
Key Indicators & Formulas
1. Relative Strength Index (RSI)
RS = Average Gain / Average Loss (14 periods)
Interpretation: RSI > 70 = Overbought, RSI < 30 = Oversold
2. MACD (Moving Average Convergence Divergence)
Signal Line = EMA(9) of MACD Line
Histogram = MACD Line - Signal Line
Interpretation: Bullish when MACD crosses above Signal, Bearish when crosses below
3. Bollinger Bands
Upper Band = SMA(20) + (2 × σ)
Lower Band = SMA(20) - (2 × σ)
Interpretation: Price touching upper band = potential resistance, lower band = potential support
4. Average True Range (ATR)
ATR = EMA(14) of TR
Use Case: Volatility measurement for position sizing and stop-loss placement
Fundamental Analysis
Key Ratios & Metrics
1. Price-to-Earnings (P/E) Ratio
Interpretation: Lower P/E may indicate undervaluation. Compare to industry average.
2. Return on Equity (ROE)
Benchmark: ROE > 15% is considered excellent
3. Debt-to-Equity Ratio
Interpretation: Lower is better. Ratios > 2.0 indicate high leverage risk
4. Current Ratio (Liquidity)
Benchmark: Ratio > 1.5 indicates good short-term financial health
5. Piotroski F-Score
9-point score based on profitability, leverage, and operating efficiency:
- Profitability: ROA, Operating Cash Flow, ΔRO, Accruals
- Leverage: ΔLever, ΔLiquid, Equity Offering
- Operating: ΔMargin, ΔTurnover
Interpretation: Score 8-9 = Strong fundamentals, 0-2 = Weak fundamentals
Discounted Cash Flow (DCF) Valuation
DCF Formula
Where:
CFt = Free Cash Flow in year t
WACC = Weighted Average Cost of Capital
Terminal Value = CFn × (1 + g) / (WACC - g)
g = Perpetual growth rate
Three Scenarios
Pessimistic
Lower growth rate, higher discount rate. Conservative valuation.
Base Case
Historical growth rates, standard WACC. Most likely scenario.
Optimistic
Higher growth assumptions, lower discount rate. Bull case.
Sentiment Analysis
Fear & Greed Index
Composite score (0-100) based on:
- News Sentiment: NLP analysis of financial news articles
- Social Media: Twitter/Reddit sentiment (when available)
- Analyst Ratings: Buy/Hold/Sell distribution
- Market Momentum: Price momentum vs moving averages
- Put/Call Ratio: Options market sentiment
Interpretation
- 0-25 (Extreme Fear): Potential buying opportunity
- 25-45 (Fear): Negative sentiment, cautious
- 45-55 (Neutral): Balanced sentiment
- 55-75 (Greed): Positive sentiment, watchful
- 75-100 (Extreme Greed): Potential market top, take profits
Machine Learning Predictions
Model Ensemble
1. XGBoost (Gradient Boosting)
Weight: 30% | Fast, interpretable, works well with tabular data
2. LSTM (Long Short-Term Memory)
Weight: 15% | Captures long-term dependencies in time series
it = σ(Wi · [ht-1, xt] + bi)
Ct = ft * Ct-1 + it * tanh(WC · [ht-1, xt] + bC)
3. CNN-LSTM Hybrid
Weight: 15% | CNN extracts local patterns, LSTM models temporal dependencies
4. Transformer
Weight: 15% | Multi-head attention for parallel sequence processing
5. VAE (Variational Autoencoder)
Weight: 10% | Learns latent representations, provides uncertainty estimates
6. TCN (Temporal Convolutional Network)
Weight: 15% | Dilated causal convolutions for long-range dependencies
Feature Engineering (100+ Features)
- Technical indicators (RSI, MACD, Bollinger Bands, etc.)
- Statistical moments (mean, variance, skewness, kurtosis)
- Entropy indicators (sample, fuzzy, permutation entropy)
- Wavelet decomposition
- Kalman filtering
- Market microstructure features
Ensemble Method
Where wi are model weights (sum to 1)
Risk Management
Key Metrics
1. Value at Risk (VaR)
Where μ = mean return, σ = standard deviation
Interpretation: Maximum expected loss over a time period at 95% confidence
2. Sharpe Ratio
Where Rp = portfolio return, Rf = risk-free rate, σp = portfolio std dev
Benchmark: Ratio > 1.0 is good, > 2.0 is excellent
3. Maximum Drawdown
4. Beta (Market Sensitivity)
Interpretation: β > 1 = More volatile than market, β < 1 = Less volatile
Master Scoring System
Score Aggregation Formula
Component Scores
- Technical Score (0-100): Momentum indicators, trend strength, volume analysis
- Fundamental Score (0-100): Financial ratios, growth rates, profitability
- Quantitative Score (0-100): DCF valuation, quality metrics (Piotroski F-Score)
- Sentiment Score (0-100): Fear & Greed Index, analyst ratings
Score Interpretation
90-100: Exceptional
Strong BuyExcellent across all metrics. High conviction opportunity.
75-89: Strong
BuyStrong fundamentals and technicals. Good entry point.
60-74: Good
Moderate BuyGenerally positive with some caution areas.
40-59: Neutral
HoldMixed signals. Wait for better clarity.
25-39: Weak
Moderate SellConcerning signals. Consider reducing exposure.
0-24: Poor
Strong SellWeak fundamentals and/or technicals. Avoid or exit.
Recommendation Logic
Decision Framework
Final recommendations consider multiple factors beyond the master score:
Bullish Signals
- Master Score > 75
- RSI in 40-60 range (momentum without overbought)
- MACD bullish crossover
- Price > 50-day and 200-day MA
- Positive earnings surprises
- DCF indicates undervaluation (> 20% upside)
- Low debt-to-equity ratio
- Positive sentiment trend
Bearish Signals
- Master Score < 40
- RSI > 70 (overbought)
- MACD bearish crossover
- Price < key moving averages
- Negative earnings surprises
- DCF indicates overvaluation (> 30% downside)
- High leverage ratios
- Declining analyst sentiment
Risk Adjustments
Recommendations are adjusted based on:
- Volatility: High volatility → reduce position size recommendations
- Market Regime: Bear market → increase caution threshold
- Sector Performance: Weak sector → downgrade recommendation
- Liquidity: Low liquidity → add warning flags
Data Sources
Market Data
- Yahoo Finance API (yfinance)
- Historical prices, volume, dividends
- Real-time quotes (15-min delay)
Financial Statements
- Income statements
- Balance sheets
- Cash flow statements
News & Sentiment
- Financial news APIs
- Social media feeds (when available)
- Analyst reports
Options Data
- Options chains
- Implied volatility
- Greeks calculations
Important Disclaimers
This tool is for informational and educational purposes only.
- Not financial advice. Consult a licensed financial advisor before making investment decisions.
- Past performance does not guarantee future results.
- All models have limitations and can produce inaccurate predictions.
- Market conditions can change rapidly, invalidating analysis.
- User assumes all risk for trading decisions.