New FRank revisions and updated documentation

The revised FRank() is live. It’s has a simpler parameter list and a new functionality with the #Param type. Here’s the new documentation

FRank(‘‘formula’’[,type,sort]): Ranks stocks based on a formula and returns the percentile.

Parameter ‘type’: Determines how stocks are grouped before ranking each group’s constituents from 100 to 0.

Values	STOCKS	ETFs	Description
#Universe   Y	Y   Ranks within selected universe
#Industry   Y       Ranks within selected Industry
#Sector	    Y       Ranks within selected Sector
#Previous(1)Y   Y   Operates on the results from previous rule
#GroupVar(2)   Y   Y   Operates on groups based on value of variable @Group
#Family         Y   Ranks within each ETF Family
#AssetClass     Y   Ranks within each ETF Class
#Region         Y   Ranks within each ETF Region
#Method         Y   Ranks within each ETF Method
#Style          Y   Ranks within each ETF Style
#Size           Y   Ranks within each ETF Size
#ETFSector      Y   Ranks within each ETF Sector

(1)Available only in the Screener & Custom Universe (2)Not available in Ranking Systems

Parameter ‘sort’:
#ASC- ascending
#DESC- descending (DEFAULT)

Examples:
Rank within each sector by the ratio of the latest price divided by price 5 bars ago (1 week return)

FRank("Close(0)/Close(5)",#Sector,#DESC)

Rank in two groups: stocks that have a yield and stocks that do not. It then returns the two highest ranked stocks from each group

SetVar(@Group,Yield>0) 
SetVar(@rank,FRank("MktCap",#GroupVar,#DESC)) 
@rank=100

Logic:

-The formula in quotes is evaluated for all the stocks in the universe. The formula could be a single factor, like “MktCap” or more complex like “Close(0)/Close(10)”.
-The results are placed in an array
-The array is sorted using the ASC/DESC setting. If you selected within a sector or industry, multiple sorts are executed for each industry or sector.
-A percentile is assigned to each stock. This is the value returned by FRank. For example: if your universe is 500 stocks the top stock in the array gets 100, the next one 100 - 100/500 = 99.8, the next one 99.6 and so on. If you rank within and industry/sector you’ll have multiple stocks with 100, and the rank-delta’s (the rank difference between two consecutive positions in the array) will be different depending on how many stocks are in the industry or sector.

Special cases:
-NA’a are always placed at the bottom of the array and all get the same percentile. The percentile
-Equal values get assigned the same percentile. The next non-equal value gets a percentile equal to: ( percentile of the equal values) minus (number of equal values * rank-delta)

Marco,

I don’t understand why I am getting an error message “ERROR: Value #Universe is invalid for the ‘type’ parameter in FRank()” for “FRank(“Prc2SalesIncDebt”,#Universe,#ASC)>95” in my ranking sys http://www.portfolio123.com/app/ranking-system/173511 when I run screener http://www.portfolio123.com/app/screen/summary/54340?st=1. The format of the FRank seems to be correct and I check it over and over again and I cannot find where the error is. Could you please help?

Many thanks.

Al

Change #Universe to #All

Steve

FRank should support both #All & #Universe for backwards compatibilty in the first parameter. Sorry about that should have a fix soon. In the meantime use #All (I updated the documentation)

Only have time now to check posting. Busy week. Thank you Steve and Marco for the reply. The ranking sys is working now.

Al

I have a screen with rules like this:

mktcap >= fmedian("mktcap",#all, #previous)
isna(Pr2BookQ, 0) > 0
isna(Pr2CashFlQ, 0) > 0

to restrict the set of stocks, then a rule like this:

SetVar(@P2B_r, frankOLD("Pr2BookQ", #Industry , #ASC,#Previous))

to get a ranking by industry within just that set of stocks.

Basically, I want the ranking to ignore any stock that is below the median market cap (for example) and any stocks which fail the other tests.

How can I do this with the new FRANK?
Am I misunderstanding something?

The example:

SetVar(@Group,Yield>0)
SetVar(@rank,FRank(“MktCap”,#GroupVar,#DESC))

works with the screener but not with sims. Is this supposed to be the case? (I thought it was some sort of work around for #Previous not working in Sims). If it only works for the sceener then the documentation should reflect this.

Steve