Closed soaked-reflection closed 2 years ago
The response data are all deserialized into predefined models. If you want the original raw data. There are two possible ways:
to_dict
method which can be used to convert to a Python native dict. For list responses, you need to iterate and to_dict
each model inside_preload_content=False
when you call API methods, e.g., list_futures_contracts(_preload_content=False)
. No deserialization will be done and an urllib3.HTTPResponse
will be returned, so you can retrieve the raw response with urllib3.HTTPResponse.data
attribute. Details about the deserialization can be found hereThanks.
I just started to use gateapi and look for opportunities on futures. I saw this function list_futures_contracts( ). As my habit I tend to store things in a DataFrame cause it's easy to view. I saw the return of this function and I thought it was a list of dictionaries so I tried the normal approach but failed. Turned out it's a collection of Contract objects which the compiler told me not subscriptable. So what's the easiest to to store them in a Dataframe, thanks in advance.