diff --git a/README.md b/README.md index 9f4de69..e70354f 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,10 @@ Following examples will use the `await` form, which requires some configuration - [marginIsolatedTransfer](#marginIsolatedTransfer) - [marginIsolatedTransferHistory](#marginIsolatedTransferHistory) - [marginOrder](#marginOrder) + - [marginCancelOrder](#marginCancelOrder) - [marginOrderOco](#marginOrderOco) + - [marginOpenOrders](#marginOpenOrders) + - [marginCancelOpenOrders](#marginCancelOpenOrders) - [marginGetOrder](#marginGetOrder) - [marginGetOrderOco](#marginGetOrderOco) - [disableMarginAccount](#disableMarginAccount) @@ -3194,6 +3197,49 @@ console.log(await client.marginOrder({ +#### marginCancelOrder + +Cancels an active margin order. + +```js +console.log( + await client.marginCancelOrder({ + symbol: 'ETHBTC', + orderId: 1, + }), +) +``` + +| Param | Type | Required | Description | +| ----------------- | ------ | -------- | -------------------------------------------------------------------------- | +| symbol | String | true | +| orderId | Number | true | Not required if `origClientOrderId` is used | +| origClientOrderId | String | false | +| newClientOrderId | String | false | Used to uniquely identify this cancel. Automatically generated by default. | +| recvWindow | Number | false | + +
+Output + +```js +{ + symbol: "LTCBTC", + orderId: 28, + origClientOrderId: "myOrder1", + clientOrderId: "cancelMyOrder1", + price: "1.00000000", + origQty: "10.00000000", + executedQty: "8.00000000", + cummulativeQuoteQty: "8.00000000", + status: "CANCELED", + timeInForce: "GTC", + type: "LIMIT", + side: "SELL" +} +``` + +
+ #### marginOrderOco ```js @@ -3286,6 +3332,95 @@ console.log(await client.marginOrderOco({ +#### marginOpenOrders + +Query Margin Account's Open Orders + +```js +console.log( + await client.marginOpenOrders({ + symbol: 'XLMBTC', + }), +) +``` + +| Param | Type | Required | +| ---------- | ------ | -------- | +| symbol | String | false | +| isIsolated | String | false | +| recvWindow | Number | false | + +
+Output + +```js +;[ + { + clientOrderId: "qhcZw71gAkCCTv0t0k8LUK", + cummulativeQuoteQty: "0.00000000", + executedQty: "0.00000000", + icebergQty: "0.00000000", + isWorking: true, + orderId: 211842552, + origQty: "0.30000000", + price: "0.00475010", + side: "SELL", + status: "NEW", + stopPrice: "0.00000000", + symbol: "BNBBTC", + isIsolated: true, + time: 1562040170089, + timeInForce: "GTC", + type: "LIMIT", + selfTradePreventionMode: "NONE", + updateTime: 1562040170089 + } +] +``` + +
+ +#### marginCancelOpenOrders + +Cancels all active orders on a symbol for margin account. +This includes OCO orders. + +```js +console.log( + await client.marginCancelOpenOrders({ + symbol: 'ETHBTC' + }), +) +``` +| Param | Type | Required | +|------------|----------|-----------| +| symbol | String | true | +| isIsolated | String | false | + +
+Output + +```js +[ + { + symbol: 'ETHBTC', + isIsolated: false, + origClientOrderId: 'bnAoRHgI18gRD80FJmsfNP', + orderId: 1, + clientOrderId: 'RViSsQPTp1v3WmLYpeKT11' + }, + { + symbol: 'ETHBTC', + isIsolated: false, + origClientOrderId: 'IDbzcGmfwSCKihxILK1snu', + orderId: 2, + clientOrderId: 'HKFcuWAm9euMgRuwVGR8CL' + } +] +``` + +
+ #### marginGetOrder Query Margin Account's Order diff --git a/index.d.ts b/index.d.ts index 429912d..b533399 100644 --- a/index.d.ts +++ b/index.d.ts @@ -378,6 +378,12 @@ declare module 'binance-api-node' { useServerTime?: boolean } + export type marginCancelOpenOrdersOptions = { + symbol: string + useServerTime?: boolean, + isIsolated?: 'TRUE' | 'FALSE' | boolean + } + export interface GetInfo { spot: GetInfoDetails futures: GetInfoDetails @@ -770,6 +776,7 @@ declare module 'binance-api-node' { symbol?: string useServerTime?: boolean }): Promise + marginCancelOpenOrders(options: marginCancelOpenOrdersOptions): Promise marginRepay(options: MarginBorrowOptions): Promise<{ tranId: number }> marginLoan(options: MarginBorrowOptions): Promise<{ tranId: number }> marginAccountInfo(options?: { recvWindow?: number }): Promise diff --git a/src/http-client.js b/src/http-client.js index 642754f..4a53799 100644 --- a/src/http-client.js +++ b/src/http-client.js @@ -440,6 +440,7 @@ export default opts => { marginGetOrderOco: payload => privCall('/sapi/v1/margin/orderList', payload), marginCancelOrder: payload => privCall('/sapi/v1/margin/order', payload, 'DELETE'), marginOpenOrders: payload => privCall('/sapi/v1/margin/openOrders', payload), + marginCancelOpenOrders: payload => privCall('/sapi/v1/margin/openOrders', payload, 'DELETE'), marginAccountInfo: payload => privCall('/sapi/v1/margin/account', payload), marginMyTrades: payload => privCall('/sapi/v1/margin/myTrades', payload), marginRepay: payload => privCall('/sapi/v1/margin/repay', payload, 'POST'),