TypeError: Object of type set is not JSON serializable

3.9k Views Asked by At

When I try running this line in python, using the Bitmex Rest API

qty2 = self.client.Position.Position_get(json.dumps({'symbol': 'XBTUSD'}),json.dumps({'currentQty'})).result()

I get this error

File "c:/Users/User2/sample_market_maker/SAMPLE/botv2.py", line 113, in place_orders
qty2 = self.client.Position.Position_get(json.dumps({'symbol': 'XBTUSD'}),json.dumps({'currentQty'})).result()
File "c:\users\user2\appdata\local\programs\python\python37-32\Lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "c:\users\user2\appdata\local\programs\python\python37-32\Lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "c:\users\user2\appdata\local\programs\python\python37-32\Lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "c:\users\user2\appdata\local\programs\python\python37-32\Lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '

TypeError: Object of type set is not JSON serializable

I have seen How to JSON serialize sets?. It shows a similar problem with an example but I am not sure how to implement it in my code.

0

There are 0 best solutions below