Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portfolio Optimizer (Indian Equities)

A full-stack, end-to-end quantitative portfolio optimizer designed for the Indian stock market (NSE). This project computes optimal capital allocation using modern portfolio theory, allowing investors to maximize risk-adjusted returns or minimize volatility across a selected basket of Indian equities.

Features

  • Automated Data Pipeline: Fetches and cleans up to 2 years of daily OHLCV historical pricing data from Yahoo Finance. Users simply input standard NSE tickers (e.g., RELIANCE, TCS, INFY) and the backend automatically normalizes them (.NS).
  • Optimization Routines:
    • Max Sharpe Ratio: Discovers the portfolio weight allocation that maximizes return per unit of risk, benchmarked against the default Indian risk-free rate (6.5%).
    • Global Minimum Variance: Identifies the portfolio structure with the lowest absolute volatility.
    • Custom Target Return: Computes the lowest-risk portfolio that mathematically guarantees a precise target yield.
  • Interactive Dashboard: Built with Vanilla HTML/JS and Plotly.js to render real-time Efficient Frontier scatter plots and customized asset allocation donut charts.
  • Data Export: Instant CSV export of weights, performance metrics, and equal-weight comparison baselines, standardized in ₹ INR.

Tech Stack

  • Backend / API: FastAPI, Python 3.9
  • Quantitative Engine: scipy.optimize.minimize (SLSQP with multi-start architecture for edge case handling), pandas, numpy, yfinance
  • Frontend: Vanilla HTML5 / CSS Variables / Vanilla JS, Plotly.js (CDN)
  • UI Design System: Custom-built, developer-focus aesthetic using Inter and JetBrains Mono.

Getting Started

Prerequisites

  • Python 3.9+
  • pip

Installation & Setup

  1. Clone the repository:

    git clone https://github.com/SakshamDev/portfolio-optimizer.git
    cd portfolio-optimizer
  2. Install the dependencies:

    pip install -r requirements.txt
  3. Start the backend server:

    python backend/main.py
  4. Launch the dashboard: Open your browser and navigate to http://localhost:8000.

Constraints & Limitations

  • Long-only Portfolios: Short selling is unsupported (Weights ≥ 0).
  • Fully Invested: The model enforces that 100% of capital must be allocated.
  • Asset Limits: An arbitrary concentration cap of 40% per individual asset is set to prevent extreme skewing. Max limit of 10 tickers simultaneously to ensure API reliability.

Future Improvements

  • Incorporate custom risk models (e.g., Shrinkage estimators for the Covariance matrix).
  • Add support for fractional shares and precise capital sizing (e.g., allocating a specific ₹ amount instead of raw percentages).
  • Integrate continuous deployment via Render or Railway.

About

A full-stack web application designed to compute the optimal weight allocation for a portfolio of Indian stocks using modern portfolio theory.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages