Skip to content

Conversation

@dorsaalh
Copy link

Add USDⓈ-M Futures algo order endpoints for Binance migration

Adds the 6 new algo order methods needed for Binance's conditional orders migration to Algo Service (effective Dec 2, 2025).

New methods:

  • futures_create_algo_order
  • futures_cancel_algo_order
  • futures_cancel_all_open_algo_orders
  • futures_get_algo_order
  • futures_get_open_algo_orders
  • futures_get_all_algo_orders

Both sync and async clients included. Follows existing patterns.

- Implement 6 new methods for conditional orders migration to Algo Service
- Add futures_create_algo_order, futures_cancel_algo_order,
  futures_cancel_all_open_algo_orders, futures_get_algo_order,
  futures_get_open_algo_orders, futures_get_all_algo_orders
- Support both sync and async clients with comprehensive documentation
- Prepare for Binance API migration effective 2025-12-02
- Follow existing library patterns and conventions
@carlosmiei
Copy link
Collaborator

@dorsaalh thanks for your contribution, we will review it soon

Copilot finished reviewing on behalf of carlosmiei November 12, 2025 18:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for USDⓈ-M Futures algo order endpoints to facilitate Binance's migration of conditional orders to their Algo Service (effective December 2, 2025).

Key Changes:

  • Added 6 new algo order methods to both sync and async clients
  • Methods include create, cancel (single/all), and query (single/open/all) operations for algo orders
  • Implementation follows existing patterns for regular futures orders

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

File Description
binance/client.py Added 6 synchronous algo order methods with full documentation (futures_create_algo_order, futures_cancel_algo_order, futures_cancel_all_open_algo_orders, futures_get_algo_order, futures_get_open_algo_orders, futures_get_all_algo_orders)
binance/async_client.py Added 6 asynchronous algo order methods corresponding to sync client implementations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

params["newClientOrderId"] = self.CONTRACT_ORDER_PREFIX + self.uuid22()
return await self._request_futures_api("post", "order", True, data=params)

async def futures_create_algo_order(self, **params):
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstrings for all algo order methods. The sync client methods (client.py) have proper documentation with descriptions and API reference links, but these async versions are missing them. Add docstrings to maintain consistency with the sync client and help users understand these methods. See the corresponding methods in client.py (lines 7784-7994) for reference.

Suggested change
async def futures_create_algo_order(self, **params):
async def futures_create_algo_order(self, **params):
"""Send in a new futures algo order.
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/algo-order
"""

Copilot uses AI. Check for mistakes.
Comment on lines +2009 to +2021
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)

async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)

async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)

async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)

async def futures_cancel_all_open_algo_orders(self, **params):
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstrings for all algo order methods. The sync client methods (client.py) have proper documentation with descriptions and API reference links, but these async versions are missing them. Add docstrings to maintain consistency with the sync client and help users understand these methods. See the corresponding methods in client.py (lines 7784-7994) for reference.

Suggested change
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
async def futures_get_algo_order(self, **params):
"""Get a specific algo order (Futures).
https://binance-docs.github.io/apidocs/futures/en/#query-algo-order-user_data
:param symbol: str
:param algoId: str
:param isIsolated: str (optional)
:param recvWindow: int (optional)
:return: API response
"""
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
"""Get all open algo orders (Futures).
https://binance-docs.github.io/apidocs/futures/en/#query-open-algo-orders-user_data
:param symbol: str
:param isIsolated: str (optional)
:param algoType: str (optional)
:param recvWindow: int (optional)
:return: API response
"""
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
"""Get all algo orders (Futures).
https://binance-docs.github.io/apidocs/futures/en/#query-all-algo-orders-user_data
:param symbol: str
:param isIsolated: str (optional)
:param algoType: str (optional)
:param startTime: int (optional)
:param endTime: int (optional)
:param limit: int (optional)
:param recvWindow: int (optional)
:return: API response
"""
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
"""Cancel a specific algo order (Futures).
https://binance-docs.github.io/apidocs/futures/en/#cancel-algo-order-trade
:param symbol: str
:param algoId: str
:param isIsolated: str (optional)
:param recvWindow: int (optional)
:return: API response
"""
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
"""Cancel all open algo orders (Futures).
https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-algo-orders-trade
:param symbol: str
:param isIsolated: str (optional)
:param algoType: str (optional)
:param recvWindow: int (optional)
:return: API response
"""

