tardis-dev 13.19.1 → 13.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/consts.d.ts +3 -2
- package/dist/consts.d.ts.map +1 -1
- package/dist/consts.js +25 -2
- package/dist/consts.js.map +1 -1
- package/dist/mappers/bybit.d.ts +200 -2
- package/dist/mappers/bybit.d.ts.map +1 -1
- package/dist/mappers/bybit.js +262 -3
- package/dist/mappers/bybit.js.map +1 -1
- package/dist/mappers/bybitspot.d.ts +1 -1
- package/dist/mappers/cryptocom.d.ts +1 -1
- package/dist/mappers/huobi.d.ts +3 -3
- package/dist/mappers/index.d.ts +4 -4
- package/dist/mappers/index.d.ts.map +1 -1
- package/dist/mappers/index.js +19 -11
- package/dist/mappers/index.js.map +1 -1
- package/dist/realtimefeeds/bybit.d.ts +16 -4
- package/dist/realtimefeeds/bybit.d.ts.map +1 -1
- package/dist/realtimefeeds/bybit.js +67 -19
- package/dist/realtimefeeds/bybit.js.map +1 -1
- package/dist/realtimefeeds/index.d.ts.map +1 -1
- package/dist/realtimefeeds/index.js +2 -2
- package/dist/realtimefeeds/index.js.map +1 -1
- package/package.json +1 -1
- package/src/consts.ts +26 -2
- package/src/mappers/bybit.ts +428 -5
- package/src/mappers/index.ts +40 -12
- package/src/realtimefeeds/bybit.ts +60 -38
- package/src/realtimefeeds/index.ts +3 -3
- package/dist/realtimefeeds/bybitspot.d.ts +0 -10
- package/dist/realtimefeeds/bybitspot.d.ts.map +0 -1
- package/dist/realtimefeeds/bybitspot.js +0 -40
- package/dist/realtimefeeds/bybitspot.js.map +0 -1
- package/src/realtimefeeds/bybitspot.ts +0 -39
|
@@ -1,39 +1,25 @@
|
|
|
1
|
+
import { batch } from '../handy'
|
|
1
2
|
import { Filter } from '../types'
|
|
2
3
|
import { RealTimeFeedBase, MultiConnectionRealTimeFeedBase } from './realtimefeed'
|
|
3
4
|
|
|
4
5
|
export class BybitRealTimeDataFeed extends MultiConnectionRealTimeFeedBase {
|
|
5
6
|
protected *_getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void) {
|
|
6
7
|
const linearContractsFilters = filters.reduce(
|
|
7
|
-
this._only((s) => s.endsWith('USDT')),
|
|
8
|
+
this._only((s) => s.endsWith('USDT') || s.includes('-') || s.endsWith('PERP')),
|
|
8
9
|
[] as Filter<string>[]
|
|
9
10
|
)
|
|
10
11
|
|
|
11
12
|
const inverseContractsFilters = filters.reduce(
|
|
12
|
-
this._only((s) => s.endsWith('USDT') === false && s.endsWith('PERP') === false),
|
|
13
|
-
[] as Filter<string>[]
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
const usdcContracts = filters.reduce(
|
|
17
|
-
this._only((s) => s.endsWith('PERP')),
|
|
13
|
+
this._only((s) => s.endsWith('USDT') === false && s.includes('-') === false && s.endsWith('PERP') === false),
|
|
18
14
|
[] as Filter<string>[]
|
|
19
15
|
)
|
|
20
16
|
|
|
21
17
|
if (linearContractsFilters.length > 0) {
|
|
22
|
-
yield new
|
|
18
|
+
yield new BybitLinearRealTimeDataFeed(exchange, linearContractsFilters, timeoutIntervalMS, onError)
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
if (inverseContractsFilters.length > 0) {
|
|
26
|
-
yield new
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (usdcContracts.length > 0) {
|
|
30
|
-
yield new BybitSingleConnectionRealTimeDataFeed(
|
|
31
|
-
'perpetual/ws/v1/realtime_public',
|
|
32
|
-
exchange,
|
|
33
|
-
usdcContracts,
|
|
34
|
-
timeoutIntervalMS,
|
|
35
|
-
onError
|
|
36
|
-
)
|
|
22
|
+
yield new BybitInverseRealTimeDataFeed(exchange, inverseContractsFilters, timeoutIntervalMS, onError)
|
|
37
23
|
}
|
|
38
24
|
}
|
|
39
25
|
|
|
@@ -55,36 +41,28 @@ export class BybitRealTimeDataFeed extends MultiConnectionRealTimeFeedBase {
|
|
|
55
41
|
}
|
|
56
42
|
}
|
|
57
43
|
|
|
58
|
-
class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase {
|
|
59
|
-
protected readonly wssURL: string
|
|
60
|
-
|
|
61
|
-
constructor(
|
|
62
|
-
wsURLSuffix: string,
|
|
63
|
-
exchange: string,
|
|
64
|
-
filters: Filter<string>[],
|
|
65
|
-
timeoutIntervalMS?: number,
|
|
66
|
-
onError?: (error: Error) => void
|
|
67
|
-
) {
|
|
68
|
-
super(exchange, filters, timeoutIntervalMS, onError)
|
|
69
|
-
this.wssURL = `wss://stream.bybit.com/${wsURLSuffix}`
|
|
70
|
-
}
|
|
44
|
+
abstract class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase {
|
|
45
|
+
protected abstract readonly wssURL: string
|
|
71
46
|
|
|
72
47
|
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
73
48
|
const args = filters
|
|
74
49
|
.map((filter) => {
|
|
50
|
+
if (!filter.symbols || filter.symbols.length === 0) {
|
|
51
|
+
throw new Error('BybitRealTimeDataFeed requires explicitly specified symbols when subscribing to live feed')
|
|
52
|
+
}
|
|
53
|
+
|
|
75
54
|
return filter.symbols!.map((symbol) => {
|
|
76
|
-
|
|
77
|
-
return `${filter.channel}${suffix}.${symbol}`
|
|
55
|
+
return `${filter.channel}.${symbol}`
|
|
78
56
|
})
|
|
79
57
|
})
|
|
80
58
|
.flatMap((f) => f)
|
|
81
59
|
|
|
82
|
-
return [
|
|
83
|
-
{
|
|
60
|
+
return [...batch(args, 10)].map((argBatch) => {
|
|
61
|
+
return {
|
|
84
62
|
op: 'subscribe',
|
|
85
|
-
args
|
|
63
|
+
args: argBatch
|
|
86
64
|
}
|
|
87
|
-
|
|
65
|
+
})
|
|
88
66
|
}
|
|
89
67
|
|
|
90
68
|
protected messageIsError(message: any): boolean {
|
|
@@ -99,3 +77,47 @@ class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase {
|
|
|
99
77
|
return msg.ret_msg === 'pong' || msg.op == 'pong'
|
|
100
78
|
}
|
|
101
79
|
}
|
|
80
|
+
|
|
81
|
+
class BybitLinearRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
82
|
+
protected wssURL: string = 'wss://stream.bybit.com/v5/public/linear'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
class BybitInverseRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
86
|
+
protected wssURL: string = 'wss://stream.bybit.com/v5/public/inverse'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class BybitSpotRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
90
|
+
protected wssURL: string = 'wss://stream.bybit.com/v5/public/spot'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class BybitOptionsRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
94
|
+
protected wssURL: string = 'wss://stream.bybit.com/v5/public/option'
|
|
95
|
+
|
|
96
|
+
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
97
|
+
const args = filters
|
|
98
|
+
.map((filter) => {
|
|
99
|
+
if (!filter.symbols || filter.symbols.length === 0) {
|
|
100
|
+
throw new Error('BybitRealTimeDataFeed requires explicitly specified symbols when subscribing to live feed')
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (filter.channel === 'publicTrade') {
|
|
104
|
+
const baseCoins = [...new Set(filter.symbols.map((s) => s.split('-')[0]))]
|
|
105
|
+
return baseCoins.map((symbol) => {
|
|
106
|
+
return `${filter.channel}.${symbol}`
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return filter.symbols!.map((symbol) => {
|
|
111
|
+
return `${filter.channel}.${symbol}`
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
.flatMap((f) => f)
|
|
115
|
+
|
|
116
|
+
return [...batch(args, 10)].map((argBatch) => {
|
|
117
|
+
return {
|
|
118
|
+
op: 'subscribe',
|
|
119
|
+
args: argBatch
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -11,7 +11,7 @@ import { BitfinexRealTimeFeed } from './bitfinex'
|
|
|
11
11
|
import { BitflyerRealTimeFeed } from './bitflyer'
|
|
12
12
|
import { BitmexRealTimeFeed } from './bitmex'
|
|
13
13
|
import { BitstampRealTimeFeed } from './bitstamp'
|
|
14
|
-
import { BybitRealTimeDataFeed } from './bybit'
|
|
14
|
+
import { BybitOptionsRealTimeDataFeed, BybitRealTimeDataFeed, BybitSpotRealTimeDataFeed } from './bybit'
|
|
15
15
|
import { CoinbaseRealTimeFeed } from './coinbase'
|
|
16
16
|
import { CryptofacilitiesRealTimeFeed } from './cryptofacilities'
|
|
17
17
|
import { DeribitRealTimeDataFeed } from './deribit'
|
|
@@ -41,7 +41,6 @@ import { DydxRealTimeFeed } from './dydx'
|
|
|
41
41
|
import { SerumRealTimeFeed } from './serum'
|
|
42
42
|
import { StarAtlasRealTimeFeed } from './staratlas'
|
|
43
43
|
import { MangoRealTimeFeed } from './mango'
|
|
44
|
-
import { BybitSpotRealTimeFeed } from './bybitspot'
|
|
45
44
|
import { CryptoComRealTimeFeed } from './cryptocom'
|
|
46
45
|
import { KucoinRealTimeFeed } from './kucoin'
|
|
47
46
|
import { BitnomialRealTimeFeed } from './bitnomial'
|
|
@@ -96,7 +95,8 @@ const realTimeFeedsMap: {
|
|
|
96
95
|
'star-atlas': StarAtlasRealTimeFeed,
|
|
97
96
|
'huobi-dm-options': HuobiDMOptionsRealTimeFeed,
|
|
98
97
|
mango: MangoRealTimeFeed,
|
|
99
|
-
'bybit-spot':
|
|
98
|
+
'bybit-spot': BybitSpotRealTimeDataFeed,
|
|
99
|
+
'bybit-options': BybitOptionsRealTimeDataFeed,
|
|
100
100
|
'crypto-com': CryptoComRealTimeFeed,
|
|
101
101
|
'crypto-com-derivatives': CryptoComRealTimeFeed,
|
|
102
102
|
kucoin: KucoinRealTimeFeed,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Filter } from '../types';
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed';
|
|
3
|
-
export declare class BybitSpotRealTimeFeed extends RealTimeFeedBase {
|
|
4
|
-
protected wssURL: string;
|
|
5
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[];
|
|
6
|
-
protected messageIsError(message: any): boolean;
|
|
7
|
-
protected sendCustomPing: () => void;
|
|
8
|
-
protected messageIsHeartbeat(msg: any): boolean;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=bybitspot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bybitspot.d.ts","sourceRoot":"","sources":["../../src/realtimefeeds/bybitspot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,qBAAa,qBAAsB,SAAQ,gBAAgB;IACzD,SAAS,CAAC,MAAM,SAA4C;IAE5D,SAAS,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,EAAE;IAqBlE,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAI/C,SAAS,CAAC,cAAc,aAEvB;IAED,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG;CAGtC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BybitSpotRealTimeFeed = void 0;
|
|
4
|
-
const realtimefeed_1 = require("./realtimefeed");
|
|
5
|
-
class BybitSpotRealTimeFeed extends realtimefeed_1.RealTimeFeedBase {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.wssURL = 'wss://stream.bybit.com/spot/quote/ws/v2';
|
|
9
|
-
this.sendCustomPing = () => {
|
|
10
|
-
this.send({ ping: new Date().valueOf() });
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
mapToSubscribeMessages(filters) {
|
|
14
|
-
return filters
|
|
15
|
-
.map((filter) => {
|
|
16
|
-
if (!filter.symbols || filter.symbols.length === 0) {
|
|
17
|
-
throw new Error('BybitSpotRealTimeFeed requires explicitly specified symbols when subscribing to live feed');
|
|
18
|
-
}
|
|
19
|
-
return filter.symbols.map((symbol) => {
|
|
20
|
-
return {
|
|
21
|
-
event: 'sub',
|
|
22
|
-
topic: filter.channel,
|
|
23
|
-
params: {
|
|
24
|
-
binary: false,
|
|
25
|
-
symbol: symbol
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
})
|
|
30
|
-
.flatMap((c) => c);
|
|
31
|
-
}
|
|
32
|
-
messageIsError(message) {
|
|
33
|
-
return message.code !== undefined && message.code !== '0';
|
|
34
|
-
}
|
|
35
|
-
messageIsHeartbeat(msg) {
|
|
36
|
-
return msg.pong !== undefined;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.BybitSpotRealTimeFeed = BybitSpotRealTimeFeed;
|
|
40
|
-
//# sourceMappingURL=bybitspot.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bybitspot.js","sourceRoot":"","sources":["../../src/realtimefeeds/bybitspot.ts"],"names":[],"mappings":";;;AACA,iDAAiD;AAEjD,MAAa,qBAAsB,SAAQ,+BAAgB;IAA3D;;QACY,WAAM,GAAG,yCAAyC,CAAA;QA2BlD,mBAAc,GAAG,GAAG,EAAE;YAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;QAC3C,CAAC,CAAA;IAKH,CAAC;IAhCW,sBAAsB,CAAC,OAAyB;QACxD,OAAO,OAAO;aACX,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBAClD,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAA;aAC7G;YAED,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBACnC,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,MAAM,CAAC,OAAO;oBACrB,MAAM,EAAE;wBACN,MAAM,EAAE,KAAK;wBACb,MAAM,EAAE,MAAM;qBACf;iBACF,CAAA;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IACtB,CAAC;IAES,cAAc,CAAC,OAAY;QACnC,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,GAAG,CAAA;IAC3D,CAAC;IAMS,kBAAkB,CAAC,GAAQ;QACnC,OAAO,GAAG,CAAC,IAAI,KAAK,SAAS,CAAA;IAC/B,CAAC;CACF;AAnCD,sDAmCC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Filter } from '../types'
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed'
|
|
3
|
-
|
|
4
|
-
export class BybitSpotRealTimeFeed extends RealTimeFeedBase {
|
|
5
|
-
protected wssURL = 'wss://stream.bybit.com/spot/quote/ws/v2'
|
|
6
|
-
|
|
7
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[] {
|
|
8
|
-
return filters
|
|
9
|
-
.map((filter) => {
|
|
10
|
-
if (!filter.symbols || filter.symbols.length === 0) {
|
|
11
|
-
throw new Error('BybitSpotRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return filter.symbols.map((symbol) => {
|
|
15
|
-
return {
|
|
16
|
-
event: 'sub',
|
|
17
|
-
topic: filter.channel,
|
|
18
|
-
params: {
|
|
19
|
-
binary: false,
|
|
20
|
-
symbol: symbol
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
.flatMap((c) => c)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
protected messageIsError(message: any): boolean {
|
|
29
|
-
return message.code !== undefined && message.code !== '0'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
protected sendCustomPing = () => {
|
|
33
|
-
this.send({ ping: new Date().valueOf() })
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
protected messageIsHeartbeat(msg: any) {
|
|
37
|
-
return msg.pong !== undefined
|
|
38
|
-
}
|
|
39
|
-
}
|