Object of type int64 is not JSON serializable

I am getting following error while executing my python script to place an order.

Here’s the order data structure:

{‘symbol’: ‘NSE:CUB24SEP172.5CE’,

‘qty’: 5000,

‘type’: 1,

‘side’: 1,

‘productType’: ‘INTRADAY’,

‘limitPrice’: 5.15,

‘stopPrice’: 0,

‘validity’: ‘IOC’,

‘disclosedQty’: 0,

‘offlineOrder’: False,

‘orderTag’: ‘NSE:CUB24SEP172.5CE’

}

Here’s the exception:

Traceback (most recent call last): File “/Users/Nitin.Nagoria/Library/Python/3.9/lib/python/site-packages/fyers_apiv3/fyersModel.py”, line 75, in post_call data=json.dumps(data), File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/init.py”, line 231, in dumps return _default_encoder.encode(obj) File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/encoder.py”, line 199, in encode chunks = self.iterencode(o, _one_shot=True) File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/encoder.py”, line 257, in iterencode return _iterencode(o, 0) File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/encoder.py”, line 179, in default raise TypeError(f’Object of type {o.class.name} ’ TypeError: Object of type int64 is not JSON serializable

Can someone pls help?

orderTag shouldn’t contain special characters(‘orderTag’: ‘NSE:CUB24SEP172.5CE’).
Kindly try this change.

dm incase of any issue.

Hi @JOJYsbsZnC I am facing similar issue Object of type int64 is not JSON serializable

Can you please let me know, what is the problem in my payload ? I am placing limit order

Copy

{'symbol': 'MCX:SILVERMIC24NOVFUT', 'qty': 1, 'type': 1, 'side': 1, 'productType': 'MARGIN', 'limitPrice': 91496, 'stopPrice': 0, 'validity': 'DAY', 'stopLoss': 0, 'takeProfit': 0, 'offlineOrder': False, 'disclosedQty': 0} 

{'Error': 'Object of type int64 is not JSON serializable'}