Created
June 12, 2015 13:38
-
-
Save StuartGordonReid/799ee85cb2aa726ded67 to your computer and use it in GitHub Desktop.
Risk adjusted returns based on volatility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Note that this Gist uses functions made available in another Gist - | |
https://gist.github.com/StuartGordonReid/67a1ec4fbc8a84c0e856 | |
""" | |
def treynor_ratio(er, returns, market, rf): | |
return (er - rf) / beta(returns, market) | |
def sharpe_ratio(er, returns, rf): | |
return (er - rf) / vol(returns) | |
def information_ratio(returns, benchmark): | |
diff = returns - benchmark | |
return numpy.mean(diff) / vol(diff) | |
def modigliani_ratio(er, returns, benchmark, rf): | |
np_rf = numpy.empty(len(returns)) | |
np_rf.fill(rf) | |
rdiff = returns - np_rf | |
bdiff = benchmark - np_rf | |
return (er - rf) * (vol(rdiff) / vol(bdiff)) + rf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment