Custom Metric Functions and Examples

Custom Metric Examples

Listed below are three different examples of custom metrics. The second example includes a screenshot of what the example looks like in the Custom Metric editor. Note that the tag inside the brackets indicates the time period to use for each metric in the expression. For example, Now refers to the most current trailing twelve month period. TTM1 refers to the trailing twelve month period one year ago, so 12 month prior to the Now period. Likewise TTM2 refers to the trailing twelve month period two years ago. To specify calender years, you would use an tag like Y2, to specify the calendar year two years ago.

Long Term Debt over Operating Income

“Long Term Debt [Now] ” / “Operating Income [Now] “

Return on Invested Capital vs. Prior 3 Year’s Average

ROIC [Now] ” -(( “ROIC [TTM1] ” + “ROIC [TTM2] ” + “ROIC [TTM3] ” )/3)

Here is what the custom metric looks like in the interface:

CustomMetricExample

The Graham Number

The Graham Number is a figure that measures a stock’s fundamental value by taking into account the company’s earnings per share and book value per share. The Graham number is the upper bound of the price range that a defensive investor should pay for the stock. According to the theory, any stock price below the Graham number is considered undervalued and thus worth investing in. The formula is as follows:

Square Root (22.5 x Earnings per share x Book Value per share)

Custom Metric when Negative Numbers need to be Ignored

In this example, we want to take the square root of a number, but the POW function only accepts number greater than or equal to zero. So to ensure the number we pass to POW is positive, we use a Case statement inside of the POW function. It is a little tricky, but it does the job. The formula is as follows:

100 * pow(case when (“EPS [Now]” – “EPS [Y5]”) / “EPS [Y5]” <= 0 then null else ("EPS [Now]" - "EPS [Y5]") / "EPS [Y5]" end, 1/5) -1

Custom Metric Functions

Here is a list of functions available in the custom metric and equation screener facilities:

**Note: The functions are case sensitive and must be written in lower case

Function Name Description Example
abs Returns the absolute value of value abs(-1.5) returns 1.5
case when then else end This function lets you evaluate conditions and return a value when the first condition is met (like an IF-THEN-ELSE statement) case when x > 0 then 1 else 0 returns 1 if x is greater than 0 otherwise it is 0.
exp Return e raised to the power of number exp(2) returns 7.38905609893065
ifnull Returns the second value if first value is null. ifnull(null,0) returns 0
A Stock Rover example if you want to find companies that have good long term returns but have not existed for a long time you can use an example like this:
ifnull(“Annualized 10-Year Return”, “Annualized 3-Year Return”) > 10
null A special term for values that unavailable or not applicable. Metrics will commonly evaluate as null when trying to compute a growth rate of negative values or when comparing historical values that go further back than the stock’s history. null can be used within the nullif and ifnull functions
nullif Returns null if the first and second are equal otherwise it returns the first value. nullif(5,5) returns null
pow Returns the value raised to the nth power pow (8,3) returns 512
A Stock Rover example to get the 5 yr eps growth rate:
100 * pow(case when (“EPS [Now]” – “EPS [Y5]”) / “EPS [Y5]” <= 0 then null else ("EPS [Now]" - "EPS [Y5]") / "EPS [Y5]" end, 1/5) -1
Please note the case statement is used within the pow function because the pow function does not accept negative numbers.
round Returns a number rounded to a certain number of decimal places. round(345.156, 0) returns 345