OPEN BETA: 'Formula Weight' Position Sizing Method

In the same way IndCount is representative of the industry classification of the current stock, CapCount is representative of the market cap classification of the current stock. MicroCount, MidCount, SmallCount, and LargeCount are like CapCount, but resolve to 0 when the current stock doesn’t match the classification of the factor.

Thanks!

The only problem I’ve noticed so far with the beta is that it does not remember the universe desired, giving a “No universe defined” error on each rerun unless I specifically set the universe before the rerun.

My experimenting so far with the beta is focused on eliminating the small, inefficient buy/sell transactions in the current system using Allow Sold Holdings to be Rebought set to Yes and a Sell rule of True, to attempt mirroring the actions of a screen. I am simply trying to get results similar to a screen’s results as a starting point before manipulating the logic. Here’s what seems to work for me; at least it seems to be working like I intended:

To access the Advanced Setting that allows for a minimum transaction size, set Sizing Method to Formula Weight. If you then want equal weights, you can then enter a constant like the number 1 in the formula box.
Set Allow Sold Holdings to be Rebought to No; it is not needed (for this exercise, but might be handy for specific models). It will charge the transaction costs on each sale and repurchase.
Mirror all Buy Rules as Sell Rules, to reflect the screen’s logic. For example, if you have a Buy rule like EPSExclXor(0,TTM)>0, use a Sell Rule of EPSExclXor(0,TTM)<=0 or something similar. These can be manipulated later to examine the effect.
With Rebalance Minimum turned off, running the model could result in a lot of small and inefficient rebalance transactions.
Set Rebalance Minimum to On and enter a value that reflects the minimum transaction size you desire. I am using a dollar minimum because of fixed transaction fees. Rerunning the model now should show the effect of getting rid of the transactions smaller than you specified.

If anyone sees an error in how I am doing it, or has further suggestions, please comment!

Thank you, Portfolio123 staff, for developing this improvement. There are a lot of added capabilities to comprehend and consider. Pandora’s Box, indeed!

I’m having trouble getting the formula weight to work. As my formula I’ve been using variations of rank (e.g. rank - 90, rank - 98, rank - 99) and rankpos (e.g. 1/rankpos). On the rebalance (every 4 weeks), it rebalances accordingly, but on the buy/sell (weekly; I have no buy rules and only one sell rule: rankpos > 27) it buys every new stock with an equal dollar amount rather than by weight. I can’t figure out what I’m doing wrong.


Yuval,
If RankPos = 1 then 1/1 = 1 or 1%. A lower RankPos with be even lower than one. E.G., a RankPos of 5 will give 1/5 or 0.2%. All will trade at the same weight of 1% (or perhaps scaled later but all the same). One could think 0.10 is 10% but the way P123 is doing this is consistent with the Rank weights.

If this is the problem then 10*(1/RankPos) should work. A quick test on one of my sims gives different buy sizes with larger purchases for the stocks with a higher RankPos using this formula.

-Jim

No the problem was that reconstitution without rebalance invests funds equally among new positions. There doesn’t seem to be a way around that. I would prefer to reconsitute every week with variable weighting and rarely rebalance my existing positions–maybe every three months. Will that be an option in the future, even if it isn’t right now? In the meantime I suppose I can stop the rebalancing by setting rebalance minimum to 100% or the tolerance to 100% . . . But it would be nice to be able to rebalance once a month or once every three months while reconstituting every week . . .

I’ve been fiddling with the tolerance and rebalance minimum fields and don’t understand how they differ. If I set tolerance to 40% and rebalance minimum to 2.5%, I get tons of rebalancing for deviations that are way less than 40%. Does rebalance minimum overrule tolerance? If I set them both to 40%, I get much less rebalancing . . .

I think you’re making this too complicated. I believe you can tear this weighting principle back to screener, as in Weight(“formula”, [etc]). And if you really want to up the game, in Ranker allow Node(Weight(“Formula”)) or something…

Good morning to all those who are much cleverer than me. I base position size on risk. I use the following 2 basic methods, both derived from Van Tharp and both well known. Is there now a way of doing this via P123 position sizing?

  1. Percent Risk Position Sizing

The formula is:-
Position size = (CE * %PE)/(stock price - stop price)

Where
CE is the current portfolio equity.
%PE is the percentage of portfolio equity to risk per trade.

I like to determine the initial stop by reference to the stock’s ATR (eg 3 ATRs from the current low).

So, for example, if portfolio size is $100,000 and you are willing to risk 2% per trade, the stock price is $20 and the stop loss is $19, you buy 2,000 shares.

  1. Percent Volatility Position Sizing

The formula is:-
Position size = (CE * %PE) / SV
Where
CE is the current portfolio equity.
%PE is the percentage of portfolio equity to risk per trade.
SV is the stock’s volatility (by reference to the X period ATR of price).

So, for example, if portfolio size is $100,000, you are willing to risk 2% per trade and the stock’s volatility is $1.25, then ($100,000 * 2%) / $1.25 = 1,600 shares.

Steve

OK, I’ve played around with this a lot. I have a few problems.

First, I don’t think the “tolerance” button does anything at all, as far as I can see. I’ve varied the settings a lot and can’t see what it’s doing.

Second, the purchase amounts are so crazily far from the “ideal” that they make no sense. I have a situation where in one week the ideal is 7.38% and it buys $214K of a stock, the next week the ideal is 3.95% and it buys $203K of a stock, the next week the ideal is 5.12% and it buys a whopping $533K of a stock, and the next week the ideals (for two stocks) are 7.41% each and it buys only $156K of each stock! Even if the portfolio total has varied quite a bit, it certainly hasn’t varied to that extent (I’m working with a 16-stock portfolio).

Third, I want to vary position sizing when buying every week but I don’t want to rebalance my existing positions–I like to let my winners run up and my losers run down–so I set the “minimum transaction” to 200%, which seems to do the trick. There should be an easier way to do this: you should allow us to reconstitute weekly but rebalance every three months.

Fourth, every time I run a new simulation I have to reset my universe.

Fifth, the trading system tab when the sizing method is % of portfolio value doesn’t show the buy constraint.

I’m hoping these are bugs that can be fixed. If not, I don’t think this is an improvement at all on the old way of doing things. If purchases are extremely far from the ideal from week to week depending on how many positions are sold and how big those positions are, it’s better to have equal weight with a buy constraint than to have variable weight with no buy constraint.

I might add to the possible bug list that “Minimum Position Weight” may not be doing what is desired. Specifically, when I use the formula 20-RankPos the sim ultimately sells the position due to “No Weight” even when I have a “Minimum Weight Position” of 3. The workaround I have used is Eval(RankPos < 20,20-RankPos,3) which causes a sell, as desired, using the sell rules. This is what I would have thought would happen when putting Minimum Weight Position = 3. The “workaround” works fine if “Minimum Weight Position” has another purpose.

I have seen some benefits from variable positions based on rank in models with a larger number of positions (e.g., 25 or more stocks) as you would expect. Why would you think a stock with a RankPos of 25 would perform as well as a stock with a RankPos of 1? For those of us who do not always want to buy the same amount of a stock, or for those who may want to scale out of a position, this will be a helpful addition.

-Jim

Thanks to the P123 team, nice work. Any chance you’ll add this functionality to the Screener?

I’ve spent some time with the new weighting feature and am reading Marc’s tutorial PDFs. I’ve been waiting many years for this feature to be introduced, hurrah! (And believe me, I’ve tried every possible workaround on here for years to get there, short of this new feature)

I have practiced Dynamic Position Weighting for 30 years running money. It’s the absolute basis for my portfolio diversification.

In the past I have used Excel Solver to accomplish this. Selecting one primary factor to max out while manipulating several sub-factors to push the primary. Typically, if I have a 20 stock (buckets) portfolio at rebalance I would sell several positions not contributing. So, say then I am left with 5 open buckets. I would freeze the weights of the existing positions and present up to 50 stocks to fill the 5 buckets, using solver as above. Max the primary by manipulating the weights of the new 50 stocks using sub-factors. Eventually finding 5 positions that push the primary factor, and sub-factors, higher and fill the empty buckets.

Simply put in P123 terms. Perhaps I want a high average Rank . So I sell the laggards and by the top 5 by rank. This pushes the overall portfolio average rank up. I can push it further by overweighting these 5 new positions.

Now, in reading Marc’s tutorial I came across this:

Most user will choose rebalancing intervals that are equal to or more frequent than
reconstitution intervals.
• Note, though, that the platform will allow you to reconstitute without rebalancing. If
you choose to do so, positions not sold will retain their current weightings and new
positions will be equally allocated
based on the available funds.

In my opinion, for tax and transaction cost reasons, as well as there could be a position(s) on a rocket uptrend, it makes no sense to rebalance existing positions beyond outright closing the position, or if they become uncomfortably overweighted (Weight>X).

But, as highlighted above, if the existing remaining positions are kept at current weight then “new positions are added at equal weight”. This is illogical.

So, my 2 cents, allow the weighting algorithm to vary the weight of new positions to maximize whatever Formula Weight the user chooses. Such as Rank>90, or… Frankly you’ve made this overly complicated. Weighting would be so much better with a simple rule If x then weight X. Plus, the real gold is in dynamic weightings in ranker, should that ever happen.

Try setting “Rebalance Minimum” to X%. Seems to accomplish what you are wishing for: at least for my sims.

You can also change “Total Drift Tolerance” (and probably should). But “Total Drift Tolerance” serves 2 purposes. It does change the Rebalance Minimum but also does what “Buy Constraint From Ideal Size (+/-)” does for new positions—it does not affect just rebalancing. It also affects new purchases.

Total Drift Tolerance and Transaction Scaling are not intuitive. And frankly, I have not looked at this close enough to know if I would recommend any changes. But it absolutely has to be there in some form when automating variable positions.

