-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: add USDⓈ-M Futures algo order endpoints for conditional orders migration #1632
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
base: master
Are you sure you want to change the base?
Conversation
- 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
|
@dorsaalh thanks for your contribution, we will review it soon |
There was a problem hiding this 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): |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.
| 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 | |
| """ |
| 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): |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.
| 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 | |
| """ |
| 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): |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.
| 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 | |
| """ |
binance/client.py
Outdated
| 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 |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.
| """Get all algo orders; active, CANCELED, TRIGGERED or FINISHED | |
| """Get all algo orders; active, CANCELED, TRIGGERED or FINISHED. |
| 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) |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.).
| return self._request_futures_api('post', 'algoOrder', True, data=params) | |
| return self._request_futures_api("post", "algoOrder", True, data=params) |
| 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): |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.
| 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 | |
| """ |
| 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): |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.
| 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 | |
| """ |
| 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): |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.
| 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 | |
| """ |
binance/async_client.py
Outdated
| 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) |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.).
| return await self._request_futures_api('post', 'algoOrder', True, data=params) | |
| return await self._request_futures_api("post", "algoOrder", True, data=params) |
|
@carlosmiei Thanks, appreciate it! |
|
@dorsaalh can you check the review comments from copilot? |
|
@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 Just following up on this PR before tomorrow's migration (Dec 2). |
|
@dorsaalh we're aware we will do an update today |
|
@dorsaalh actually we noticed this was postponed 1 week |
|
@carlosmiei thanks for the update. 😊 |

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:
Both sync and async clients included. Follows existing patterns.