Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save StuartGordonReid/6c1b4281e6662cad397f to your computer and use it in GitHub Desktop.

Select an option

Save StuartGordonReid/6c1b4281e6662cad397f to your computer and use it in GitHub Desktop.

Revisions

  1. StuartGordonReid created this gist Jun 12, 2015.
    24 changes: 24 additions & 0 deletions PartialMomentsAdjustedReturns.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    """
    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))