If I sell one very large position and the port has me replacing it with a very small position—say 1/10 as large—what should the port do?
Clearly, this is possible with a 10 stock portfolio and a position formula of 11-RankPos. You could easily be selling 10 times as much as the “Ideal Weight” of the new position. It could even be worse if you are selling multiple stocks and buying only one stock: which can happen. I believe P123 uses fairly standard normalization methods—which someone at P123 seems to understand very very well—to address this.

So you have to ask yourself: do I want to leave money in cash? Should I deviate from my “Idea Weight” and use all of my cash or do I want to hold some cash until the next rebalance? If I do deviate from my ideal weigh how much do I want to deviate? Maybe I should rebalance everything and get everything in the exact proportion that I want. That way I can be 100% invested with everything weighted exactly like I want.

I have more to learn on this and I cannot confirm that everything is working as desired. Indeed, there are some obvious bugs in this beta. I have 2 goals. 1) I want to be fully invested without leaving any money in cash. But I also want to vary positions sizes. 2) Rebalance minimum takes on new importance if I am adjusting weights as the metrics for my stocks change—which is what this is all about. If I buy a stock with RankPos 1 do I want to change the position size as its rank position drifts down to 70? Looks like scaling out does help for many of my ports.

But I cannot be 100% invested and approximate my desired (and varying) position weights without some rebalancing. The only question for me is: will I be able to set this in whatever imperfect way I wish? I’m not sure yet, but maybe.

-Jim

Yes, I have tried tweaking the min-max rebalance %. It seems to honor the min% however if I set a min 3% and a max 10% for a 20 stock port the resulting buys come back equally weighted within a few decimal points.

Nevertheless this new feature is a step in the right direction for sure.

There is only “Rebalance Minimum” near the bottom. No Maximum. Not to be confused with “Minimum Position Weight” and “Maximum Position Weight.”

I was addressing only this concern:

-Jim

I strongly agree with Steve. I don’t want to rebalance my existing positions. I only want my initial buys in a simulation to reflect my actual buys in real life. If I’m buying a stock with low liquidity, I’m going to buy a lot less of it than a stock with high liquidity, because it’ll be a lot harder to sell down the road. Jim makes some excellent points as to how the new set-up is configured. The real problem is the inflexibility of the # of stocks. With the old system, your portfolio could have a few stocks more or less than would be justified by the percentage depending on the buy and sell rules and weight variations, but every buy would be within 20% of the desired weight. Now the only way to get a buy to be within 20% of the desired weight is to rebalance all stocks every time you want to buy something.

But the designers of the new system, I believe, misplaced their priorities. In the new system, the absolute #1 priority of a portfolio is that it have a certain number of stocks. It follows, therefore, that if you want to have unequal buys that are consistent from week to week, you have to rebalance the existing holdings, otherwise you’ll end up with weird things happening like selling an overweight position and replacing it with an overweight position. I think the priority should have been unequal buys, and who cares if the number of stocks in the portfolio varies somewhat. The easiest way to accomplish this would have been to make the Eval(Weight . . . formula work for the buy rules rather than only for the sell rules.

Yuval,
I know you have spent a lot of time looking at this.

I am surprise that setting “Tolerance Limit” to 0% (or 20%) and “Rebalance Minimum” to 10,000% does not accomplish this. And, of course, I would get rid of anything that says “scaling” for this port. A quick look at one of my ports suggests this gets rid of the rebalances. The purchases look close to the idea weights but I did not pull out my calculator and my port is probably a lot different so it would not matter anyway.

P123, does normalize behind the scenes which is usually good but may be a problem here.

In any case, if this is not a bug then we should ask P123 what they were thinking on this. You should be able to accomplish this (and more) before it goes to live, IMHO.

You should be able to pick a weight based on a liquidity formula and have it stick as close to that weight as you desire.

-Jim

Thanks Yuval for the +1, and I agree with your comments about rebalancing.

I know I’m beginning to sound like a broken record, but all we really need is a factor to set a position weight. Weight(“formula”,%wieght,etc). This could be put as a buy rule and solve this weighting thing once and for all.

Furthermore, a Weight Factor could also be used in Screener, Series and Universes for testing. It would be a powerful thing to have available.

Finally, Dynamic Weights in Ranker would be nuclear.

By the way, Steve, here’s a way to kind of simulate having a weight formula in a buy rule. Let’s say you want to have stocks with formula $X less than 10 be half the weight of other stocks and you’re using a weekly rebalance. Add a sell rule as follows: Eval(Weight > 0 and NoDays = 7 and $X < 10, 0.5, 0). This will sell half the shares of each stock with formula $X less than 10 one week after buying them. Assuming you’re holding stocks a lot longer than one week and don’t mind paying extra transaction costs, it’s somewhat close to having a “Weight” buy rule. The “Weight > 0” part is to fool the system; it won’t work without that. It also won’t work if you move the other conditions with "and"s outside the Eval parentheses. - Yuval