Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-100

Treynor Ratio

Problem

Compute the Treynor ratio: (mean(returns) - rf) / beta, the excess return earned per unit of systematic risk.

Return 0.0 when returns is empty or beta is 0.

Hint

Only systematic risk (beta) is in the denominator.

Test cases

case 1
in: [[0.1,0.2,0.3],1.5,0.02]
expected: 0.12
case 2
in: [[0.05],0,0]
expected: 0
case 3
in: [[0.1,-0.05],2,0]
expected: 0.0125
case 4
in: [[0.1,0.1],1,0.1]
expected: 0
Starter codePython
def treynor_ratio(returns, beta, rf):
    # Your code here
    pass

4 test cases · run your code against them in the editor