BitMEX / api-connectors

Libraries for connecting to the BitMEX API.
https://www.bitmex.com/app/restAPI
910 stars 795 forks source link

client.User.User_getExecutionHistory() casue SwaggerMappingError #289

Open Loches525 opened 5 years ago

Loches525 commented 5 years ago

`import bitmex import json import pandas as pd

client = bitmex.bitmex(test=False, api_key="****", api_secret="**") result_pos = client.Position.Position_get(filter=json.dumps({'symbol': 'XBTUSD'})).result() t = pd.to_datetime('2018-12-04T12:00:00.000Z') result_tra = client.User.User_getExecutionHistory(symbol='XBTUSD', timestamp=t).result()`

Traceback (most recent call last): File "C:/Users/jarvis/Desktop/BBGData-develop-6c9d2e05b8d6cf8c5c12c19a3526cc5f742c6ecb/test9].py", line 9, in result_tra = client.User.User_getExecutionHistory(symbol='XBTUSD', timestamp=t).result() File "C:\Users\jarvis\AppData\Local\Programs\Python\Python36\lib\site-packages\bravado\http_future.py", line 214, in result swagger_result = self._get_swagger_result(incoming_response) File "C:\Users\jarvis\AppData\Local\Programs\Python\Python36\lib\site-packages\bravado\http_future.py", line 97, in wrapper return func(self, *args, **kwargs) File "C:\Users\jarvis\AppData\Local\Programs\Python\Python36\lib\site-packages\bravado\http_future.py", line 239, in _get_swagger_result self.request_config.response_callbacks, File "C:\Users\jarvis\AppData\Local\Programs\Python\Python36\lib\site-packages\bravado\http_future.py", line 268, in unmarshal_response op=operation, File "C:\Users\jarvis\AppData\Local\Programs\Python\Python36\lib\site-packages\bravado\http_future.py", line 317, in unmarshal_response_inner value=content_value, File "C:\Users\jarvis\AppData\Local\Programs\Python\Python36\lib\site-packages\bravado_core\unmarshal.py", line 61, in unmarshal_schema_object return unmarshal_object(swagger_spec, schema_object_spec, value) File "C:\Users\jarvis\AppData\Local\Programs\Python\Python36\lib\site-packages\bravado_core\unmarshal.py", line 128, in unmarshal_object type(object_value), object_value)) bravado_core.exception.SwaggerMappingError: Expected dict like type for <class 'list'>:[....]

Loches525 commented 5 years ago

Should I need to revise the parameter to a correct format?

cryptonaut1357 commented 5 years ago

i got the same issue. Any suggestions?

Loches525 commented 5 years ago

i got the same issue. Any suggestions?

Actually not yet. Finally there is trades record in the exception info, u can catch them via a python library traceback

derekwong9 commented 5 years ago

Have the same issue as well, you get records in exception but its really working properly

combstraight commented 5 years ago

I get this error as well.

combstraight commented 5 years ago

I think the issue is that bitmex REST API returns a list object while unmarshal.unmarshal_object() expects a dictionary list.

apojii commented 5 years ago

I get this error as well. Is there any solutions?

pierthodo commented 5 years ago

Any update on this ?

TobiWo commented 5 years ago

I'm having the same problem here. Very annoying. Currently I'm doing this workaround: try: working_response = client.User.User_getExecutionHistory(symbol="XBTUSD", timestamp = timestamp).result() except Exception as e: exception_response = re.search("\[{.+}\]", str(e)) final_response = response.group() final_response2 = final_response.replace("'", "\"") final_response3 = final_response2.replace("None", "\"None\"") final_json = json.loads(final_response3) for item in final_json: print(item)

This is really bad code but as @Loches525 stated, the actual response is in the error message. And because I want to retrieve the data for personal interest it is kind of ok to use this workaround.

dcimring commented 4 years ago

I'm having the same issue :(