-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix conditional swap order #1639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix conditional swap order #1639
Conversation
This update adds support for Binance's new algo order endpoints for conditional orders, which will be mandatory after 2025-12-09 for order types: STOP, STOP_MARKET, TAKE_PROFIT, TAKE_PROFIT_MARKET, and TRAILING_STOP_MARKET. Changes: - Added new order status enums: ACCEPTED, TRIGGERING, TRIGGERED, FINISHED - Added new dedicated algo order methods: * futures_create_algo_order() / async * futures_get_algo_order() / async * futures_get_all_algo_orders() / async * futures_get_open_algo_orders() / async * futures_cancel_algo_order() / async * futures_cancel_all_algo_open_orders() / async - Updated existing futures order methods to auto-detect and route conditional orders: * futures_create_order() now automatically routes conditional order types to algo endpoint * futures_get_order() supports 'conditional' parameter and algoId/clientAlgoId * futures_get_all_orders() supports 'conditional' parameter * futures_get_open_orders() supports 'conditional' parameter * futures_cancel_order() supports 'conditional' parameter and algoId/clientAlgoId * futures_cancel_all_open_orders() supports 'conditional' parameter - Applied same changes to both sync (client.py) and async (async_client.py) clients References: - https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Algo-Order - https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Cancel-Algo-Order - https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Algo-Order
Added tests for both sync and async clients covering: - Creating algo orders via dedicated method - Auto-routing conditional orders in futures_create_order - Getting specific algo orders - Getting all algo orders history - Getting open algo orders - Canceling algo orders - Canceling all algo open orders - Using conditional parameter with existing methods Tests validate both the new dedicated algo order methods and the backward-compatible conditional parameter on existing methods.
The Binance API expects the trigger price parameter to be lowercase 'triggerprice' not camelCase 'triggerPrice'. Updated both client implementations and tests to use the correct parameter name. Changes: - Updated futures_create_order to convert triggerPrice -> triggerprice - Added handling for both camelCase and lowercase input - Updated all tests to use lowercase 'triggerprice' parameter - Fixes APIError: Mandatory parameter 'triggerprice' was not sent This ensures compatibility with Binance's algo order endpoints which expect lowercase parameter names for trigger prices.
After reviewing the official Binance API documentation at: https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Algo-Order The parameter is clearly documented as 'triggerPrice' (camelCase), not 'triggerprice' (lowercase). Example from API docs: - Parameter: triggerPrice (DECIMAL, NO) - Response field: "triggerPrice": "750.000" Changes: - Reverted futures_create_order to use triggerPrice (camelCase) - Updated tests to use triggerPrice (camelCase) - Removed incorrect lowercase conversion The API error message may display parameter names in lowercase, but the actual parameter expected by the API is camelCase as documented.
I think it will be more semantic if the package can split Eg:
|
|
@percy507 it does,
basically we support both to minimize the required changes |
|
@carlosmiei My mistake. I didn't notice you had already provided them!😂 |
Uh oh!
There was an error while loading. Please reload this page.