-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Sharpe Ratio does not take risk-free rate as a parameter #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
With interest rates effectively zero or negative, and with short-term bond yields close to zero, assuming the risk-free rate at 0% was an honest, intended, and not unreasonable simplification. Does your Sharpe change significantly if you amend it so? |
Yes it does. Risk free rate here in India is ~6%. |
As a quick workaround, might this fix your Sharpe? def adjusted_sharpe(stats, riskfree_rate=.06):
mean_return = stats['Avg. Trade [%]'] / 100
return stats['Sharpe Ratio'] / mean_return * (mean_return - riskfree_rate) You can also use it to optimize: |
Haha thanks for going the extra mile but that's pretty much what I am already doing. Not a deal breaker for me. However most users kind of expect a risk-free-rate parameter for a Sharpe function coming from other quant packages so I guess adding it would avoid some confusion and time spent scouring through the source code to ensure it hasn't been hardcoded to something like 2%. |
It is since v0.3.2 possible to use stats = Backtest(GOOG, MyStrategy).run()
new_stats = compute_stats(stats=stats, data=GOOG, risk_free_rate=.02) |
Backtesting.py Line #954
backtesting.py/backtesting/backtesting.py
Line 952 in 7010d68
Expected Behavior
Actual Behavior
Additional info
Sharpe Ratio
The text was updated successfully, but these errors were encountered: