David:
Regarding cross-sections, FPctile aside, we did have some internal discussions about adding a scope which could be used in sell and weight rules. Namely, being able to evaluate over the current holdings exclusively would allow for better introspection and more robust systems. This is not currently being developed, but it may be requested as a feature.
Where are you getting negative weightings? Is it terminating the backtest? If not, there’s a problem we’ll need to look into.
I saved off a version of the PortSim which results in negative weights. I will no longer make any changes to it. Negative weights appear to be only for very low priced “penny” stocks.
The “Weight Constraint” settings appear to be the culprit. When I set these to 0% and 100%, there does not appear to be negative weights.
Attached image shows most recent holdings; there were previous iterations with much more exaggerated negative numbers (i.e., < -25%), but I have been unable to replicate weightings of this magnitude.
So, the code to compute shares and fees from an amount was flipping the sign in that particular case due to the low price and the way the commissions were being applied. I revised it to compute the shares in a more sensible fashion for that exceptional case (not affecting computations that would succeed with the old method), so you should never see negative shares again.
Hi all and thank you for your responses and / or examples.
Sorry for the delay in following-up - I have been tied up for the last few weeks with well … oh… work.
@Aaron:
While I am in favor of pseudo-code for the same reason as the others, I must confess I struggle to understand this one finely enough (I do not know that language - Java?).
I get the broad gist but I do not comprehend the details well enough
Would you mind articulating it in a more “universal” pseudo code and precising the “assumptions/starting points” (e.g. what is ideal[0]?)?
Adding this in the appendix of reference document would be very helpful. Thank you in advance
@all:
Going back to the example I mentioned in the initial post
Assume you have set Min weight = 5% ; Max weight = 15%
if you have a buy condition that prevents buying for an extended period of time (e.g. bear market) → say, you end up one day with 5 positions (over time, the portfolio sold some stocks but is forbidden from buying new ones)
You will typically end-up invested significantly more than 50% (ie somewhat closer to 75% = 5 * 15%).
My concern is that it means a very high concentration risk on these 5 stocks (if one goes bust) - especially at a time of market stress (bear market)
I tried to tie the cash invested to the # of holdings but I do not think it is possible with Active weighting. We would need Max Weight to also be dynamic e.g. Max Weight = ‘eval(Bear market,10%,15%)’
Solution would be an easy one if there were a “Portfolio Weight” formula which tied total exposure to some formula; would also be useful for market timing.