tardis-dev
Advanced tools
Comparing version 11.0.1 to 11.0.2
@@ -155,2 +155,15 @@ "use strict"; | ||
exports.OkexDerivativeTickerMapper = OkexDerivativeTickerMapper; | ||
function asNumberIfValid(val) { | ||
if (val === undefined || val === null) { | ||
return; | ||
} | ||
var asNumber = Number(val); | ||
if (isNaN(asNumber) || isFinite(asNumber) === false) { | ||
return; | ||
} | ||
if (asNumber === 0) { | ||
return; | ||
} | ||
return asNumber; | ||
} | ||
class OkexOptionSummaryMapper { | ||
@@ -206,16 +219,16 @@ constructor() { | ||
expirationDate, | ||
bestBidPrice: Number(summary.best_bid) === 0 ? undefined : Number(summary.best_bid), | ||
bestBidAmount: Number(summary.best_bid_size) === 0 ? undefined : Number(summary.best_bid_size), | ||
bestBidIV: Number(summary.bid_vol) === 0 ? undefined : Number(summary.bid_vol), | ||
bestAskPrice: Number(summary.best_ask) === 0 ? undefined : Number(summary.best_ask), | ||
bestAskAmount: Number(summary.best_ask_size) === 0 ? undefined : Number(summary.best_ask_size), | ||
bestAskIV: Number(summary.ask_vol) === 0 ? undefined : Number(summary.ask_vol), | ||
lastPrice: Number(summary.last) === 0 ? undefined : Number(summary.last), | ||
openInterest: Number(summary.open_interest), | ||
markPrice: Number(summary.mark_price), | ||
markIV: Number(summary.mark_vol), | ||
delta: Number(summary.delta), | ||
gamma: Number(summary.gamma), | ||
vega: Number(summary.vega), | ||
theta: Number(summary.theta), | ||
bestBidPrice: asNumberIfValid(summary.best_bid), | ||
bestBidAmount: asNumberIfValid(summary.best_bid_size), | ||
bestBidIV: asNumberIfValid(summary.bid_vol), | ||
bestAskPrice: asNumberIfValid(summary.best_ask), | ||
bestAskAmount: asNumberIfValid(summary.best_ask_size), | ||
bestAskIV: asNumberIfValid(summary.ask_vol), | ||
lastPrice: asNumberIfValid(summary.last), | ||
openInterest: asNumberIfValid(summary.open_interest), | ||
markPrice: asNumberIfValid(summary.mark_price), | ||
markIV: asNumberIfValid(summary.mark_vol), | ||
delta: asNumberIfValid(summary.delta), | ||
gamma: asNumberIfValid(summary.gamma), | ||
vega: asNumberIfValid(summary.vega), | ||
theta: asNumberIfValid(summary.theta), | ||
rho: undefined, | ||
@@ -222,0 +235,0 @@ underlyingPrice: lastUnderlyingPrice, |
import { Filter } from '../types'; | ||
import { RealTimeFeedBase } from './realtimefeed'; | ||
export declare class BybitRealTimeDataFeed extends RealTimeFeedBase { | ||
protected wssURL: string; | ||
import { RealTimeFeedBase, MultiConnectionRealTimeFeedBase } from './realtimefeed'; | ||
export declare class BybitRealTimeDataFeed extends MultiConnectionRealTimeFeedBase { | ||
protected _getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void): Generator<BybitSingleConnectionRealTimeDataFeed, void, unknown>; | ||
private _only; | ||
} | ||
declare class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase { | ||
protected readonly wssURL: string; | ||
constructor(wsURLSuffix: string, exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void); | ||
protected mapToSubscribeMessages(filters: Filter<string>[]): any[]; | ||
protected messageIsError(message: any): boolean; | ||
} | ||
export {}; | ||
//# sourceMappingURL=bybit.d.ts.map |
@@ -5,13 +5,38 @@ "use strict"; | ||
const realtimefeed_1 = require("./realtimefeed"); | ||
class BybitRealTimeDataFeed extends realtimefeed_1.RealTimeFeedBase { | ||
constructor() { | ||
super(...arguments); | ||
this.wssURL = 'wss://stream.bybit.com/realtime'; | ||
class BybitRealTimeDataFeed extends realtimefeed_1.MultiConnectionRealTimeFeedBase { | ||
*_getRealTimeFeeds(exchange, filters, timeoutIntervalMS, onError) { | ||
const linearContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT')), []); | ||
const inverseContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT') === false), []); | ||
if (linearContractsFilters.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('realtime_public', exchange, linearContractsFilters, timeoutIntervalMS, onError); | ||
} | ||
if (inverseContractsFilters.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('realtime', exchange, inverseContractsFilters, timeoutIntervalMS, onError); | ||
} | ||
} | ||
_only(filter) { | ||
return (prev, current) => { | ||
if (!current.symbols || current.symbols.length === 0) { | ||
throw new Error('BybitRealTimeDataFeed requires explicitly specified symbols when subscribing to live feed'); | ||
} | ||
const symbols = current.symbols.filter(filter); | ||
if (symbols.length > 0) { | ||
prev.push({ | ||
channel: current.channel, | ||
symbols | ||
}); | ||
} | ||
return prev; | ||
}; | ||
} | ||
} | ||
exports.BybitRealTimeDataFeed = BybitRealTimeDataFeed; | ||
class BybitSingleConnectionRealTimeDataFeed extends realtimefeed_1.RealTimeFeedBase { | ||
constructor(wsURLSuffix, exchange, filters, timeoutIntervalMS, onError) { | ||
super(exchange, filters, timeoutIntervalMS, onError); | ||
this.wssURL = `wss://stream.bybit.com/${wsURLSuffix}`; | ||
} | ||
mapToSubscribeMessages(filters) { | ||
const args = filters | ||
.map((filter) => { | ||
if (!filter.symbols || filter.symbols.length === 0) { | ||
throw new Error('BybitRealTimeDataFeed requires explicitly specified symbols when subscribing to live feed'); | ||
} | ||
return filter.symbols.map((symbol) => { | ||
@@ -34,3 +59,2 @@ const suffix = filter.channel === 'instrument_info' || filter.channel === 'orderBook_200' ? '.100ms' : ''; | ||
} | ||
exports.BybitRealTimeDataFeed = BybitRealTimeDataFeed; | ||
//# sourceMappingURL=bybit.js.map |
@@ -34,3 +34,3 @@ "use strict"; | ||
super(...arguments); | ||
this.wssURL = 'wss://ftx.us/ws/'; | ||
this.wssURL = 'wss://ws.ftx.com/ws'; | ||
} | ||
@@ -37,0 +37,0 @@ } |
@@ -40,3 +40,3 @@ "use strict"; | ||
const payload = filters.flatMap((filter) => { | ||
if (filter.channel === 'depth') { | ||
if (filter.channel === 'order_book') { | ||
return filter.symbols.map((symbol) => { | ||
@@ -43,0 +43,0 @@ return { |
@@ -50,3 +50,3 @@ "use strict"; | ||
super(...arguments); | ||
this.wssURL = 'wss://api.huobi.pro/ws'; | ||
this.wssURL = 'wss://api-aws.huobi.pro/ws'; | ||
this.channelSuffixMap = { | ||
@@ -63,3 +63,3 @@ trade: '.detail', | ||
super(...arguments); | ||
this.wssURL = 'wss://api.hbdm.com/ws'; | ||
this.wssURL = 'wss://api.hbdm.vn/ws'; | ||
this.channelSuffixMap = { | ||
@@ -75,3 +75,3 @@ trade: '.detail', | ||
super(...arguments); | ||
this.wssURL = 'wss://api.hbdm.com/swap-ws'; | ||
this.wssURL = 'wss://api.hbdm.vn/swap-ws'; | ||
this.channelSuffixMap = { | ||
@@ -78,0 +78,0 @@ trade: '.detail', |
@@ -35,2 +35,3 @@ "use strict"; | ||
const poloniex_1 = require("./poloniex"); | ||
const coinflex_1 = require("./coinflex"); | ||
__exportStar(require("./realtimefeed"), exports); | ||
@@ -70,3 +71,4 @@ const realTimeFeedsMap = { | ||
'gate-io-futures': gateiofutures_1.GateIOFuturesRealTimeFeed, | ||
poloniex: poloniex_1.PoloniexRealTimeFeed | ||
poloniex: poloniex_1.PoloniexRealTimeFeed, | ||
coinflex: coinflex_1.CoinflexRealTimeFeed | ||
}; | ||
@@ -73,0 +75,0 @@ function getRealTimeFeedFactory(exchange) { |
@@ -9,3 +9,3 @@ "use strict"; | ||
super(...arguments); | ||
this.wssURL = 'wss://real.okex.com:8443/ws/v3'; | ||
this.wssURL = 'wss://awspush.okex.com:8443/ws/v3'; | ||
this.decompress = (message) => { | ||
@@ -12,0 +12,0 @@ message = zlib_1.inflateRawSync(message); |
@@ -72,9 +72,9 @@ import { EXCHANGES, EXCHANGE_CHANNELS_INFO } from './consts'; | ||
lastPrice: number | undefined; | ||
openInterest: number; | ||
markPrice: number; | ||
markIV: number; | ||
delta: number; | ||
gamma: number; | ||
vega: number; | ||
theta: number; | ||
openInterest: number | undefined; | ||
markPrice: number | undefined; | ||
markIV: number | undefined; | ||
delta: number | undefined; | ||
gamma: number | undefined; | ||
vega: number | undefined; | ||
theta: number | undefined; | ||
rho: number | undefined; | ||
@@ -81,0 +81,0 @@ underlyingPrice: number | undefined; |
{ | ||
"name": "tardis-dev", | ||
"version": "11.0.1", | ||
"version": "11.0.2", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=12" |
@@ -175,2 +175,20 @@ import { BookChange, DerivativeTicker, Exchange, Trade, OptionSummary } from '../types' | ||
function asNumberIfValid(val: string | undefined | null) { | ||
if (val === undefined || val === null) { | ||
return | ||
} | ||
var asNumber = Number(val) | ||
if (isNaN(asNumber) || isFinite(asNumber) === false) { | ||
return | ||
} | ||
if (asNumber === 0) { | ||
return | ||
} | ||
return asNumber | ||
} | ||
export class OkexOptionSummaryMapper implements Mapper<'okex-options', OptionSummary> { | ||
@@ -234,20 +252,20 @@ private readonly _indexPrices = new Map<string, number>() | ||
bestBidPrice: Number(summary.best_bid) === 0 ? undefined : Number(summary.best_bid), | ||
bestBidAmount: Number(summary.best_bid_size) === 0 ? undefined : Number(summary.best_bid_size), | ||
bestBidIV: Number(summary.bid_vol) === 0 ? undefined : Number(summary.bid_vol), | ||
bestBidPrice: asNumberIfValid(summary.best_bid), | ||
bestBidAmount: asNumberIfValid(summary.best_bid_size), | ||
bestBidIV: asNumberIfValid(summary.bid_vol), | ||
bestAskPrice: Number(summary.best_ask) === 0 ? undefined : Number(summary.best_ask), | ||
bestAskAmount: Number(summary.best_ask_size) === 0 ? undefined : Number(summary.best_ask_size), | ||
bestAskIV: Number(summary.ask_vol) === 0 ? undefined : Number(summary.ask_vol), | ||
bestAskPrice: asNumberIfValid(summary.best_ask), | ||
bestAskAmount: asNumberIfValid(summary.best_ask_size), | ||
bestAskIV: asNumberIfValid(summary.ask_vol), | ||
lastPrice: Number(summary.last) === 0 ? undefined : Number(summary.last), | ||
openInterest: Number(summary.open_interest), | ||
lastPrice: asNumberIfValid(summary.last), | ||
openInterest: asNumberIfValid(summary.open_interest), | ||
markPrice: Number(summary.mark_price), | ||
markIV: Number(summary.mark_vol), | ||
markPrice: asNumberIfValid(summary.mark_price), | ||
markIV: asNumberIfValid(summary.mark_vol), | ||
delta: Number(summary.delta), | ||
gamma: Number(summary.gamma), | ||
vega: Number(summary.vega), | ||
theta: Number(summary.theta), | ||
delta: asNumberIfValid(summary.delta), | ||
gamma: asNumberIfValid(summary.gamma), | ||
vega: asNumberIfValid(summary.vega), | ||
theta: asNumberIfValid(summary.theta), | ||
rho: undefined, | ||
@@ -254,0 +272,0 @@ |
import { Filter } from '../types' | ||
import { RealTimeFeedBase } from './realtimefeed' | ||
import { RealTimeFeedBase, MultiConnectionRealTimeFeedBase } from './realtimefeed' | ||
export class BybitRealTimeDataFeed extends RealTimeFeedBase { | ||
protected wssURL = 'wss://stream.bybit.com/realtime' | ||
export class BybitRealTimeDataFeed extends MultiConnectionRealTimeFeedBase { | ||
protected *_getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void) { | ||
const linearContractsFilters = filters.reduce( | ||
this._only((s) => s.endsWith('USDT')), | ||
[] as Filter<string>[] | ||
) | ||
const inverseContractsFilters = filters.reduce( | ||
this._only((s) => s.endsWith('USDT') === false), | ||
[] as Filter<string>[] | ||
) | ||
if (linearContractsFilters.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('realtime_public', exchange, linearContractsFilters, timeoutIntervalMS, onError) | ||
} | ||
if (inverseContractsFilters.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('realtime', exchange, inverseContractsFilters, timeoutIntervalMS, onError) | ||
} | ||
} | ||
private _only(filter: (symbol: string) => boolean) { | ||
return (prev: Filter<string>[], current: Filter<string>) => { | ||
if (!current.symbols || current.symbols.length === 0) { | ||
throw new Error('BybitRealTimeDataFeed requires explicitly specified symbols when subscribing to live feed') | ||
} | ||
const symbols = current.symbols.filter(filter) | ||
if (symbols.length > 0) { | ||
prev.push({ | ||
channel: current.channel, | ||
symbols | ||
}) | ||
} | ||
return prev | ||
} | ||
} | ||
} | ||
class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase { | ||
protected readonly wssURL: string | ||
constructor( | ||
wsURLSuffix: string, | ||
exchange: string, | ||
filters: Filter<string>[], | ||
timeoutIntervalMS?: number, | ||
onError?: (error: Error) => void | ||
) { | ||
super(exchange, filters, timeoutIntervalMS, onError) | ||
this.wssURL = `wss://stream.bybit.com/${wsURLSuffix}` | ||
} | ||
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] { | ||
const args = filters | ||
.map((filter) => { | ||
if (!filter.symbols || filter.symbols.length === 0) { | ||
throw new Error('BybitRealTimeDataFeed requires explicitly specified symbols when subscribing to live feed') | ||
} | ||
return filter.symbols.map((symbol) => { | ||
return filter.symbols!.map((symbol) => { | ||
const suffix = filter.channel === 'instrument_info' || filter.channel === 'orderBook_200' ? '.100ms' : '' | ||
@@ -16,0 +62,0 @@ return `${filter.channel}${suffix}.${symbol}` |
@@ -31,3 +31,3 @@ import { Filter } from '../types' | ||
export class FtxUSRealTimeFeed extends FtxRealTimeFeed { | ||
protected wssURL = 'wss://ftx.us/ws/' | ||
protected wssURL = 'wss://ws.ftx.com/ws' | ||
} |
@@ -59,3 +59,3 @@ import { Filter } from '../types' | ||
const payload = filters.flatMap((filter) => { | ||
if (filter.channel === 'depth') { | ||
if (filter.channel === 'order_book') { | ||
return filter.symbols!.map((symbol) => { | ||
@@ -62,0 +62,0 @@ return { |
@@ -55,3 +55,3 @@ import { unzipSync } from 'zlib' | ||
export class HuobiRealTimeFeed extends HuobiRealTimeFeedBase { | ||
protected wssURL = 'wss://api.huobi.pro/ws' | ||
protected wssURL = 'wss://api-aws.huobi.pro/ws' | ||
@@ -66,3 +66,3 @@ protected channelSuffixMap = { | ||
export class HuobiDMRealTimeFeed extends HuobiRealTimeFeedBase { | ||
protected wssURL = 'wss://api.hbdm.com/ws' | ||
protected wssURL = 'wss://api.hbdm.vn/ws' | ||
@@ -76,3 +76,3 @@ protected channelSuffixMap = { | ||
export class HuobiDMSwapRealTimeFeed extends HuobiRealTimeFeedBase { | ||
protected wssURL = 'wss://api.hbdm.com/swap-ws' | ||
protected wssURL = 'wss://api.hbdm.vn/swap-ws' | ||
@@ -79,0 +79,0 @@ protected channelSuffixMap = { |
@@ -30,2 +30,3 @@ import { Exchange, Filter } from '../types' | ||
import { PoloniexRealTimeFeed } from './poloniex' | ||
import { CoinflexRealTimeFeed } from './coinflex' | ||
@@ -69,3 +70,4 @@ export * from './realtimefeed' | ||
'gate-io-futures': GateIOFuturesRealTimeFeed, | ||
poloniex: PoloniexRealTimeFeed | ||
poloniex: PoloniexRealTimeFeed, | ||
coinflex: CoinflexRealTimeFeed | ||
} | ||
@@ -72,0 +74,0 @@ |
@@ -6,3 +6,3 @@ import { inflateRawSync } from 'zlib' | ||
export class OkexRealTimeFeed extends RealTimeFeedBase { | ||
protected wssURL = 'wss://real.okex.com:8443/ws/v3' | ||
protected wssURL = 'wss://awspush.okex.com:8443/ws/v3' | ||
@@ -9,0 +9,0 @@ protected decompress = (message: any) => { |
@@ -84,11 +84,11 @@ import { EXCHANGES, EXCHANGE_CHANNELS_INFO } from './consts' | ||
lastPrice: number | undefined | ||
openInterest: number | ||
openInterest: number | undefined | ||
markPrice: number | ||
markIV: number | ||
markPrice: number | undefined | ||
markIV: number | undefined | ||
delta: number | ||
gamma: number | ||
vega: number | ||
theta: number | ||
delta: number | undefined | ||
gamma: number | undefined | ||
vega: number | undefined | ||
theta: number | undefined | ||
rho: number | undefined | ||
@@ -95,0 +95,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
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
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
904875
349
16227