Dynamic Position Sizing and Margin

Why is it that I have a port sim with no margin selected yet when I backtest it using Dynamic position sizing it frequently uses leverage > 1. I would think that shouldn’t be possible. I’ve only found two ways to contain the leverage to <1

  1. Make the Weight Constraints max equal to an equal weight % of the port (10% max for a 10stk port) (This doesn’t give me dynamic sizing)
  2. Select “Automatically adjust new transactions to remain at 100% invested” (Not desired if I want the port to hold cash when there aren’t enough stocks that pass the buy rule)

Neither of these options give the outcome I want when looking at exposure and buy weighting in the transactions.

I was under the impression that setting the Weight Constraints Min/Max was the top and bottom scaling factor for the weighting formula. So if I had a 10stk port and set the min to 5% and Max to 15% that would only allow for a 10% variance when weighting new buys and at rebalances provided the “Min Rebalance Transaction” was exceeded. Or more bluntly, no Stk would be given >15% weight or <5% weight in the port at rebalance.

What am I missing?

This document might help: https://www.portfolio123.com/doc/side_help_item.jsp?id=62

You are correct that there are exactly two ways to avoid margin when using dynamic position sizing, and you have identified them both. It’s pretty clear to me that you’ve been experimenting with the feature a great deal and have a pretty good understanding of it. I don’t think you’re “missing” anything. The reason it’s necessary to use margin on occasion is simply that if you’re not using one of those two methods, the mathematics of position sizing basically demands margin use or else you’ll end up with buys that are radically different in size from one week to another even if the formula behind those buys is the same, simply based on the amount of cash there is in the portfolio.

What I do is adjust for margin in Excel after running the simulation. But if you want the portfolio to hold cash on occasion, that’s not a good option either. I would advise playing with option number 1) a bit more. The weight constraints are primary (as you suspect): they’re imposed prior to the formula, and the formula operates within those constraints.

Does the CashPct buy rule work with this type of port? If so, then the solution might be to have a buy rule CashPct>5. Under normal circumstances, you would hold 5% cash but it provides a buffer for when the orders overshoot the expected prices.

Steve

Steve, Your suggestion works to avoid negative cash (margin), but cannot be used with Formula Weight, only with Portfolio Weight rebalancing. However, it reduces return a bit.
Thanks

Cash reserve is a feature that P123 should offer for both Formula Weight and Portfolio Weight rebalancing. Not everyone wants to invest with a margin account and having orders bounced due to insufficient funds can be more than inconvenient.

*** EDIT *** “Not everyone wants” should be “Not everyone wants or is able to”. Not all investors qualify for margin accounts.

Steve

The issue of course is that most/all tax sheltered accounts don’t support margin and these are very commonly used accounts for investing/trading. Smart weighting holds an advantage provided a designer finds a reasonable edge. I do understand the issue with weighting new positions accurately and therefore requiring margin, however I would imagine there must be an another way. Perhaps an option to only scale new and rebalanced positions based on the ports cash position (after sells of course) rather than the ports value. Yes this would lead to an incorrect amount used on some new positions but I would rather have a skewed weight with no margin then an accurate weight with margin (as an option).

You’re right that cash isn’t the best option when there are unfilled buys, but we don’t currently have a sweep cash feature at rebalance. It would be great to have the choice to take all the unfilled positions and buy MINT or TLT … (Canadian ETF options would be great to, are we getting them with the new Factset data?) … until the next rebalance.

I was thinking the code would flow something like this:

Port = $100K no margin option
Ideal holdings = 10
Min Weight = 5%
Max Weight = 15%
Rebal min = 1% ($1k)

  • Current holdings = $100K (10 positions)
  • Sell Rules Value = $24K (-3 Positions)
  • New positions to reach ideal = 3
  • Buy Rules Positions = 1 (no more pass the buy rules)
  • Rebal port based on 8 positions with remainder in cash
    → The 2 empty cash positions default to an equal weight value of (port_value/ideal_positions) = 100K/10 = 10K each
    ->> The rebalance transaction min would have to be triggered before action taken (same as now).
  • Positions available for new weights = Buys + min_triggers
  • Weight avail positions with aggregate position value
  • Display rebal buys/sells

The above example only leaves $4k for the new position before rebal.
e.g. … After the rebal formula there are only 2 stocks that meet the Transaction Min. Therefore only 3 stocks are adjusted in the port after the sell rules. Let’s say the new position ideally would hold a 15% weight and the 2 rebal positions also get adjusted up for higher weights. The 3 positions get weighted but this time as a group of 3 using only the aggregate value of the 3. Yes this would mean that they likely would not be at 15% weight in the port but at least they would be weighted relative to each other. Possibly at next rebalance they would be adjusted if they met the min transaction value. This would likely lead to a little bit higher port turn over but I don’t feel it would be significant. Commissions are very cheap, slippage could be a concern but these are rebalance amounts not full position amounts so they would have much less effect. Also if a port is designed to scale to cash in down markets this allows you to do that as an equal weighted position. I would be much less worried about my stocks holding underweight positions during down markets and that is the only time the port is not 100% invested. I think it’s a fair trade off if the above can be coded to work.

Thoughts?

You’ve come to the crux of the matter here. Personally, I’d rather have an accurate weight with margin than a skewed weight with no margin. But we’re giving users both options. If you can’t live with margin (and, by the way, the margin amount is very low–almost always less than 10%), either adjust your maximum weight to provide a cash buffer (for a ten-stock-max portfolio, adjust the maximum weight to 10%) or check the “Automatically adjust new transactions to remain at 100% invested” circle.

I use a live strategy with automatic rebalancing and trade it on IB via Invest. It has the margin problem (which, by the way, I’ve been struggling with for well over a year, and feel like I only understand it fully now). But it doesn’t present real problems for my trading. Occasionally a buy order will get only partially filled, but that’s OK.

For the particular situation you’re describing, I would advise you to adjust the weights down to a minimum of 3% and a maximum of 10%. You’ll get exactly the same diversion in weights between your largest and smallest positions (3X) and you’ll be holding cash when the number of positions falls. If that means you’re holding too much cash at other times, you can adjust the weights back up–experiment a bit with it. Keep in mind that the minimum and maximum weights are the primary constraints–the formulas are applied after setting those. So (I’m not 100% sure this is the way it works, but I think so) if your rebalance formula is, say, MktCap, your $2 billion stock won’t have a weight of 10% of your $20 billion stock if your minimum is 5% and your maximum is 15%. Instead your $2 billion stock might have a weight of 5% and your $20 billion stock might have a weight of 15%, making it only a 3X difference rather than a 10X one. If you want a 10X difference, you need to adjust the weights–lower the minimum to one-tenth of the maximum and that’ll do it. By adjusting minimums and maximums, I think you’ll be able to get the weighting that you want while still having a cash buffer when the number of positions gets low. Fiddle with it a bit and let me know if that works or not.

From what I’ve been able to figure out. It looks like I can get the port to operate how I want with a Min/Max Weight constraint for 5/15% and not enter into margin, however you have to be willing to put up with a warning message to recommend you increase the max weight. The system is trying to keep you as close to fully invested as possible and 15% was all I would allow a position to be. This seems like common sense since I would never want all my eggs in one stock if the trading system only had one stock that passed the buy rules. Maybe P123 could put in a check box beside Max Weight to accept the risk of not being 100% invested at all times anytime the max weight value is below 100%?



I’m so glad you were able to get this to work for you. The warning is, as you’ve probably figured out, just a warning–it doesn’t have any effect on your simulation’s results. You can safely ignore it.