Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Created October 11, 2023 17:29
Show Gist options
  • Save quantra-go-algo/775bbc1b77b140446d688953b6dca72b to your computer and use it in GitHub Desktop.
Save quantra-go-algo/775bbc1b77b140446d688953b6dca72b to your computer and use it in GitHub Desktop.
# Set the figure size
plt.figure(figsize=(15,7))
# Plot both the Buy-and-hold, SMA and HMM-DC-based strategy cumulative returns
plt.plot(plot_data.index, plot_data['buy_hold_cum_rets'], label = "Buy and Hold Returns")
plt.plot(plot_data.index, plot_data['basic_stra_cum_rets'], label = "SMA Strategy Returns", color='g')
plt.plot(plot_data.index, plot_data['hmm_dc_stra_cum_rets'], label = "HMM-DC-based Strategy Returns", color='r')
#plt.plot(plot_data.index, plot_data['hmm_stra_cum_rets'], label = "HMM-based Strategy Returns", color='y')
# Set the title of the graph
plt.title('Buy-and-Hold, SMA and HMM-DC-based Cumulative Returns', fontsize=16)
# Set the x- and y- axis labels and ticks sizes
plt.xlabel('Year', fontsize=15)
plt.ylabel('Cumulative Returns', fontsize=15)
plt.tick_params(axis='both', labelsize=15)
# Set the plot legend location
plt.legend(loc=2, prop={'size': 15}, bbox_to_anchor=(0,1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment