Skip to content

halim-quantlab/portfolio-optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 Optimal Portfolio Allocation Tool

This Python-based financial engineering tool allows users to construct an optimized investment portfolio using real-time market data and quantitative methods. It applies Modern Portfolio Theory (MPT) and convex optimization (via cvxpy) to generate long-only portfolios that maximize return for a given level of risk.

Whether you're an aspiring quant, finance student, or curious investor, this tool helps you analyze asset performance, visualize optimal allocation, and simulate portfolio growth with clean, professional outputs.


🔧 Features

✅ Fetches historical adjusted close prices from Yahoo Finance using yfinance
✅ Computes annualized expected returns and covariance matrix
✅ Solves the mean-variance optimization problem using cvxpy
✅ Enforces realistic constraints: long-only, fully invested (weights sum to 1)
✅ Automatically cleans tiny or invalid weights, preventing noise
✅ Visualizes allocation with a beautiful, labeled pie chart
✅ Simulates portfolio growth with backtested cumulative returns
✅ Detects and logs invalid tickers or zero-weighted assets


✅ The input is not case-sensitive and automatically trims spaces, so these are all valid:

image

✅ The default input for start date : 2020-01-01 image

📈 Example Output

  • 💼 Optimal Portfolio Allocation:

image

(excluded 0% weight from chart)

  • 📉 Portfolio Metrics:

image

  • 📊 Visualization:
    • 🥧 Clean pie chart with [TICKER] labels

image

  • 📈 Portfolio value curve over time

image

  • 📈 Efficient frontier plot

image


🧪 Technologies Used

  • Python 3.x
  • yfinance – market data
  • cvxpy – optimization modeling
  • numpy, pandas – data analysis
  • matplotlib – charting

About

A Python-based tool that applies Modern Portfolio Theory to optimize asset allocation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors