Weighting Formulas

I’m starting this thread to open discussion of weighting formulas you have been using, testing, developing, etc. This is a new area for p123 so there will be a learning curve inj getting the formulas to do what we think they will do (just like when you first started on p123 and had to get screening rules and rank factors that really did what you thought).

So if you’re having any issues or questions along these lines or just want feedback on ideas, let’s do it.

Hi Marc, your tutorial on the new beta rebalance backtester is great!

…and I’m a guy who does not like to read instruction manuals but likes to figure things out on his own.

AvgCorrel(bars) would be a useful (and perhaps popular) function.


How would you have a portfolio with position sizes ranging from 20% to 2% depending on the rank? (Ranks usually range from 98-100.)

How would one approach volatility based sizing? Something like 1/ATR(14) ?

Marc,
What simple weighting formula for ETFs would you suggest.

Here are the weighting formulae I would like to use most, and with which I’ve been experimenting (they work for setting ideal weights):

a) Eval(MedianDailyTot(65) < 200000, MedianDailyTot(65)/200000, 1). You can vary those numbers, of course. This says that if a stock’s liquidity is low, you buy less of it, but if its liquidity is high, you buy equal amounts.

b) Eval(RankPos > 4, 1.2 - 0.15*Ln(RankPos), 1). So the top four ranked stocks would have a relative weight of 1, and as you go down, the weight gets lower, but not by a whole lot–the stock ranked 5 gets a relative weight of 0.96 and the stock ranked 20 gets a relative weight of 0.75.

weight = 9*(rank)-880

so if rank is 100 you get 9*(100) - 880 = 20

and if rank is 98 you get 9*(98) -880 = 2. With a linear progression between these values.

The 9, or “slope” of the linear equations, comes from (20%-2%)/(100-98). The 880 is solving 9*(100) - X = 20. One could also solve 9*(98) - X = 2 with the same solution.

If you think you might ever have a sell rule like Rank < 90 you might want to use Eval(Rank>=98, 9*(Rank) -880,2) to avoid a negative value for the equation and setting a minimum weight.

-Jim

Probably the easiest way to get started is to work with MktCap to understand how the large-cap skew influences benchmarks against which you compare and the way the absence of it has influenced your portfolios. Also, experiment with it until you get a feel for how rebalancing can work even without reconstitution, and get a feel for things like Min/Max weights and tolerance. It’s one thing to read about all that in the docs, but its another thing to get the feel for it.

Next, move onto SalesTTM as a weighting factor (or some other thing like operating profit, or dividends paid). Now, you want to get a feel for size-based weighting that is not dependent on stock price movements (smart beta).

As to getting more complex, I think the easiest way to do it is to use Rating(“…”) as a weighting formula. Somebody asked about volatility-based weighting. Consider creating a ranking system using, as factors, various iterations of BetaFun() and PctDev(), etc. Assuming each individual factor/formula is set to lower is better, your overall model can then be a traditional higher-is-better ranking system. Then, a stock with a rank of 93 would be a lot more stable than a one with rank of 67 and would wind up with a larger weight.

Remember, ranking systems aren’t the just for sorting stocks that pass Buy rules. We already have had access to Rating(…) and Rank for use as buy/sell rues. Now, there is a third use for ranking systems – as weighting factors. Sometimes, you can use a system you design for traditional uses or, as with volatility, it may be a ranking system to you use mainly for weighting.

Take your time with this. In some ways, it’s like when you first joined p123. You start from scratch and build your way up.

For those who may not have seen it, there is a second draft doc available here on weighting strategy.


Topic 9 - Position Sizing - Weighting.pdf (2.45 MB)

Have to get some free time to Reverse Engineer on my Ranking Systems to find the recent factors that have the most current market tailwinds behind them to use as weighting, and swap out periodically. A way to cyclically adjust ports without fundamentally changing the rank and screen wiring underneath that cleared backtesting.

The Beta Rebalance platform is great. One can now eliminate all Buy/Sell Difference trades.

Below are screen prints of the Trading stats of the DM model 3ETF-Trader plus. First table is for the current version of P123. It shows that there were Tot Realized Trades=609, and Tot Sell Trades=747. Therefore there were 138 meaningless B/S Difference trades.
The second Trade stats table is from the Beta platform. Now Tot Realized Trades=614, and Tot Sell Trades=614. Therefore there were no B/S Difference trades. Annualized Return= 43.1% (old), 42.6% (beta).

Thank you, P123 Team.



:slight_smile:

Marc,
A few postings higher up I asked: “What simple weighting formula for ETFs would you suggest.”
In the meantime I had inquiries as to what formula I used.

I used a P123 custom series %AboveSMA200-SP500, which seems to work well.
Formula: close(0,GetSeries(“%AboveSMA200-SP500”)).

I don’t know how the position weight formula works with ETFs and perhaps Marc can enlighten us on this. I have 5 positions in a test ETF model and their weights are always 20% when they are bought, so obviously this weight formula does not affect the weightings of the individual positions. Anyway, how could this formula affect the weights?

One needs to have at least 2 positions in the model, obviously, and one also needs a position weight formula, otherwise the rebalancing module does not work. Perhaps another option would be to leave the formula field blank if one wants equal weight rebalancing only, but currently leaving it blank does not work.

