Hi,
I am trying to write a proper momentum portfolio simulation, rather than the simple examples on Quantopian.
For those who aren't up with it, the correct use of momentum involves a set of overlapping sub-portfolios. I have implemented this using python classes where each class represents one of the overlapping sub-portfolios.
The same security could be held in more than 1 subportfolio. I resolve this by allowing each subportfolio to store an internal object containing all the orderids it has issued.
This all works fine until there is a stock split. When I want to liquidate a subportfolio, I get back all the orders it has placed, and for each one, obtain the quantity (stored in amount), and sell that amount. Unfortunately, when there is a stock split, it appears the actual portfolio gets correctly adjusted by quantopian, but the order amounts are not adjusted.
Example: If I bought 1000 of XYZ into subportfolio 1, then that orderid for XYZ shows amount of 1000. If 6 months later, I want to liquidate portfolio 1, I get_order that orderid, and it correctly shows 1000. If in the meantime there was a 2:1 share split, then my actual portfolio only contains 500 XYZ. Selling the original 1000 then makes me short 500.
Essentially, the order amount hasn't been adjusted, but the portfolio quantity has. In the overlapping portfolio structure, orders could have been issued for XYZ from several different subportfolios (subportfolio1, subportfolio2 and subportfolio3 for example), so there appears to be no way to identify how many XYZ should be sold when closing a specific subportfolio - each subportfolio has correctly stored its orderids, but they do not contain the updated quantity after the split, only the original quantity)
I would appreciate any thoughts on how I can resolve this problem.
Cheers,
Bruce