Skip to content

Conversation

@pcriadoperez
Copy link
Collaborator

@pcriadoperez pcriadoperez commented Dec 1, 2025

  • Add algo orders to client, async and websockets
  • Update futures createOrder

pcriadoperez and others added 3 commits February 18, 2025 01:07
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
@pcriadoperez pcriadoperez marked this pull request as draft December 1, 2025 22:58
claude and others added 6 commits December 1, 2025 23:09
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.
@pcriadoperez pcriadoperez self-assigned this Dec 2, 2025
@pcriadoperez pcriadoperez marked this pull request as ready for review December 2, 2025 08:21
@carlosmiei
Copy link
Collaborator

@carlosmiei carlosmiei closed this Dec 5, 2025
@carlosmiei carlosmiei reopened this Dec 5, 2025
@carlosmiei carlosmiei merged commit a76774b into sammchardy:master Dec 5, 2025
8 checks passed
@percy507
Copy link

percy507 commented Dec 6, 2025

  • Add algo orders to client, async and websockets
  • Update futures createOrder

I think it will be more semantic if the package can split normal order and algo order with their own apis. But merge them is ok, just an advice.

Eg:

  • futures_create_order and futures_create_algo_order
  • futures_get_open_orders and futures_get_open_algo_orders

@carlosmiei
Copy link
Collaborator

@percy507 it does,

futures_create_order will only use the algoOrder service if the type matches, same thing with futures_get_open_orders (only if conditional is true)

basically we support both to minimize the required changes

@percy507
Copy link

percy507 commented Dec 7, 2025

@carlosmiei My mistake. I didn't notice you had already provided them!😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants