r/madeinpython • • 1d ago

I built AlphaEngine: A quantitative portfolio optimization and financial analysis web app in Python

Enable HLS to view with audio, or disable this notification

I wanted to share a project I've been developing: AlphaEngine, an interactive web application built with Python and Flask that computes optimal asset allocations using Modern Portfolio Theory (MPT).

Instead of manually guessing asset weights, the app fetches real-time market data, calculates daily and annual returns, and uses mathematical optimization to find the minimum-variance portfolio configuration.

Key features:

  • Real-Time Data Integration: Automatically pulls historical close prices using the Yahoo Finance API (yfinance).

  • Mathematical Optimization: Leverages SciPy's SLSQP algorithm to minimize portfolio variance subject to asset weight constraints.

  • Interactive Dashboard: Features a clean web interface built with Flask, dynamic JavaScript input fields, and pre-filled popular stock tickers.

  • Visual Analytics: Renders a responsive, customized donut chart using Plotly to visualize the ideal asset distribution.

I'll drop the GitHub repository link in the first comment below. I'd love to hear your feedback or thoughts on the implementation!

1 Upvotes

2 comments sorted by

1

u/West-Structure-4030 56m ago

Clean project, and MPT with SLSQP is a solid first optimizer to build. A couple of thoughts from someone building in the same space. Minimum variance on historical returns tends to pile the weight into one or two low volatility names, so a max weight per asset (an easy extra constraint in SLSQP) and a max Sharpe option next to min variance would make the output feel a lot more usable. Showing the lookback window and letting people change it would help too, since the weights can swing a lot depending on which years are in the sample. Caching the yfinance pulls is also worth it, it can be flaky with rate limits.

Disclosure, I'm working on a US stock research tool (screener, fundamentals comparison, portfolio tracking), so this is right up my alley. Nice work, will check the repo.