Skip to content

Commit

Permalink
Add endpoint marginGetOrderOco (#666)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Binczak <binczakmartin@gmail.com>
  • Loading branch information
binczakmartin and Martin Binczak authored Nov 8, 2024
1 parent 6d27134 commit 70c1c4b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Following examples will use the `await` form, which requires some configuration
- [marginOrder](#marginOrder)
- [marginOrderOco](#marginOrderOco)
- [marginGetOrder](#marginGetOrder)
- [marginGetOrderOco](#marginGetOrderOco)
- [disableMarginAccount](#disableMarginAccount)
- [enableMarginAccount](#enableMarginAccount)
- [Portfolio Margin](#portfolio-margin)
Expand Down Expand Up @@ -3331,6 +3332,55 @@ console.log(await client.marginGetOrder({

</details>

#### marginGetOrderOco

Retrieves a specific Margin OCO based on provided optional parameters

```js
console.log(
await client.getMarginOrderOco({
orderListId: 27,
}),
)
```

| Param | Type | Required | Description |
| ----------------- | ------ | -------- | ------------------------------------------- |
| orderListId | Number | true | Not required if `listClientOrderId` is used |
| symbol | Boolean| false | mandatory for isolated margin, not supported for cross margin
| isIsolated | Boolean| false |
| listClientOrderId | String | false |
| recvWindow | Number | false |

<details>
<summary>Output</summary>

```js
{
orderListId: 27,
contingencyType: 'OCO',
listStatusType: 'EXEC_STARTED',
listOrderStatus: 'EXECUTING',
listClientOrderId: 'h2USkA5YQpaXHPIrkd96xE',
transactionTime: 1565245656253,
symbol: 'LTCBTC',
isIsolated: false,
orders: [
{
symbol: 'LTCBTC',
orderId: 4,
clientOrderId: 'qD1gy3kc3Gx0rihm9Y3xwS'
},
{
symbol: 'LTCBTC',
orderId: 5,
clientOrderId: 'ARzZ9I00CPM8i3NhmU9Ega'
}
]
}
```
</details>

### Portfolio Margin Endpoints

Only Portfolio Margin Account is accessible to these endpoints.
Expand Down
19 changes: 19 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,13 @@ declare module 'binance-api-node' {
origClientOrderId?: string
recvWindow?: number
}): Promise<Order>
marginGetOrderOco(options: {
symbol: string
isIsolated?: string | boolean
orderId?: string
origClientOrderId?: string
recvWindow?: number
}): Promise<QueryOrderOcoResult>
marginAllOrders(options: {
symbol: string
useServerTime?: boolean
Expand Down Expand Up @@ -1905,6 +1912,18 @@ declare module 'binance-api-node' {
orders: Order[]
}

export interface QueryMarginOrderOcoResult {
orderListId: number
contingencyType: OcoOrderType.CONTINGENCY_TYPE
listStatusType: ListStatusType_LT
listOrderStatus: ListOrderStatus_LT
listClientOrderId: string
transactionTime: number
symbol: string
isIsolated: Boolean
orders: Order[]
}

export interface CancelOrderResult {
symbol: string
origClientOrderId: string
Expand Down
1 change: 1 addition & 0 deletions src/http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ export default opts => {
marginOrder: payload => order(privCall, payload, '/sapi/v1/margin/order'),
marginOrderOco: payload => orderOco(privCall, payload, '/sapi/v1/margin/order/oco'),
marginGetOrder: payload => privCall('/sapi/v1/margin/order', payload),
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),
marginAccountInfo: payload => privCall('/sapi/v1/margin/account', payload),
Expand Down

0 comments on commit 70c1c4b

Please sign in to comment.