Again thank you P123 Team for all your efforts. Perhaps you can also add a hedging module for ETF sims, which has been promised years ago.

Position weighting with ETFs is something people here may have to invent from scratch. Traditionally a single ETF is regarded as a complete self-contained portfolio where weighting decisions are done in portfolio construction. So with SPY, you have a cap weighted portfolio of …

We all know now that in the real world, it’s commonplace to hold portfolios of ETFs. The only systemic weighting approach I know of are the MPT efficient frontier derived weights (albeit with a lot of heuristic hacks since strict MPT computation typically gives crazy results.)

So i think you all need to be the pioneers for other kinds of systemic ETF portfolio weights.

As to ideas like close(0,GetSeries(“%AboveSMA200-SP500”)), well, that’s why we made it as open ended as we did; to give you opportunities, to create and test, and use ideas like that. The only question I’d ask about this, and other ideas like it is: How do the numbers work out? Can the raw results of your formula give you a set of weights that makes sense? Bear in mind you always have the choice to force things onto a 0 to 100 scale by using FRank, and you can, if you need to, work with z-scores (the statistical kind; the number of standard deviations above or below the mean).

Marc,

Yuval has been posting about this and I have followed his posts for a while. I think he would like to supplement it. I have been trying to tell him how great this is but at the same time understand what he would like to see. And I how his ideas might be implemented.

I am excited about this regardless.

For background, for a long time, Yuval has wanted to have a list of stocks to buy (based on the usual buy rules and rank) and buy them of course. He would then—by his algorithm–like to sell his lowest ranked stocks until he has enough money to buy the new stocks. If there are no new stocks to buy he sees no need to sell any of his present stocks even if the rank has declined below some arbitrary level. There are times when he would not like to trigger the sell rule Rank <90 if he does not have any new highly ranking stocks to buy.

Seems that this is a pretty good idea. Also, this may be the ideal time to implements this.

It would only require a check box. “Fund Stocks with Highest Rank First: Check box (yes no)”

The lower ranked stocks would be sold when there were no longer adequate funds for those stocks because the higher ranked stocks were funded first. When there are no funds left for the lowest ranking stocks they are sold. The sell rule would be “No Funds.” Or keep the “No Weight” because the final weight is based on available funds.

It does seem that this is rational algorithm. As rational as scaling the purchases based on the available funds or getting money from rebalancing.

One could buy according to the exact desired Tolerance. One could set a high Rebalance Minimum so there would be not buy/sell different. Or rebalance some if they want to. And the lower ranked stocks would be sold if if there were not adequate funds after funding the higher priority stocks.

So basically instead of freeing up money by by using a tight rebalance minimum you would often be selling one more of your lower ranked stocks than you might have otherwise. But other times you would not be selling as many stock but rather holding them until the money from a sale of these stocks is needed.

May be impossible to implement now. The math on this would be boringly simple. Far easier than “scaling” but I am not sure about the programming.

But you should take a look at how difficult it would be to implement. It is a pretty good idea.

Yuval, please correct me if this would not give you want you want or if you have additional ideas.

I got this idea from Yuval but I think the merits of it stand on their own.

Again, I like this regardless. I mean this as an additional option. No need to throw the baby out with the bathwater: it is a beautiful baby.

Thanks.

-Jim

Georg: The formula you provided is effectively always equally weighting the holdings. [font=courier new]Close(0, GetSeries(“…”))[/font] will always be independent of stock/ETF, so the value will be the same for every position. The only case this will not be equal-weighting is when the series is not positive, in which case it will sell all or result in an error. What are you trying to accomplish with it?

Marc,
Yes, it appears that the position weighting formula does not do much for ETFs.

Also beware of using formulas which are specific to the ETFs, such as AvgDailyTot(10). A lot of ETFs on P123 have been extended for dates prior to inception when there is obviously no data for the ETFs, other than simulated prices from their proxies.

So as per my previous suggestion: provide option to leaving position weighting field clear for equal weights. Currently you must have a formula there.

Aaron,
Thanks for your reply.
I only want to be able to run an ETF rebalance with equal weights and eliminate all Buy/Sell Difference Trades. If there is no formula in the field the rebalance module does not work so I used the %AboveSMA200-SP500 series because the series is always > zero.

Alright. In that case, I would recommend using the formula [font=courier new]1[/font] to simplify it semantically and computationally.

Yes, “1” gives the same results - works great.
Thanks

You will find in this article my findings about weighting formulas:

https://inovestor.am/testing-dynamic-weight-allocation/

Will ‘Position Weight Formula’=True also work?

I’m seeing weirdness with a port that realizes a minimum one year holding period by stalling sells (w/ NoDays>366). When I sim with sizing=‘% of Portfolio Value’ and weekly reconstitution, there are no buy/sell rebalancing transactions reported.

When I try the same port w/ sizing=‘Formula Weight’, weekly rebalancing and weekly reconstitution and formula=true, I see many small rebalances within the first year of an opening position.

I may be misunderstanding something, but I expected similar behavior. Does ‘Formula Weight’ respect NoDays?

Walter