-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comparison of Portfolio Weights and issue with "only_long" #15
Comments
Some excellent feedback here. Let me go through all your points and get back to you. |
@sarvotham the problem with only long that it is only applied in the backtest. For you to see the weights they would have to be applied by each strategy individually. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@tradytics
Firstly, thank you for putting this together. I've been working on portfolio optimization through backtesting and this is definitely a simple and great setup. As I was testing your code, I wanted to call out a few things,
The
only_long
setting does not work. Irrespective of whether this is set to 0 or 1, the resulting weights are long_short lying between (-1, 1). This is the exact command i used as per your description:python portfolio_manager.py --is_test 1 --future_bars 90 --data_granularity_minutes 3600 --history_to_use all --apply_noise_filtering 1 --market_index SPY --only_long 0 --eigen_portfolio_number 3 --stocks_file_path stocks/stocks.txt
I only changed
only_long
to1 or 0
in my tests and it doesn't alter the weights. Let me know if I'm doing something wrong.I then used the weights that were returned by your algorithm and plotted it on the efficient frontier created with over 150,000 portfolios (from random weights) on the same ohlc dataset.
Below are the weights from your algorithm,
This is what the efficient frontier looks like for the above weights with the backtest data:
For the portfolios returned by your max sharpe (Eiten max sharpe) and Eigen (Eiten Eigen PF) the sharpe ratios are 0.07 and 0.15 respectively. As you can see, the genetic algorithm weights returned a sharpe ratio of 1.78 and the starred max_sharpe is 1.63 (close, but definitely more room for optimization). The starred max_sharpe is just the best performing random weight portfolio. We can nearly draw a straight line from the risk free return to the GA point cutting through the starred max_sharpe points. I guess the GA has only cranked up the risk for higher returns.
Similary the EF for the future data is as shown below and the max_sharpe in this case is 3.78 (from random weights):
Let me know if i'm doing anything wrong running this as the performance of max sharpe and eigen portfolio from your algorithm does not correspond to the best performing portfolio even in the back testing case. There is still room to reduce risk and increase returns here.
The text was updated successfully, but these errors were encountered: