Full Description
Returns the percentile rank for each stock based on user specified parameters for the formula, the scope and the sorting direction. It works like this:
- The formula in quotes is evaluated for all the stocks in each scope. 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 'sort' parameter. If you selected a sector scope multiple sorts are executed for each 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.
Special cases:
- NA's, if included, are always placed at the bottom of the array and all get the same percentile. The percentile assigned is the next percentile below the last meaningful value
- 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)
Parameters
scope: determines how stocks are grouped before ranking (see below)
sort: Direction of sort within the group
#ASC- ascending (lower is better)
#DESC- descending (default; higher is better)
incl_na: Whether to include stocks with NA values in the rank
#InclNA - include NA values in the set to be ranked (default)
#ExclNA - exclude NA values from the set to be ranked, assigning NA to such stocks
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 three groups: stocks that have a yield = 0 , yield less than 5% , and 5% or more. Then return the stock in each group with the highest MktCap rank.
setvar(@group , eval( Yield=0 , 0 , eval ( Yield > 5 , 2 , 1) ) )
SetVar(@rank,FRank("MktCap",#GroupVar,#DESC))
@rank=100
This produces these stocks in July 2020:
For Yield = 0 AMZN with a MktCap of 1.4T
For Yield 0-5 APPL with a MktCap of 1.6T
For Yield > 5 T with a MktCap of 200M
Scope Parameter
Values |
Stocks |
ETFs |
Description |
#All | Y | Y | Operates on current universe |
#Previous1 | Y | Y | Operates on the results from previous rules |
#GroupVar1 | Y | Y | Operates on groups based on value of variable @Group |
--------------------------- For Stocks Only --------------------------- |
#Sector | Y | | Operates within each Sector of current universe |
#SubSector | Y | | Operates within each SubSector of current universe |
#Industry | Y | | Operates within each Industry of current universe |
#SubIndustry | Y | | Operates within each SubIndustry of current universe |
--------------------------- For ETFs Only ------------------------------ |
#Family | | Y | Operates within each ETF Family |
#AssetClass | | Y | Operates within each ETF Class |
#Region | | Y | Operates within each ETF Region |
#Country | | Y | Operates within each ETF Country |
#Method | | Y | Operates within each ETF Method |
#Style | | Y | Operates within each ETF Style |
#Size | | Y | Operates within each ETF Size |
#ETFSector | | Y | Operates within each ETF Sector |
1Available only in the Screener and Custom Universe