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 13.4.7 to 13.4.8

54

dist/mappers/bybit.d.ts

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

};
declare type BybitTradeDataMessage = BybitDataMessage & {
declare type BybitTradeDataMessage = (BybitDataMessage & {
data: {

@@ -76,2 +76,16 @@ timestamp: string;

}[];
}) | {
topic: 'trade.BTCPERP';
data: [
{
symbol: 'BTCPERP';
tickDirection: 'PlusTick';
price: '21213.00';
size: 0.007;
timestamp: '2022-06-21T09:36:58.000Z';
tradeTimeMs: '1655804218524';
side: 'Sell';
tradeId: '7aad7741-f763-5f78-bf43-c38b29a40f67';
}
];
};

@@ -87,4 +101,7 @@ declare type BybitBookLevel = {

order_book: BybitBookLevel[];
} | {
orderBook: BybitBookLevel[];
};
timestamp_e6: number | string;
timestampE6: number | string;
};

@@ -99,2 +116,3 @@ declare type BybitBookSnapshotUpdateMessage = BybitDataMessage & {

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

@@ -115,5 +133,39 @@ declare type BybitInstrumentUpdate = {

updated_at: string;
lastPriceE4: '212130000';
lastPrice: '21213.00';
lastTickDirection: 'PlusTick';
prevPrice24hE4: '207180000';
prevPrice24h: '20718.00';
price24hPcntE6: '23892';
highPrice24hE4: '214085000';
highPrice24h: '21408.50';
lowPrice24hE4: '198005000';
lowPrice24h: '19800.50';
prevPrice1hE4: '213315000';
prevPrice1h: '21331.50';
price1hPcntE6: '-5555';
markPriceE4: '212094700';
markPrice: '21209.47';
indexPriceE4: '212247200';
indexPrice: '21224.72';
openInterestE8: '18317600000';
totalTurnoverE8: '94568739311650000';
turnover24hE8: '1375880657550000';
totalVolumeE8: '2734659400000';
volume24hE8: '66536799999';
fundingRateE6: '-900';
predictedFundingRateE6: '-614';
crossSeq: '385207672';
createdAt: '1970-01-01T00:00:00.000Z';
updatedAt: '2022-06-21T09:36:58.000Z';
nextFundingTime: '2022-06-21T16:00:00Z';
countDownHour: '7';
bid1PriceE4: '212130000';
bid1Price: '21213.00';
ask1PriceE4: '212135000';
ask1Price: '21213.50';
};
declare type BybitInstrumentDataMessage = BybitDataMessage & {
timestamp_e6: string;
timestampE6: string;
data: BybitInstrumentUpdate | {

@@ -120,0 +172,0 @@ update: [BybitInstrumentUpdate];

@@ -28,3 +28,7 @@ "use strict";

for (const trade of message.data) {
const timestamp = trade.trade_time_ms !== undefined ? new Date(Number(trade.trade_time_ms)) : new Date(trade.timestamp);
const timestamp = 'trade_time_ms' in trade
? new Date(Number(trade.trade_time_ms))
: 'tradeTimeMs' in trade
? new Date(Number(trade.tradeTimeMs))
: new Date(trade.timestamp);
yield {

@@ -34,3 +38,3 @@ type: 'trade',

exchange: this._exchange,
id: trade.trade_id,
id: 'trade_id' in trade ? trade.trade_id : trade.tradeId,
price: Number(trade.price),

@@ -85,5 +89,9 @@ amount: trade.size,

? message.data.order_book
: message.data
: 'orderBook' in message.data
? message.data.orderBook
: message.data
: [...message.data.delete, ...message.data.update, ...message.data.insert];
const timestampBybit = Number(message.timestamp_e6);
// TODO: test instrument info
// TODO: test liquidations?
const timestampBybit = message.timestamp_e6 !== undefined ? Number(message.timestamp_e6) : Number(message.timestampE6);
const timestamp = new Date(timestampBybit / 1000);

@@ -129,22 +137,38 @@ timestamp.μs = timestampBybit % 1000;

const pendingTickerInfo = this.pendingTickerInfoHelper.getPendingTickerInfo(instrumentInfo.symbol, 'bybit');
pendingTickerInfo.updateFundingRate(instrumentInfo.funding_rate_e6 !== undefined ? Number(instrumentInfo.funding_rate_e6) / 1000000 : undefined);
pendingTickerInfo.updatePredictedFundingRate(instrumentInfo.predicted_funding_rate_e6 !== undefined ? instrumentInfo.predicted_funding_rate_e6 / 1000000 : undefined);
pendingTickerInfo.updateFundingTimestamp(instrumentInfo.next_funding_time !== undefined && new Date(instrumentInfo.next_funding_time).valueOf() > 0
? new Date(instrumentInfo.next_funding_time)
: undefined);
const fundingRate = 'funding_rate_e6' in instrumentInfo ? instrumentInfo.funding_rate_e6 : instrumentInfo.fundingRateE6;
pendingTickerInfo.updateFundingRate(fundingRate !== undefined ? Number(fundingRate) / 1000000 : undefined);
const predictedFundingRate = 'predicted_funding_rate_e6' in instrumentInfo ? instrumentInfo.predicted_funding_rate_e6 : instrumentInfo.predictedFundingRateE6;
pendingTickerInfo.updatePredictedFundingRate(predictedFundingRate !== undefined ? Number(predictedFundingRate) / 1000000 : undefined);
const nextFundingTime = 'next_funding_time' in instrumentInfo ? instrumentInfo.next_funding_time : instrumentInfo.nextFundingTime;
pendingTickerInfo.updateFundingTimestamp(nextFundingTime !== undefined && new Date(nextFundingTime).valueOf() > 0 ? new Date(nextFundingTime) : undefined);
if (instrumentInfo.index_price !== undefined) {
pendingTickerInfo.updateIndexPrice(Number(instrumentInfo.index_price));
}
else if (instrumentInfo.indexPrice !== undefined) {
pendingTickerInfo.updateIndexPrice(Number(instrumentInfo.indexPrice));
}
else if (instrumentInfo.index_price_e4 !== undefined) {
pendingTickerInfo.updateIndexPrice(Number(instrumentInfo.index_price_e4) / 10000);
}
else if (instrumentInfo.indexPriceE4 !== undefined) {
pendingTickerInfo.updateIndexPrice(Number(instrumentInfo.indexPriceE4) / 10000);
}
if (instrumentInfo.mark_price !== undefined) {
pendingTickerInfo.updateMarkPrice(Number(instrumentInfo.mark_price));
}
else if (instrumentInfo.markPrice !== undefined) {
pendingTickerInfo.updateMarkPrice(Number(instrumentInfo.markPrice));
}
else if (instrumentInfo.mark_price_e4 !== undefined) {
pendingTickerInfo.updateMarkPrice(instrumentInfo.mark_price_e4 / 10000);
pendingTickerInfo.updateMarkPrice(Number(instrumentInfo.mark_price_e4) / 10000);
}
else if (instrumentInfo.markPriceE4 !== undefined) {
pendingTickerInfo.updateMarkPrice(Number(instrumentInfo.markPriceE4) / 10000);
}
if (instrumentInfo.open_interest !== undefined) {
pendingTickerInfo.updateOpenInterest(instrumentInfo.open_interest);
}
else if (instrumentInfo.openInterestE8 !== undefined) {
pendingTickerInfo.updateOpenInterest(Number(instrumentInfo.openInterestE8) / 100000000);
}
else if (instrumentInfo.open_interest_e8 !== undefined) {

@@ -156,5 +180,11 @@ pendingTickerInfo.updateOpenInterest(instrumentInfo.open_interest_e8 / 100000000);

}
else if (instrumentInfo.lastPrice !== undefined) {
pendingTickerInfo.updateLastPrice(Number(instrumentInfo.lastPrice));
}
else if (instrumentInfo.last_price_e4 !== undefined) {
pendingTickerInfo.updateLastPrice(Number(instrumentInfo.last_price_e4) / 10000);
}
else if (instrumentInfo.lastPriceE4) {
pendingTickerInfo.updateLastPrice(Number(instrumentInfo.lastPriceE4) / 10000);
}
if (message.timestamp_e6 !== undefined) {

@@ -166,2 +196,8 @@ const timestampBybit = Number(message.timestamp_e6);

}
else if (message.timestampE6 !== undefined) {
const timestampBybit = Number(message.timestampE6);
const timestamp = new Date(timestampBybit / 1000);
timestamp.μs = timestampBybit % 1000;
pendingTickerInfo.updateTimestamp(timestamp);
}
else {

@@ -168,0 +204,0 @@ pendingTickerInfo.updateTimestamp(new Date(instrumentInfo.updated_at));

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

const linearContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT')), []);
const inverseContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT') === false), []);
const inverseContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT') === false && s.endsWith('PERP') === false), []);
const usdcContracts = filters.reduce(this._only((s) => s.endsWith('PERP')), []);
if (linearContractsFilters.length > 0) {

@@ -16,2 +17,5 @@ yield new BybitSingleConnectionRealTimeDataFeed('realtime_public', exchange, linearContractsFilters, timeoutIntervalMS, onError);

}
if (usdcContracts.length > 0) {
yield new BybitSingleConnectionRealTimeDataFeed('perpetual/ws/v1/realtime_public', exchange, usdcContracts, timeoutIntervalMS, onError);
}
}

@@ -18,0 +22,0 @@ _only(filter) {

2

package.json
{
"name": "tardis-dev",
"version": "13.4.7",
"version": "13.4.8",
"engines": {

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

@@ -30,3 +30,8 @@ import { upperCaseSymbols } from '../handy'

for (const trade of message.data) {
const timestamp = trade.trade_time_ms !== undefined ? new Date(Number(trade.trade_time_ms)) : new Date(trade.timestamp)
const timestamp =
'trade_time_ms' in trade
? new Date(Number(trade.trade_time_ms))
: 'tradeTimeMs' in trade
? new Date(Number(trade.tradeTimeMs))
: new Date(trade.timestamp)

@@ -37,3 +42,3 @@ yield {

exchange: this._exchange,
id: trade.trade_id,
id: 'trade_id' in trade ? trade.trade_id : trade.tradeId,
price: Number(trade.price),

@@ -91,6 +96,11 @@ amount: trade.size,

? message.data.order_book
: 'orderBook' in message.data
? message.data.orderBook
: message.data
: [...message.data.delete, ...message.data.update, ...message.data.insert]
const timestampBybit = Number(message.timestamp_e6)
// TODO: test instrument info
// TODO: test liquidations?
const timestampBybit = message.timestamp_e6 !== undefined ? Number(message.timestamp_e6) : Number(message.timestampE6)
const timestamp = new Date(timestampBybit / 1000)

@@ -142,13 +152,14 @@ timestamp.μs = timestampBybit % 1000

const pendingTickerInfo = this.pendingTickerInfoHelper.getPendingTickerInfo(instrumentInfo.symbol, 'bybit')
const fundingRate = 'funding_rate_e6' in instrumentInfo ? instrumentInfo.funding_rate_e6 : instrumentInfo.fundingRateE6
pendingTickerInfo.updateFundingRate(
instrumentInfo.funding_rate_e6 !== undefined ? Number(instrumentInfo.funding_rate_e6) / 1000000 : undefined
)
pendingTickerInfo.updatePredictedFundingRate(
instrumentInfo.predicted_funding_rate_e6 !== undefined ? instrumentInfo.predicted_funding_rate_e6 / 1000000 : undefined
)
pendingTickerInfo.updateFundingRate(fundingRate !== undefined ? Number(fundingRate) / 1000000 : undefined)
const predictedFundingRate =
'predicted_funding_rate_e6' in instrumentInfo ? instrumentInfo.predicted_funding_rate_e6 : instrumentInfo.predictedFundingRateE6
pendingTickerInfo.updatePredictedFundingRate(predictedFundingRate !== undefined ? Number(predictedFundingRate) / 1000000 : undefined)
const nextFundingTime = 'next_funding_time' in instrumentInfo ? instrumentInfo.next_funding_time : instrumentInfo.nextFundingTime
pendingTickerInfo.updateFundingTimestamp(
instrumentInfo.next_funding_time !== undefined && new Date(instrumentInfo.next_funding_time).valueOf() > 0
? new Date(instrumentInfo.next_funding_time)
: undefined
nextFundingTime !== undefined && new Date(nextFundingTime).valueOf() > 0 ? new Date(nextFundingTime) : undefined
)

@@ -158,4 +169,8 @@

pendingTickerInfo.updateIndexPrice(Number(instrumentInfo.index_price))
} else if (instrumentInfo.indexPrice !== undefined) {
pendingTickerInfo.updateIndexPrice(Number(instrumentInfo.indexPrice))
} else if (instrumentInfo.index_price_e4 !== undefined) {
pendingTickerInfo.updateIndexPrice(Number(instrumentInfo.index_price_e4) / 10000)
} else if (instrumentInfo.indexPriceE4 !== undefined) {
pendingTickerInfo.updateIndexPrice(Number(instrumentInfo.indexPriceE4) / 10000)
}

@@ -165,4 +180,8 @@

pendingTickerInfo.updateMarkPrice(Number(instrumentInfo.mark_price))
} else if (instrumentInfo.markPrice !== undefined) {
pendingTickerInfo.updateMarkPrice(Number(instrumentInfo.markPrice))
} else if (instrumentInfo.mark_price_e4 !== undefined) {
pendingTickerInfo.updateMarkPrice(instrumentInfo.mark_price_e4 / 10000)
pendingTickerInfo.updateMarkPrice(Number(instrumentInfo.mark_price_e4) / 10000)
} else if (instrumentInfo.markPriceE4 !== undefined) {
pendingTickerInfo.updateMarkPrice(Number(instrumentInfo.markPriceE4) / 10000)
}

@@ -172,2 +191,4 @@

pendingTickerInfo.updateOpenInterest(instrumentInfo.open_interest)
} else if (instrumentInfo.openInterestE8 !== undefined) {
pendingTickerInfo.updateOpenInterest(Number(instrumentInfo.openInterestE8) / 100000000)
} else if (instrumentInfo.open_interest_e8 !== undefined) {

@@ -179,4 +200,8 @@ pendingTickerInfo.updateOpenInterest(instrumentInfo.open_interest_e8 / 100000000)

pendingTickerInfo.updateLastPrice(Number(instrumentInfo.last_price))
} else if (instrumentInfo.lastPrice !== undefined) {
pendingTickerInfo.updateLastPrice(Number(instrumentInfo.lastPrice))
} else if (instrumentInfo.last_price_e4 !== undefined) {
pendingTickerInfo.updateLastPrice(Number(instrumentInfo.last_price_e4) / 10000)
} else if (instrumentInfo.lastPriceE4) {
pendingTickerInfo.updateLastPrice(Number(instrumentInfo.lastPriceE4) / 10000)
}

@@ -189,2 +214,7 @@

pendingTickerInfo.updateTimestamp(timestamp)
} else if (message.timestampE6 !== undefined) {
const timestampBybit = Number(message.timestampE6)
const timestamp = new Date(timestampBybit / 1000)
timestamp.μs = timestampBybit % 1000
pendingTickerInfo.updateTimestamp(timestamp)
} else {

@@ -262,13 +292,29 @@ pendingTickerInfo.updateTimestamp(new Date(instrumentInfo.updated_at))

type BybitTradeDataMessage = BybitDataMessage & {
data: {
timestamp: string
trade_time_ms?: number | string
symbol: string
side: 'Buy' | 'Sell'
size: number
price: number | string
trade_id: string
}[]
}
type BybitTradeDataMessage =
| (BybitDataMessage & {
data: {
timestamp: string
trade_time_ms?: number | string
symbol: string
side: 'Buy' | 'Sell'
size: number
price: number | string
trade_id: string
}[]
})
| {
topic: 'trade.BTCPERP'
data: [
{
symbol: 'BTCPERP'
tickDirection: 'PlusTick'
price: '21213.00'
size: 0.007
timestamp: '2022-06-21T09:36:58.000Z'
tradeTimeMs: '1655804218524'
side: 'Sell'
tradeId: '7aad7741-f763-5f78-bf43-c38b29a40f67'
}
]
}

@@ -283,4 +329,5 @@ type BybitBookLevel = {

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

@@ -296,2 +343,3 @@

timestamp_e6: number | string
timestampE6: number | string
}

@@ -313,12 +361,47 @@

updated_at: string
lastPriceE4: '212130000'
lastPrice: '21213.00'
lastTickDirection: 'PlusTick'
prevPrice24hE4: '207180000'
prevPrice24h: '20718.00'
price24hPcntE6: '23892'
highPrice24hE4: '214085000'
highPrice24h: '21408.50'
lowPrice24hE4: '198005000'
lowPrice24h: '19800.50'
prevPrice1hE4: '213315000'
prevPrice1h: '21331.50'
price1hPcntE6: '-5555'
markPriceE4: '212094700'
markPrice: '21209.47'
indexPriceE4: '212247200'
indexPrice: '21224.72'
openInterestE8: '18317600000'
totalTurnoverE8: '94568739311650000'
turnover24hE8: '1375880657550000'
totalVolumeE8: '2734659400000'
volume24hE8: '66536799999'
fundingRateE6: '-900'
predictedFundingRateE6: '-614'
crossSeq: '385207672'
createdAt: '1970-01-01T00:00:00.000Z'
updatedAt: '2022-06-21T09:36:58.000Z'
nextFundingTime: '2022-06-21T16:00:00Z'
countDownHour: '7'
bid1PriceE4: '212130000'
bid1Price: '21213.00'
ask1PriceE4: '212135000'
ask1Price: '21213.50'
}
type BybitInstrumentDataMessage = BybitDataMessage & {
timestamp_e6: string
data:
| BybitInstrumentUpdate
| {
update: [BybitInstrumentUpdate]
}
}
type BybitInstrumentDataMessage =
| BybitDataMessage & {
timestamp_e6: string
timestampE6: string
data:
| BybitInstrumentUpdate
| {
update: [BybitInstrumentUpdate]
}
}

@@ -325,0 +408,0 @@ type BybitLiquidationMessage = BybitDataMessage & {

@@ -12,6 +12,11 @@ import { Filter } from '../types'

const inverseContractsFilters = filters.reduce(
this._only((s) => s.endsWith('USDT') === false),
this._only((s) => s.endsWith('USDT') === false && s.endsWith('PERP') === false),
[] as Filter<string>[]
)
const usdcContracts = filters.reduce(
this._only((s) => s.endsWith('PERP')),
[] as Filter<string>[]
)
if (linearContractsFilters.length > 0) {

@@ -24,2 +29,12 @@ yield new BybitSingleConnectionRealTimeDataFeed('realtime_public', exchange, linearContractsFilters, timeoutIntervalMS, onError)

}
if (usdcContracts.length > 0) {
yield new BybitSingleConnectionRealTimeDataFeed(
'perpetual/ws/v1/realtime_public',
exchange,
usdcContracts,
timeoutIntervalMS,
onError
)
}
}

@@ -26,0 +41,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

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