fix conditional swap order#1639
Merged
carlosmiei merged 15 commits intosammchardy:masterfrom Dec 5, 2025
Merged
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.
Collaborator
I think it will be more semantic if the package can split Eg:
|
Collaborator
|
@percy507 it does,
basically we support both to minimize the required changes |
|
@carlosmiei My mistake. I didn't notice you had already provided them!😂 |
pcriadoperez
added a commit
to pcriadoperez/python-binance
that referenced
this pull request
Mar 22, 2026
* add timeout to jobs * feat: Add support for Binance USDS-M Futures conditional/algo orders 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 * test: Add comprehensive tests for algo/conditional orders 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. * fix: Use lowercase 'triggerprice' parameter for algo orders 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. * fix: Revert to camelCase 'triggerPrice' per official API docs 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. * fix tests * update websockets * fix tests * add tests * default algoType * update readme * fix test id * skip test * fix linting --------- Co-authored-by: Claude <[email protected]> Co-authored-by: carlosmiei <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.