tardis-dev 13.20.0 → 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/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/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,16 +1,28 @@
|
|
|
1
1
|
import { Filter } from '../types';
|
|
2
2
|
import { RealTimeFeedBase, MultiConnectionRealTimeFeedBase } from './realtimefeed';
|
|
3
3
|
export declare class BybitRealTimeDataFeed extends MultiConnectionRealTimeFeedBase {
|
|
4
|
-
protected _getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void): Generator<
|
|
4
|
+
protected _getRealTimeFeeds(exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void): Generator<BybitLinearRealTimeDataFeed | BybitInverseRealTimeDataFeed, void, unknown>;
|
|
5
5
|
private _only;
|
|
6
6
|
}
|
|
7
|
-
declare class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase {
|
|
8
|
-
protected readonly wssURL: string;
|
|
9
|
-
constructor(wsURLSuffix: string, exchange: string, filters: Filter<string>[], timeoutIntervalMS?: number, onError?: (error: Error) => void);
|
|
7
|
+
declare abstract class BybitSingleConnectionRealTimeDataFeed extends RealTimeFeedBase {
|
|
8
|
+
protected abstract readonly wssURL: string;
|
|
10
9
|
protected mapToSubscribeMessages(filters: Filter<string>[]): any[];
|
|
11
10
|
protected messageIsError(message: any): boolean;
|
|
12
11
|
protected sendCustomPing: () => void;
|
|
13
12
|
protected messageIsHeartbeat(msg: any): boolean;
|
|
14
13
|
}
|
|
14
|
+
declare class BybitLinearRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
15
|
+
protected wssURL: string;
|
|
16
|
+
}
|
|
17
|
+
declare class BybitInverseRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
18
|
+
protected wssURL: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class BybitSpotRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
21
|
+
protected wssURL: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class BybitOptionsRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
24
|
+
protected wssURL: string;
|
|
25
|
+
protected mapToSubscribeMessages(filters: Filter<string>[]): any[];
|
|
26
|
+
}
|
|
15
27
|
export {};
|
|
16
28
|
//# sourceMappingURL=bybit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bybit.d.ts","sourceRoot":"","sources":["../../src/realtimefeeds/bybit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bybit.d.ts","sourceRoot":"","sources":["../../src/realtimefeeds/bybit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAA;AAElF,qBAAa,qBAAsB,SAAQ,+BAA+B;IACxE,SAAS,CAAE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;IAoBtI,OAAO,CAAC,KAAK;CAgBd;AAED,uBAAe,qCAAsC,SAAQ,gBAAgB;IAC3E,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IAE1C,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;AAED,cAAM,2BAA4B,SAAQ,qCAAqC;IAC7E,SAAS,CAAC,MAAM,EAAE,MAAM,CAA4C;CACrE;AAED,cAAM,4BAA6B,SAAQ,qCAAqC;IAC9E,SAAS,CAAC,MAAM,EAAE,MAAM,CAA6C;CACtE;AAED,qBAAa,yBAA0B,SAAQ,qCAAqC;IAClF,SAAS,CAAC,MAAM,EAAE,MAAM,CAA0C;CACnE;AAED,qBAAa,4BAA6B,SAAQ,qCAAqC;IACrF,SAAS,CAAC,MAAM,EAAE,MAAM,CAA4C;IAEpE,SAAS,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,EAAE;CA2BnE"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BybitRealTimeDataFeed = void 0;
|
|
3
|
+
exports.BybitOptionsRealTimeDataFeed = exports.BybitSpotRealTimeDataFeed = exports.BybitRealTimeDataFeed = void 0;
|
|
4
|
+
const handy_1 = require("../handy");
|
|
4
5
|
const realtimefeed_1 = require("./realtimefeed");
|
|
5
6
|
class BybitRealTimeDataFeed extends realtimefeed_1.MultiConnectionRealTimeFeedBase {
|
|
6
7
|
*_getRealTimeFeeds(exchange, filters, timeoutIntervalMS, onError) {
|
|
7
|
-
const linearContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT')), []);
|
|
8
|
-
const inverseContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT') === false && s.endsWith('PERP') === false), []);
|
|
9
|
-
const usdcContracts = filters.reduce(this._only((s) => s.endsWith('PERP')), []);
|
|
8
|
+
const linearContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT') || s.includes('-') || s.endsWith('PERP')), []);
|
|
9
|
+
const inverseContractsFilters = filters.reduce(this._only((s) => s.endsWith('USDT') === false && s.includes('-') === false && s.endsWith('PERP') === false), []);
|
|
10
10
|
if (linearContractsFilters.length > 0) {
|
|
11
|
-
yield new
|
|
11
|
+
yield new BybitLinearRealTimeDataFeed(exchange, linearContractsFilters, timeoutIntervalMS, onError);
|
|
12
12
|
}
|
|
13
13
|
if (inverseContractsFilters.length > 0) {
|
|
14
|
-
yield new
|
|
15
|
-
}
|
|
16
|
-
if (usdcContracts.length > 0) {
|
|
17
|
-
yield new BybitSingleConnectionRealTimeDataFeed('perpetual/ws/v1/realtime_public', exchange, usdcContracts, timeoutIntervalMS, onError);
|
|
14
|
+
yield new BybitInverseRealTimeDataFeed(exchange, inverseContractsFilters, timeoutIntervalMS, onError);
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
_only(filter) {
|
|
@@ -35,28 +32,29 @@ class BybitRealTimeDataFeed extends realtimefeed_1.MultiConnectionRealTimeFeedBa
|
|
|
35
32
|
}
|
|
36
33
|
exports.BybitRealTimeDataFeed = BybitRealTimeDataFeed;
|
|
37
34
|
class BybitSingleConnectionRealTimeDataFeed extends realtimefeed_1.RealTimeFeedBase {
|
|
38
|
-
constructor(
|
|
39
|
-
super(
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
40
37
|
this.sendCustomPing = () => {
|
|
41
38
|
this.send({ op: 'ping' });
|
|
42
39
|
};
|
|
43
|
-
this.wssURL = `wss://stream.bybit.com/${wsURLSuffix}`;
|
|
44
40
|
}
|
|
45
41
|
mapToSubscribeMessages(filters) {
|
|
46
42
|
const args = filters
|
|
47
43
|
.map((filter) => {
|
|
44
|
+
if (!filter.symbols || filter.symbols.length === 0) {
|
|
45
|
+
throw new Error('BybitRealTimeDataFeed requires explicitly specified symbols when subscribing to live feed');
|
|
46
|
+
}
|
|
48
47
|
return filter.symbols.map((symbol) => {
|
|
49
|
-
|
|
50
|
-
return `${filter.channel}${suffix}.${symbol}`;
|
|
48
|
+
return `${filter.channel}.${symbol}`;
|
|
51
49
|
});
|
|
52
50
|
})
|
|
53
51
|
.flatMap((f) => f);
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
52
|
+
return [...(0, handy_1.batch)(args, 10)].map((argBatch) => {
|
|
53
|
+
return {
|
|
56
54
|
op: 'subscribe',
|
|
57
|
-
args
|
|
58
|
-
}
|
|
59
|
-
|
|
55
|
+
args: argBatch
|
|
56
|
+
};
|
|
57
|
+
});
|
|
60
58
|
}
|
|
61
59
|
messageIsError(message) {
|
|
62
60
|
return message.success === false;
|
|
@@ -65,4 +63,54 @@ class BybitSingleConnectionRealTimeDataFeed extends realtimefeed_1.RealTimeFeedB
|
|
|
65
63
|
return msg.ret_msg === 'pong' || msg.op == 'pong';
|
|
66
64
|
}
|
|
67
65
|
}
|
|
66
|
+
class BybitLinearRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
67
|
+
constructor() {
|
|
68
|
+
super(...arguments);
|
|
69
|
+
this.wssURL = 'wss://stream.bybit.com/v5/public/linear';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class BybitInverseRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
73
|
+
constructor() {
|
|
74
|
+
super(...arguments);
|
|
75
|
+
this.wssURL = 'wss://stream.bybit.com/v5/public/inverse';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
class BybitSpotRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
79
|
+
constructor() {
|
|
80
|
+
super(...arguments);
|
|
81
|
+
this.wssURL = 'wss://stream.bybit.com/v5/public/spot';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.BybitSpotRealTimeDataFeed = BybitSpotRealTimeDataFeed;
|
|
85
|
+
class BybitOptionsRealTimeDataFeed extends BybitSingleConnectionRealTimeDataFeed {
|
|
86
|
+
constructor() {
|
|
87
|
+
super(...arguments);
|
|
88
|
+
this.wssURL = 'wss://stream.bybit.com/v5/public/option';
|
|
89
|
+
}
|
|
90
|
+
mapToSubscribeMessages(filters) {
|
|
91
|
+
const args = filters
|
|
92
|
+
.map((filter) => {
|
|
93
|
+
if (!filter.symbols || filter.symbols.length === 0) {
|
|
94
|
+
throw new Error('BybitRealTimeDataFeed requires explicitly specified symbols when subscribing to live feed');
|
|
95
|
+
}
|
|
96
|
+
if (filter.channel === 'publicTrade') {
|
|
97
|
+
const baseCoins = [...new Set(filter.symbols.map((s) => s.split('-')[0]))];
|
|
98
|
+
return baseCoins.map((symbol) => {
|
|
99
|
+
return `${filter.channel}.${symbol}`;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return filter.symbols.map((symbol) => {
|
|
103
|
+
return `${filter.channel}.${symbol}`;
|
|
104
|
+
});
|
|
105
|
+
})
|
|
106
|
+
.flatMap((f) => f);
|
|
107
|
+
return [...(0, handy_1.batch)(args, 10)].map((argBatch) => {
|
|
108
|
+
return {
|
|
109
|
+
op: 'subscribe',
|
|
110
|
+
args: argBatch
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.BybitOptionsRealTimeDataFeed = BybitOptionsRealTimeDataFeed;
|
|
68
116
|
//# sourceMappingURL=bybit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bybit.js","sourceRoot":"","sources":["../../src/realtimefeeds/bybit.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"b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CAAA;gBACtC,CAAC,CAAC,CAAA;aACH;YAED,OAAO,MAAM,CAAC,OAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBACpC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,EAAE,CAAA;YACtC,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;QAEpB,OAAO,CAAC,GAAG,IAAA,aAAK,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC3C,OAAO;gBACL,EAAE,EAAE,WAAW;gBACf,IAAI,EAAE,QAAQ;aACf,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA9BD,oEA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtimefeeds/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AA6B3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtimefeeds/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AA6B3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAoB7C,cAAc,gBAAgB,CAAA;AA0D9B,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAMvE;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EACzB,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,iDAKjC;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,QAEpF"}
|
|
@@ -44,7 +44,6 @@ const dydx_1 = require("./dydx");
|
|
|
44
44
|
const serum_1 = require("./serum");
|
|
45
45
|
const staratlas_1 = require("./staratlas");
|
|
46
46
|
const mango_1 = require("./mango");
|
|
47
|
-
const bybitspot_1 = require("./bybitspot");
|
|
48
47
|
const cryptocom_1 = require("./cryptocom");
|
|
49
48
|
const kucoin_1 = require("./kucoin");
|
|
50
49
|
const bitnomial_1 = require("./bitnomial");
|
|
@@ -95,7 +94,8 @@ const realTimeFeedsMap = {
|
|
|
95
94
|
'star-atlas': staratlas_1.StarAtlasRealTimeFeed,
|
|
96
95
|
'huobi-dm-options': huobi_1.HuobiDMOptionsRealTimeFeed,
|
|
97
96
|
mango: mango_1.MangoRealTimeFeed,
|
|
98
|
-
'bybit-spot':
|
|
97
|
+
'bybit-spot': bybit_1.BybitSpotRealTimeDataFeed,
|
|
98
|
+
'bybit-options': bybit_1.BybitOptionsRealTimeDataFeed,
|
|
99
99
|
'crypto-com': cryptocom_1.CryptoComRealTimeFeed,
|
|
100
100
|
'crypto-com-derivatives': cryptocom_1.CryptoComRealTimeFeed,
|
|
101
101
|
kucoin: kucoin_1.KucoinRealTimeFeed,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/realtimefeeds/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,uCAMkB;AAClB,6CAAqD;AACrD,yCAAiD;AACjD,yCAAiD;AACjD,qCAA6C;AAC7C,yCAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/realtimefeeds/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,uCAMkB;AAClB,6CAAqD;AACrD,yCAAiD;AACjD,yCAAiD;AACjD,qCAA6C;AAC7C,yCAAiD;AACjD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C3C,CAAC;AAFD,wDAEC"}
|
package/package.json
CHANGED
|
@@ -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
|
-
}
|