Hi,
in the course "AI for portfolio management: LSTM Networks" you show different examples of optimizations and backtests in sections 5 and 6.
- In the long-only, no leverage version of section 5, the code provided generates an equally-weighted portfoliofor the first 90 days, and from then on a different set of weights that are obtained from the optimization based on the returns of the first 90 days (i.e., walk-forward logic). This is consistent with what explained in the previous video, and with the idea of avoiding any form of look-ahead bias.
- But then, in the other examples (e.g., long-short with no leverage, long-short with leverage, etc... in section 6), the weights used in the fisrt 90-day-period are all different across assets. I would have expected to use an equally-weighted portfolio for these first 90 days as well (otherwise how are we able to get such weights and calculate the strategy returns without falling in the look-ahead bias trap for these first 90 days?).
Maybe the logic of the code is not very clear to me. Can you please better explain why in the first case we start (as expected) with an equally-weighted portfolio for the first 90 days, while in the others we start with a different set of weights for the same initial 90 days, and hence how we avoid look-ahead bias in this second case?
Thanks for your help!
Luca
Hello Luca,
We have used the same logic while creating different portfolios, i.e. starting with the equal weighted portfolios.
In fact, you can print the weights dataframe to check.
For example, we are using the code,
returns_eq_minus_1, weights_eq_minus_1 = get_optimal_weights(asset, 90, lower_bound=-1, allocation_type = 'eq')
to create a "Long-Short Constraint with No Leverage" portfolio.
Here, the weights_eq_minus_1 dataframe stores the weights for each of the assets for a particular day. And if you print this dataframe, you will see that it is equal-weighted initially.
Hope this helps.
Hi Rekhit, you're right, I was looking at the wrong dataframe. Thanks for your support!
Best regards,
Luca