Copilot uses AI. Check for mistakes.
Comment on lines +2009 to +2021
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)

async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)

async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)

async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)

async def futures_cancel_all_open_algo_orders(self, **params):
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstrings for all algo order methods. The sync client methods (client.py) have proper documentation with descriptions and API reference links, but these async versions are missing them. Add docstrings to maintain consistency with the sync client and help users understand these methods. See the corresponding methods in client.py (lines 7784-7994) for reference.

Suggested change
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
async def futures_get_algo_order(self, **params):
"""
Get a single algo order on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#query-algo-order-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
"""
Get all open algo orders on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#current-open-algo-orders-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
"""
Get all algo orders (historical and current) on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#query-algo-orders-history-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
"""
Cancel a single algo order on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#cancel-algo-order-trade
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
"""
Cancel all open algo orders on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-algo-orders-trade
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""

Copilot uses AI. Check for mistakes.
return self._request_futures_api("get", "openAlgoOrders", True, data=params)

def futures_get_all_algo_orders(self, **params):
"""Get all algo orders; active, CANCELED, TRIGGERED or FINISHED
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing period at the end of the docstring. Add a period to maintain consistency with similar methods like futures_get_all_orders at line 7915.

Suggested change
"""Get all algo orders; active, CANCELED, TRIGGERED or FINISHED
"""Get all algo orders; active, CANCELED, TRIGGERED or FINISHED.

Copilot uses AI. Check for mistakes.
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Algo-Order

"""
return self._request_futures_api('post', 'algoOrder', True, data=params)
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent quote style. Use double quotes for the method parameter to match the style used in other methods in this file (e.g., line 7782, 7962, etc.).

Suggested change
return self._request_futures_api('post', 'algoOrder', True, data=params)
return self._request_futures_api("post", "algoOrder", True, data=params)

Copilot uses AI. Check for mistakes.
Comment on lines +2009 to +2021
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)

async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)

async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)

async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)

async def futures_cancel_all_open_algo_orders(self, **params):
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstrings for all algo order methods. The sync client methods (client.py) have proper documentation with descriptions and API reference links, but these async versions are missing them. Add docstrings to maintain consistency with the sync client and help users understand these methods. See the corresponding methods in client.py (lines 7784-7994) for reference.

Suggested change
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
async def futures_get_algo_order(self, **params):
"""
Get a single algo order on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#query-algo-order-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
"""
Get all open algo orders on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#current-open-algo-orders-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
"""
Get all algo orders (historical and current) on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#all-algo-orders-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
"""
Cancel a single algo order on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#cancel-algo-order-trade
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
"""
Cancel all open algo orders on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-algo-orders-trade
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""

Copilot uses AI. Check for mistakes.
Comment on lines +2009 to +2021
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)

async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)

async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)

async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)

async def futures_cancel_all_open_algo_orders(self, **params):
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstrings for all algo order methods. The sync client methods (client.py) have proper documentation with descriptions and API reference links, but these async versions are missing them. Add docstrings to maintain consistency with the sync client and help users understand these methods. See the corresponding methods in client.py (lines 7784-7994) for reference.

Suggested change
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
async def futures_get_algo_order(self, **params):
"""
Get a single algo order on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#query-algo-order-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
"""
Get all open algo orders on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#current-open-algo-orders-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
"""
Get all algo orders (historical and current) on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#query-algo-order-history-user_data
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
"""
Cancel a single algo order on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#cancel-algo-order-trade
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
"""
Cancel all open algo orders on Binance Futures.
https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-algo-orders-trade
:param params: See Binance API documentation for accepted parameters.
:return: API response
"""

