binance-api-node
Advanced tools
Comparing version 0.9.22 to 0.9.23
@@ -16,2 +16,18 @@ "use strict"; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
@@ -28,2 +44,3 @@ | ||
var BASE = 'wss://stream.binance.com:9443/ws'; | ||
var FUTURES = 'wss://fstream.binance.com/ws'; | ||
@@ -397,3 +414,16 @@ var depth = function depth(payload, cb) { | ||
exports.userEventHandler = userEventHandler; | ||
var STREAM_METHODS = ['get', 'keep', 'close']; | ||
var capitalize = function capitalize(str, check) { | ||
return check ? "".concat(str[0].toUpperCase()).concat(str.slice(1)) : str; | ||
}; | ||
var getStreamMethods = function getStreamMethods(opts) { | ||
var variator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var methods = (0, _httpClient.default)(opts); | ||
return STREAM_METHODS.reduce(function (acc, key) { | ||
return [].concat(_toConsumableArray(acc), [methods["".concat(variator).concat(capitalize("".concat(key, "DataStream"), !!variator))]]); | ||
}, []); | ||
}; | ||
var keepStreamAlive = function keepStreamAlive(method, listenKey) { | ||
@@ -407,8 +437,10 @@ return method({ | ||
var user = function user(opts, margin) { | ||
var user = function user(opts, variator) { | ||
return function (cb) { | ||
var methods = (0, _httpClient.default)(opts); | ||
var getDataStream = margin ? methods.marginGetDataStream : methods.getDataStream; | ||
var keepDataStream = margin ? methods.marginKeepDataStream : methods.keepDataStream; | ||
var closeDataStream = margin ? methods.marginCloseDataStream : methods.closeDataStream; | ||
var _getStreamMethods = getStreamMethods(opts, variator), | ||
_getStreamMethods2 = _slicedToArray(_getStreamMethods, 3), | ||
getDataStream = _getStreamMethods2[0], | ||
keepDataStream = _getStreamMethods2[1], | ||
closeDataStream = _getStreamMethods2[2]; | ||
var currentListenKey = null; | ||
@@ -457,3 +489,3 @@ var int = null; | ||
var listenKey = _ref2.listenKey; | ||
w = (0, _openWebsocket.default)("".concat(BASE, "/").concat(listenKey)); | ||
w = (0, _openWebsocket.default)("".concat(variator === 'futures' ? FUTURES : BASE, "/").concat(listenKey)); | ||
@@ -497,3 +529,4 @@ w.onmessage = function (msg) { | ||
user: user(opts), | ||
marginUser: user(opts, true) | ||
marginUser: user(opts, 'margin'), | ||
futuresUser: user(opts, 'futures') | ||
}; | ||
@@ -500,0 +533,0 @@ }; |
@@ -202,3 +202,2 @@ // tslint:disable:interface-name | ||
futuresPositionRisk(options?: { recvWindow: number }): Promise<PositionRiskResult[]>; | ||
} | ||
@@ -219,4 +218,6 @@ | ||
aggTrades: (pairs: string | string[], callback: (trade: Trade) => void) => ReconnectingWebSocketHandler; | ||
user: (callback: (msg: OutboundAccountInfo | ExecutionReport) => void) => Function; | ||
marginUser: (callback: (msg: OutboundAccountInfo | ExecutionReport) => void) => Function; | ||
futuresUser: (callback: (msg: OutboundAccountInfo | ExecutionReport) => void) => Function; | ||
} | ||
@@ -223,0 +224,0 @@ |
{ | ||
"name": "binance-api-node", | ||
"version": "0.9.22", | ||
"version": "0.9.23", | ||
"description": "A node API wrapper for Binance", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
@@ -1762,13 +1762,10 @@ # binance-api-node [![build](https://img.shields.io/travis/Ashlar/binance-api-node/master.svg?style=flat-square)](https://travis-ci.org/Ashlar/binance-api-node) [![cover](https://img.shields.io/coveralls/github/Ashlar/binance-api-node/master?style=flat-square)](https://coveralls.io/github/Ashlar/binance-api-node?branch=master) [![bnb](https://img.shields.io/badge/binance-winner-yellow.svg?style=flat-square)](https://github.com/binance-exchange/binance-api-node) | ||
Live user messages data feed on margin wallet. | ||
There is also two equivalent functions to query either the margin or futures wallet: | ||
**Requires authentication** | ||
```js | ||
const clean = await client.ws.marginUser(msg => { | ||
console.log(msg) | ||
}) | ||
client.ws.marginUser() | ||
client.ws.futuresUser() | ||
``` | ||
Note that this methods returns a promise which will resolve the `clean` callback. | ||
Note that these methods all return a promise which will resolve the `clean` callback. | ||
@@ -1775,0 +1772,0 @@ <details> |
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
106359
1737
1798