Feature Request: FMin(), FMax() and others to augment existing cross-sectional functions

I am requesting additional cross-sectional functions to assist in the analysis of aggregates and sets.

One potential use-case is covered in a recent thread “MORE DETAILS ON HOW THE DYNAMIC POSITION SIZING WORKS IN THE BACKGROUND. AN EXAMPLE…”. But the use-cases do not stop there; I am confident that other users will find these additional functions handy.

Specifically, I am requesting the addition of the following functions:

  1. FMin(“Formula” [,scope, excl_zero])
  2. FMax(“Formula” [,scope, excl_zero])
  3. FPercentile(“Formula”, k, [,scope, excl_zero]):

Returns the formula value of the kth percentile within set. A generalization of several functions which functions identically to Excel function “Percentile.Inc” with addition of optional P123 scope parameters. For example, FPercentile(“MktCap”, 50, #All, False) would return the same value as FMedian(“MktCap”, #All, False); FPercentile(“MktCap”, 100, #All, False) would return the same value as FMax(“MktCap”, #All, False).

Likewise, it is the inverse of the Rank function. For example, ‘MktCap > FPercentile(“MktCap”, 90, #All, False)’ would function identically to 'FRank(“MktCap”,#All,#Desc) > 90.
View the feature request here.

Add to this:

LoopRank(“formula”,“k”,iterations[,start,increment,noNAs,break])

This would be useful for assessing a security’s history as its own “universe”. For example, a stock can have an attractive earnings yield with regard to an absolute threshold (e.g., NetIncBXorTTM/MktCap > .1) or to a cross-section of the broader market (e.g., FRank(“NetIncBXorTTM/MktCap”,#All,#DESC) > 90), a peer group (e.g., FRank(“NetIncBXorTTM/MktCap”,#Industry,#DESC) > 90), or to its own history. Currently, I think assessing a securities valuation relative to its own history is under-regarded on this platform. Sure, there are workarounds, but nothing so robust as being able to perform a non-parametric rank test.

For example, how do we know that 10% is an attractive earnings yield for a stock like AMZN which has no (GAAP) earnings? Well, if we wanted to look at the its current P/E versus where the stock has traded over the years in weekly increments, we could do as follows:

LoopRank(“NetIncBXor(Trunc(CTR/63),TTM)/SharesFD(Trunc(CTR/63),TTM)/Close(WeeksIntoQ*5+CTR)”,“NetIncBXorTTM/SharesFDTTM/Price”,51,5,0)

So, AMZN’s current earnings yield of 0.3% would be assessed relative to the company’s history which we can see, from the following graph, has ranged between .3% to .6% over the previous year. Thus, a very simple visual examination indicates that AMZN is expensive relative to its own history. However, there is no currently not a way to perform this easy test using programmatic methods.

//dpa


I agree that a min and max ‘factor’ function is vital. As it is - we need to use a massive series with fhist and then apply a min and max to that series.

But a min or max with a formula would be so much faster and better. My only addition would be to specify the look back period and how frequently to sample. So you could have a one year lookback and weekly sampling or 5 year lookback and quarterly sampling and so forth.

FMin & FMax shouldn’t be much of a stretch for P123. After all, it’s kinda available in the Custom Series tool as Universe Operation UnivMin and UnivMax.

As for LoopRank, I like it very much.

At one time I proposed loop stochastic as a convenience function. It would replace the stuff on the right with a call that looks something like the left-side.

LoopStoch(“GMgn%TTM”,12,4) = (GMgn%(4,TTM)-LoopMin(“GMgn%(CTR,TTM)”,12,4)/(LoopMax(“GMgn%(CTR,TTM)”,12,4)-LoopMin(“GMgn%(CTR,TTM)”,12,4))

The LoopRank seems more flexible since it accommodates the datum to rank (as ‘k’, if I’m reading things right).

Walter

I’d like to expand this request to include Daniel’s suggestion for a function which returns the k-percentile rank of a value x. See: https://www.portfolio123.com/mvnforum/viewthread_thread,11438

It is the same as Excel’s [font=courier new]PercentRank(array, x[, significance])[/font].

Translated it might look like:

FPercentRank(“formula”, value [, #Scope, #Sort])