Copilot uses AI. Check for mistakes.
Comment on lines +2009 to +2021
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)

async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)

async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)

async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)

async def futures_cancel_all_open_algo_orders(self, **params):
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstrings for all algo order methods. The sync client methods (client.py) have proper documentation with descriptions and API reference links, but these async versions are missing them. Add docstrings to maintain consistency with the sync client and help users understand these methods. See the corresponding methods in client.py (lines 7784-7994) for reference.

Suggested change
async def futures_get_algo_order(self, **params):
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
async def futures_get_algo_order(self, **params):
"""
Get a single algo order on Binance Futures.
See Binance API documentation:
https://binance-docs.github.io/apidocs/futures/en/#query-algo-order-user_data
:param params: Required and optional parameters for the endpoint.
:type params: dict
:return: API response
"""
return await self._request_futures_api("get", "algoOrder", True, data=params)
async def futures_get_open_algo_orders(self, **params):
"""
Get all open algo orders on Binance Futures.
See Binance API documentation:
https://binance-docs.github.io/apidocs/futures/en/#current-open-algo-orders-user_data
:param params: Required and optional parameters for the endpoint.
:type params: dict
:return: API response
"""
return await self._request_futures_api("get", "openAlgoOrders", True, data=params)
async def futures_get_all_algo_orders(self, **params):
"""
Get all algo orders (historical and current) on Binance Futures.
See Binance API documentation:
https://binance-docs.github.io/apidocs/futures/en/#query-all-algo-orders-user_data
:param params: Required and optional parameters for the endpoint.
:type params: dict
:return: API response
"""
return await self._request_futures_api("get", "allAlgoOrders", True, data=params)
async def futures_cancel_algo_order(self, **params):
"""
Cancel a single algo order on Binance Futures.
See Binance API documentation:
https://binance-docs.github.io/apidocs/futures/en/#cancel-algo-order-trade
:param params: Required and optional parameters for the endpoint.
:type params: dict
:return: API response
"""
return await self._request_futures_api("delete", "algoOrder", True, data=params)
async def futures_cancel_all_open_algo_orders(self, **params):
"""
Cancel all open algo orders on Binance Futures.
See Binance API documentation:
https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-algo-orders-trade
:param params: Required and optional parameters for the endpoint.
:type params: dict
:return: API response
"""

Copilot uses AI. Check for mistakes.
return await self._request_futures_api("post", "order", True, data=params)

async def futures_create_algo_order(self, **params):
return await self._request_futures_api('post', 'algoOrder', True, data=params)
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent quote style. Use double quotes for string literals to match the style used in other methods in this file (e.g., line 7782 uses "post" and "order", line 7962 uses "get" and "algoOrder", etc.).

Suggested change
return await self._request_futures_api('post', 'algoOrder', True, data=params)
return await self._request_futures_api("post", "algoOrder", True, data=params)

Copilot uses AI. Check for mistakes.
@dorsaalh
Copy link
Author

@carlosmiei Thanks, appreciate it!

@carlosmiei
Copy link
Collaborator

@dorsaalh can you check the review comments from copilot?

@dorsaalh
Copy link
Author

@carlosmiei Yeah, I checked them! All are about code style consistency, I'm fixing those now.

For the docstring comments, I noticed the async client traditionally doesn't have docstrings (unlike the sync client), so I followed that existing pattern. Happy to add them if you'd prefer though - just let me know which way to go!

@carlosmiei carlosmiei closed this Nov 19, 2025
@carlosmiei carlosmiei reopened this Nov 19, 2025
@dorsaalh
Copy link
Author

dorsaalh commented Dec 1, 2025

@carlosmiei Just following up on this PR before tomorrow's migration (Dec 2).

@carlosmiei
Copy link
Collaborator

@dorsaalh we're aware we will do an update today

@carlosmiei
Copy link
Collaborator

@dorsaalh actually we noticed this was postponed 1 week
image

@dorsaalh
Copy link
Author

dorsaalh commented Dec 2, 2025

@carlosmiei thanks for the update. 😊

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.

2 participants