tardis-dev
Advanced tools
Comparing version 13.1.15 to 13.2.0
@@ -9,6 +9,6 @@ export declare const EXCHANGES: readonly ["bitmex", "deribit", "binance-futures", "binance-delivery", "binance-options", "binance", "ftx", "okex-futures", "okex-options", "okex-swap", "okex", "huobi-dm", "huobi-dm-swap", "huobi-dm-linear-swap", "huobi", "bitfinex-derivatives", "bitfinex", "coinbase", "cryptofacilities", "kraken", "bitstamp", "gemini", "poloniex", "bybit", "phemex", "delta", "ftx-us", "binance-us", "gate-io-futures", "gate-io", "okcoin", "bitflyer", "hitbtc", "coinflex", "binance-jersey", "binance-dex", "upbit", "ascendex", "dydx", "serum", "huobi-dm-options", "star-atlas"]; | ||
kraken: readonly ["trade", "ticker", "book", "spread"]; | ||
okex: readonly ["spot/trade", "spot/depth", "spot/depth_l2_tbt", "spot/ticker", "system/status", "margin/interest_rate", "trades", "books-l2-tbt", "tickers", "interest-rate-loan-quota", "vip-interest-rate-loan-quota", "status", "instruments", "taker-volume"]; | ||
'okex-swap': readonly ["swap/trade", "swap/depth", "swap/depth_l2_tbt", "swap/ticker", "swap/funding_rate", "swap/mark_price", "swap/liquidation", "index/ticker", "system/status", "information/sentiment", "information/long_short_ratio", "information/margin", "trades", "books-l2-tbt", "tickers", "open-interest", "mark-price", "price-limit", "funding-rate", "status", "instruments", "index-tickers", "long-short-account-ratio", "taker-volume", "liquidations"]; | ||
'okex-futures': readonly ["futures/trade", "futures/depth", "futures/depth_l2_tbt", "futures/ticker", "futures/mark_price", "futures/liquidation", "index/ticker", "system/status", "information/sentiment", "information/long_short_ratio", "information/margin", "trades", "books-l2-tbt", "tickers", "open-interest", "mark-price", "price-limit", "status", "instruments", "index-tickers", "long-short-account-ratio", "taker-volume", "liquidations"]; | ||
'okex-options': readonly ["option/trade", "option/depth", "option/depth_l2_tbt", "option/ticker", "option/summary", "option/instruments", "index/ticker", "system/status", "option/trades", "trades", "books-l2-tbt", "tickers", "opt-summary", "status", "instruments", "index-tickers", "open-interest", "mark-price", "price-limit"]; | ||
okex: readonly ["spot/trade", "spot/depth", "spot/depth_l2_tbt", "spot/ticker", "system/status", "margin/interest_rate", "trades", "books-l2-tbt", "bbo-tbt", "tickers", "interest-rate-loan-quota", "vip-interest-rate-loan-quota", "status", "instruments", "taker-volume"]; | ||
'okex-swap': readonly ["swap/trade", "swap/depth", "swap/depth_l2_tbt", "swap/ticker", "swap/funding_rate", "swap/mark_price", "swap/liquidation", "index/ticker", "system/status", "information/sentiment", "information/long_short_ratio", "information/margin", "trades", "books-l2-tbt", "bbo-tbt", "tickers", "open-interest", "mark-price", "price-limit", "funding-rate", "status", "instruments", "index-tickers", "long-short-account-ratio", "taker-volume", "liquidations"]; | ||
'okex-futures': readonly ["futures/trade", "futures/depth", "futures/depth_l2_tbt", "futures/ticker", "futures/mark_price", "futures/liquidation", "index/ticker", "system/status", "information/sentiment", "information/long_short_ratio", "information/margin", "trades", "books-l2-tbt", "bbo-tbt", "tickers", "open-interest", "mark-price", "price-limit", "status", "instruments", "index-tickers", "long-short-account-ratio", "taker-volume", "liquidations"]; | ||
'okex-options': readonly ["option/trade", "option/depth", "option/depth_l2_tbt", "option/ticker", "option/summary", "option/instruments", "index/ticker", "system/status", "option/trades", "trades", "books-l2-tbt", "bbo-tbt", "tickers", "opt-summary", "status", "instruments", "index-tickers", "open-interest", "mark-price", "price-limit"]; | ||
binance: readonly ["trade", "aggTrade", "ticker", "depth", "depthSnapshot", "bookTicker", "recentTrades", "borrowInterest"]; | ||
@@ -15,0 +15,0 @@ 'binance-jersey': readonly ["trade", "aggTrade", "ticker", "depth", "depthSnapshot", "bookTicker", "recentTrades", "borrowInterest"]; |
@@ -113,2 +113,3 @@ "use strict"; | ||
'books-l2-tbt', | ||
'bbo-tbt', | ||
'tickers', | ||
@@ -137,2 +138,3 @@ 'interest-rate-loan-quota', | ||
'books-l2-tbt', | ||
'bbo-tbt', | ||
'tickers', | ||
@@ -165,2 +167,3 @@ 'open-interest', | ||
'books-l2-tbt', | ||
'bbo-tbt', | ||
'tickers', | ||
@@ -191,2 +194,3 @@ 'open-interest', | ||
'books-l2-tbt', | ||
'bbo-tbt', | ||
'tickers', | ||
@@ -193,0 +197,0 @@ 'opt-summary', |
@@ -55,5 +55,9 @@ "use strict"; | ||
const OKEX_V5_API_SWITCH_DATE = new Date('2021-12-23T00:00:00.000Z'); | ||
const OKEX_V5_TBT_BOOK_TICKER_RELEASE_DATE = new Date('2022-05-06T00:00:00.000Z'); | ||
const shouldUseOkexV5Mappers = (localTimestamp) => { | ||
return isRealTime(localTimestamp) || localTimestamp.valueOf() >= OKEX_V5_API_SWITCH_DATE.valueOf(); | ||
}; | ||
const canUseOkexTbtBookTicker = (localTimestamp) => { | ||
return isRealTime(localTimestamp) || localTimestamp.valueOf() >= OKEX_V5_TBT_BOOK_TICKER_RELEASE_DATE.valueOf(); | ||
}; | ||
const tradesMappers = { | ||
@@ -224,9 +228,13 @@ bitmex: () => bitmex_1.bitmexTradesMapper, | ||
kraken: () => kraken_1.krakenBookTickerMapper, | ||
okex: (localTimestamp) => shouldUseOkexV5Mappers(localTimestamp) ? new okex_1.OkexV5BookTickerMapper('okex') : new okex_1.OkexBookTickerMapper('okex', 'spot'), | ||
okex: (localTimestamp) => shouldUseOkexV5Mappers(localTimestamp) | ||
? new okex_1.OkexV5BookTickerMapper('okex', canUseOkexTbtBookTicker(localTimestamp)) | ||
: new okex_1.OkexBookTickerMapper('okex', 'spot'), | ||
'okex-futures': (localTimestamp) => shouldUseOkexV5Mappers(localTimestamp) | ||
? new okex_1.OkexV5BookTickerMapper('okex-futures') | ||
? new okex_1.OkexV5BookTickerMapper('okex-futures', canUseOkexTbtBookTicker(localTimestamp)) | ||
: new okex_1.OkexBookTickerMapper('okex-futures', 'futures'), | ||
'okex-swap': (localTimestamp) => shouldUseOkexV5Mappers(localTimestamp) ? new okex_1.OkexV5BookTickerMapper('okex-swap') : new okex_1.OkexBookTickerMapper('okex-swap', 'swap'), | ||
'okex-swap': (localTimestamp) => shouldUseOkexV5Mappers(localTimestamp) | ||
? new okex_1.OkexV5BookTickerMapper('okex-swap', canUseOkexTbtBookTicker(localTimestamp)) | ||
: new okex_1.OkexBookTickerMapper('okex-swap', 'swap'), | ||
'okex-options': (localTimestamp) => shouldUseOkexV5Mappers(localTimestamp) | ||
? new okex_1.OkexV5BookTickerMapper('okex-options') | ||
? new okex_1.OkexV5BookTickerMapper('okex-options', canUseOkexTbtBookTicker(localTimestamp)) | ||
: new okex_1.OkexBookTickerMapper('okex-options', 'option'), | ||
@@ -233,0 +241,0 @@ okcoin: () => new okex_1.OkexBookTickerMapper('okcoin', 'spot'), |
@@ -26,9 +26,15 @@ import { BookChange, BookTicker, DerivativeTicker, Exchange, Liquidation, OptionSummary, Trade } from '../types'; | ||
private readonly _exchange; | ||
constructor(_exchange: Exchange); | ||
private readonly _useTbtTickerChannel; | ||
constructor(_exchange: Exchange, _useTbtTickerChannel: boolean); | ||
canHandle(message: any): boolean; | ||
getFilters(symbols?: string[]): { | ||
channel: "bbo-tbt"; | ||
symbols: string[] | undefined; | ||
}[] | { | ||
channel: "tickers"; | ||
symbols: string[] | undefined; | ||
}[]; | ||
map(message: OkexV5TickerMessage, localTimestamp: Date): IterableIterator<BookTicker>; | ||
map(message: OkexV5TickerMessage | OkexBBOTbtData, localTimestamp: Date): IterableIterator<BookTicker>; | ||
private _mapFromTbtTicker; | ||
private _mapFromTicker; | ||
} | ||
@@ -415,3 +421,14 @@ export declare class OkexV5DerivativeTickerMapper implements Mapper<'okex-futures' | 'okex-swap', DerivativeTicker> { | ||
}; | ||
declare type OkexBBOTbtData = { | ||
arg: { | ||
channel: 'bbo-tbt'; | ||
instId: 'WAVES-USDT-SWAP'; | ||
}; | ||
data: [{ | ||
asks: [['16.083', '65', '0', '1']]; | ||
bids: [['16.082', '143', '0', '4']]; | ||
ts: '1651750920000'; | ||
}]; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=okex.d.ts.map |
@@ -104,4 +104,5 @@ "use strict"; | ||
class OkexV5BookTickerMapper { | ||
constructor(_exchange) { | ||
constructor(_exchange, _useTbtTickerChannel) { | ||
this._exchange = _exchange; | ||
this._useTbtTickerChannel = _useTbtTickerChannel; | ||
} | ||
@@ -112,2 +113,5 @@ canHandle(message) { | ||
} | ||
if (this._useTbtTickerChannel) { | ||
return message.arg.channel === 'bbo-tbt'; | ||
} | ||
return message.arg.channel === 'tickers'; | ||
@@ -117,2 +121,10 @@ } | ||
symbols = (0, handy_1.upperCaseSymbols)(symbols); | ||
if (this._useTbtTickerChannel) { | ||
return [ | ||
{ | ||
channel: `bbo-tbt`, | ||
symbols | ||
} | ||
]; | ||
} | ||
return [ | ||
@@ -125,3 +137,32 @@ { | ||
} | ||
*map(message, localTimestamp) { | ||
map(message, localTimestamp) { | ||
if (message.arg.channel === 'bbo-tbt') { | ||
return this._mapFromTbtTicker(message, localTimestamp); | ||
} | ||
else { | ||
return this._mapFromTicker(message, localTimestamp); | ||
} | ||
} | ||
*_mapFromTbtTicker(message, localTimestamp) { | ||
if (!message.data) { | ||
return; | ||
} | ||
for (const tbtTicker of message.data) { | ||
const bestAsk = tbtTicker.asks !== undefined && tbtTicker.asks[0] ? mapBookLevel(tbtTicker.asks[0]) : undefined; | ||
const bestBid = tbtTicker.bids !== undefined && tbtTicker.bids[0] ? mapBookLevel(tbtTicker.bids[0]) : undefined; | ||
const ticker = { | ||
type: 'book_ticker', | ||
symbol: message.arg.instId, | ||
exchange: this._exchange, | ||
askAmount: bestAsk === null || bestAsk === void 0 ? void 0 : bestAsk.amount, | ||
askPrice: bestAsk === null || bestAsk === void 0 ? void 0 : bestAsk.price, | ||
bidPrice: bestBid === null || bestBid === void 0 ? void 0 : bestBid.price, | ||
bidAmount: bestBid === null || bestBid === void 0 ? void 0 : bestBid.amount, | ||
timestamp: new Date(Number(tbtTicker.ts)), | ||
localTimestamp: localTimestamp | ||
}; | ||
yield ticker; | ||
} | ||
} | ||
*_mapFromTicker(message, localTimestamp) { | ||
for (const okexTicker of message.data) { | ||
@@ -128,0 +169,0 @@ const ticker = { |
{ | ||
"name": "tardis-dev", | ||
"version": "13.1.15", | ||
"version": "13.2.0", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=12" |
@@ -118,2 +118,3 @@ export const EXCHANGES = [ | ||
'books-l2-tbt', | ||
'bbo-tbt', | ||
'tickers', | ||
@@ -145,2 +146,3 @@ 'interest-rate-loan-quota', | ||
'books-l2-tbt', | ||
'bbo-tbt', | ||
'tickers', | ||
@@ -175,2 +177,3 @@ 'open-interest', | ||
'books-l2-tbt', | ||
'bbo-tbt', | ||
'tickers', | ||
@@ -203,2 +206,3 @@ 'open-interest', | ||
'books-l2-tbt', | ||
'bbo-tbt', | ||
'tickers', | ||
@@ -205,0 +209,0 @@ 'opt-summary', |
@@ -97,3 +97,3 @@ import { ONE_SEC_IN_MS } from '../handy' | ||
const OKEX_V5_API_SWITCH_DATE = new Date('2021-12-23T00:00:00.000Z') | ||
const OKEX_V5_TBT_BOOK_TICKER_RELEASE_DATE = new Date('2022-05-06T00:00:00.000Z') | ||
const shouldUseOkexV5Mappers = (localTimestamp: Date) => { | ||
@@ -103,2 +103,6 @@ return isRealTime(localTimestamp) || localTimestamp.valueOf() >= OKEX_V5_API_SWITCH_DATE.valueOf() | ||
const canUseOkexTbtBookTicker = (localTimestamp: Date) => { | ||
return isRealTime(localTimestamp) || localTimestamp.valueOf() >= OKEX_V5_TBT_BOOK_TICKER_RELEASE_DATE.valueOf() | ||
} | ||
const tradesMappers = { | ||
@@ -301,15 +305,19 @@ bitmex: () => bitmexTradesMapper, | ||
okex: (localTimestamp: Date) => | ||
shouldUseOkexV5Mappers(localTimestamp) ? new OkexV5BookTickerMapper('okex') : new OkexBookTickerMapper('okex', 'spot'), | ||
shouldUseOkexV5Mappers(localTimestamp) | ||
? new OkexV5BookTickerMapper('okex', canUseOkexTbtBookTicker(localTimestamp)) | ||
: new OkexBookTickerMapper('okex', 'spot'), | ||
'okex-futures': (localTimestamp: Date) => | ||
shouldUseOkexV5Mappers(localTimestamp) | ||
? new OkexV5BookTickerMapper('okex-futures') | ||
? new OkexV5BookTickerMapper('okex-futures', canUseOkexTbtBookTicker(localTimestamp)) | ||
: new OkexBookTickerMapper('okex-futures', 'futures'), | ||
'okex-swap': (localTimestamp: Date) => | ||
shouldUseOkexV5Mappers(localTimestamp) ? new OkexV5BookTickerMapper('okex-swap') : new OkexBookTickerMapper('okex-swap', 'swap'), | ||
shouldUseOkexV5Mappers(localTimestamp) | ||
? new OkexV5BookTickerMapper('okex-swap', canUseOkexTbtBookTicker(localTimestamp)) | ||
: new OkexBookTickerMapper('okex-swap', 'swap'), | ||
'okex-options': (localTimestamp: Date) => | ||
shouldUseOkexV5Mappers(localTimestamp) | ||
? new OkexV5BookTickerMapper('okex-options') | ||
? new OkexV5BookTickerMapper('okex-options', canUseOkexTbtBookTicker(localTimestamp)) | ||
: new OkexBookTickerMapper('okex-options', 'option'), | ||
@@ -316,0 +324,0 @@ |
@@ -114,3 +114,3 @@ import { asNumberIfValid, upperCaseSymbols } from '../handy' | ||
export class OkexV5BookTickerMapper implements Mapper<OKEX_EXCHANGES, BookTicker> { | ||
constructor(private readonly _exchange: Exchange) {} | ||
constructor(private readonly _exchange: Exchange, private readonly _useTbtTickerChannel: boolean) {} | ||
@@ -121,2 +121,7 @@ canHandle(message: any) { | ||
} | ||
if (this._useTbtTickerChannel) { | ||
return message.arg.channel === 'bbo-tbt' | ||
} | ||
return message.arg.channel === 'tickers' | ||
@@ -128,2 +133,10 @@ } | ||
if (this._useTbtTickerChannel) { | ||
return [ | ||
{ | ||
channel: `bbo-tbt` as const, | ||
symbols | ||
} | ||
] | ||
} | ||
return [ | ||
@@ -137,3 +150,38 @@ { | ||
*map(message: OkexV5TickerMessage, localTimestamp: Date): IterableIterator<BookTicker> { | ||
map(message: OkexV5TickerMessage | OkexBBOTbtData, localTimestamp: Date): IterableIterator<BookTicker> { | ||
if (message.arg.channel === 'bbo-tbt') { | ||
return this._mapFromTbtTicker(message as OkexBBOTbtData, localTimestamp) | ||
} else { | ||
return this._mapFromTicker(message as OkexV5TickerMessage, localTimestamp) | ||
} | ||
} | ||
private *_mapFromTbtTicker(message: OkexBBOTbtData, localTimestamp: Date): IterableIterator<BookTicker> { | ||
if (!message.data) { | ||
return | ||
} | ||
for (const tbtTicker of message.data) { | ||
const bestAsk = tbtTicker.asks !== undefined && tbtTicker.asks[0] ? mapBookLevel(tbtTicker.asks[0]) : undefined | ||
const bestBid = tbtTicker.bids !== undefined && tbtTicker.bids[0] ? mapBookLevel(tbtTicker.bids[0]) : undefined | ||
const ticker: BookTicker = { | ||
type: 'book_ticker', | ||
symbol: message.arg.instId, | ||
exchange: this._exchange, | ||
askAmount: bestAsk?.amount, | ||
askPrice: bestAsk?.price, | ||
bidPrice: bestBid?.price, | ||
bidAmount: bestBid?.amount, | ||
timestamp: new Date(Number(tbtTicker.ts)), | ||
localTimestamp: localTimestamp | ||
} | ||
yield ticker | ||
} | ||
} | ||
private *_mapFromTicker(message: OkexV5TickerMessage, localTimestamp: Date): IterableIterator<BookTicker> { | ||
for (const okexTicker of message.data) { | ||
@@ -1056,1 +1104,6 @@ const ticker: BookTicker = { | ||
} | ||
type OkexBBOTbtData = { | ||
arg: { channel: 'bbo-tbt'; instId: 'WAVES-USDT-SWAP' } | ||
data: [{ asks: [['16.083', '65', '0', '1']]; bids: [['16.082', '143', '0', '4']]; ts: '1651750920000' }] | ||
} |
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
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
1400717
25675