Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

binance-api-node

Package Overview
Dependencies
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binance-api-node - npm Package Compare versions

Comparing version 0.7.6 to 0.8.0

15

dist/websocket.js

@@ -225,5 +225,5 @@ 'use strict';

var trades = function trades(payload, cb) {
var tradesInternal = function tradesInternal(payload, streamName, cb) {
var cache = (Array.isArray(payload) ? payload : [payload]).map(function (symbol) {
var w = (0, _openWebsocket2.default)(BASE + '/' + symbol.toLowerCase() + '@aggTrade');
var w = (0, _openWebsocket2.default)(BASE + '/' + symbol.toLowerCase() + '@' + streamName);
w.onmessage = function (msg) {

@@ -237,2 +237,3 @@ var _JSON$parse4 = JSON.parse(msg.data),

maker = _JSON$parse4.m,
isBuyerMaker = _JSON$parse4.M,
tradeId = _JSON$parse4.a;

@@ -247,2 +248,3 @@

maker: maker,
isBuyerMaker: isBuyerMaker,
tradeId: tradeId

@@ -262,2 +264,10 @@ });

var aggTrades = function aggTrades(payload, cb) {
return tradesInternal(payload, 'aggTrade', cb);
};
var trades = function trades(payload, cb) {
return tradesInternal(payload, 'trade', cb);
};
var userTransforms = {

@@ -363,2 +373,3 @@ outboundAccountInfo: function outboundAccountInfo(m) {

trades: trades,
aggTrades: aggTrades,
ticker: ticker,

@@ -365,0 +376,0 @@ allTickers: allTickers,

@@ -16,2 +16,13 @@ // tslint:disable:interface-name

}
export interface AggregatedTrade {
aggId: number;
price: string;
quantity: string;
firstId: number;
lastId: number;
timestamp: number;
isBuyerMaker: boolean;
wasBestPrice: boolean;
}

@@ -26,2 +37,3 @@ export interface AssetBalance {

accountInfo(options?: { useServerTime: boolean }): Promise<Account>;
aggTrades(options?: { symbol: string, fromId?: string, startTime?: number, endTime?: number, limit?: number }): Promise<AggregatedTrade>;
book(options: { symbol: string, limit?: number }): Promise<OrderBook>;

@@ -55,2 +67,3 @@ exchangeInfo(): Promise<ExchangeInfo>;

trades: (pairs: string[], callback: (trade: Trade) => void) => Function;
aggTrades: (pairs: string[], callback: (trade: Trade) => void) => Function;
user: ( callback: (msg: OutboundAccountInfo|ExecutionReport) => void) => Function;

@@ -322,2 +335,3 @@ }

maker: boolean;
isBuyerMaker: boolean;
tradeId: number;

@@ -324,0 +338,0 @@ }

2

package.json
{
"name": "binance-api-node",
"version": "0.7.6",
"version": "0.8.0",
"description": "A node API wrapper for Binance",

@@ -5,0 +5,0 @@ "main": "dist",

@@ -74,3 +74,4 @@ # binance-api-node [![build](https://img.shields.io/travis/HyperCubeProject/binance-api-node.svg?style=flat-square)](https://travis-ci.org/HyperCubeProject/binance-api-node) [![cover](https://img.shields.io/coveralls/HyperCubeProject/binance-api-node.svg?style=flat-square)](https://coveralls.io/github/HyperCubeProject/binance-api-node) [![bnb](https://img.shields.io/badge/binance-winner-yellow.svg?style=flat-square)](https://github.com/binance-exchange/binance-api-node)

- [candles](#candles-1)
- [trades](#trades)
- [aggTrades](#aggtrades-1)
- [trades](#trades-1)
- [user](#user)

@@ -430,3 +431,3 @@ - [ErrorCodes](#errorcodes)

|price|Number|true||Optional for `MARKET` orders|
|timeInForce|String|false|`GTC`|`GTC`, `IOC`|
|timeInForce|String|false|`GTC`|`FOK`, `GTC`, `IOC`|
|newClientOrderId|String|false||A unique id for the order. Automatically generated if not sent.|

@@ -1036,3 +1037,3 @@ |stopPrice|Number|false||Used with stop orders|

Live trade data feed. Pass either a single symbol string or an array of symbols.
Live trade data feed. Pass either a single symbol string or an array of symbols. The trade streams push raw trade information; each trade has a unique buyer and seller.

@@ -1050,2 +1051,29 @@ ```js

{
eventType: 'trade',
eventTime: 1508614495052,
symbol: 'ETHBTC',
price: '0.04923600',
quantity: '3.43500000',
maker: false,
tradeId: 2148226
}
```
</details>
#### aggTrades
Live trade data feed. Pass either a single symbol string or an array of symbols. The aggregate trade streams push trade information that is aggregated for a single taker order.
```js
client.ws.aggTrades(['ETHBTC', 'BNBBTC'], trade => {
console.log(trade)
})
```
<details>
<summary>Output</summary>
```js
{
eventType: 'aggTrade',

@@ -1052,0 +1080,0 @@ eventTime: 1508614495052,

@@ -165,5 +165,5 @@ import zip from 'lodash.zipobject'

const trades = (payload, cb) => {
const tradesInternal = (payload, streamName, cb) => {
const cache = (Array.isArray(payload) ? payload : [payload]).map(symbol => {
const w = openWebSocket(`${BASE}/${symbol.toLowerCase()}@aggTrade`)
const w = openWebSocket(`${BASE}/${symbol.toLowerCase()}@${streamName}`)
w.onmessage = msg => {

@@ -177,2 +177,3 @@ const {

m: maker,
M: isBuyerMaker,
a: tradeId,

@@ -188,2 +189,3 @@ } = JSON.parse(msg.data)

maker,
isBuyerMaker,
tradeId,

@@ -199,2 +201,6 @@ })

const aggTrades = (payload, cb) => tradesInternal(payload, 'aggTrade', cb)
const trades = (payload, cb) => tradesInternal(payload, 'trade', cb)
const userTransforms = {

@@ -276,2 +282,3 @@ outboundAccountInfo: m => ({

trades,
aggTrades,
ticker,

@@ -278,0 +285,0 @@ allTickers,

@@ -186,2 +186,11 @@ import test from 'ava'

test('[WS] aggregate trades', t => {
return new Promise(resolve => {
client.ws.aggTrades(['BNBBTC', 'ETHBTC', 'BNTBTC'], trade => {
checkFields(t, trade, ['eventType', 'tradeId', 'quantity', 'price', 'symbol'])
resolve()
})
})
})
test('[WS] userEvents', t => {

@@ -188,0 +197,0 @@ const accountPayload = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc