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

  1. Data Collection: Historical prices, financials, news, options data
  2. Feature Engineering: Calculate 100+ technical & fundamental indicators
  3. Multi-Module Analysis: Run all analysis modules in parallel
  4. Score Aggregation: Combine scores with weighted averaging
  5. Recommendation Generation: Generate buy/sell/hold recommendation

Analysis Modules (19+)

1. Technical Analysis
50+ Indicators

RSI, MACD, Bollinger Bands, Moving Averages, Stochastic Oscillators, ADX, ATR, and more

2. Fundamental Analysis
30+ Ratios

P/E, P/B, ROE, ROA, Debt Ratios, Margins, Growth Rates, Liquidity Metrics

3. DCF Valuation
3 Scenarios

Discounted Cash Flow with Pessimistic, Base, and Optimistic projections

4. Sentiment Analysis
Fear & Greed

News sentiment, social media, analyst ratings, market psychology

5. Sector Analysis
11 Sectors

Relative performance vs sector ETFs, sector rotation analysis

6. Earnings Analysis
Surprises

EPS trends, earnings surprises, revenue growth, guidance

7. Options Analysis
Greeks

Implied volatility, put/call ratio, Greeks (Delta, Gamma, Theta, Vega)

8. Alternative Data
ESG

ESG scores, web traffic, job postings, satellite data

9. Risk Management
VaR

Value at Risk, Sharpe Ratio, Maximum Drawdown, Beta, stress tests

10. Market Timing
HMM

Market regime detection, breadth analysis, volatility patterns

11. ML Predictions
6+ Models

XGBoost, LSTM, CNN-LSTM, Transformer, VAE, TCN ensemble

Technical Analysis

Key Indicators & Formulas

1. Relative Strength Index (RSI)
RSI = 100 - (100 / (1 + RS))
RS = Average Gain / Average Loss (14 periods)

Interpretation: RSI > 70 = Overbought, RSI < 30 = Oversold

2. MACD (Moving Average Convergence Divergence)
MACD Line = EMA(12) - EMA(26)
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
Middle Band = SMA(20)
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)
TR = max[(High - Low), |High - Closeprev|, |Low - Closeprev|]
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
P/E Ratio = Stock Price / Earnings Per Share (EPS)

Interpretation: Lower P/E may indicate undervaluation. Compare to industry average.

2. Return on Equity (ROE)
ROE = (Net Income / Shareholder's Equity) × 100%

Benchmark: ROE > 15% is considered excellent

3. Debt-to-Equity Ratio
D/E Ratio = Total Debt / Total Equity

Interpretation: Lower is better. Ratios > 2.0 indicate high leverage risk

4. Current Ratio (Liquidity)
Current Ratio = Current Assets / Current Liabilities

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

DCF = Σ [CFt / (1 + WACC)t] + Terminal Value / (1 + WACC)n

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
Overall Sentiment = 0.30×News + 0.20×Social + 0.25×Analyst + 0.15×Momentum + 0.10×Put/Call

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

ŷ = Σ fk(x), where fk is a decision tree
2. LSTM (Long Short-Term Memory)

Weight: 15% | Captures long-term dependencies in time series

ft = σ(Wf · [ht-1, xt] + bf)
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

Attention(Q, K, V) = softmax(QKT / √dk) V
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

Final Prediction = Σ (wi × predictioni)
Where wi are model weights (sum to 1)

Risk Management

Key Metrics

1. Value at Risk (VaR)
VaR95% = μ - (1.65 × σ)
Where μ = mean return, σ = standard deviation

Interpretation: Maximum expected loss over a time period at 95% confidence

2. Sharpe Ratio
Sharpe Ratio = (Rp - Rf) / σp
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
MDD = (Trough Value - Peak Value) / Peak Value × 100%
4. Beta (Market Sensitivity)
β = Cov(Rstock, Rmarket) / Var(Rmarket)

Interpretation: β > 1 = More volatile than market, β < 1 = Less volatile

Master Scoring System

Score Aggregation Formula

Master Score = 0.25×Technical + 0.30×Fundamental + 0.25×Quantitative + 0.20×Sentiment

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 Buy

Excellent across all metrics. High conviction opportunity.

75-89: Strong
Buy

Strong fundamentals and technicals. Good entry point.

60-74: Good
Moderate Buy

Generally positive with some caution areas.

40-59: Neutral
Hold

Mixed signals. Wait for better clarity.

25-39: Weak
Moderate Sell

Concerning signals. Consider reducing exposure.

0-24: Poor
Strong Sell

Weak 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.
Esc
Analyzing...