import pandas as pd
import matplotlib.pyplot as plt

model1 = pd.read_csv(r"Poutput\VIX_base_forecast_result\1d\Normal.csv", index_col = 0).dropna()
model2 = pd.read_csv(r"Poutput\VIX_base_forecast_result\1d\GED.csv", index_col = 0).dropna()
model3 = pd.read_csv(r"Poutput\VIX_base_forecast_result\1d\skewstud.csv", index_col = 0).dropna()
model4 = pd.read_csv(r"Poutput\VIX_base_forecast_result\1d\studT.csv", index_col = 0).dropna()

model1e = pd.read_csv(r"Poutput\VIX_base_forecast_result\1d\Normal_egarch.csv", index_col = 0).dropna()
model2e = pd.read_csv(r"Poutput\VIX_base_forecast_result\1d\GED_egarch.csv", index_col = 0).dropna()
model3e = pd.read_csv(r"Poutput\VIX_base_forecast_result\1d\skewstud_egarch.csv", index_col = 0).dropna()
model4e = pd.read_csv(r"Poutput\VIX_base_forecast_result\1d\studT_egarch.csv", index_col = 0).dropna()

model1_3d = pd.read_csv(r"Poutput\VIX_base_forecast_result\3d\Normal.csv", index_col = 0).dropna()
model2_3d = pd.read_csv(r"Poutput\VIX_base_forecast_result\3d\GED.csv", index_col = 0).dropna()
model3_3d = pd.read_csv(r"Poutput\VIX_base_forecast_result\3d\skewstud.csv", index_col = 0).dropna()
model4_3d = pd.read_csv(r"Poutput\VIX_base_forecast_result\3d\studT.csv", index_col = 0).dropna()

model1_5d = pd.read_csv(r"Poutput\VIX_base_forecast_result\5d\Normal.csv", index_col = 0).dropna()
model2_5d = pd.read_csv(r"Poutput\VIX_base_forecast_result\5d\GED.csv", index_col = 0).dropna()
model3_5d = pd.read_csv(r"Poutput\VIX_base_forecast_result\5d\skewstud.csv", index_col = 0).dropna()
model4_5d = pd.read_csv(r"Poutput\VIX_base_forecast_result\5d\studT.csv", index_col = 0).dropna()

model1_3de = pd.read_csv(r"Poutput\VIX_base_forecast_result\3d\Normal_egarch.csv", index_col = 0).dropna()
model2_3de= pd.read_csv(r"Poutput\VIX_base_forecast_result\3d\GED_egarch.csv", index_col = 0).dropna()
model3_3de = pd.read_csv(r"Poutput\VIX_base_forecast_result\3d\skewstud_egarch.csv", index_col = 0).dropna()
model4_3de = pd.read_csv(r"Poutput\VIX_base_forecast_result\3d\studT_egarch.csv", index_col = 0).dropna()

model1_5de = pd.read_csv(r"Poutput\VIX_base_forecast_result\5d\Normal_egarch.csv", index_col = 0).dropna()
model2_5de = pd.read_csv(r"Poutput\VIX_base_forecast_result\5d\GED_egarch.csv", index_col = 0).dropna()
model3_5de = pd.read_csv(r"Poutput\VIX_base_forecast_result\5d\skewstud_egarch.csv", index_col = 0).dropna()
model4_5de = pd.read_csv(r"Poutput\VIX_base_forecast_result\5d\studT_egarch.csv", index_col = 0).dropna()

