-
Notifications
You must be signed in to change notification settings - Fork 775
feat: add new algo service #968
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
Conversation
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 Binance futures algorithmic orders through a new dedicated API service. The implementation intelligently routes conditional order types (STOP, STOP_MARKET, TAKE_PROFIT, TAKE_PROFIT_MARKET, TRAILING_STOP_MARKET) to the algo order endpoint, while maintaining backward compatibility with the existing futures order system.
Key Changes
- Extended
FuturesOrderinterface to support algo-specific fields (algoId, clientAlgoId, triggerPrice, etc.) by making many existing fields optional - Enhanced
futuresOrder()to automatically detect and route conditional orders to the algo order endpoint - Added dedicated
futuresAlgoOrder()method for explicit algo order creation - Extended existing methods (cancel, status, open orders) with
conditionalparameter support and added dedicated algo-specific variants
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/types.ts | Extended FuturesOrder interface by making most fields optional and adding 13 new algo-specific fields to accommodate different order response types |
| src/node-binance-api.ts | Added auto-detection logic in futuresOrder(), new futuresAlgoOrder() method, and 5 new dedicated algo order management methods (status, cancel, cancel all, open orders, all orders) with conditional parameter support in existing methods |
| tests/binance-class-static.test.ts | Added 2 test cases validating algo order routing through both automatic detection and dedicated endpoint |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return await this.privateFuturesRequest('v1/order', params, 'POST'); | ||
| } | ||
|
|
||
| // Futures internal functions |
Copilot
AI
Dec 9, 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.
This comment "// Futures internal functions" is redundant as it's already declared at line 1158. This appears to be a copy-paste error and should be removed.
| // Futures internal functions |
| it( 'Futures Limit trigger Buy', async function ( ) { | ||
| await binance.futuresOrder('STOP', 'BUY', 'LTCUSDT', 0.5, 100, {'triggerPrice': 90} ) | ||
| assert.isTrue( interceptedUrl.startsWith('https://fapi.binance.com/fapi/v1/algoOrder' )) | ||
| const obj = urlToObject( interceptedUrl.replace('https://fapi.binance.com/fapi/v1/algoOrder?', '') ) | ||
| assert.equal( obj.symbol, 'LTCUSDT' ) | ||
| assert.equal( obj.side, 'BUY' ) | ||
| assert.equal( obj.type, 'STOP' ) | ||
| assert.equal( obj.quantity, 0.5 ) | ||
| assert(obj.clientAlgoId.startsWith(CONTRACT_PREFIX)) | ||
| }) |
Copilot
AI
Dec 9, 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.
The test should verify that algoType is set to 'CONDITIONAL' in the request, as this is a required parameter for algo orders according to the implementation in futuresOrder (line 1205 of node-binance-api.ts).
| it( 'Futures Limit trigger Buy using dedicated endpoint', async function ( ) { | ||
| await binance.futuresAlgoOrder('STOP', 'BUY', 'LTCUSDT', 0.5, 100, {'triggerPrice': 90} ) | ||
| assert.isTrue( interceptedUrl.startsWith('https://fapi.binance.com/fapi/v1/algoOrder' )) | ||
| const obj = urlToObject( interceptedUrl.replace('https://fapi.binance.com/fapi/v1/algoOrder?', '') ) | ||
| assert.equal( obj.symbol, 'LTCUSDT' ) | ||
| assert.equal( obj.side, 'BUY' ) | ||
| assert.equal( obj.type, 'STOP' ) | ||
| assert.equal( obj.quantity, 0.5 ) | ||
| assert(obj.clientAlgoId.startsWith(CONTRACT_PREFIX)) | ||
| }) |
Copilot
AI
Dec 9, 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.
The test should verify that algoType is set to 'CONDITIONAL' in the request, as this is a required parameter for algo orders according to the implementation in futuresAlgoOrder (line 1249 of node-binance-api.ts).
No description provided.