Back to Community
Portfolio Optimization Using Genetic Algorithm

In this code a genetic algorithm is used to perform a mean-variance portfolio optimization. In this example, at the beginning of each year, a portfolio of SPY, GLD, AGG and LQD is optimized to find the tangency portfolio from the efficient frontier (the portfolio with the highest sharpe ratio) using data from the past 3 years. This portfolio is hold through out the whole year re-balancing it every week.

The code can be modified to trade other assets, just change the asset list on line 137.

Clone Algorithm
117
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 583c503efc0611444a315ad9
There was a runtime error.