-
-
Save quantra-go-algo/9ab07bce65a52bbcb94ba88e46ab6ec0 to your computer and use it in GitHub Desktop.
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
mean_strategy_return = aapl_data['Strategy_Return'].mean() | |
std_dev_strategy_return = aapl_data['Strategy_Return'].std(ddof=1) | |
# ddof=1 or Delta Degrees of Freedom for sample standard deviation | |
# Annual risk-free rate | |
annual_risk_free_rate = 0.05 | |
# Convert annual risk-free rate to daily rate | |
daily_risk_free_rate = annual_risk_free_rate / 252 | |
# Calculate Sharpe Ratio with daily risk-free rate | |
excess_return = aapl_data['Strategy_Return'] - daily_risk_free_rate | |
sharpe_ratio = np.sqrt(len(aapl_data)) * (mean_strategy_return / std_dev_strategy_return) | |
print(f"Sharpe Ratio with daily risk-free rate: {sharpe_ratio}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment