Open-source factor investing backtester for Indian equities (NSE).
Build, test, and analyze momentum, low-volatility, quality, and value strategies on 10+ years of Indian market data — in your browser, for free.
Factor investing selects stocks by measurable characteristics ("factors") that have historically predicted returns — the approach behind smart-beta funds worldwide, grounded in academic work by Fama-French and Carhart:
- Momentum — stocks that went up tend to keep going up (3/6/9/12-month returns, with optional 1-month lag)
- Low Volatility — calmer stocks have historically delivered better risk-adjusted returns
- Quality — profitable, well-run companies (ROE, ROCE)
- Value — cheap stocks by P/E, P/B, dividend yield
AlphaEngine lets you combine these into custom strategies (e.g., 30% momentum + 20% low-vol + 30% quality + 20% value), backtest them against Indian market history, and inspect CAGR, Sharpe ratio, drawdowns, and calendar-year returns.
- 4 factor families with multiple parameter choices each, plus multi-factor combinations with custom weights
- 6 weighting methods: Equal, Market Cap, Inverse Market Cap, Factor-weighted, Market Cap × Factor, and more
- Universe filtering: NSE 500, Nifty 200, and other index universes
- Industry filters: Non-Financial / Financial-Lending / Financial-Non-Lending groups
- Configurable rebalancing frequency and portfolio size, with score capping
- Full analytics: equity curve vs benchmark, CAGR, Sharpe, max drawdown, calendar-year returns table
- JWT-authenticated API with persistent backtest results
flowchart LR
A[React + Vite frontend] -->|Axios / JSON| B[FastAPI backend]
B --> C[Backtest engine<br/>pandas + NumPy]
C --> D[(SQLite<br/>prices, fundamentals,<br/>universes)]
Backend (Python 3.10+):
cd backend
python -m venv venv && source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8000Frontend (Node 20+):
cd frontend
npm install
npm run dev # opens http://localhost:5173Default dev credentials are admin / admin123 — override with environment variables (see backend/.env.example) before deploying anywhere public.
The engine reads from a SQLite database (backend/alphaengine.db, path configurable via DB_PATH). The database is not shipped in this repo — populate it with your own data (NSE bhavcopy, yfinance, or any vendor) using this schema:
CREATE TABLE scrips (
symbol TEXT PRIMARY KEY, name TEXT NOT NULL, isin TEXT,
industry_name TEXT, industry_type TEXT
);
CREATE TABLE daily_prices (
symbol TEXT, date TEXT,
open REAL, high REAL, low REAL, close REAL NOT NULL,
volume INTEGER, free_float_market_cap REAL,
PRIMARY KEY (symbol, date)
);
CREATE TABLE index_prices (
index_name TEXT, date TEXT,
open REAL, high REAL, low REAL, close REAL NOT NULL,
PRIMARY KEY (index_name, date)
);
CREATE TABLE daily_metrics (
symbol TEXT, date TEXT,
pe_ratio REAL, pb_ratio REAL, volume REAL,
volatility_90d REAL, beta_adj REAL, ev_to_ebitda REAL,
PRIMARY KEY (symbol, date)
);
CREATE TABLE quarterly_metrics (
symbol TEXT, date TEXT,
profit_margin REAL, net_income REAL, operating_margin REAL,
eps REAL, debt_to_equity REAL, ebitda REAL,
PRIMARY KEY (symbol, date)
);backend/ingest_data.py and backend/scripts/ contain ingestion helpers; backend/scripts/update_prices.py keeps prices current via yfinance.
| Env var | Default | Purpose |
|---|---|---|
ADMIN_USERNAME |
admin |
Login username |
ADMIN_PASSWORD |
admin123 |
Login password (change it) |
ADMIN_JWT_SECRET |
dev default | JWT signing secret (change it) |
DB_PATH |
backend/alphaengine.db |
SQLite database location |
VITE_API_URL |
auto | Frontend → backend API base URL |
AlphaEngine is a research and educational tool. Backtest results are hypothetical, do not fully account for transaction costs, slippage, taxes, or survivorship bias, and are not investment advice or a recommendation to buy or sell any security.
Contributions welcome — see CONTRIBUTING.md. Good first areas: new factor definitions, data ingestion adapters, analytics, and tests.
MIT © 2026 Prathamesh Satam