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

tardis-dev

Package Overview
Dependencies
Maintainers
1
Versions
272
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tardis-dev - npm Package Compare versions

Comparing version 10.1.3 to 10.1.4

21

dist/mappers/bybit.d.ts

@@ -5,2 +5,3 @@ import { BookChange, DerivativeTicker, Exchange, Trade } from '../types';

private readonly _exchange;
private readonly _seenSymbols;
constructor(_exchange: Exchange);

@@ -19,9 +20,9 @@ canHandle(message: BybitDataMessage): boolean;

canHandle(message: BybitDataMessage): boolean;
getFilters(symbols?: string[]): ({
getFilters(symbols?: string[]): {
readonly channel: "orderBook_200";
readonly symbols: string[] | undefined;
}[] | {
readonly channel: "orderBookL2_25";
readonly symbols: string[] | undefined;
} | {
readonly channel: "orderBook_200";
readonly symbols: string[] | undefined;
})[];
}[];
map(message: BybitBookSnapshotDataMessage | BybitBookSnapshotUpdateMessage, localTimestamp: Date): Generator<{

@@ -60,3 +61,3 @@ readonly type: "book_change";

timestamp: string;
trade_time_ms?: number;
trade_time_ms?: number | string;
symbol: string;

@@ -76,4 +77,6 @@ side: 'Buy' | 'Sell';

type: 'snapshot';
data: BybitBookLevel[];
timestamp_e6: number;
data: BybitBookLevel[] | {
order_book: BybitBookLevel[];
};
timestamp_e6: number | string;
};

@@ -87,3 +90,3 @@ declare type BybitBookSnapshotUpdateMessage = BybitDataMessage & {

};
timestamp_e6: number;
timestamp_e6: number | string;
};

@@ -90,0 +93,0 @@ declare type BybitInstrumentUpdate = {

@@ -8,2 +8,3 @@ "use strict";

this._exchange = _exchange;
this._seenSymbols = new Set();
}