#Model with no volatility process estimated
M1_n = pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M1_n.csv", index_col=0).dropna()
M1_st = pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M1_st.csv", index_col=0).dropna()
M1_ged = pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M1_ged.csv", index_col=0).dropna()
M2_n= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M2_n.csv", index_col=0).dropna()
M2_st= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M2_st.csv", index_col=0).dropna()
M2_ged= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M2_ged.csv", index_col=0).dropna()
M2a_n= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M2a_n.csv", index_col=0).dropna()
M2a_st= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M2a_st.csv", index_col=0).dropna()
M2a_ged= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M2a_ged.csv", index_col=0).dropna()
M3_n= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M3_n.csv", index_col=0).dropna()
M3_st= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M3_st.csv", index_col=0).dropna()
M3_ged= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M3_ged.csv", index_col=0).dropna()
M4_n= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M4_n.csv", index_col=0).dropna()
M4_st= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M4_st.csv", index_col=0).dropna()
M4_ged= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M4_ged.csv", index_col=0).dropna()
M5_ged= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M5_ged.csv", index_col=0).dropna()
M6_ged= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M6_ged.csv", index_col=0).dropna()
M7_ged= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M7_ged.csv", index_col=0).dropna()
M7_st= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M7_st.csv", index_col=0).dropna()

M8_st= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M8_st.csv", index_col=0).dropna()
M8_n= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M8_n.csv", index_col=0).dropna()
M8_ged= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M8_ged.csv", index_col=0).dropna()
M9_st= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M9_st.csv", index_col=0).dropna()
M9_n= pd.read_csv("Poutput/VIX_X_forecast_result/base/1d/M9_n.csv", index_col=0).dropna()

#Model with EGARCH(1,1)
M1_n_e = pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M1_n.csv", index_col=0).dropna()
M1_st_e = pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M1_st.csv", index_col=0).dropna()
M1_ged_e = pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M1_ged.csv", index_col=0).dropna()
M2_n_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M2_n.csv", index_col=0).dropna()
M2_st_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M2_st.csv", index_col=0).dropna()
M2_ged_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M2_ged.csv", index_col=0).dropna()
M2a_n_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M2a_n.csv", index_col=0).dropna()
M2a_st_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M2a_st.csv", index_col=0).dropna()
M2a_ged_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M2a_ged.csv", index_col=0).dropna()
M3_n_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M3_n.csv", index_col=0).dropna()
M3_st_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M3_st.csv", index_col=0).dropna()
M3_ged_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M3_ged.csv", index_col=0).dropna()
M4_n_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M4_n.csv", index_col=0).dropna()
M4_st_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M4_st.csv", index_col=0).dropna()
M4_ged_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M4_ged.csv", index_col=0).dropna()
M5_ged_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M5_ged.csv", index_col=0).dropna()
M6_ged_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M6_ged.csv", index_col=0).dropna()
M7_ged_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M7_ged.csv", index_col=0).dropna()
M7_st_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M7_st.csv", index_col=0).dropna()
M8_st_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M8_st.csv", index_col=0).dropna()
M8_n_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M8_n.csv", index_col=0).dropna()
M8_ged_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M8_ged.csv", index_col=0).dropna()
M9_st_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M9_st.csv", index_col=0).dropna()
M9_n_e= pd.read_csv("Poutput/VIX_X_forecast_result/egarch/1d/M9_n.csv", index_col=0).dropna()

def get_forecast_plot(x, name):
    name = '%s' % str(name)
    x.loc[:,['vix','forecast','close_err']].plot(secondary_y=['close_err'], mark_right = False, figsize = (10,4), grid=False)
    plt.savefig('Pgraphs\casts\exog\%s.png'% name)

def get_forecast_plot3d(x, name):
    name = '%s' % str(name)
    x.loc[:,['vix','forecast-3d','close_err']].plot(secondary_y=['close_err'], mark_right = False, figsize = (10,4), grid=False)
    plt.savefig('Pgraphs\casts\exog\%s.png'% name)

def get_forecast_plot5d(x, name):
    name = '%s' % str(name)
    x.loc[:,['vix','forecast-5d','close_err']].plot(secondary_y=['close_err'], mark_right = False, figsize = (10,4), grid=False)
    plt.savefig('Pgraphs\casts\exog\%s.png'% name)

