Portfolio weighting based on available equity
Author: sburgener
Creation Date: 9/5/2012 11:34 AM
profile picture

sburgener

#1
Hi,

I am backtesting a strategy where I need to rescale the trades according to the available equity level. In particular I would like to have my portfolio fully invested at all times, with a reweighing of positions every time I enter (or exit) a new position, in order all positions are always equally weighted. It seems like the PosSizer SpreadEquityEqually doesn't serve my purpose as I would have to close all positions every time a new position is entered (or exited) and reenter in all the remaining ones, which would cause unneccessary trades and thus too high commissions.

I have been looking through various posts in your forum and it seems like there are two alternatives:
1) Interacting Dynamically with Portfolio Level Equity
2) Manually keep track of the portfolio equity level for each bar (in the script) as explained in the post Portfolio Equity Tracker.

In the second post above (2), you mention that the 1st method (1) might have inherent problems such as slowness and imprecision. Is this still the case or have these issues (especially imprecision) been adressed?

Also, as an alternative, would it be possible to use a PosSizer to achieve the above (which would require a potentially different % weight for every bar, which seems not possible)?

So, my questions are:
- Are all three methods I mentioned above feasible?
- Among these three, which is the most robust and which would you recommend?

Thank you in advance for your help.

Best,
Seb
profile picture

Cone

#2
(We really need a FAQ for this.)

QUOTE:
reweighing of positions every time I enter (or exit) a new position, in order all positions are always equally weighted.
You can't get there with a PosSizer, which only sizes new Positions.

The problem is in the fact that Wealth-Lab is Position-based. Once you have a Position, you can only do 2 things with it: 1) split it (which creates 2 positions), or 2) exit it. To reduce shares you can split a Position and exit one of the lots. You cannot add shares to a Position - you can only enter another Position, and then manage all the individual lots.

A feasible approach is to turn off commission costs, and create a Strategy (looping through the DataSetSymbols on each bar) that exits all Positions whenever a reweighting is required, and then re-enter the Positions you still want to hold.

Another less-optimal way is to write the Strategy on a symbol level, exit Positions on every bar and re-enter the ones you intend to keep.

Eugene will probably add to this...
profile picture

Eugene

#3
"Interacting Dynamically with Portfolio Level Equity" could produce imprecise results at the time the post #2 was written. Since the issue was addressed in v2012.03 of the library, it's considered reliable. However, I have concerns regarding the solution's applicability for your task mainly for performance reasons. The "equity interaction" class has to loop by historical positions in order to function, and, as Cone pointed out above, you might be creating lots of positions due to the rebalancing, so the solution's performance might not be optimal in this case.
profile picture

sburgener

#4
Thanks for your prompt reply Cone and Eugene.

The easiest seems indeed to use the PosSizer SpreadEquityEqually. As I would have to set commissions to 0, I could then create an artificial dataSeries replicating the sum of all my commissions and output the latter in a chart. At least I could have an idea of my overall commissions and subtract the latter amount from the total PnL.

Alternatively and given the fact that I only rebalance my portfolio once a month (and occasionally twice), would you rather use "Interacting Dynamically with Portfolio Level Equity" (1) or keep track of the portfolio equity level manually (2)?

Thanks again!
profile picture

Eugene

#5
QUOTE:
The easiest seems indeed to use the PosSizer SpreadEquityEqually.

Yes, seems like that - in conjunction to Cone's suggestion above.
QUOTE:
Alternatively and given the fact that I only rebalance my portfolio once a month (and occasionally twice), would you rather use "Interacting Dynamically with Portfolio Level Equity" (1) or keep track of the portfolio equity level manually (2)?

I'm not familiar with (2). With (1), script execution speed depends on the number of taken trades.
profile picture

sburgener

#6
Thanks again to both of you. I will give it a go.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).