Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 712b943

Browse files
authored
Add margin order oco (ccxt#500)
* Add margin order oco * Update Readme with marginOrderOco
1 parent 64ef9d9 commit 712b943

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Following examples will use the `await` form, which requires some configuration
112112
- [marginIsolatedTransfer](#marginIsolatedTransfer)
113113
- [marginIsolatedTransferHistory](#marginIsolatedTransferHistory)
114114
- [marginOrder](#marginOrder)
115+
- [marginOrderOco](#marginOrderOco)
115116
- [marginGetOrder](#marginGetOrder)
116117
- [Futures Authenticated REST Endpoints](#futures-authenticated-rest-endpoints)
117118
- [futuresGetOrder](#futuresGetOrder)
@@ -2749,6 +2750,98 @@ console.log(await client.marginOrder({
27492750

27502751
</details>
27512752

2753+
#### marginOrderOco
2754+
2755+
```js
2756+
console.log(await client.marginOrderOco({
2757+
symbol: 'AUDIOUSDT',
2758+
type: 'MARKET',
2759+
side: 'SELL',
2760+
quantity: '10',
2761+
}));
2762+
```
2763+
2764+
| Param | Type | Required | Description |
2765+
| ----------------- | ------- | -------- | ------------------------- |
2766+
| symbol | String | true | asset, such as `BTC` |
2767+
| isIsolated | String | false | for isolated margin or not, `TRUE`, `FALSE`, default `FALSE`
2768+
| side | String | true | `BUY` `SELL` |
2769+
| type | String | true |
2770+
| quantity | String | false |
2771+
| quoteOrderQty | String | false |
2772+
| price | String | false |
2773+
| stopPrice | String | false | Used with `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders.
2774+
| stopLimitPrice | String | false | Used with `STOP_LOSS_LIMIT` orders.
2775+
| newClientOrderId | String | false | A unique id among open orders. Automatically generated if not sent.
2776+
| icebergQty | Boolean | false | Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order.
2777+
| newOrderRespType | String | false | Set the response JSON. `ACK`, `RESULT`, or `FULL`; `MARKET` and `LIMIT` order types default to `FULL`, all other orders default to `ACK`.
2778+
| sideEffectType | String | false | `NO_SIDE_EFFECT`, `MARGIN_BUY`, `AUTO_REPAY`; default `NO_SIDE_EFFECT`.
2779+
| timeInForce | String | false | `GTC`,`IOC`,`FOK` |
2780+
| recvWindow | Number | false | No more than 60000 |
2781+
2782+
<details>
2783+
<summary>Output</summary>
2784+
2785+
```js
2786+
{
2787+
"orderListId": 45514668,
2788+
"contingencyType": 'OCO',
2789+
"listStatusType": 'EXEC_STARTED',
2790+
"listOrderStatus": 'EXECUTING',
2791+
"listClientOrderId": 'CD9UzEJfmcGZ4kLfZT2ga2',
2792+
"transactionTime": 1632192162785,
2793+
"symbol": 'AUDIOUSDT',
2794+
"isIsolated": true,
2795+
"orders": [
2796+
{
2797+
"symbol": 'AUDIOUSDT',
2798+
"orderId": 239313661,
2799+
"clientOrderId": 'ZbUwgKv6UB8eMzf2yfXENl'
2800+
},
2801+
{
2802+
"symbol": 'AUDIOUSDT',
2803+
"orderId": 239313662,
2804+
"clientOrderId": 'f5u1RIHAPRd4W3fFhFykBo'
2805+
}
2806+
],
2807+
"orderReports": [
2808+
{
2809+
"symbol": 'AUDIOUSDT',
2810+
"orderId": 239313661,
2811+
"orderListId": 45514668,
2812+
"clientOrderId": 'ZbUwgKv6UB8eMzf2yfXENl',
2813+
"transactTime": 1632192162785,
2814+
"price": '2.20000000',
2815+
"origQty": '12.80000000',
2816+
"executedQty": '0',
2817+
"cummulativeQuoteQty": '0',
2818+
"status": 'NEW',
2819+
"timeInForce": 'GTC',
2820+
"type": 'STOP_LOSS_LIMIT',
2821+
"side": 'SELL',
2822+
"stopPrice": '2.20000000'
2823+
},
2824+
{
2825+
"symbol": 'AUDIOUSDT',
2826+
"orderId": 239313662,
2827+
"orderListId": 45514668,
2828+
"clientOrderId": 'f5u1RIHAPRd4W3fFhFykBo',
2829+
"transactTime": 1632192162785,
2830+
"price": '2.50000000',
2831+
"origQty": '12.80000000',
2832+
"executedQty": '0',
2833+
"cummulativeQuoteQty": '0',
2834+
"status": 'NEW',
2835+
"timeInForce": 'GTC',
2836+
"type": 'LIMIT_MAKER',
2837+
"side": 'SELL'
2838+
}
2839+
]
2840+
}
2841+
```
2842+
2843+
</details>
2844+
27522845
#### marginGetOrder
27532846

27542847
Query Margin Account's Order

index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ declare module 'binance-api-node' {
542542
recvWindow?: number
543543
}): Promise<FuturesIncomeResult[]>
544544
marginOrder(options: NewOrderMargin): Promise<Order>
545+
marginOrderOco(options: NewOcoOrderMargin): Promise<MarginOcoOrder>
545546
marginGetOrder(options: {
546547
symbol: string
547548
isIsolated?: string | boolean
@@ -925,6 +926,10 @@ declare module 'binance-api-node' {
925926

926927
export type NewOrderMargin = NewOrderSpot & NewMarginOrderParent
927928

929+
export type NewOcoOrderMargin = NewOrderSpot & NewOcoOrder & NewMarginOrderParent & {}
930+
931+
export type MarginOcoOrder = OcoOrder & { isIsolated?: 'TRUE' | 'FALSE' | boolean }
932+
928933
export type SideEffectType_LT = 'NO_SIDE_EFFECT' | 'MARGIN_BUY' | 'AUTO_REPAY'
929934

930935
export const enum SideEffectType {

src/http-client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ export default opts => {
392392

393393
marginAllOrders: payload => privCall('/sapi/v1/margin/allOrders', payload),
394394
marginOrder: payload => order(privCall, payload, '/sapi/v1/margin/order'),
395+
marginOrderOco: payload => _orderOco(privCall, payload, '/sapi/v1/margin/order/oco'),
395396
marginGetOrder: payload => privCall('/sapi/v1/margin/order', payload),
396397
marginCancelOrder: payload => privCall('/sapi/v1/margin/order', payload, 'DELETE'),
397398
marginOpenOrders: payload => privCall('/sapi/v1/margin/openOrders', payload),

0 commit comments

Comments
 (0)