Comparing version 1.1.1 to 1.1.2
# Changelog | ||
## 1.1.2 | ||
- Add lots of example responses and query paramter details to the README | ||
- Fix onUserData where the promise wasn't being returned | ||
- Add travis CI and coveralls | ||
## 1.1.1 | ||
@@ -4,0 +9,0 @@ - Minor docs updates |
@@ -10,2 +10,3 @@ const WebSocket = require('ws'); | ||
this._beautifier = new Beautifier(); | ||
this._dataStreamInterval = -1; | ||
} | ||
@@ -42,3 +43,3 @@ | ||
onUserData(binanceRest, eventHandler, interval) { | ||
binanceRest.startUserDataStream() | ||
return binanceRest.startUserDataStream() | ||
.then((response) => { | ||
@@ -51,4 +52,5 @@ return this._setupWebSocket(eventHandler, response.listenKey); | ||
} | ||
} | ||
module.exports = BinanceWS; |
{ | ||
"name": "binance", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "node.js wrapper for the Binance REST and WebSocket APIs", | ||
"main": "./lib/binance.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha", | ||
"cover": "istanbul cover _mocha", | ||
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls" | ||
}, | ||
"dependencies": { | ||
"coveralls": "^3.0.0", | ||
"istanbul": "^0.4.5", | ||
"mocha-lcov-reporter": "^1.3.0", | ||
"request": "^2.81.0", | ||
@@ -11,0 +16,0 @@ "underscore": "^1.8.3", |
688
README.md
@@ -0,1 +1,5 @@ | ||
![npm downloads](https://img.shields.io/npm/dt/binance.svg) | ||
![testing status](https://img.shields.io/travis/aarongarvey/binance.svg) | ||
![code coverage](https://img.shields.io/coveralls/github/aarongarvey/binance.svg) | ||
# Binance | ||
@@ -80,59 +84,689 @@ A wrapper for the Binance REST and WebSocket APIs. Uses both promises and callbacks, and beautifies the | ||
[allPrices([callback _function_])](https://www.binance.com/restapipub.html#user-content-market-data-endpoints) | ||
### **[allPrices([callback _function_])](https://www.binance.com/restapipub.html#user-content-market-data-endpoints)** | ||
[allBookTickersTi([callback _function_])](https://www.binance.com/restapipub.html#user-content-market-data-endpoints) | ||
Response | ||
```javascript | ||
[ | ||
{ | ||
symbol: 'ETHBTC', | ||
price: '0.04789700' | ||
},{ | ||
symbol: 'LTCBTC', | ||
price: '0.01885200' | ||
}, | ||
... | ||
] | ||
``` | ||
[ping([callback _function_])](https://www.binance.com/restapipub.html#user-content-test-connectivity) | ||
### **[allBookTickers([callback _function_])](https://www.binance.com/restapipub.html#user-content-market-data-endpoints)** | ||
[time([callback _function_])](https://www.binance.com/restapipub.html#user-content-check-server-time) | ||
Response | ||
```javascript | ||
[ | ||
{ | ||
symbol: 'ETHBTC', | ||
bidPrice: '0.04790000', | ||
bidQty: '15.00000000', | ||
askPrice: '0.04801200', | ||
askQty: '13.86000000' | ||
}, | ||
{ | ||
symbol: 'LTCBTC', | ||
bidPrice: '0.01885200', | ||
bidQty: '3.13000000', | ||
askPrice: '0.01889000', | ||
askQty: '0.07000000' | ||
}, | ||
... | ||
] | ||
``` | ||
[depth(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-order-book) | ||
### **[ping([callback _function_])](https://www.binance.com/restapipub.html#user-content-test-connectivity)** | ||
[aggTrades(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-compressedaggregate-trades-list) | ||
Response | ||
```javascript | ||
{} | ||
``` | ||
[klines(query _object_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-klinecandlesticks) | ||
### **[time([callback _function_])](https://www.binance.com/restapipub.html#user-content-check-server-time)** | ||
[ticker24hr(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-24hr-ticker-price-change-statistics) | ||
Response | ||
```javascript | ||
{ serverTime: 1513800453289 } | ||
``` | ||
[newOrder(query _object_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-new-order--signed) | ||
### **[depth(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-order-book)** | ||
[testOrder(query _object_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-test-new-order-signed) - If this ends up making a real order it's the API, not this library | ||
Query Parameters | ||
[queryOrder(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-query-order-signed) | ||
| Name | Type | Details | | ||
|--------------------|---------|----------------------------| | ||
| symbol | string | | | ||
| limit *(optional)* | integer | Default and maximum of 100 | | ||
[cancelOrder(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-cancel-order-signed) | ||
Response | ||
```javascript | ||
{ | ||
lastUpdateId: 52347642, | ||
bids: [ | ||
[ | ||
'0.04838500', // Price | ||
'0.18400000', // Quantity | ||
[] // Ignored | ||
], | ||
... | ||
], | ||
asks: [ | ||
[ | ||
'0.04843900', | ||
'10.73400000', | ||
[] | ||
], | ||
... | ||
] | ||
} | ||
``` | ||
[openOrders(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-current-open-orders-signed) | ||
### **[aggTrades(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-compressedaggregate-trades-list)** | ||
[allOrders(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-all-orders-signed) | ||
Query Parameters | ||
[account(query _object_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-information-signed) | ||
| Name | Type | Details | | ||
|------------------------|---------|-------------------------------------------------------------------| | ||
| symbol | string | | | ||
| fromId *(optional)* | long | include to retrieve trades with ID >= fromId | | ||
| startTime *(optional)* | long | Timestamp in ms, include to retrieve trade.timestamp >= startTime | | ||
| endTime *(optional)* | long | Timestamp in ms, include to retrieve trade.timestamp <= endTime | | ||
| limit *(optional)* | integer | Default and maximum of 500 | | ||
[myTrades(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed) | ||
Response | ||
```javascript | ||
[ | ||
{ | ||
aggTradeId: 7891757, | ||
price: '0.04840900', | ||
quantity: '0.02800000', | ||
firstTradeId: 8516629, | ||
lastTradeId: 8516629, | ||
timestamp: 1513801086350, | ||
maker: false, | ||
bestPriceMatch: true | ||
}, | ||
{ | ||
aggTradeId: 7891758, | ||
price: '0.04841100', | ||
quantity: '0.10600000', | ||
firstTradeId: 8516630, | ||
lastTradeId: 8516630, | ||
timestamp: 1513801086350, | ||
maker: false, | ||
bestPriceMatch: true | ||
}, | ||
... | ||
] | ||
``` | ||
[withdraw(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed) | ||
### **[klines(query _object_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-klinecandlesticks)** | ||
[withdrawHistory(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed) | ||
Query Parameters | ||
[depositHistory(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed) | ||
[depositAddress(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed) | ||
| Name | Type | Description | | ||
|------------------------|---------|------------------------------------------------------------------------| | ||
| symbol | string | | | ||
| interval | string | Options: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M | | ||
| startTime *(optional)* | long | Timestamp in ms | | ||
| endTime *(optional)* | long | Timestamp in ms | | ||
| limit *(optional)* | integer | Default and maximum of 500 | | ||
[startUserDataStream([callback _function_])](https://www.binance.com/restapipub.html#user-content-start-user-data-stream-api-key) | ||
Response | ||
```javascript | ||
[ | ||
{ | ||
openTime: 1513802580000, | ||
open: '0.04837200', | ||
high: '0.04859200', | ||
low: '0.04837000', | ||
close: '0.04837100', | ||
volume: '181.69100000', | ||
closeTime: 1513802639999, | ||
quoteAssetVolume: '8.79608770', | ||
trades: 249, | ||
takerBaseAssetVolume: '75.74200000', | ||
takerQuoteAssetVolume: '3.67104146', | ||
ignored: '0' | ||
}, | ||
{ | ||
openTime: 1513802640000, | ||
open: '0.04837100', | ||
high: '0.04850100', | ||
low: '0.04837000', | ||
close: '0.04837200', | ||
volume: '93.56300000', | ||
closeTime: 1513802699999, | ||
quoteAssetVolume: '4.53177905', | ||
trades: 149, | ||
takerBaseAssetVolume: '20.14700000', | ||
takerQuoteAssetVolume: '0.97561723', | ||
ignored: '0' | ||
}, | ||
... | ||
] | ||
``` | ||
[keepAliveUserDataStream(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-keepalive-user-data-stream-api-key) | ||
### **[ticker24hr(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-24hr-ticker-price-change-statistics)** | ||
[closeUserDataStream(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-close-user-data-stream-api-key) | ||
Query Parameters | ||
| Name | Type | Description | | ||
|--------|--------|-------------| | ||
| symbol | string | | | ||
Response | ||
```javascript | ||
{ | ||
symbol: 'ETHBTC', | ||
priceChange: '0.00177600', | ||
priceChangePercent: '3.809', | ||
weightedAvgPrice: '0.04668755', | ||
prevClosePrice: '0.04662400', | ||
lastPrice: '0.04840000', | ||
lastQty: '4.91500000', | ||
bidPrice: '0.04831400', | ||
bidQty: '0.76500000', | ||
askPrice: '0.04844200', | ||
askQty: '7.13800000', | ||
openPrice: '0.04662400', | ||
highPrice: '0.04900000', | ||
lowPrice: '0.04400000', | ||
volume: '306627.07000000', | ||
quoteVolume: '14315.66748465', | ||
openTime: 1513716659596, | ||
closeTime: 1513803059596, | ||
firstId: 8168545, | ||
lastId: 8523993, | ||
count: 355449 | ||
} | ||
``` | ||
</details> | ||
### **[newOrder(query _object_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-new-order--signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|-------------------------------|---------|--------------------------------------------------------------------| | ||
| symbol | string | | | ||
| side | enum | BUY, SELL | | ||
| type | enum | LIMIT, MARKET | | ||
| timeInForce | enum | GTC, IOC (Good till cancelled, Immediate or Cancel) | | ||
| quantity | decimal | | | ||
| price | decimal | | | ||
| newClientOrderId *(optional)* | string | A unique id for the order, will be generated if not sent | | ||
| stopPrice *(optional)* | decimal | Used with stop orders | | ||
| icebergQty *(optional)* | decimal | Used with iceberg orders | | ||
Response | ||
```javascript | ||
{ | ||
"symbol": "LTCBTC", | ||
"orderId": 1, | ||
"clientOrderId": "myOrder1", | ||
"transactTime": 1499827319559 | ||
} | ||
``` | ||
### **[testOrder(query _object_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-test-new-order-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|-------------------------------|---------|--------------------------------------------------------------------| | ||
| symbol | string | | | ||
| side | enum | BUY, SELL | | ||
| type | enum | LIMIT, MARKET | | ||
| timeInForce | enum | GTC, IOC (Good till cancelled, Immediate or Cancel) | | ||
| quantity | decimal | | | ||
| price | decimal | | | ||
| newClientOrderId *(optional)* | string | A unique id for the order, will be generated if not sent | | ||
| stopPrice *(optional)* | decimal | Used with stop orders | | ||
| icebergQty *(optional)* | decimal | Used with iceberg orders | | ||
Response | ||
```javascript | ||
{} | ||
``` | ||
### **[queryOrder(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-query-order-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|--------------------------------|--------|--------------------------------------------------------------------| | ||
| symbol | string | | | ||
| orderId *(optional)* | long | If not present, origClientOrderId must be sent | | ||
| origClientOrderId *(optional)* | string | If not present, orderId must be sent | | ||
Response | ||
```javascript | ||
{ | ||
"symbol": "LTCBTC", | ||
"orderId": 1, | ||
"clientOrderId": "myOrder1", | ||
"price": "0.1", | ||
"origQty": "1.0", | ||
"executedQty": "0.0", | ||
"status": "NEW", | ||
"timeInForce": "GTC", | ||
"type": "LIMIT", | ||
"side": "BUY", | ||
"stopPrice": "0.0", | ||
"icebergQty": "0.0", | ||
"time": 1499827319559 | ||
} | ||
``` | ||
### **[cancelOrder(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-cancel-order-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|--------------------------------|--------|-------------------------------------------------------------| | ||
| symbol | string | | | ||
| orderId *(optional)* | long | If not present, origClientOrderId must be sent | | ||
| origClientOrderId *(optional)* | string | If not present, orderId must be sent | | ||
| newClientOrderId *(optional)* | string | Used to uniquely identify this cancel, generated by default | | ||
Response | ||
```javascript | ||
{ | ||
"symbol": "LTCBTC", | ||
"origClientOrderId": "myOrder1", | ||
"orderId": 1, | ||
"clientOrderId": "cancelMyOrder1" | ||
} | ||
``` | ||
### **[openOrders(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-current-open-orders-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|--------------------------------|--------|-------------| | ||
| symbol | string | | | ||
Response | ||
```javascript | ||
[ | ||
{ | ||
"symbol": "LTCBTC", | ||
"orderId": 1, | ||
"clientOrderId": "myOrder1", | ||
"price": "0.1", | ||
"origQty": "1.0", | ||
"executedQty": "0.0", | ||
"status": "NEW", | ||
"timeInForce": "GTC", | ||
"type": "LIMIT", | ||
"side": "BUY", | ||
"stopPrice": "0.0", | ||
"icebergQty": "0.0", | ||
"time": 1499827319559 | ||
}, | ||
... | ||
] | ||
``` | ||
### **[allOrders(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-all-orders-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|----------------------|---------|--------------------------------------------------------------------------------| | ||
| symbol | string | | | ||
| orderId *(optional)* | long | If set, retrieve orders with ID >= orderId, otherwise most recent are returned | | ||
| limit *(optional)* | integer | Default and maximum of 500 | | ||
Response | ||
```javascript | ||
[ | ||
{ | ||
"symbol": "LTCBTC", | ||
"orderId": 1, | ||
"clientOrderId": "myOrder1", | ||
"price": "0.1", | ||
"origQty": "1.0", | ||
"executedQty": "0.0", | ||
"status": "NEW", | ||
"timeInForce": "GTC", | ||
"type": "LIMIT", | ||
"side": "BUY", | ||
"stopPrice": "0.0", | ||
"icebergQty": "0.0", | ||
"time": 1499827319559 | ||
}, | ||
... | ||
] | ||
``` | ||
### **[account(query _object_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-information-signed)** | ||
Response | ||
```javascript | ||
{ | ||
"makerCommission": 15, | ||
"takerCommission": 15, | ||
"buyerCommission": 0, | ||
"sellerCommission": 0, | ||
"canTrade": true, | ||
"canWithdraw": true, | ||
"canDeposit": true, | ||
"updateTime": 1502765854332, | ||
"balances": [ | ||
{ | ||
"asset": "BTC", | ||
"free": "4723846.89208129", | ||
"locked": "0.00000000" | ||
}, | ||
... | ||
] | ||
} | ||
``` | ||
### **[myTrades(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|---------------------|---------|-----------------------------------------------------------------| | ||
| symbol | string | | | ||
| fromId *(optional)* | long | TradeId to fetch from. Retrieves most recent trades by default | | ||
| limit *(optional)* | integer | Default and maximum of 500 | | ||
Response | ||
```javascript | ||
[ | ||
{ | ||
id: 1068299, | ||
orderId: 5496403, | ||
price: '0.00050431', | ||
qty: '30.00000000', | ||
commission: '0.00001513', | ||
commissionAsset: 'BTC', | ||
time: 1513275761857, | ||
isBuyer: false, | ||
isMaker: false, | ||
isBestMatch: true | ||
}, | ||
... | ||
] | ||
``` | ||
### **[withdraw(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|-------------------------|---------|--------------------------------------------------------------| | ||
| asset | string | | | ||
| address | string | | | ||
| addressTag *(optional)* | string | Secondary address identifier for coins like XRP, XMR, etc... | | ||
| amount | decimal | | | ||
| name *(optional)* | string | Description of the address | | ||
Response | ||
```javascript | ||
{ | ||
"msg": "success", | ||
"success": true, | ||
"id": "7213fea8e94b4a5593d507237e5a555b" | ||
} | ||
``` | ||
### **[withdrawHistory(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|------------------------|---------|---------------------------------------------------------------------------------------------------------------------------| | ||
| asset *(optional)* | string | | | ||
| status *(optional)* | integer | { 0: 'Email Sent', 1: 'Cancelled', 2: 'Awaiting Approval', 3: 'Rejected', 4: 'Processing', 5: 'Failure', 6: 'Completed' } | | ||
| startTime *(optional)* | long | Timestamp in ms | | ||
| endTime *(optional)* | long | Timestamp in ms | | ||
Response | ||
```javascript | ||
{ | ||
"withdrawList": [ | ||
{ | ||
"id": "7213fea8e94b4a5593d507237e5a555b" | ||
"amount": 1, | ||
"address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b", | ||
"asset": "ETH", | ||
"txId": "0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1", | ||
"applyTime": 1508198532000, | ||
"status": 4 | ||
}, | ||
... | ||
], | ||
"success": true | ||
} | ||
``` | ||
### **[depositHistory(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|------------------------|---------|--------------------------------| | ||
| asset *(optional)* | string | | | ||
| status *(optional)* | integer | { 0: 'Pending', 1: 'Success' } | | ||
| startTime *(optional)* | long | Timestamp in ms | | ||
| endTime *(optional)* | long | Timestamp in ms | | ||
Response | ||
```javascript | ||
{ | ||
"depositList": [ | ||
{ | ||
"insertTime": 1508298532000, | ||
"amount": 1000, | ||
"asset": "XMR", | ||
"address": "463tWEBn5XZJSxLU34r6g7h8jtxuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ", | ||
"addressTag": "342341222", | ||
"txId": "b3c6219639c8ae3f9cf010cdc24fw7f7yt8j1e063f9b4bd1a05cb44c4b6e2509", | ||
"status": 1 | ||
}, | ||
... | ||
], | ||
"success": true | ||
} | ||
``` | ||
### **[depositAddress(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-account-trade-list-signed)** | ||
Query Parameters | ||
| Name | Type | Description | | ||
|-------------------------|---------|-------------| | ||
| asset | string | | | ||
Response | ||
```javascript | ||
{ | ||
"address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b", | ||
"success": true, | ||
"addressTag": "1231212", | ||
"asset": "BNB" | ||
} | ||
``` | ||
### **[startUserDataStream([callback _function_])](https://www.binance.com/restapipub.html#user-content-start-user-data-stream-api-key)** | ||
Response | ||
```javascript | ||
{ "listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1" } | ||
``` | ||
### **[keepAliveUserDataStream(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-keepalive-user-data-stream-api-key)** | ||
Response | ||
```javascript | ||
{} | ||
``` | ||
### **[closeUserDataStream(query _object|string_, [callback _function_])](https://www.binance.com/restapipub.html#user-content-close-user-data-stream-api-key)** | ||
Response | ||
```javascript | ||
{} | ||
``` | ||
# WebSocket APIs | ||
[onDepthUpdate(symbol, eventHandler)](https://www.binance.com/restapipub.html#depth-wss-endpoint) - Returns the websocket, an instance of https://www.npmjs.com/package/ws | ||
### **[onDepthUpdate(symbol, eventHandler)](https://www.binance.com/restapipub.html#depth-wss-endpoint)** | ||
[onKline(symbol, interval, eventHandler)](https://www.binance.com/restapipub.html#kline-wss-endpoint) - Returns the websocket, an instance of https://www.npmjs.com/package/ws | ||
Function call returns the websocket, an instance of https://www.npmjs.com/package/ws | ||
[onAggTrade(symbol, eventHandler)](https://www.binance.com/restapipub.html#trades-wss-endpoint) - Returns the websocket, an instance of https://www.npmjs.com/package/ws | ||
Response | ||
```javascript | ||
{ | ||
eventType: 'depthUpdate', | ||
eventTime: 1513807798461, | ||
symbol: 'BNBBTC', | ||
U: 17962354, | ||
updateId: 17962357, // syncs with updateId on depth route | ||
bidDepthDelta: [ | ||
{ | ||
price: '0.00031239', | ||
quantity: '0.00000000', //quantity of 0 means remove it | ||
ignored: [] | ||
}, | ||
... | ||
], | ||
askDepthDelta: [ | ||
{ | ||
price: '0.00031388', | ||
quantity: '0.00000000', | ||
ignored: [] | ||
}, | ||
... | ||
] | ||
} | ||
``` | ||
[onUserData(binanceRest, eventHandler, [interval])](https://www.binance.com/restapipub.html#user-wss-endpoint) - Will return the websocket via promise, **interval** defaults to 60000, is the amount of time between calls made to keep the user stream alive, **binanceRest** should be an instance of BinanceRest that will be used to get the listenKey and keep the stream alive | ||
### **[onKline(symbol, interval, eventHandler)](https://www.binance.com/restapipub.html#kline-wss-endpoint)** | ||
Returns the websocket, an instance of https://www.npmjs.com/package/ws | ||
Response | ||
```javascript | ||
{ | ||
eventType: 'kline', | ||
eventTime: 1513808234049, | ||
symbol: 'ETHBTC', | ||
kline: | ||
{ | ||
startTime: 1513808220000, | ||
endTime: 1513808279999, | ||
symbol: 'ETHBTC', | ||
interval: '1m', | ||
firstTradeId: 8542266, | ||
lastTradeId: 8542357, | ||
open: '0.04854000', | ||
close: '0.04865100', | ||
high: '0.04865200', | ||
low: '0.04854000', | ||
volume: '53.30600000', | ||
trades: 92, | ||
final: false, | ||
quoteVolume: '2.59145375', | ||
volumeActive: '41.01100000', | ||
quoteVolumeActive: '1.99422739', | ||
ignored: '0' | ||
} | ||
} | ||
``` | ||
### **[onAggTrade(symbol, eventHandler)](https://www.binance.com/restapipub.html#trades-wss-endpoint)** | ||
Returns the websocket, an instance of https://www.npmjs.com/package/ws | ||
Response | ||
```javascript | ||
{ | ||
eventType: 'aggTrade', | ||
eventTime: 1513808427335, | ||
symbol: 'ETHBTC', | ||
tradeId: 7915993, | ||
price: '0.04858100', | ||
quantity: '0.06100000', | ||
firstTradeId: 8543066, | ||
lastTradeId: 8543066, | ||
time: 1513808427329, | ||
maker: false, | ||
ignored: true | ||
} | ||
``` | ||
### **[onUserData(binanceRest, eventHandler, [interval])](https://www.binance.com/restapipub.html#user-wss-endpoint)** | ||
Will return the websocket via promise, **interval** defaults to 60000, is the amount of time between calls made to keep the user stream alive, **binanceRest** should be an instance of BinanceRest that will be used to get the listenKey and keep the stream alive | ||
Responses | ||
```javascript | ||
{ | ||
eventType: 'executionReport', | ||
eventTime: 1513808673916, | ||
symbol: 'IOTABTC', | ||
newClientOrderId: '81gmMRozYdU73D27Ho1W1K', | ||
side: 'SELL', | ||
orderType: 'LIMIT', | ||
cancelType: 'GTC', | ||
quantity: '10.00000000', | ||
price: '0.00030120', | ||
P: '0.00000000', | ||
F: '0.00000000', | ||
g: -1, | ||
C: 'null', | ||
executionType: 'TRADE', | ||
orderStatus: 'FILLED', | ||
rejectReason: 'NONE', | ||
orderId: 9409314, | ||
lastTradeQuantity: '10.00000000', | ||
accumulatedQuantity: '10.00000000', | ||
lastTradePrice: '0.00030120', | ||
commission: '0.00000301', | ||
commissionAsset: 'BTC', | ||
tradeTime: 1513808673912, | ||
tradeId: 3023119, | ||
I: 21799081, | ||
w: false, | ||
maker: true, | ||
M: true | ||
} | ||
``` | ||
```javascript | ||
{ | ||
eventType: 'outboundAccountInfo', | ||
eventTime: 1513808673916, | ||
makerCommission: 10, | ||
takerCommission: 10, | ||
buyerCommission: 0, | ||
sellerCommission: 0, | ||
canTrade: true, | ||
canWithdraw: true, | ||
canDeposit: true, | ||
balances: [ | ||
{ | ||
asset: 'BTC', | ||
availableBalance: '0.00301025', | ||
onOrderBalance: '0.00000000' | ||
}, | ||
... | ||
] | ||
} | ||
``` | ||
# License | ||
[MIT](LICENSE) |
Sorry, the diff of this file is not supported yet
216832
25
950
771
6
+ Addedcoveralls@^3.0.0
+ Addedistanbul@^0.4.5
+ Addedmocha-lcov-reporter@^1.3.0
+ Addedabbrev@1.0.9(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedasync@1.5.2(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcoveralls@3.1.1(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addedescodegen@1.8.1(transitive)
+ Addedesprima@2.7.34.0.1(transitive)
+ Addedestraverse@1.9.3(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedfast-levenshtein@2.0.6(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedhandlebars@4.7.8(transitive)
+ Addedhas-flag@1.0.0(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedistanbul@0.4.5(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedlcov-parse@1.0.0(transitive)
+ Addedlevn@0.3.0(transitive)
+ Addedlog-driver@1.2.7(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedmocha-lcov-reporter@1.3.0(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addednopt@3.0.6(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedoptionator@0.8.3(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprelude-ls@1.1.2(transitive)
+ Addedresolve@1.1.7(transitive)
+ Addedsource-map@0.2.00.6.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedsupports-color@3.2.3(transitive)
+ Addedtype-check@0.3.2(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedword-wrap@1.2.5(transitive)
+ Addedwordwrap@1.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)