Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-098

Calmar Ratio

Problem

Compute the Calmar ratio as total_return / abs(max_drawdown), a return measure scaled by the worst peak-to-trough loss.

Return 0.0 when max_drawdown is 0.

Hint

Only the magnitude of the drawdown matters, not its sign convention.

Test cases

case 1
in: [0.5,0.25]
expected: 2
case 2
in: [0.3,0]
expected: 0
case 3
in: [-0.1,0.2]
expected: -0.5
case 4
in: [0.4,-0.2]
expected: 2
Starter codePython
def calmar_ratio(total_return, max_drawdown):
    # Your code here
    pass

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