Skip to content
10 changes: 10 additions & 0 deletions src/http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ export default opts => {

// Order endpoints
order: payload => order(privCall, payload, '/api/v3/order'),
updateOrder: payload => privCall('/api/v3/order/cancelReplace', payload, 'POST'),
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The updateOrder endpoint lacks test coverage. Other order endpoints in test/orders.js have corresponding tests (e.g., orderTest, getOrder, cancelOrder). Consider adding tests for updateOrder to verify parameter handling, error cases, and successful order updates using the /api/v3/order/cancelReplace endpoint.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

Consider adding parameter validation or using a helper function similar to the 'order' helper used for the order endpoint. The order endpoint validates required parameters like 'symbol' and 'side' and handles automatic newClientOrderId generation. The updateOrder endpoint likely has similar requirements that should be validated.

Copilot uses AI. Check for mistakes.
orderOco: payload => orderOco(privCall, payload, '/api/v3/order/oco'),
orderTest: payload => order(privCall, payload, '/api/v3/order/test'),
getOrder: payload => privCall('/api/v3/order', payload),
Expand Down Expand Up @@ -598,6 +599,15 @@ export default opts => {
// Use regular order endpoint
return order(privCall, payload, '/fapi/v1/order')
},
futuresUpdateOrder: payload => {
if (payload && 'conditional' in payload) {
// for now it is not supported
// const payloadCopy = { ...payload }
// delete payloadCopy.conditional
// return privCall('/fapi/v1/algoOrder', payloadCopy, 'PUT')
Comment on lines +625 to +628
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

Commented-out code should be removed. If this functionality is planned for future implementation, consider creating a TODO comment or GitHub issue instead of leaving commented code in the codebase.

Copilot uses AI. Check for mistakes.
}
Comment on lines +623 to +629
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The conditional check at line 603 does not perform any action when 'conditional' is present in the payload. The if block is empty (only contains commented code), so the function will continue to line 609 regardless. Either implement the conditional order update logic or remove this placeholder code.

Copilot uses AI. Check for mistakes.
return privCall('/fapi/v1/order', payload, 'PUT')
},
Comment on lines +623 to +631
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The futuresUpdateOrder endpoint lacks test coverage. Other futures order endpoints in test/futures.js have corresponding tests (e.g., futuresOrder, futuresGetOrder, futuresCancelOrder). Consider adding tests for futuresUpdateOrder to verify parameter handling, error cases, and successful order updates using the /fapi/v1/order PUT endpoint.

Copilot uses AI. Check for mistakes.
Comment on lines +623 to +631
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The futuresUpdateOrder implementation is inconsistent with futuresGetOrder and futuresCancelOrder patterns. Both of those methods handle conditional orders by checking the conditional flag and properly routing to the algo endpoint, and they also create a payloadCopy to remove the 'conditional' property before making the API call. Consider implementing similar logic here for consistency.

Copilot uses AI. Check for mistakes.
futuresBatchOrders: payload => privCall('/fapi/v1/batchOrders', payload, 'POST'),
futuresGetOrder: payload => {
// Check if this is a request for a conditional/algo order
Expand Down