Build · 3h 30m · ₹0
A full-stack equity research platform combining technical indicators with a 6-tier algebraic fundamental derivation cascade to handle missing financial API data for NSE and global markets.
What it does
The mechanics, data flow, and user interaction model behind AlphaMind.
Given any stock symbol, AlphaMind computes technical signals (14-period RSI, SMA 50/200 golden/death-crosses, 6-month momentum, volume breakout ratios) and fundamental health metrics, fusing them into a single weighted recommendation (60% fundamental / 40% technical → Strong Buy through Avoid). To resolve the pervasive issue of free-tier financial APIs returning 0.0% or null on mid/small-cap fundamentals, AlphaMind executes a 6-tier mathematical derivation cascade: live API data → verified static NSE blue-chip catalog → algebraic derivation from (P/B) / (P/E) → derivation from EPS and Book Value → derivation from ROA scaled by leverage → operating margin approximations. It also generates publication-grade PDF research digests and invoices using custom two-pass ReportLab canvases for exact page numbering.
Technical Highlights
- 6-tier algebraic fallback cascade deriving missing ROE and financial ratios when free API feeds return null: (P/B) / (P/E) = EPS / Book Value = ROE
- Blended recommendation engine combining 60% fundamental health + 40% technical momentum into 5-tier actionable signals
- Two-pass ReportLab PDF generation engine with dynamic 'Page X of Y' canvas numbering for weekly market digests
- Production-grade FastAPI backend with OAuth2/JWT auth, bcrypt password hashing, SQLAlchemy models, and Alembic migrations
- Real-time technical indicator computation engine (14-period RSI, SMA 50/200 crossovers, 6-month momentum, volume surges)
Why it matters
The architectural judgment, practical engineering decisions, and core problems solved.
Free financial data feeds (like yfinance and Finnhub) are notoriously incomplete precisely where retail investors need analysis most — on smaller and mid-cap equities. Rather than silently passing broken zeroes into scoring models, AlphaMind implements rigorous quantitative accounting math to back-calculate missing balance sheet metrics. It demonstrates true domain engineering: structured FastAPI architecture (service layers, OAuth2 JWT auth, Alembic migrations), two-pass PDF rendering, and clear financial disclaimer boundaries.
Retail equity research and quantitative screener for NSE and international equities
Automated weekly investment digest and portfolio audit report generation
Reference architecture for building resilient data ingestion pipelines around flaky third-party APIs
Educational benchmark for exploring fundamental valuation modeling and technical crossover strategies
System architecture
End-to-end execution pipeline running across FastAPI, SQLAlchemy, Pandas, ReportLab, React 19.
Fetches OHLCV price histories, market cap, and preliminary financial statements via asynchronous workers
Algebraically back-calculates missing ROE, EPS, and leverage metrics through accounting formula fallbacks
Computes 14-day RSI, 50/200 SMA crossovers, MACD, and historical volatility bands
Calculates 60/40 blended fundamental-technical rating matrix (Strong Buy to Avoid)
Two-pass PDF research digest generator + modern React 19 / TypeScript equity dashboard
The path
Step-by-step implementation guide. Verbatim code snippets, configurations, and prompts.
Building the 6-Tier Algebraic Fundamental Derivation Cascade
Implement the resilient fallback cascade to calculate ROE and financial health ratios when API providers return missing fields.
Verbatim Code / Config
def derive_roe(data: dict) -> float:
if data.get('roe'): return data['roe']
if pb := data.get('pb_ratio') and (pe := data.get('pe_ratio')) and pe > 0:
return pb / pe # (Price/Book) / (Price/EPS) = EPS/Book = ROE
if eps := data.get('eps') and (bv := data.get('book_value')) and bv > 0:
return eps / bv
if roa := data.get('roa') and (lev := data.get('leverage_ratio')):
return roa * lev
return fallback_catalog.get(data['symbol'], {}).get('roe', 0.0)Technical Signal Engine in Pandas & NumPy
Write vectorized technical calculation routines for 14-period RSI, exponential moving averages, golden/death-cross triggers, and volume breakout factors.
Verbatim Code / Config
def compute_technicals(df: pd.DataFrame) -> dict:
delta = df['Close'].diff()
gain = delta.where(delta > 0, 0).rolling(14).mean()
loss = (-delta.where(delta < 0, 0)).rolling(14).mean()
rs = gain / (loss + 1e-9)
rsi = 100 - (100 / (1 + rs))
sma_50 = df['Close'].rolling(50).mean()
sma_200 = df['Close'].rolling(200).mean()
return {'rsi': rsi.iloc[-1], 'golden_cross': sma_50.iloc[-1] > sma_200.iloc[-1]}Two-Pass Numbered PDF Canvas in ReportLab
Create a custom ReportLab canvas class that intercepts draw operations to calculate total page count dynamically for professional 'Page X of Y' footers.
Verbatim Code / Config
class NumberedCanvas(canvas.Canvas):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._saved_page_states = []
def showPage(self):
self._saved_page_states.append(dict(self.__dict__))
self._startPage()
def save(self):
num_pages = len(self._saved_page_states)
for state in self._saved_page_states:
self.__dict__.update(state)
self.draw_page_number(num_pages)
super().showPage()
super().save()FastAPI Service Architecture with JWT & Alembic
Structure the backend into providers, services, schemas, and SQLAlchemy ORM models with Alembic versioning for user portfolios and watchlists.
Verbatim Code / Config
app = FastAPI(title='AlphaMind Engine')
app.include_router(auth_router, prefix='/api/auth')
app.include_router(analysis_router, prefix='/api/stocks')
app.include_router(digest_router, prefix='/api/reports')Where it broke
The failure mode, root-cause breakdown, and resolution discovered during development.
The Tell
“Mid-cap and small-cap stocks frequently displayed 0.0% ROE and broken valuation scores despite having healthy historical earnings.”
Why it failed
Free-tier financial APIs return empty strings or 0.0 for balance sheet items on non-S&P500 / non-NIFTY50 tickers, which raw scoring algorithms interpreted as total insolvency.
The Fix
Constructed the 6-tier algebraic derivation cascade that back-calculates ROE from P/B and P/E ratios and fallback catalogs before passing data to the scoring engine.
What it cost
₹0 to build and run permanently within verified free tiers.
| Service / Tool | Cost | Free Tier Limits |
|---|---|---|
| FastAPI & Python Stack | ₹0 | Open-source asynchronous backend framework |
| yfinance & Finnhub | ₹0 | Free-tier market data API endpoints (60 calls/min) |
| SQLAlchemy & SQLite/Postgres | ₹0 | Open-source relational database layer |
| ReportLab Open Source | ₹0 | Free LGPL PDF generation library |
| React 19 & Tailwind CSS v4 | ₹0 | Open-source web application interface |
Make it yours
Three concrete variations you can build and ship using this exact foundation.
- 01
Crypto On-Chain & Technical Screener: Replaces equities with decentralized exchange token liquidity and wallet accumulation signals.
- 02
Commodity Futures Margin & Spread Calculator: Computes carry costs, seasonality curves, and term-structure contango/backwardation spreads.
- 03
SaaS Company Metric Benchmark Dashboard: Computes Rule of 40, CAC payback period, and Net Revenue Retention cascades from self-reported financials.
Where next
Ready to ship AlphaMind?
Review the architecture, clone the prompt and implementation steps, and deploy your live URL for ₹0.