Skip to content

Conversation

@carlosmiei
Copy link
Collaborator

No description provided.

@carlosmiei carlosmiei self-assigned this Dec 9, 2025
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 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 FuturesOrder interface 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 conditional parameter 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
Copy link

Copilot AI Dec 9, 2025

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.

Suggested change
// Futures internal functions

Copilot uses AI. Check for mistakes.
Comment on lines 238 to 247
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))
})
Copy link

Copilot AI Dec 9, 2025

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).

Copilot uses AI. Check for mistakes.
Comment on lines 249 to 258
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))
})
Copy link

Copilot AI Dec 9, 2025

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).

Copilot uses AI. Check for mistakes.
@carlosmiei carlosmiei merged commit c2d4402 into master Dec 9, 2025
1 check failed
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.

3 participants