tardis-dev
Advanced tools
Comparing version 8.0.4 to 8.0.5
@@ -205,4 +205,2 @@ "use strict"; | ||
const lastUpdateId = depthContext.lastUpdateId; | ||
// if update has pu set to -1, it means server provided book snapshot | ||
const isSnapshot = binanceDepthUpdateData.pu === -1; | ||
// based on https://binanceapitest.github.io/Binance-Futures-API-doc/wss/#how-to-manage-a-local-order-book-correctly | ||
@@ -215,3 +213,3 @@ // Drop any event where u is < lastUpdateId in the snapshot | ||
if (!depthContext.validatedFirstUpdate) { | ||
if ((binanceDepthUpdateData.U <= lastUpdateId && binanceDepthUpdateData.u >= lastUpdateId) || isSnapshot) { | ||
if (binanceDepthUpdateData.U <= lastUpdateId && binanceDepthUpdateData.u >= lastUpdateId) { | ||
depthContext.validatedFirstUpdate = true; | ||
@@ -234,3 +232,3 @@ } | ||
exchange: this.exchange, | ||
isSnapshot, | ||
isSnapshot: false, | ||
bids: binanceDepthUpdateData.b.map(this.mapBookLevel), | ||
@@ -286,3 +284,3 @@ asks: binanceDepthUpdateData.a.map(this.mapBookLevel), | ||
if (symbols !== undefined) { | ||
return symbols.map(s => s.toLocaleLowerCase()); | ||
return symbols.map(s => s.toLowerCase()); | ||
} | ||
@@ -289,0 +287,0 @@ return; |
@@ -127,3 +127,3 @@ "use strict"; | ||
if (symbols !== undefined) { | ||
return symbols.map(s => s.toLocaleLowerCase()); | ||
return symbols.map(s => s.toLowerCase()); | ||
} | ||
@@ -130,0 +130,0 @@ return; |
@@ -25,3 +25,3 @@ "use strict"; | ||
*map(message, localTimestamp) { | ||
const symbol = message.ch.split('.')[1]; | ||
const symbol = message.ch.split('.')[1].toUpperCase(); | ||
for (const huobiTrade of message.tick.data) { | ||
@@ -63,3 +63,3 @@ yield { | ||
*map(message, localTimestamp) { | ||
const symbol = message.ch.split('.')[1]; | ||
const symbol = message.ch.split('.')[1].toUpperCase(); | ||
const isSnapshot = 'event' in message.tick ? message.tick.event === 'snapshot' : 'update' in message ? false : true; | ||
@@ -91,3 +91,3 @@ const data = message.tick; | ||
// huobi-com and us expects lower cased symbols | ||
return s.toLocaleLowerCase(); | ||
return s.toLowerCase(); | ||
}); | ||
@@ -94,0 +94,0 @@ } |
{ | ||
"name": "tardis-dev", | ||
"version": "8.0.4", | ||
"version": "8.0.5", | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"description": "Fast and convenient access to tick-level real-time and historical cryptocurrency market data via Node.js", | ||
"description": "Convenient access to tick-level historical and real-time cryptocurrency market data via Node.js", | ||
"main": "dist/index.js", | ||
@@ -46,3 +46,4 @@ "source": "src/index.ts", | ||
"binance", | ||
"trading" | ||
"trading", | ||
"high granularity order book data" | ||
], | ||
@@ -86,6 +87,3 @@ "license": "MPL-2.0", | ||
}, | ||
"runkitExampleFilename": "example.js", | ||
"optionalDependencies": { | ||
"bufferutil": "^4.0.1" | ||
} | ||
"runkitExampleFilename": "example.js" | ||
} |
@@ -13,8 +13,10 @@ # tardis-dev | ||
```javascript | ||
const { streamNormalized, normalizeTrades, normalizeBookChanges } = require('tardis-dev') | ||
const { replayNormalized, normalizeTrades, normalizeBookChanges } = require('tardis-dev') | ||
const messages = streamNormalized( | ||
const messages = replayNormalized( | ||
{ | ||
exchange: 'bitmex', | ||
symbols: ['XBTUSD', 'ETHUSD'] | ||
symbols: ['XBTUSD', 'ETHUSD'], | ||
from: '2019-05-01', | ||
to: '2019-05-02' | ||
}, | ||
@@ -30,3 +32,3 @@ normalizeTrades, | ||
[![Try this code live on RunKit](https://img.shields.io/badge/-Try%20this%20code%20live%20on%20RunKit-c?color=5558be)](https://runkit.com/thad/tardis-dev-stream-market-data-normalized) | ||
[![Try this code live on RunKit](https://img.shields.io/badge/-Try%20this%20code%20live%20on%20RunKit-c?color=5558be)](https://runkit.com/thad/tardis-dev-replay-market-data-normalized) | ||
@@ -38,11 +40,11 @@ <br/> | ||
- [real-time streaming](https://docs.tardis.dev/api/node-js#streaming-real-time-market-data) of tick-level market data with unified API for connecting directly to exchanges public WebSocket APIs without any intermediary/3rd party proxy | ||
- historical tick-level [market data replay](https://docs.tardis.dev/api/node-js#replaying-historical-market-data) backed by [tardis.dev HTTP API](https://docs.tardis.dev/api/http#data-feeds-exchange) — includes full order book depth snapshots plus incremental updates, tick-by-tick trades, historical open interest, funding, index, mark prices, liquidations and more | ||
<br/> | ||
<br/> | ||
- historical tick-level [market data replay](https://docs.tardis.dev/api/node-js#replaying-historical-market-data) backed by [tardis.dev HTTP API](https://docs.tardis.dev/api/http#data-feeds-exchange) — includes full order book depth snapshots plus incremental updates, tick-by-tick trades, historical open interest, funding, index, mark prices, liquidations and more | ||
- consolidated [real-time data streaming API](https://docs.tardis.dev/api/node-js#streaming-real-time-market-data) connecting directly to exchanges' public WebSocket APIs | ||
<br/> | ||
- support for both exchange native and [normalized market data](https://docs.tardis.dev/api/node-js#data-normalization) formats \(consistent format for accessing market data across multiple exchanges — normalized trades, order book and ticker data\) | ||
- support for both [exchange-native](https://docs.tardis.dev/faq/data#what-is-a-difference-between-exchange-native-and-normalized-data-format) and [normalized market data](https://docs.tardis.dev/faq/data#what-is-a-difference-between-exchange-native-and-normalized-data-format) formats (unified format for accessing market data across all supported exchanges — normalized trades, order book and ticker data) | ||
@@ -59,3 +61,3 @@ <br/> | ||
- support for top cryptocurrency exchanges: BitMEX, Deribit, Binance, Binance Futures, FTX, OKEx, Huobi Global, Huobi DM, bitFlyer, Bitstamp, Coinbase Pro, Crypto Facilities, Gemini, Kraken, Bitfinex, Bybit, OKCoin, CoinFLEX and more. | ||
- support for top cryptocurrency exchanges: BitMEX, Deribit, Binance, Binance Futures, FTX, OKEx, Huobi Global, Huobi DM, bitFlyer, Bitstamp, Coinbase Pro, Crypto Facilities, Gemini, Kraken, Bitfinex, Bybit, OKCoin, CoinFLEX and more | ||
@@ -105,9 +107,2 @@ <br/> | ||
## Debugging and logging | ||
`tardis-dev` lib uses [debug](https://github.com/visionmedia/debug) package for verbose logging and debugging purposes that can be enabled via `DEBUG` environment variable set to `tardis-dev*`. | ||
<br/> | ||
<br/> | ||
## Documentation | ||
@@ -114,0 +109,0 @@ |
@@ -232,4 +232,3 @@ import { BookChange, DerivativeTicker, Exchange, FilterForExchange, Trade } from '../types' | ||
const lastUpdateId = depthContext.lastUpdateId! | ||
// if update has pu set to -1, it means server provided book snapshot | ||
const isSnapshot = binanceDepthUpdateData.pu === -1 | ||
// based on https://binanceapitest.github.io/Binance-Futures-API-doc/wss/#how-to-manage-a-local-order-book-correctly | ||
@@ -243,3 +242,3 @@ // Drop any event where u is < lastUpdateId in the snapshot | ||
if (!depthContext.validatedFirstUpdate) { | ||
if ((binanceDepthUpdateData.U <= lastUpdateId && binanceDepthUpdateData.u >= lastUpdateId) || isSnapshot) { | ||
if (binanceDepthUpdateData.U <= lastUpdateId && binanceDepthUpdateData.u >= lastUpdateId) { | ||
depthContext.validatedFirstUpdate = true | ||
@@ -264,3 +263,3 @@ } else { | ||
exchange: this.exchange, | ||
isSnapshot, | ||
isSnapshot: false, | ||
@@ -325,3 +324,3 @@ bids: binanceDepthUpdateData.b.map(this.mapBookLevel), | ||
if (symbols !== undefined) { | ||
return symbols.map(s => s.toLocaleLowerCase()) | ||
return symbols.map(s => s.toLowerCase()) | ||
} | ||
@@ -328,0 +327,0 @@ return |
@@ -149,3 +149,3 @@ import { BookChange, Trade } from '../types' | ||
if (symbols !== undefined) { | ||
return symbols.map(s => s.toLocaleLowerCase()) | ||
return symbols.map(s => s.toLowerCase()) | ||
} | ||
@@ -152,0 +152,0 @@ return |
@@ -28,3 +28,3 @@ import { BookChange, Exchange, Trade } from '../types' | ||
*map(message: HuobiTradeDataMessage, localTimestamp: Date): IterableIterator<Trade> { | ||
const symbol = message.ch.split('.')[1] | ||
const symbol = message.ch.split('.')[1].toUpperCase() | ||
@@ -70,3 +70,3 @@ for (const huobiTrade of message.tick.data) { | ||
*map(message: HuobiDepthDataMessage, localTimestamp: Date) { | ||
const symbol = message.ch.split('.')[1] | ||
const symbol = message.ch.split('.')[1].toUpperCase() | ||
const isSnapshot = 'event' in message.tick ? message.tick.event === 'snapshot' : 'update' in message ? false : true | ||
@@ -99,3 +99,3 @@ const data = message.tick | ||
// huobi-com and us expects lower cased symbols | ||
return s.toLocaleLowerCase() | ||
return s.toLowerCase() | ||
}) | ||
@@ -102,0 +102,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
7
605067
10649
270