The only thing that jumps out at me is that one of them you are sending a list []
and the other one you are sending a dict {}
, which should be also be a list in:
if 'type' in order and '_id' in order:
payload = [{
"contractName": "market",
"contractAction": "cancel",
"contractPayload": {
"type": order["type"],
"id": str(order["_id"])
}
}]
elif 'orderId' in order:
payload = { # <-- This one is missing the [
"contractName": "market",
"contractAction": "cancel",
"contractPayload": {
"orderId": str(order["orderId"])
}
} # <--- and the closing ]
else:
print("[CANCEL ERROR] Order missing required fields for cancellation:", order)
return False