Created
October 11, 2023 17:27
-
-
Save quantra-go-algo/59f16876ce34ce011f3b672a19a29cff to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Compute the Buy-and-Hold cumulative returns | |
plot_data['buy_hold_cum_rets'] = np.exp(plot_data['returns'].cumsum()) | |
# Compute the simple 4-day moving average strategy returns | |
plot_data['basic_stra_rets'] = plot_data['returns']*plot_data['signal'].shift(1) | |
# Compute the simple 4-day moving average strategy cumulative returns | |
plot_data['basic_stra_cum_rets'] = np.exp(plot_data['basic_stra_rets'].cumsum()) | |
# Compute the HMM-DC-based strategy returns | |
plot_data['hmm_dc_stra_rets'] = plot_data['returns']*plot_data['signal'].shift(1)*plot_data['dc_leverage'].shift(1) | |
# Compute the HMM-DC-based strategy cumulative returns | |
plot_data['hmm_dc_stra_cum_rets'] = np.exp(plot_data['hmm_dc_stra_rets'].cumsum()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment