tardis-dev
Advanced tools
Comparing version 13.20.0 to 13.20.1
import { Filter } from '../types'; | ||
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>; | ||
protected _getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void): Generator<BybitLinearRealTimeDataFeed | BybitInverseRealTimeDataFeed, 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); | ||
declare abstract class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase { | ||
protected abstract readonly wssURL: string; | ||
protected mapToSubscribeMessages(filters: Filter<string>[]): any[]; | ||
@@ -15,3 +14,16 @@ protected messageIsError(message: any): boolean; | ||
} | ||
declare class BybitLinearRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
protected wssURL: string; | ||
} | ||
declare class BybitInverseRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
protected wssURL: string; | ||
} | ||
export declare class BybitSpotRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
protected wssURL: string; | ||
} | ||
export declare class BybitOptionsRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
protected wssURL: string; | ||
protected mapToSubscribeMessages(filters: Filter<string>[]): any[]; | ||
} | ||
export {}; | ||
//# sourceMappingURL=bybit.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BybitRealTimeDataFeed = void 0; | ||
exports.BybitOptionsRealTimeDataFeed = exports.BybitSpotRealTimeDataFeed = exports.BybitRealTimeDataFeed = void 0; | ||
const handy_1 = require("../handy"); | ||
const realtimefeed_1 = require("./realtimefeed"); | ||
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 && s.endsWith('PERP') === false), []); | ||
const usdcContracts = filters.reduce(this._only((s) => s.endsWith('PERP')), []); | ||
const linearContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT') || s.includes('-') || s.endsWith('PERP')), []); | ||
const inverseContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT') === false && s.includes('-') === false && s.endsWith('PERP') === false), []); | ||
if (linearContractsFilters.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('realtime_public', exchange, linearContractsFilters, timeoutIntervalMS, onError); | ||
yield new BybitLinearRealTimeDataFeed(exchange, linearContractsFilters, timeoutIntervalMS, onError); | ||
} | ||
if (inverseContractsFilters.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('realtime', exchange, inverseContractsFilters, timeoutIntervalMS, onError); | ||
yield new BybitInverseRealTimeDataFeed(exchange, inverseContractsFilters, timeoutIntervalMS, onError); | ||
} | ||
if (usdcContracts.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('perpetual/ws/v1/realtime_public', exchange, usdcContracts, timeoutIntervalMS, onError); | ||
} | ||
} | ||
@@ -38,8 +35,7 @@ _only(filter) { | ||
class BybitSingleConnectionRealTimeDataFeed extends realtimefeed_1.RealTimeFeedBase { | ||
constructor(wsURLSuffix, exchange, filters, timeoutIntervalMS, onError) { | ||
super(exchange, filters, timeoutIntervalMS, onError); | ||
constructor() { | ||
super(...arguments); | ||
this.sendCustomPing = () => { | ||
this.send({ op: 'ping' }); | ||
}; | ||
this.wssURL = `wss://stream.bybit.com/${wsURLSuffix}`; | ||
} | ||
@@ -49,14 +45,16 @@ mapToSubscribeMessages(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) => { | ||
const suffix = filter.channel === 'instrument_info' || filter.channel === 'orderBook_200' ? '.100ms' : ''; | ||
return `${filter.channel}${suffix}.${symbol}`; | ||
return `${filter.channel}.${symbol}`; | ||
}); | ||
}) | ||
.flatMap((f) => f); | ||
return [ | ||
{ | ||
return [...(0, handy_1.batch)(args, 10)].map((argBatch) => { | ||
return { | ||
op: 'subscribe', | ||
args | ||
} | ||
]; | ||
args: argBatch | ||
}; | ||
}); | ||
} | ||
@@ -70,2 +68,52 @@ messageIsError(message) { | ||
} | ||
class BybitLinearRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
constructor() { | ||
super(...arguments); | ||
this.wssURL = 'wss://stream.bybit.com/v5/public/linear'; | ||
} | ||
} | ||
class BybitInverseRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
constructor() { | ||
super(...arguments); | ||
this.wssURL = 'wss://stream.bybit.com/v5/public/inverse'; | ||
} | ||
} | ||
class BybitSpotRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
constructor() { | ||
super(...arguments); | ||
this.wssURL = 'wss://stream.bybit.com/v5/public/spot'; | ||
} | ||
} | ||
exports.BybitSpotRealTimeDataFeed = BybitSpotRealTimeDataFeed; | ||
class BybitOptionsRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
constructor() { | ||
super(...arguments); | ||
this.wssURL = 'wss://stream.bybit.com/v5/public/option'; | ||
} | ||
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'); | ||
} | ||
if (filter.channel === 'publicTrade') { | ||
const baseCoins = [...new Set(filter.symbols.map((s) => s.split('-')[0]))]; | ||
return baseCoins.map((symbol) => { | ||
return `${filter.channel}.${symbol}`; | ||
}); | ||
} | ||
return filter.symbols.map((symbol) => { | ||
return `${filter.channel}.${symbol}`; | ||
}); | ||
}) | ||
.flatMap((f) => f); | ||
return [...(0, handy_1.batch)(args, 10)].map((argBatch) => { | ||
return { | ||
op: 'subscribe', | ||
args: argBatch | ||
}; | ||
}); | ||
} | ||
} | ||
exports.BybitOptionsRealTimeDataFeed = BybitOptionsRealTimeDataFeed; | ||
//# sourceMappingURL=bybit.js.map |
@@ -47,3 +47,2 @@ "use strict"; | ||
const mango_1 = require("./mango"); | ||
const bybitspot_1 = require("./bybitspot"); | ||
const cryptocom_1 = require("./cryptocom"); | ||
@@ -99,3 +98,4 @@ const kucoin_1 = require("./kucoin"); | ||
mango: mango_1.MangoRealTimeFeed, | ||
'bybit-spot': bybitspot_1.BybitSpotRealTimeFeed, | ||
'bybit-spot': bybit_1.BybitSpotRealTimeDataFeed, | ||
'bybit-options': bybit_1.BybitOptionsRealTimeDataFeed, | ||
'crypto-com': cryptocom_1.CryptoComRealTimeFeed, | ||
@@ -102,0 +102,0 @@ 'crypto-com-derivatives': cryptocom_1.CryptoComRealTimeFeed, |
{ | ||
"name": "tardis-dev", | ||
"version": "13.20.0", | ||
"version": "13.20.1", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=12" |
@@ -0,1 +1,2 @@ | ||
import { batch } from '../handy' | ||
import { Filter } from '../types' | ||
@@ -7,3 +8,3 @@ import { RealTimeFeedBase, MultiConnectionRealTimeFeedBase } from './realtimefeed' | ||
const linearContractsFilters = filters.reduce( | ||
this._only((s) => s.endsWith('USDT')), | ||
this._only((s) => s.endsWith('USDT') || s.includes('-') || s.endsWith('PERP')), | ||
[] as Filter<string>[] | ||
@@ -13,28 +14,13 @@ ) | ||
const inverseContractsFilters = filters.reduce( | ||
this._only((s) => s.endsWith('USDT') === false && s.endsWith('PERP') === false), | ||
this._only((s) => s.endsWith('USDT') === false && s.includes('-') === 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) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('realtime_public', exchange, linearContractsFilters, timeoutIntervalMS, onError) | ||
yield new BybitLinearRealTimeDataFeed(exchange, linearContractsFilters, timeoutIntervalMS, onError) | ||
} | ||
if (inverseContractsFilters.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed('realtime', exchange, inverseContractsFilters, timeoutIntervalMS, onError) | ||
yield new BybitInverseRealTimeDataFeed(exchange, inverseContractsFilters, timeoutIntervalMS, onError) | ||
} | ||
if (usdcContracts.length > 0) { | ||
yield new BybitSingleConnectionRealTimeDataFeed( | ||
'perpetual/ws/v1/realtime_public', | ||
exchange, | ||
usdcContracts, | ||
timeoutIntervalMS, | ||
onError | ||
) | ||
} | ||
} | ||
@@ -60,22 +46,14 @@ | ||
class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase { | ||
protected readonly wssURL: string | ||
abstract class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase { | ||
protected abstract 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) => { | ||
const suffix = filter.channel === 'instrument_info' || filter.channel === 'orderBook_200' ? '.100ms' : '' | ||
return `${filter.channel}${suffix}.${symbol}` | ||
return `${filter.channel}.${symbol}` | ||
}) | ||
@@ -85,8 +63,8 @@ }) | ||
return [ | ||
{ | ||
return [...batch(args, 10)].map((argBatch) => { | ||
return { | ||
op: 'subscribe', | ||
args | ||
args: argBatch | ||
} | ||
] | ||
}) | ||
} | ||
@@ -106,1 +84,45 @@ | ||
} | ||
class BybitLinearRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
protected wssURL: string = 'wss://stream.bybit.com/v5/public/linear' | ||
} | ||
class BybitInverseRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
protected wssURL: string = 'wss://stream.bybit.com/v5/public/inverse' | ||
} | ||
export class BybitSpotRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
protected wssURL: string = 'wss://stream.bybit.com/v5/public/spot' | ||
} | ||
export class BybitOptionsRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed { | ||
protected wssURL: string = 'wss://stream.bybit.com/v5/public/option' | ||
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') | ||
} | ||
if (filter.channel === 'publicTrade') { | ||
const baseCoins = [...new Set(filter.symbols.map((s) => s.split('-')[0]))] | ||
return baseCoins.map((symbol) => { | ||
return `${filter.channel}.${symbol}` | ||
}) | ||
} | ||
return filter.symbols!.map((symbol) => { | ||
return `${filter.channel}.${symbol}` | ||
}) | ||
}) | ||
.flatMap((f) => f) | ||
return [...batch(args, 10)].map((argBatch) => { | ||
return { | ||
op: 'subscribe', | ||
args: argBatch | ||
} | ||
}) | ||
} | ||
} |
@@ -14,3 +14,3 @@ import { Exchange, Filter } from '../types' | ||
import { BitstampRealTimeFeed } from './bitstamp' | ||
import { BybitRealTimeDataFeed } from './bybit' | ||
import { BybitOptionsRealTimeDataFeed, BybitRealTimeDataFeed, BybitSpotRealTimeDataFeed } from './bybit' | ||
import { CoinbaseRealTimeFeed } from './coinbase' | ||
@@ -45,3 +45,2 @@ import { CryptofacilitiesRealTimeFeed } from './cryptofacilities' | ||
import { MangoRealTimeFeed } from './mango' | ||
import { BybitSpotRealTimeFeed } from './bybitspot' | ||
import { CryptoComRealTimeFeed } from './cryptocom' | ||
@@ -101,3 +100,4 @@ import { KucoinRealTimeFeed } from './kucoin' | ||
mango: MangoRealTimeFeed, | ||
'bybit-spot': BybitSpotRealTimeFeed, | ||
'bybit-spot': BybitSpotRealTimeDataFeed, | ||
'bybit-options': BybitOptionsRealTimeDataFeed, | ||
'crypto-com': CryptoComRealTimeFeed, | ||
@@ -104,0 +104,0 @@ 'crypto-com-derivatives': CryptoComRealTimeFeed, |
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
1736548
469
32105