get_forecast_plot(M1_n, 'M1_n')
get_forecast_plot(M2_n, 'M2_n')
get_forecast_plot(M3_n, 'M3_n')
get_forecast_plot(M4_n, 'M4_n')
get_forecast_plot(M8_n, 'M8_n')
get_forecast_plot(M9_n, 'M9_n')

get_forecast_plot(M1_st, 'M1_st')
get_forecast_plot(M2_st, 'M2_st')
get_forecast_plot(M3_st, 'M3_st')
get_forecast_plot(M4_st, 'M4_st')
get_forecast_plot(M7_st, 'M7_st')
get_forecast_plot(M8_st, 'M8_st')
get_forecast_plot(M9_st, 'M9_st')

get_forecast_plot(M1_ged, 'M1_ged')
get_forecast_plot(M2_ged, 'M2_ged')
get_forecast_plot(M3_ged, 'M3_ged')
get_forecast_plot(M4_ged, 'M4_ged')
get_forecast_plot(M5_ged, 'M5_ged')
get_forecast_plot(M6_ged, 'M6_ged')
get_forecast_plot(M7_ged, 'M7_ged')
get_forecast_plot(M8_ged, 'M8_ged')

get_forecast_plot(M1_n_e, 'M1_n_e')
get_forecast_plot(M2_n_e, 'M2_n_e')
get_forecast_plot(M3_n_e, 'M3_n_e')
get_forecast_plot(M4_n_e, 'M4_n_e')
get_forecast_plot(M8_n_e, 'M8_n_e')
get_forecast_plot(M9_n_e, 'M9_n_e')

get_forecast_plot(M1_st_e, 'M1_st_e')
get_forecast_plot(M2_st_e, 'M2_st_e')
get_forecast_plot(M3_st_e, 'M3_st_e')
get_forecast_plot(M4_st_e, 'M4_st_e')
get_forecast_plot(M7_st_e, 'M7_st_e')
get_forecast_plot(M8_st_e, 'M8_st_e')
get_forecast_plot(M9_st_e, 'M9_st_e')


get_forecast_plot(M1_ged_e, 'M1_ged_e')
get_forecast_plot(M2_ged_e, 'M2_ged_e')
get_forecast_plot(M3_ged_e, 'M3_ged_e')
get_forecast_plot(M4_ged_e, 'M4_ged_e')
get_forecast_plot(M5_ged_e, 'M5_ged_e')
get_forecast_plot(M6_ged_e, 'M6_ged_e')
get_forecast_plot(M7_ged_e, 'M7_ged_e')
get_forecast_plot(M8_ged_e, 'M8_ged_e')

get_forecast_plot(model1, '1dnorm')
get_forecast_plot(model2, '1dged')
get_forecast_plot(model3, '1dsse')
get_forecast_plot(model4, '1dst')
get_forecast_plot(model1e, '1dnorm_e')
get_forecast_plot(model2e, '1dged_e')
get_forecast_plot(model3e, '1dsse_e')
get_forecast_plot(model4e, '1dst_e')

get_forecast_plot3d(model1_3d, '3dnorm')
get_forecast_plot3d(model2_3d, '3dged')
get_forecast_plot3d(model3_3d, '3dsse')
get_forecast_plot3d(model4_3d, '3dst')
get_forecast_plot3d(model1_3de, '3dnorm_e')
get_forecast_plot3d(model2_3de, '3dged_e')
get_forecast_plot3d(model3_3de, '3dsse_e')
get_forecast_plot3d(model4_3de, '3dst_e')

get_forecast_plot5d(model1_5d, '5dnorm')
get_forecast_plot5d(model2_5d, '5dged')
get_forecast_plot5d(model3_5d, '5dsse')
get_forecast_plot5d(model4_5d, '5dst')
get_forecast_plot5d(model1_5de, '5dnorm_e')
get_forecast_plot5d(model2_5de, '5dged_e')
get_forecast_plot5d(model3_5de, '5dsse_e')
