Based on this github example, i learn how to create parallel requests with events , where i need to retrieve snapshot data. However, I have a question,
- how do i concatenate the results to form a larger dataframe ? Code below produce errors, as df_snap is referenced before assignment. Can someone show me the propoer way to concatenate results with index equal to the original dataframe, so i can reconcile / join the results with the original dataframe.
df_snap = pd.DataFrame()
def concat_response(response, definition, session):
if response.is_success:
df_snap = pd.concat([df_snap , response.data.df], axis=0)
else:
print(response.http_status)
for idx, row in data.iterrows():
asyncio.get_event_loop().create_task(
historical_pricing.events.Definition(universe=row['ricCode'], fields=["TRDPRC_1","MID_PRICE"],start = row['GMT Time'], count = 1).get_data_async(on_response = concat_response, closure = str(idx))
)