@@ -26,3 +27,10 @@ canHandle(message) {

for (const trade of message.data) {
const timestamp = trade.trade_time_ms !== undefined ? new Date(trade.trade_time_ms) : new Date(trade.timestamp);
const symbol = trade.symbol;
const isLinear = symbol.endsWith('USDT');
// for some reason bybit publishes 'stale' trades for it's linear contracts (trades that already been published before disconnect)
if (isLinear && this._seenSymbols.has(symbol) === false) {
this._seenSymbols.add(symbol);
break;
}
const timestamp = trade.trade_time_ms !== undefined ? new Date(Number(trade.trade_time_ms)) : new Date(trade.timestamp);
yield {

@@ -68,5 +76,2 @@ type: 'trade',

}
// subscribe to both book channels and in canHandle decide which one to use
// as one can subscribe to date range period that overlaps both when only orderBookL2_25 has been available
// and when both were available
return [

@@ -76,6 +81,2 @@ {

symbols
},
{
channel: 'orderBook_200',
symbols
}

@@ -87,5 +88,10 @@ ];

const symbol = topicArray[topicArray.length - 1];
const data = message.type === 'snapshot' ? message.data : [...message.data.delete, ...message.data.update, ...message.data.insert];
const timestamp = new Date(message.timestamp_e6 / 1000);
timestamp.μs = message.timestamp_e6 % 1000;
const data = message.type === 'snapshot'
? 'order_book' in message.data
? message.data.order_book
: message.data
: [...message.data.delete, ...message.data.update, ...message.data.insert];
const timestampBybit = Number(message.timestamp_e6);
const timestamp = new Date(timestampBybit / 1000);
timestamp.μs = timestampBybit % 1000;
yield {

@@ -92,0 +98,0 @@ type: 'book_change',

@@ -84,3 +84,3 @@ "use strict";

'huobi-dm-swap': () => new huobi_1.HuobiBookChangeMapper('huobi-dm-swap'),
bybit: (localTimestamp) => new bybit_1.BybitBookChangeMapper('bybit', localTimestamp.valueOf() >= new Date('2019-12-24').valueOf()),
bybit: () => new bybit_1.BybitBookChangeMapper('bybit', false),
okcoin: (localTimestamp) => new okex_1.OkexBookChangeMapper('okcoin', 'spot', localTimestamp.valueOf() >= new Date('2020-02-13').valueOf()),

@@ -87,0 +87,0 @@ hitbtc: () => hitbtc_1.hitBtcBookChangeMapper,

{
"name": "tardis-dev",
"version": "10.1.3",
"version": "10.1.4",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=12"

@@ -7,2 +7,4 @@ import { BookChange, DerivativeTicker, Exchange, Trade } from '../types'

export class BybitTradesMapper implements Mapper<'bybit', Trade> {
private readonly _seenSymbols = new Set<string>()
constructor(private readonly _exchange: Exchange) {}

@@ -28,4 +30,13 @@ canHandle(message: BybitDataMessage) {

for (const trade of message.data) {
const timestamp = trade.trade_time_ms !== undefined ? new Date(trade.trade_time_ms) : new Date(trade.timestamp)
const symbol = trade.symbol
const isLinear = symbol.endsWith('USDT')
// for some reason bybit publishes 'stale' trades for it's linear contracts (trades that already been published before disconnect)
if (isLinear && this._seenSymbols.has(symbol) === false) {
this._seenSymbols.add(symbol)
break
}
const timestamp = trade.trade_time_ms !== undefined ? new Date(Number(trade.trade_time_ms)) : new Date(trade.timestamp)
yield {

@@ -71,6 +82,2 @@ type: 'trade',

// subscribe to both book channels and in canHandle decide which one to use
// as one can subscribe to date range period that overlaps both when only orderBookL2_25 has been available
// and when both were available
return [

@@ -80,6 +87,2 @@ {

symbols
} as const,
{
channel: 'orderBook_200',
symbols
} as const

@@ -92,6 +95,13 @@ ]

const symbol = topicArray[topicArray.length - 1]
const data = message.type === 'snapshot' ? message.data : [...message.data.delete, ...message.data.update, ...message.data.insert]
const timestamp = new Date(message.timestamp_e6 / 1000)
timestamp.μs = message.timestamp_e6 % 1000
const data =
message.type === 'snapshot'
? 'order_book' in message.data
? message.data.order_book
: message.data
: [...message.data.delete, ...message.data.update, ...message.data.insert]
const timestampBybit = Number(message.timestamp_e6)
const timestamp = new Date(timestampBybit / 1000)
timestamp.μs = timestampBybit % 1000
yield {

@@ -165,3 +175,3 @@ type: 'book_change',

timestamp: string
trade_time_ms?: number
trade_time_ms?: number | string
symbol: string

@@ -183,4 +193,4 @@ side: 'Buy' | 'Sell'

type: 'snapshot'
data: BybitBookLevel[]
timestamp_e6: number
data: BybitBookLevel[] | { order_book: BybitBookLevel[] }
timestamp_e6: number | string
}

@@ -195,3 +205,3 @@

}
timestamp_e6: number
timestamp_e6: number | string
}

@@ -198,0 +208,0 @@

@@ -95,3 +95,3 @@ import { ONE_SEC_IN_MS } from '../handy'

'huobi-dm-swap': () => new HuobiBookChangeMapper('huobi-dm-swap'),
bybit: (localTimestamp: Date) => new BybitBookChangeMapper('bybit', localTimestamp.valueOf() >= new Date('2019-12-24').valueOf()),
bybit: () => new BybitBookChangeMapper('bybit', false),
okcoin: (localTimestamp: Date) =>

@@ -98,0 +98,0 @@ new OkexBookChangeMapper('okcoin', 'spot', localTimestamp.valueOf() >= new Date('2020-02-13').valueOf()),

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

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