SIP & Mutual Fund Backtester (India)
A production-grade MVP for backtesting Indian mutual fund SIP investments with tax calculations, FD comparison, and portfolio rebalancing suggestions.
π― Purpose
This tool helps Indian retail investors:
- Analyze historical SIP returns for mutual funds
- Calculate post-tax returns (LTCG/STCG)
- Compare MF returns with Fixed Deposits
- Get rule-based portfolio rebalancing suggestions
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Input Form β β Results β β Rebalance β β
β β β β Dashboard β β Panel β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β React + Vite (Port 5173) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend API β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β /api/funds β β/api/simulate β β/api/rebalanceβ β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β FastAPI + Uvicorn (Port 8000) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Financial Calculation Engine β
β ββββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββββββ β
β βSIP Engine β β Returns β β Taxation β β Comparison β β
β β β βCAGR/XIRR β βLTCG/STCG β β MF vs FD β β
β ββββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Data Layer β
β Versioned CSV files (data/nav/) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Financial Assumptions
Tax Model (FY 2024-25)
| Category | Type | Rate | Notes |
|---|---|---|---|
| Equity Funds | LTCG (>1 year) | 12.5% | Exempt up to βΉ1.25L annually |
| Equity Funds | STCG (<1 year) | 20% | Full gains taxable |
| Debt Funds | All | Slab Rate | No indexation (post-April 2023) |
| Fixed Deposits | Interest | Slab Rate | Fully taxable |
FD Rates Used
- 1 year: 6.5%
- 2-3 years: 7.0%
- 5+ years: 7.25%
Rebalance Targets
| Horizon | Equity | Debt |
|---|---|---|
| Short (<3 yrs) | 20% | 80% |
| Medium (3-7 yrs) | 50% | 50% |
| Long (>7 yrs) | 80% | 20% |
π Data Sources
Sample data included for demonstration purposes.
For production use, data can be sourced from:
- AMFI India (amfiindia.com) - Official NAV data
- Fund house websites - Historical NAV disclosures
- Value Research / Morningstar - Third-party aggregators
NAV CSV Format
date,fund_id,fund_name,nav,fund_type,expense_ratio
2024-01-02,HDFC_FLEXI,HDFC Flexicap Fund,525.45,equity,1.75
π Running Locally
Prerequisites
- Python 3.11+
- Node.js 18+
- pip / npm
Backend Setup
cd backend
python -m venv venv
venv\Scripts\activate # Windows
pip install -r requirements.txt
uvicorn app.main:app --reload
Backend runs at: http://localhost:8000
Frontend Setup
cd frontend
npm install
npm run dev
Frontend runs at: http://localhost:5173
Running Tests
cd backend
pip install pytest httpx
pytest tests/ -v
π Deployment
Free Hosting Options
Backend (Python/FastAPI)
- Render.com (free tier)
- Railway.app
- Fly.io
Frontend (React)
- Vercel
- Netlify
- GitHub Pages (for static build)
Environment Variables
# Backend
CORS_ORIGINS=https://your-frontend.vercel.app
# Frontend (if not using proxy)
VITE_API_URL=https://your-backend.onrender.com
β οΈ Limitations
- Historical data only - Cannot predict future returns
- Sample data - MVP includes demo data; connect real NAV feeds for production
- Tax simplifications - Does not handle:
- Grandfathering rules
- Multiple financial years in one redemption
- Set-off of losses
- No real-time data - NAV data is static CSVs
- Single fund simulation - Multi-fund portfolio analysis not implemented
π Disclaimer
β οΈ This is an educational tool for historical analysis only.
- Past performance does not guarantee future returns
- Tax calculations are estimates based on FY 2024-25 rules
- Always consult a SEBI-registered investment advisor before investing
- Verify calculations independently before making financial decisions
π§ͺ Test Coverage
| Module | Tests |
|---|---|
| SIP Engine | Date generation, unit calculation, expense drag |
| Returns | CAGR accuracy, XIRR convergence, volatility |
| Taxation | Equity/Debt classification, LTCG/STCG edge cases |
| API | Endpoints, response schemas, error handling |
π License
MIT License - Free for personal and commercial use.
Built with β€οΈ for Indian retail investors.