Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save StuartGordonReid/6c1b4281e6662cad397f to your computer and use it in GitHub Desktop.
Save StuartGordonReid/6c1b4281e6662cad397f to your computer and use it in GitHub Desktop.
Risk adjusted returns based on Lower Partial Moments
"""
Note that this Gist uses functions made available in another Gist -
https://gist.github.com/StuartGordonReid/67a1ec4fbc8a84c0e856
"""
def omega_ratio(er, returns, rf, target=0):
return (er - rf) / lpm(returns, target, 1)
def sortino_ratio(er, returns, rf, target=0):
return (er - rf) / math.sqrt(lpm(returns, target, 2))
def kappa_three_ratio(er, returns, rf, target=0):
return (er - rf) / math.pow(lpm(returns, target, 3), float(1/3))
def gain_loss_ratio(returns, target=0):
return hpm(returns, target, 1) / lpm(returns, target, 1)
def upside_potential_ratio(returns, target=0):
return hpm(returns, target, 1) / math.sqrt(lpm(returns, target, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment