From 70c1c4bcbd2e1be3f134b6e538c2628e6bf80fe2 Mon Sep 17 00:00:00 2001 From: binczakmartin Date: Fri, 8 Nov 2024 12:08:18 +0100 Subject: [PATCH] Add endpoint marginGetOrderOco (#666) Co-authored-by: Martin Binczak --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++ index.d.ts | 19 ++++++++++++++++++ src/http-client.js | 1 + 3 files changed, 70 insertions(+) diff --git a/README.md b/README.md index 405a5940..9f4de694 100644 --- a/README.md +++ b/README.md @@ -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) @@ -3331,6 +3332,55 @@ console.log(await client.marginGetOrder({ +#### 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 | + +
+Output + +```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' + } + ] +} +``` +
+ ### Portfolio Margin Endpoints Only Portfolio Margin Account is accessible to these endpoints. diff --git a/index.d.ts b/index.d.ts index 30599ade..429912d4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -750,6 +750,13 @@ declare module 'binance-api-node' { origClientOrderId?: string recvWindow?: number }): Promise + marginGetOrderOco(options: { + symbol: string + isIsolated?: string | boolean + orderId?: string + origClientOrderId?: string + recvWindow?: number + }): Promise marginAllOrders(options: { symbol: string useServerTime?: boolean @@ -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 diff --git a/src/http-client.js b/src/http-client.js index 7156d6a1..642754fd 100644 --- a/src/http-client.js +++ b/src/http-client.js @@ -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),