All problems
Sortino Ratio
Problem
Compute the Sortino ratio: (mean(returns) - target) / downside_deviation, where the downside deviation is the square root of the mean squared shortfall min(0, r - target) over all observations.
Return 0.0 when there are no downside observations or the deviation is zero.
Hint
Only shortfalls below the target enter the denominator.
Test cases
case 1
in: [[0.1,-0.05,0.2,-0.02],0]
expected: 2.135496389036096
case 2
in: [[0.05,0.06],0]
expected: 0
case 3
in: [[0.1,0.1,0.1],0.05]
expected: 0
case 4
in: [[],0]
expected: 0
Starter codePython
def sortino_ratio(returns, target):
# Your code here
pass4 test cases · run your code against them in the editor