Deep dive into analysis
π Stock Analysis Workflow
System: ML Analysis Pipeline Β· AI Valuation Engine Β· Schwab GEX Module Β· Agentic AI
Table of Contents
- System Architecture Overview
- Step 1 β Ticker Selection
- Step 2 β Fundamental Analysis
- Step 3 β DCF Valuation (AI)
- Step 4 β Machine Learning Forecast
- Step 5 β Backtesting (MA Strategy)
- Step 6 β Sentiment Analysis
- Step 7 β Quantitative Risk Analysis
- Step 8 β Macroeconomic Analysis
- Step 9 β GEX (Gamma Exposure)
- Step 10 β Weighted Score & Signal
- Step 11 β AI Final Summary
- Step 12 β Agentic AI (Alternative Pipeline)
- Output β Email Report
- Configuration Reference
1. System Architecture Overview
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β fetch_ML_v2.py / ML_report_v2.py β
β β
β [Ticker Selection] β
β β β
β βΌ β
β βββββββββββββββ βββββββββββββ ββββββββββββ ββββββββββββββββββ β
β β Fundamental β β DCF β β ML β β Backtesting β β
β β Analysis β β (AI LLM) β β Forecast β β (MA Strategy) β β
β ββββββββ¬βββββββ βββββββ¬ββββββ ββββββ¬ββββββ βββββββββ¬βββββββββ β
β β β β β β
β ββββββββΌβββββββ ββββββββΌβββββββ ββββΌβββββββββββ ββββΌβββββββββββ β
β β Sentiment β β Quant β β Macro β β GEX β β
β β (FinBERT) β β (QuantStats)β β (FRED) β β (Schwab) β β
β ββββββββ¬βββββββ βββββββ¬ββββββββ ββββββ¬βββββββββ βββββββ¬ββββββββ β
β β β β β β
β βββββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββββ β
β β β
β [Weighted Score] β
β β β
β [AI Summary Report] β
β β β
β [Email + Database Insert] β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2. Step 1 β Ticker Selection
Source: Stock Screener Utility β Sector & momentum-ranked stock picker
How It Works
The screener finds the single highest-momentum, highest-liquidity stock each day using Finviz.
1. Sector finder
ββ Overview β all sectors sorted by daily % change
ββ Pick the TOP sector (best-performing sector today)
2. Ticker finder
ββ Custom screener with filters:
β’ Index: Any
β’ Country: USA
β’ Performance: Today Up
β’ Gap: Up (opening gap up)
ββ Order by: % Change (descending)
ββ Take top 25 results
ββ Calculate Trade Value = Price Γ Volume
ββ Sort by Trade Value (descending)
ββ Return #1 ticker β highest momentum + highest liquidity
Screener Columns Pulled
| Column | Description |
|---|---|
| Ticker | Symbol |
| Price | Current price |
| Change | Daily % change |
| Volume | Share volume |
| P/E | Price/Earnings |
| EPS this Y | EPS growth this year |
| EPS next Y | EPS growth next year |
| Sales Q/Q | Revenue growth QoQ |
| P/FCF | Price/Free Cash Flow |
| P/B | Price/Book |
| ROI | Return on Investment |
| ROE | Return on Equity |
3. Step 2 β Fundamental Analysis
Source: Fundamental Data Fetcher β Multi-source stock fundamentals aggregator (Finviz + yfinance)
Data Sources
| Source | Data |
|---|---|
Finviz (finvizfinance) |
P/E, P/B, P/S, ROA, ROE, gross margin, operating margin, EPS growth, short float, insider own% |
| yfinance | Company info, valuation, earnings, balance sheet, analyst targets, insider transactions, earnings dates |
Key Metrics Collected
Valuation
- Market Cap, Enterprise Value
- Trailing P/E, Forward P/E, PEG Ratio
- Price/Book, Price/Sales, EV/EBITDA, EV/Revenue
Profitability
- EPS (trailing & forward)
- Revenue & Revenue Growth
- Gross Margins, Operating Margins, Profit Margins
- ROE (Return on Equity), ROA (Return on Assets)
Balance Sheet Health
- Total Cash, Total Debt, Debt/Equity Ratio
- Current Ratio
- Free Cash Flow, Operating Cash Flow
Price & Targets
- Current Price
- Analyst Target (Low / Mean / Median / High)
- 52-Week High/Low
- 50-Day / 200-Day Moving Averages
- Dividend Yield, Payout Ratio
Qualitative
- Recent analyst recommendations (last 5)
- Insider transactions (last 5)
- Upcoming earnings dates
4. Step 3 β DCF Valuation (AI)
Source: AI-Powered DCF Valuation Engine β 7-step discounted cash flow analysis
Inputs (from yfinance)
ticker_yf.cashflow # Cash flow statement
ticker_yf.balance_sheet # Balance sheet
ticker_yf.income_stmt # Income statement (P&L)
company_info # Key stats dict
AI DCF Methodology
The AI model is instructed to follow this exact 7-step process:
Step 1 β Forecast 5 years of Free Cash Flow (FCF)
β’ Based on historical FCF trend
β’ Max 20% annual growth unless justified
β’ No negative forecasted FCF
Step 2 β Terminal Value (Gordon Growth Model)
TV = Final Year FCF Γ (1 + g) / (WACC - g)
Step 3 β WACC Calculation
β’ Cost of Equity = CAPM: rf + Ξ² Γ (rm - rf)
β’ Cost of Debt = avg interest rate Γ (1 - tax rate)
β’ Capital structure = Debt / (Debt + Equity)
β’ WACC = wE Γ rE + wD Γ rD
Step 4 β Discount all FCFs + Terminal Value to PV
PV = FCF_t / (1 + WACC)^t
Step 5 β Subtract Net Debt
Equity Value = Ξ£ PV(FCF) + PV(TV) - Net Debt
Net Debt = Total Debt - Cash
Step 6 β Intrinsic Share Price
Price = Equity Value / Shares Outstanding
Step 7 β Output: Intrinsic value (USD total) + per-share price
Output
Intrinsic Share Price: $XXX.XX Comparison to current market price β overvalued / fair / undervalued
5. Step 4 β Machine Learning Forecast
Source: ML Forecasting Engine β Bidirectional LSTM + XGBoost ensemble price predictor
Data Preparation
- Price history: 3 years from yfinance
- Lookback window: 60 trading days
- Forecast horizon: 20 trading days
- Train/Test split: 80% / 20%
Feature Engineering
# Price features
returns = Close.pct_change()
log_returns = log(Close / Close.shift(1))
# Moving averages (ratios β normalized)
sma_5/10/20/50 = Close.rolling(window).mean()
sma_ratio = Close / sma
# Volatility
volatility_20 = returns.rolling(20).std()
# RSI (14-period)
rsi = 100 - (100 / (1 + avg_gain / avg_loss))
# MACD
macd = EMA(12) - EMA(26)
macd_signal = EMA(macd, 9)
# Bollinger Bands
bb_mid = SMA(20)
bb_upper = SMA(20) + 2 Γ std(20)
bb_lower = SMA(20) - 2 Γ std(20)
bb_position = (Close - bb_lower) / (bb_upper - bb_lower)
Model Architecture
LSTM (Primary)
Input: (60 days Γ 1 feature β scaled Close price)
β
Bidirectional LSTM (128 units) β BatchNorm β Dropout(0.3)
β
LSTM (64 units) β BatchNorm β Dropout(0.3)
β
LSTM (32 units) β BatchNorm β Dropout(0.2)
β
Dense(16, ReLU) β Dense(1)
Optimizer: Adam (lr=0.001)
Loss: Huber (robust to outliers)
Callbacks: EarlyStopping (patience=5), restore_best_weights=True
Epochs: 10 max
XGBoost (Ensemble Pair)
XGBRegressor(
n_estimators=100,
max_depth=6,
learning_rate=0.1,
subsample=0.8,
colsample_bytree=0.8
)
Ensemble
Final Prediction = (LSTM prediction + XGBoost prediction) / 2
Forecast Output
RMSE : Root Mean Squared Error
MAE : Mean Absolute Error
MAPE : Mean Absolute Percentage Error
Model Accuracy : max(0, 100 - MAPE) %
Forecast Trend : "Up" or "Down"
Expected Return : (last_forecast - first_forecast) / first_forecast
forecast_df : DataFrame of 20-day price forecast
6. Step 5 β Backtesting (MA Strategy)
Source: MA Strategy Backtester β Vectorized moving average signal simulator
Strategy Logic
For each MA window in [5, 7, 9, 12, 15, 20, 50]:
ββββββββββββββββββββββββββββββββββββββββ
β Entry Signal β
β |Price - MA| / MA < 1% β
β (price touching the moving average)β
ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββ
β Exit Signal β
β Take Profit: PnL β₯ +5% β
β Stop Loss: PnL β€ -5% β
ββββββββββββββββββββββββββββββββββββββββ
- Data: yfinance from
2022-01-01to yesterday - Starting capital: $10,000
- Benchmark: Buy-and-Hold return over same period
Output Per MA Window
| Metric | Description |
|---|---|
total_trades |
Number of trades executed |
win_rate |
% of profitable trades |
return_pct |
Total strategy return % |
final_capital |
End capital from $10,000 |
avg_holding_days |
Average days held per trade |
Selection Criteria
Best MA Window = highest return_pct across all windows
Feeds into: best_sma stored in database, best_holding days
7. Step 6 β Sentiment Analysis
Source: Sentiment Analysis Pipeline β FinBERT NLP engine for news & Reddit crowd signals
Sentiment Models
| Model | Role |
|---|---|
FinBERT (ProsusAI/finbert) |
Primary β fine-tuned on financial text |
| VADER + custom finance lexicon | Fallback if FinBERT unavailable |
Custom Finance Lexicon (VADER additions)
'bullish': +3.7 'bearish': -3.7
'buy': +4.0 'sell': -4.0
'upgrade': +3.0 'downgrade': -3.0
'beat': +2.5 'miss': -2.5
'moon': +4.0 'crash': -3.5
'rally': +2.5 'squeeze': +2.0
News Analysis
Sources:
- Finviz β recent news headlines for the ticker
- Yahoo Finance β
yf.Ticker(ticker).news
Process:
Fetch headlines β Deduplicate β FinBERT scoring β
Average compound score β Return {score, pos%, neg%, neu%, headline_count}
Reddit Analysis
Subreddits: wallstreetbets, stocks, investing, stockmarket
Filters:
- Upvote ratio β₯ 0.70
- Upvotes β₯ 20
- Checks post title + body + top comments
Process:
Parallel fetch (4 workers) across subreddits β
Match ticker symbol or company name β
FinBERT scoring on matching posts/comments β
Average compound score β Return {score, mention_count}
8. Step 7 β Quantitative Risk Analysis
Source: Quantitative Risk Analyzer β QuantStats performance metrics + Risk/Return vs S&P 500 charting
QuantStats Metrics (from 2022-01-01)
| Metric | Meaning |
|---|---|
| Sharpe Ratio | Risk-adjusted return (rf = 4% annual) |
| Sortino Ratio | Downside-adjusted return |
| Calmar Ratio | CAGR / Max Drawdown |
| Max Drawdown | Worst peak-to-trough loss |
| Volatility | Annualized standard deviation of returns |
| Win Rate | % of positive daily returns |
| Profit Factor | Gross profit / Gross loss |
| CAGR | Compound Annual Growth Rate |
| Value at Risk (VaR) | 95% worst-case daily loss |
| Expected Return | Mean daily return |
Risk vs Return Chart
MarketVsticker.generate_vsticker() produces a scatter plot:
- X-axis: Risk (daily return std dev)
- Y-axis: Average return Γ 10
- Plots ticker vs S&P 500
- Red dashed line = S&P 500 slope (Sharpe reference line)
Tickers above the S&P line offer better risk-adjusted returns
9. Step 8 β Macroeconomic Analysis
Source: Macroeconomic Analysis Engine β FRED API data tracker with VIX and BofA Bear/Bull indicator scoring
Data Sources
| Source | Series | Description |
|---|---|---|
| FRED API | GDP |
Gross Domestic Product |
| Β | FEDFUNDS |
Federal Funds Rate |
| Β | CPIAUCSL |
CPI β inflation |
| Β | PPIACO |
Producer Price Index |
| Β | DGS10 |
10-Year Treasury Yield |
| Β | DGS2 |
2-Year Treasury Yield |
| Β | UNRATE |
Unemployment Rate |
| Β | USSLIND |
Leading Economic Index |
| Β | HOUST |
Housing Starts |
| Β | PERMIT |
Building Permits |
| Β | UMCSENT |
Consumer Confidence |
| Yahoo Finance | ^VIX |
Volatility Index |
| Β | SPY, QQQ, IWM |
Market breadth |
VIX Classification
| VIX Level | Classification |
|---|---|
| < 15 | Low (complacent) |
| 15β20 | Normal |
| 20β25 | Elevated |
| 25β30 | High |
| > 30 | Extreme (fear) |
Yield Curve Analysis
Spread = 10Y Treasury Yield - 2Y Treasury Yield
Spread < 0 β β οΈ INVERTED (Recession warning)
Spread > 0 β β
Normal
Market Breadth (SPY / QQQ / IWM)
For each index: 1D, 1W, 1M, 3M, YTD returns + trend classification:
- strong uptrend / uptrend / sideways / downtrend / strong downtrend
BofA Bear Indicators (10 signals β Market Peak Warnings)
| # | Signal | Threshold |
|---|---|---|
| 1 | Consumer Confidence | > 110 (prior 60mo) |
| 2 | Net % expecting stocks higher | > 20% (prior 6mo) |
| 3 | Sell-side indicator | βSellβ signal |
| 4 | S&P 500 LT growth 5yr Z-score | > 1 |
| 5 | M&A deals 10yr Z-score | > 1 |
| 6 | (Trailing PE + YoY CPI) Z-score | > 1 |
| 7 | Low PE underperforms High PE | by 2.5ppt (6mo) |
| 8 | Inverted yield curve | Spread < 0 |
| 9 | Credit stress indicator | < 0.25 |
| 10 | Tightening credit (SLOOS) | Triggered |
BofA Bull Indicators (10 signals β Market Bottom Signals)
| # | Signal | Threshold |
|---|---|---|
| 1 | Fed cutting rates | Prior 12mo |
| 2 | Unemployment rising | vs 12mo low |
| 3 | More bears than bulls | AAII survey |
| 4 | ERP increase | > 75bps vs 12mo low |
| 5 | 2Y yield decline | > 50bps vs 6mo high |
| 6 | Sell-side indicator | βBuyβ signal |
| 7 | Yield curve steepening | vs 6mo low |
| 8 | 5% bear market rally | Prior 3mo |
| 9 | Rule of 20 triggered | β |
| 10 | PMI improves | vs 12mo YoY low |
Macro Sentiment Classification
Bear signals - Bull signals > 2 β BEARISH
Bull signals - Bear signals > 2 β BULLISH
Otherwise β NEUTRAL
Macro Score Adjustment
if macro_sentiment == 'bearish' or bear_count >= 5:
macro_adjustment = -0.05 # Reduce buy conviction
elif macro_sentiment == 'bullish' or bull_count >= 5:
macro_adjustment = +0.02 # Slightly increase conviction
if VIX > 30:
macro_adjustment -= 0.03 # Additional caution in fear spike
10. Step 9 β GEX (Gamma Exposure)
Source: Schwab GEX Calculator β Dealer gamma exposure derived from live Schwab option chain feed
API: Charles Schwab Live Market Data β Real-time option chain endpoint (/marketdata/v1/chains)
What Is GEX?
GEX measures how much gamma market makers (dealers) hold, which predicts near-term market behavior:
GEX Formula:
Call GEX = Gamma Γ Open Interest Γ 100 Γ Spot Price (positive)
Put GEX = -Gamma Γ Open Interest Γ 100 Γ Spot Price (negative)
Total GEX = Ξ£(Call GEX) + Ξ£(Put GEX) across all strikes
Market Condition Interpretation
| Condition | Meaning | Market Behavior |
|---|---|---|
| Positive GEX (Total > 0) | Dealers are long gamma | Mean-reverting, lower volatility, price pinned to large strikes |
| Negative GEX (Total < 0) | Dealers are short gamma | Trending/accelerating, higher volatility, moves amplified |
Key GEX Levels
GEX Flip Level β Strike where cumulative GEX crosses zero
Acts as a market pivot / support-resistance
Support Level β Highest |GEX| strike below current price
Large positive GEX below = dealers hedge by buying β support
Resistance Level β Highest |GEX| strike above current price
Large positive GEX above = dealers hedge by selling β resistance
0DTE GEX
Special calculation for same-day expiration options only (highest gamma impact near expiry). Useful for intraday trading levels.
GEX Report Output
βββββββββββββββββββββββββββββββββββ
GEX ANALYSIS: SPY
βββββββββββββββββββββββββββββββββββ
π Current Price: $565.43
π° Total GEX: +$2.14B
π Market Condition: POSITIVE_GAMMA
Dealers long gamma β Market likely to mean-revert
π― Key Levels:
β’ GEX Flip: $558.00
β’ Support: $560.00
β’ Resistance: $570.00
π Top Positive GEX Strikes (Resistance):
β’ $570.00: $420.5M
β’ $575.00: $380.2M
...
Covered Call Screener (bonus)
Source: Covered Call Screener β High-IV option income opportunity finder using Schwab option chains
Screens for high-IV covered call opportunities:
| Metric | Formula |
|---|---|
| Premium Yield | bid / spot price |
| Annualized Return | premium_yield Γ 365/DTE |
| Downside Protection | bid / spot price |
| Theta/Gamma Ratio | ΞΈ / Ξ (higher = better risk/reward) |
Filters: DTE 14β60, OTM 1%β15%, min OI 10, configurable IV floor
11. Step 10 β Weighted Score & Signal
Source: ML Analysis Orchestrator β Weighted signal aggregator that combines all module outputs with macro adjustment
Score Weights
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β WEIGHTED SCORE CALCULATION β
β β
News Sentiment β score Γ 0.30 (FinBERT compound, range -1 to 1)β
Reddit Sentiment β score Γ 0.20 (FinBERT compound, range -1 to 1)β
ML Forecast β return Γ 0.30 (expected 20-day return decimal) β
Buy-and-Hold β return Γ 0.20 (historical BnH return decimal) β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β raw_score = sum of above β
β + macro_adjustment (-0.08 to +0.02) β
β βββββββββββββββββββββββββββββββββββββββββββββββ β
β weighted_score = raw_score + macro_adjustment β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Signal Decision
if weighted_score > 0.5:
signal = "Buy"
else:
signal = "Hold"
Database Record (tk_selected table)
INSERT INTO tk_selected (date, ticker, score, news, reddit, lstm, holding_days, sma, result)
VALUES (today, ticker, weighted_score, news_score, reddit_score, forecast_trend, best_holding, best_ma, signal)
12. Step 11 β AI Final Summary
Source: AI Investment Report Generator β Multi-factor synthesis engine that produces a buy-side equity memo
Inputs Fed to AI Model
βββ FUNDAMENTALS βββ (Finviz + yfinance table)
βββ TECHNICAL CHART βββ (Matplotlib chart: price + MA + forecast + sentiment + backtest)
βββ ML ANALYSIS REPORT βββ (Full text report from generate_report())
βββ QUANTITATIVE METRICS ββ (QuantStats summary)
βββ MACROECONOMIC ANALYSIS β(FRED + VIX + BofA signals)
βββ GEX ANALYSIS βββ (Schwab GEX report)
βββ DCF VALUATION βββ (AI DCF output)
Output Structure
1. Executive Summary (1-2 paragraphs)
ββ Valuation, market position, technicals, macro, sentiment
2. Macroeconomic Context
ββ VIX level, yield curve status, market breadth (SPY/QQQ/IWM)
ββ BofA Bear/Bull signals
ββ Risk-on / Risk-off assessment
3. GEX Analysis
ββ Positive vs Negative gamma interpretation
ββ Key GEX support/resistance/flip levels
ββ Position sizing guidance from GEX
4. Fundamental Strengths & Risks (bullet points)
5. Sentiment Assessment
ββ News vs Reddit divergence analysis
6. Risk/Return Positioning
ββ Volatility, drawdowns, win rate
7. Model Alignment
ββ MA backtest vs LSTM forecast alignment
8. DCF Comparison
ββ Intrinsic value vs current price
9. βββββββββββββββββββββββββββββββββββββββββββββββββββββ
π‘ Final Recommendation (as of YYYY-MM-DD)
βΆ Position: BUY / HOLD / SELL
βΆ Macro Alignment: FAVORABLE / NEUTRAL / UNFAVORABLE
βΆ GEX Condition: POSITIVE GAMMA / NEGATIVE GAMMA
Key Notes:
- Macro Context: [VIX, yield curve, market trend]
- GEX Levels: [Support $X, Resistance $Y, Flip $Z]
- Tactical entry/exit ranges
- Position sizing guidance
- Position management (trailing stop, profit target)
- 1-line Summary Statement
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
13. Step 12 β Agentic AI (Alternative Pipeline)
Source: Agentic AI Orchestrator & Specialist Agents β LLM-first sequential analysis pipeline with four domain-expert personas
This is an LLM-first alternative to the quantitative pipeline, useful for deeper qualitative analysis.
Agent Execution Flow
User provides ticker(s)
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 1: Macro Analyst (runs ONCE, shared across all tickers) β
β Skill: macroeconomic (FRED + VIX + market data) β
β Output: RISK-ON / RISK-OFF / TRANSITIONAL β
βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 2: Fundamental Analyst (per ticker) β
β Skills: microeconomic + qualitative β
β Data: yfinance financials, DCF, sector comps, news β
β Output: OVERVALUED / FAIR / UNDERVALUED + catalysts β
βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 3: Quant Analyst (per ticker) β
β Skill: quantitative β
β Data: Price history, MA structure, RSI/MACD, Sharpe, β
β max drawdown, beta, LSTM forecasts, GEX β
β Output: Technical signal + risk metrics + entry/exit β
βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 4: Portfolio Strategist (synthesis) β
β Receives: all 3 agent analyses β
β Output: BUY/HOLD/SELL + conviction (1-10) + β
β position size + risk parameters β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Agent Prompting Philosophy
Each agent has a specific system prompt persona:
| Agent | Persona |
|---|---|
| Macro Analyst | Senior macro strategist at a global macro hedge fund |
| Fundamental Analyst | Buy-side equity research analyst at a top-tier investment firm |
| Quant Analyst | Quantitative portfolio analyst at a systematic trading firm |
| Portfolio Strategist | Chief Investment Officer at a multi-strategy fund |
Running the Agentic Pipeline
from agentic_ai.orchestrator import Orchestrator
orchestrator = Orchestrator()
# Single ticker
result = orchestrator.analyze_ticker("AAPL")
# Multiple tickers (macro cached and shared)
results = orchestrator.analyze_portfolio(["AAPL", "TSLA", "NVDA"])
14. Output β Email Report
Source: Email Report Dispatcher β HTML report builder and Gmail SMTP sender
The HTML email contains all sections assembled:
Subject: "Daily Stock Report: {TICKER}, {Company Name}"
HTML Email Sections:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. ML Analysis Text Report (pre-formatted text) β
β 2. Analysis Dashboard Chart (2Γ2 matplotlib grid): β
β ββ [Top-Left] Price history (6mo) + MA20/MA50 β
β ββ [Top-Right] LSTM 20-day price forecast β
β ββ [Bot-Left] Sentiment bar chart (News/Reddit/Score) β
β ββ [Bot-Right] MA backtest returns vs win rates β
β 3. Risk vs Return Chart (vs S&P 500 scatter plot) β
β 4. Fundamental Data Table (Finviz HTML table) β
β 5. QuantStats Summary β
β 6. AI DCF Valuation Analysis β
β 7. AI Final Summary (with GEX & Macro) β
β 8. Macro Analysis Report β
β 9. GEX Report (Schwab option chain analysis) β
β 10. Covered Call Screener (optional) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
15. Configuration Reference
Source: Analysis Configuration Dataclass β All tunable parameters for the ML pipeline
Quick Reference Summary
TICKER SELECTION β Finviz: top sector + highest Trade Value stock
FUNDAMENTAL β Finviz + yfinance: P/E, margins, targets, insider
DCF β AI model: 5yr FCF forecast β WACC β intrinsic price
ML FORECAST β LSTM + XGBoost: 60-day lookback β 20-day price forecast
BACKTEST β MA strategy (5β50): touch MA β 5% TP / -5% SL
SENTIMENT β FinBERT on Finviz news + Reddit (4 subreddits)
QUANT RISK β QuantStats: Sharpe, Sortino, VaR, CAGR + Risk/Return plot
MACRO β FRED: yields, CPI, unemployment + VIX + BofA signals
GEX β Schwab API: dealer gamma β support/resistance/flip levels
WEIGHTED SCORE β 0.3(news) + 0.2(reddit) + 0.3(ML) + 0.2(BnH) Β± macro adj
SIGNAL β Score > 0.5 β BUY, else HOLD
AI SUMMARY β All data β AI model β final recommendation with entry/exit
16. Conclusion
Thatβs the entire workflow from ticker selection all the way through to a final buy & hold decision with covered calls on top. Every step feeds into the next: the screener narrows the universe, fundamentals and DCF set a fair-value anchor, ML and backtesting add a forward-looking edge, sentiment captures the crowdβs mood, macro and GEX keep me aware of the bigger picture, and the weighted score ties it all together into a single actionable signal.
Is it perfect? No. Markets will always surprise you. But having a structured, repeatable process removes most of the emotion from the decision and lets the data do the heavy lifting. The agentic AI pipeline is a newer addition that gives me a second opinion, a qualitative lens on top of the quantitative one and Iβve found the two complement each other well.
Building this system has been one of the most rewarding projects Iβve worked on. If you made it this far, I hope it gave you some ideas for your own workflow. Happy investing.