nicelgueta / pyokx

Unofficial python wrapper for the OKX V5 API
MIT License
19 stars 13 forks source link

cancel_algo_order doesn't work #4

Closed dignitas123 closed 1 year ago

dignitas123 commented 1 year ago

cancel_algo_order and cancel_advance_algo_order don't work because the body of the request has to be an array, as you can read here https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-algo-order.

Trying to exectute functions with correct parameters therefore results in JSON Syntax error.

Current interfaces only allow body: Dict[str, Any]. Should be somethink like body: Dict[str, Any] | List[Dict[str, Any]] as Union.

Exemple of working params from official Python SDK

result = tradeAPI.cancel_algo_order([{'algoId': '297394002194735104', 'instId': 'BTC-USDT-210409'}])

nicelgueta commented 1 year ago

Thanks for raising this. As the documentation specifies parameters in a table with only the request example denoting that the body should be an array of objects rather than a single object, thus this hasn't been picked up by the scraping logic. You're absolutely right though - this is non-functional and should be handled. You've mentioned cancel_algo_order and cancel_advance_algo_order here, but this will apply to many other methods that follow this pattern so should be driven from the example rather than just the parameter spec table itself. Will get a fix out for this as soon as reasonably possible. Thanks for your feedback.

nicelgueta commented 1 year ago

this has been fixed now to take body as an array rather than dict. thanks for your feedback