Skip to content

Commit

Permalink
Add endpoint marginCancelOpenOrders and documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Binczak committed Nov 9, 2024
1 parent b908ba8 commit 96ecf1f
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 0 deletions.
135 changes: 135 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -3194,6 +3197,49 @@ console.log(await client.marginOrder({

</details>

#### 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 |

<details>
<summary>Output</summary>

```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"
}
```

</details>

#### marginOrderOco

```js
Expand Down Expand Up @@ -3286,6 +3332,95 @@ console.log(await client.marginOrderOco({

</details>

#### 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 |

<details>
<summary>Output</summary>

```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
}
]
```

</details>

#### 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 |

<details>
<summary>Output</summary>

```js
[
{
symbol: 'ETHBTC',
isIsolated: false,
origClientOrderId: 'bnAoRHgI18gRD80FJmsfNP',
orderId: 1,
clientOrderId: 'RViSsQPTp1v3WmLYpeKT11'
},
{
symbol: 'ETHBTC',
isIsolated: false,
origClientOrderId: 'IDbzcGmfwSCKihxILK1snu',
orderId: 2,
clientOrderId: 'HKFcuWAm9euMgRuwVGR8CL'
}
]
```

</details>

#### marginGetOrder

Query Margin Account's Order
Expand Down
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -770,6 +776,7 @@ declare module 'binance-api-node' {
symbol?: string
useServerTime?: boolean
}): Promise<QueryOrderResult[]>
marginCancelOpenOrders(options: marginCancelOpenOrdersOptions): Promise<CancelOrderResult[]>
marginRepay(options: MarginBorrowOptions): Promise<{ tranId: number }>
marginLoan(options: MarginBorrowOptions): Promise<{ tranId: number }>
marginAccountInfo(options?: { recvWindow?: number }): Promise<IsolatedCrossAccount>
Expand Down
1 change: 1 addition & 0 deletions src/http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 96ecf1f

Please sign in to comment.