I have a function
def Vega_dict():
Sum_CE_Vega = Final_df.loc[Final_df['instrumentType'] == 'CE', 'vega'].sum()
Sum_PE_Vega = Final_df.loc[Final_df['instrumentType'] == 'PE', 'vega'].sum()
Vega_dict = []
Vega_dict.append(Time)
Vega_dict.append(Sum_CE_Vega)
Vega_dict.append(Sum_PE_Vega)
Vega_dict = np.transpose(Vega_dict)
Vega_df = pd.DataFrame(Vega_dict)
Vega_df = Vega_df.T
Vega_df.columns = ["Time", "Sum of OTM CE", "Sum of OTM PE"]
Vega_df = pd.concat([df_vg, Vega_df], ignore_index = True)
return Vega_df
That return a dataframe which has the below output
Time Sum of OTM CE Sum of OTM PE
0 20:14:32 176.90175243829978 166.3830493392582
This output will change in every 20second.
Now I need to store this dataframe so that I get a timeseries data like the below:
Time Sum of OTM CE Sum of OTM PE
0 20:14:32 176.90175243829978 166.3830493392582
1 20:14:42 176.93993499404044 166.3783648784774
and so on...
I have created the below code to store that
df_vg = pd.DataFrame()
df_vg = Vega_dict()
df_vg = pd.concat([Vega_dict(), df_vg], ignore_index = True)
print(df_vg)
But it is giving me the same output three times
Time Sum of OTM CE Sum of OTM PE
0 20:30:49 176.90175243829978 166.3830493392582
1 20:30:49 176.90175243829978 166.3830493392582
2 20:30:49 176.90175243829978 166.3830493392582
And the output is also not getting stored please help me