def plot_simulation(params, hist, i): hist = SimpleModelling.returns(hist) sim_arma = Plot_ARMA(params['arma'], hist) sim_garch = Plot_GARCH(params['garch']) sim_sv = Plot_SV(params['sv']) real_global_returns = sum(hist[(len(hist) - 251):]) plt.figure(i + 1) plt.suptitle(GlobalValue.ptf[i].stockCode, fontsize=20) plt.subplot(1, 3, 1) plt.boxplot([sim_arma]) plt.plot([real_global_returns] * len(hist)) plt.title("boxplot_ARMA") plt.subplot(1, 3, 2) plt.boxplot([sim_garch]) plt.plot([real_global_returns] * len(hist)) plt.title("boxplot_GARCH") plt.subplot(1, 3, 3) plt.boxplot([sim_sv]) plt.plot([real_global_returns] * 500) plt.title("boxplot_SV") plt.show()
def plot_simulation(params,hist,i): hist = SimpleModelling.returns(hist) sim_arma = Plot_ARMA(params['arma'],hist) sim_garch = Plot_GARCH(params['garch']) sim_sv = Plot_SV(params['sv']) real_global_returns = sum(hist[(len(hist)-251):]) plt.figure(i+1) plt.suptitle(GlobalValue.ptf[i].stockCode, fontsize=20) plt.subplot(1,3,1) plt.boxplot([sim_arma]) plt.plot([real_global_returns] * len(hist)) plt.title("boxplot_ARMA") plt.subplot(1,3,2) plt.boxplot([sim_garch]) plt.plot([real_global_returns] * len(hist)) plt.title("boxplot_GARCH") plt.subplot(1,3,3) plt.boxplot([sim_sv]) plt.plot([real_global_returns]*500) plt.title("boxplot_SV") plt.show()
def applyModel(self): # TODO: change assert to if to give a warning dialog assert len(GlobalValue.ptf) == len(GlobalValue.modelParams) assert len(GlobalValue.ptf) == len(GlobalValue.modelChoice) assert len(GlobalValue.ptf) == len(GlobalValue.yahooData) assert len(GlobalValue.ptf) > 0 for i in range(len(GlobalValue.ptf)): assert GlobalValue.modelChoice[i] >= 0 assert GlobalValue.modelChoice[i] <= 2 GlobalValue.simulations = [] for i in range(len(GlobalValue.ptf)): if GlobalValue.modelChoice[i] == 0: returns = SimpleModelling.returns(GlobalValue.yahooData[i]) GlobalValue.simulations.append( plot.choice_ARMA(GlobalValue.modelParams[i]['arma'], returns)) elif GlobalValue.modelChoice[i] == 1: GlobalValue.simulations.append( plot.Plot_GARCH(GlobalValue.modelParams[i]['garch'])) elif GlobalValue.modelChoice[i] == 2: GlobalValue.simulations.append( plot.Plot_SV(GlobalValue.modelParams[i]['sv'])) else: assert False print(GlobalValue.simulations[0])
def applyModel(self): # TODO: change assert to if to give a warning dialog assert len(GlobalValue.ptf) == len(GlobalValue.modelParams) assert len(GlobalValue.ptf) == len(GlobalValue.modelChoice) assert len(GlobalValue.ptf) == len(GlobalValue.yahooData) assert len(GlobalValue.ptf) > 0 for i in range(len(GlobalValue.ptf)): assert GlobalValue.modelChoice[i] >= 0 assert GlobalValue.modelChoice[i] <= 2 GlobalValue.simulations = [] for i in range(len(GlobalValue.ptf)): if GlobalValue.modelChoice[i] == 0: returns = SimpleModelling.returns(GlobalValue.yahooData[i]) GlobalValue.simulations.append(plot.choice_ARMA(GlobalValue.modelParams[i]['arma'], returns)) elif GlobalValue.modelChoice[i] == 1: GlobalValue.simulations.append(plot.Plot_GARCH(GlobalValue.modelParams[i]['garch'])) elif GlobalValue.modelChoice[i] == 2: GlobalValue.simulations.append(plot.Plot_SV(GlobalValue.modelParams[i]['sv'])) else: assert False print(GlobalValue.simulations[0])