binance-api-node
Advanced tools
Comparing version 0.9.14 to 0.9.15
@@ -227,2 +227,11 @@ "use strict"; | ||
}; | ||
var _orderOco = function orderOco(privCall) { | ||
var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var url = arguments.length > 2 ? arguments[2] : undefined; | ||
var newPayload = payload.stopLimitPrice && !payload.stopLimitTimeInForce ? _objectSpread({ | ||
stopLimitTimeInForce: 'GTC' | ||
}, payload) : payload; | ||
return checkParams('order', newPayload, ['symbol', 'side', 'quantity', 'price', 'stopPrice']) && privCall(url, newPayload, 'POST'); | ||
}; | ||
/** | ||
@@ -350,2 +359,5 @@ * Zip asks and bids reponse from order book | ||
}, | ||
orderOco: function orderOco(payload) { | ||
return _orderOco(privCall, payload, '/api/v3/order/oco'); | ||
}, | ||
orderTest: function orderTest(payload) { | ||
@@ -352,0 +364,0 @@ return _order(privCall, payload, '/api/v3/order/test'); |
@@ -163,2 +163,3 @@ // tslint:disable:interface-name | ||
orderTest(options: NewOrder): Promise<Order>; | ||
orderOco(options: NewOcoOrder): Promise<OcoOrder>; | ||
ping(): Promise<boolean>; | ||
@@ -348,2 +349,20 @@ prices(): Promise<{ [index: string]: string }>; | ||
export interface NewOcoOrder { | ||
symbol: string; | ||
listClientOrderId?: string; | ||
side: OrderSide; | ||
quantity: string; | ||
limitClientOrderId?: string; | ||
price: string; | ||
limitIcebergQty?: string; | ||
stopClientOrderId?: string; | ||
stopPrice: string; | ||
stopLimitPrice?: string; | ||
stopIcebergQty?: string; | ||
stopLimitTimeInForce?: TimeInForce; | ||
newOrderRespType?: NewOrderRespType; | ||
recvWindow?: number; | ||
useServerTime?: boolean; | ||
} | ||
interface OrderFill { | ||
@@ -358,5 +377,7 @@ price: string; | ||
clientOrderId: string; | ||
cummulativeQuoteQty: string, | ||
executedQty: string; | ||
icebergQty?: string; | ||
orderId: number; | ||
orderListId: number; | ||
origQty: string; | ||
@@ -374,2 +395,14 @@ price: string; | ||
interface OcoOrder { | ||
orderListId: number; | ||
contingencyType: ContingencyType; | ||
listStatusType: ListStatusType; | ||
listOrderStatus: ListOrderStatus; | ||
listClientOrderId: string; | ||
transactionTime: number; | ||
symbol: string; | ||
orders: Order[]; | ||
orderReports: Order[]; | ||
} | ||
export type OrderSide = 'BUY' | 'SELL'; | ||
@@ -395,2 +428,14 @@ | ||
export type ListOrderStatus = | ||
| 'EXECUTING' | ||
| 'ALL_DONE' | ||
| 'REJECT'; | ||
export type ListStatusType = | ||
| 'RESPONSE' | ||
| 'EXEC_STARTED' | ||
| 'ALL_DONE'; | ||
export type ContingencyType = 'OCO'; | ||
export type NewOrderRespType = 'ACK' | 'RESULT' | 'FULL'; | ||
@@ -397,0 +442,0 @@ |
{ | ||
"name": "binance-api-node", | ||
"version": "0.9.14", | ||
"version": "0.9.15", | ||
"description": "A node API wrapper for Binance", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
105
README.md
@@ -75,2 +75,3 @@ # binance-api-node [![build](https://img.shields.io/travis/Ashlar/binance-api-node.svg?style=flat-square)](https://travis-ci.org/Ashlar/binance-api-node) [![cover](https://img.shields.io/coveralls/Ashlar/binance-api-node.svg?style=flat-square)](https://coveralls.io/github/Ashlar/binance-api-node) [![bnb](https://img.shields.io/badge/binance-winner-yellow.svg?style=flat-square)](https://github.com/binance-exchange/binance-api-node) | ||
- [orderTest](#ordertest) | ||
- [orderOco](#orderoco) | ||
- [getOrder](#getorder) | ||
@@ -925,2 +926,106 @@ - [cancelOrder](#cancelorder) | ||
#### orderOco | ||
Creates a new OCO order. | ||
```js | ||
console.log( | ||
await client.orderOco({ | ||
symbol: 'XLMETH', | ||
side: 'SELL', | ||
quantity: 100, | ||
price: 0.0002, | ||
stopPrice: 0.0001, | ||
stopLimitPrice: 0.0001, | ||
}), | ||
) | ||
``` | ||
| Param | Type | Required | Description | ||
|----------------------|--------|----------|------------ | ||
| symbol | String | true | | ||
| listClientOrderId | String | false | A unique Id for the entire orderList | ||
| side | String | true | `BUY`,`SELL` | ||
| quantity | Number | true | | ||
| limitClientOrderId | String | false | A unique Id for the limit order | ||
| price | Number | true | | ||
| limitIcebergQty | Number | false | Used to make the `LIMIT_MAKER` leg an iceberg order. | ||
| stopClientOrderId | String | false | A unique Id for the stop loss/stop loss limit leg | ||
| stopPrice | Number | true | ||
| stopLimitPrice | Number | false | If provided, `stopLimitTimeInForce` is required. | ||
| stopIcebergQty | Number | false | Used with `STOP_LOSS_LIMIT` leg to make an iceberg order. | ||
| stopLimitTimeInForce | String | false | `FOK`, `GTC`, `IOC` | ||
| newOrderRespType | String | false | Returns more complete info of the order. `ACK`, `RESULT`, or `FULL` | ||
| recvWindow | Number | false | The value cannot be greater than `60000` | ||
Additional Info: | ||
- Price Restrictions: | ||
- `SELL`: Limit Price > Last Price > Stop Price | ||
- `BUY`: Limit Price < Last Price < Stop Price | ||
- Quantity Restrictions: | ||
- Both legs must have the same quantity. | ||
- ```ICEBERG``` quantities however do not have to be the same | ||
<details> | ||
<summary>Output</summary> | ||
```js | ||
{ | ||
"orderListId": 0, | ||
"contingencyType": "OCO", | ||
"listStatusType": "EXEC_STARTED", | ||
"listOrderStatus": "EXECUTING", | ||
"listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp", | ||
"transactionTime": 1514418413947, | ||
"symbol": "XLMETH", | ||
"orders": [ | ||
{ | ||
"symbol": "XLMETH", | ||
"orderId": 1740797, | ||
"clientOrderId": "1XZTVBTGS4K1e" | ||
}, | ||
{ | ||
"symbol": "XLMETH", | ||
"orderId": 1740798, | ||
"clientOrderId": "1XZTVBTGS4K1f" | ||
} | ||
], | ||
"orderReports": [ | ||
{ | ||
"symbol": "XLMETH", | ||
"orderId": 1740797, | ||
"orderListId": 0, | ||
"clientOrderId": "1XZTVBTGS4K1e", | ||
"transactTime": 1514418413947, | ||
"price": "0.000000", | ||
"origQty": "100", | ||
"executedQty": "0.000000", | ||
"cummulativeQuoteQty": "0.000000", | ||
"status": "NEW", | ||
"timeInForce": "GTC", | ||
"type": "STOP_LOSS", | ||
"side": "SELL", | ||
"stopPrice": "0.0001" | ||
}, | ||
{ | ||
"symbol": "XLMETH", | ||
"orderId": 1740798, | ||
"orderListId": 0, | ||
"clientOrderId": "1XZTVBTGS4K1f", | ||
"transactTime": 1514418413947, | ||
"price": "0.0002", | ||
"origQty": "100", | ||
"executedQty": "0.000000", | ||
"cummulativeQuoteQty": "0.000000", | ||
"status": "NEW", | ||
"timeInForce": "GTC", | ||
"type": "LIMIT_MAKER", | ||
"side": "SELL" | ||
} | ||
] | ||
} | ||
``` | ||
</details> | ||
#### getOrder | ||
@@ -927,0 +1032,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97383
1595
1740