tardis-dev 14.2.0 → 14.2.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/binarysplit.d.ts.map +1 -1
- package/dist/binarysplit.js +19 -16
- package/dist/binarysplit.js.map +1 -1
- package/dist/consts.d.ts +10 -12
- package/dist/consts.d.ts.map +1 -1
- package/dist/consts.js +30 -16
- package/dist/consts.js.map +1 -1
- package/dist/mappers/bybit.d.ts +2 -2
- package/dist/mappers/bybitspot.d.ts +1 -1
- package/dist/mappers/cryptocom.d.ts +5 -5
- package/dist/mappers/cryptocom.d.ts.map +1 -1
- package/dist/mappers/huobi.d.ts +3 -3
- package/dist/mappers/index.d.ts +0 -8
- package/dist/mappers/index.d.ts.map +1 -1
- package/dist/mappers/index.js +0 -8
- package/dist/mappers/index.js.map +1 -1
- package/dist/realtimefeeds/binance.d.ts +14 -1
- package/dist/realtimefeeds/binance.d.ts.map +1 -1
- package/dist/realtimefeeds/binance.js +150 -34
- package/dist/realtimefeeds/binance.js.map +1 -1
- package/dist/realtimefeeds/index.d.ts.map +1 -1
- package/dist/realtimefeeds/index.js +0 -3
- package/dist/realtimefeeds/index.js.map +1 -1
- package/dist/realtimefeeds/realtimefeed.d.ts +1 -0
- package/dist/realtimefeeds/realtimefeed.d.ts.map +1 -1
- package/dist/realtimefeeds/realtimefeed.js +9 -3
- package/dist/realtimefeeds/realtimefeed.js.map +1 -1
- package/package.json +3 -3
- package/src/binarysplit.ts +25 -16
- package/src/consts.ts +30 -18
- package/src/mappers/cryptocom.ts +4 -4
- package/src/mappers/index.ts +0 -8
- package/src/realtimefeeds/binance.ts +226 -43
- package/src/realtimefeeds/index.ts +0 -3
- package/src/realtimefeeds/realtimefeed.ts +12 -4
- package/dist/mappers/binanceoptions.d.ts +0 -92
- package/dist/mappers/binanceoptions.d.ts.map +0 -1
- package/dist/mappers/binanceoptions.js +0 -177
- package/dist/mappers/binanceoptions.js.map +0 -1
- package/dist/realtimefeeds/binanceoptions.d.ts +0 -9
- package/dist/realtimefeeds/binanceoptions.d.ts.map +0 -1
- package/dist/realtimefeeds/binanceoptions.js +0 -34
- package/dist/realtimefeeds/binanceoptions.js.map +0 -1
- package/src/mappers/binanceoptions.ts +0 -265
- package/src/realtimefeeds/binanceoptions.ts +0 -37
|
@@ -12,6 +12,62 @@ const binanceHttpOptions = {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const DEFAULT_OPEN_INTEREST_MIN_AVAILABLE_WEIGHT_BUFFER = 100
|
|
16
|
+
const DEFAULT_OPEN_INTEREST_POLLING_INTERVAL_MS = 5 * 1000
|
|
17
|
+
const OPEN_INTEREST_BATCH_SIZE = 10
|
|
18
|
+
const OPEN_INTEREST_REQUEST_WEIGHT = 1
|
|
19
|
+
const OPEN_INTEREST_POLLING_RECOVERY_MS = 1000
|
|
20
|
+
const OPEN_INTEREST_MAX_POLLING_INTERVAL_MS = 60 * 1000
|
|
21
|
+
|
|
22
|
+
function parseBinanceWeightHeader(headerValue: string | string[] | undefined) {
|
|
23
|
+
if (headerValue === undefined) {
|
|
24
|
+
return undefined
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const header = Array.isArray(headerValue) ? headerValue[0] : headerValue
|
|
28
|
+
const parsed = Number.parseInt(header, 10)
|
|
29
|
+
|
|
30
|
+
return Number.isFinite(parsed) ? parsed : undefined
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getExchangeScopedNumberEnv(exchange: string, suffix: string, fallback: number) {
|
|
34
|
+
const envName = `${exchange.toUpperCase().replace(/-/g, '_')}_${suffix}`
|
|
35
|
+
const rawValue = process.env[envName]
|
|
36
|
+
|
|
37
|
+
if (rawValue === undefined) {
|
|
38
|
+
return fallback
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const parsed = Number.parseInt(rawValue, 10)
|
|
42
|
+
|
|
43
|
+
return Number.isFinite(parsed) ? parsed : fallback
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getBinanceRequestWeightLimit(exchange: string, exchangeInfo: any) {
|
|
47
|
+
const configuredLimit = getExchangeScopedNumberEnv(exchange, 'REQUEST_WEIGHT_LIMIT', 0)
|
|
48
|
+
if (configuredLimit > 0) {
|
|
49
|
+
return configuredLimit
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const requestWeightLimit = exchangeInfo.rateLimits.find((d: any) => d.rateLimitType === 'REQUEST_WEIGHT')?.limit as number | undefined
|
|
53
|
+
|
|
54
|
+
if (!requestWeightLimit) {
|
|
55
|
+
throw new Error('Failed to determine Binance REQUEST_WEIGHT limit')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return requestWeightLimit
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getBinanceAvailableWeight(weightLimit: number, usedWeight: number, buffer: number) {
|
|
62
|
+
return weightLimit > 0 ? weightLimit - usedWeight - buffer : Infinity
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getDelayToNextMinuteMS() {
|
|
66
|
+
const now = new Date()
|
|
67
|
+
|
|
68
|
+
return Math.max((61 - now.getUTCSeconds()) * 1000 - now.getUTCMilliseconds(), 1)
|
|
69
|
+
}
|
|
70
|
+
|
|
15
71
|
abstract class BinanceRealTimeFeedBase extends MultiConnectionRealTimeFeedBase {
|
|
16
72
|
protected abstract wssURL: string
|
|
17
73
|
protected abstract httpURL: string
|
|
@@ -38,38 +94,179 @@ abstract class BinanceRealTimeFeedBase extends MultiConnectionRealTimeFeedBase {
|
|
|
38
94
|
if (openInterestFilters.length > 0) {
|
|
39
95
|
const instruments = openInterestFilters.flatMap((s) => s.symbols!)
|
|
40
96
|
|
|
41
|
-
yield new BinanceFuturesOpenInterestClient(exchange, this.httpURL, instruments)
|
|
97
|
+
yield new BinanceFuturesOpenInterestClient(exchange, this.httpURL, instruments, onError)
|
|
42
98
|
}
|
|
43
99
|
}
|
|
44
100
|
}
|
|
45
101
|
|
|
46
102
|
class BinanceFuturesOpenInterestClient extends PoolingClientBase {
|
|
47
|
-
|
|
48
|
-
|
|
103
|
+
private readonly _minPollingIntervalMS: number
|
|
104
|
+
private readonly _minAvailableWeightBuffer: number
|
|
105
|
+
private readonly _maxPollingIntervalMS: number
|
|
106
|
+
private _currentPollingIntervalMS: number
|
|
107
|
+
private _requestWeightLimit: number
|
|
108
|
+
private _usedWeight = 0
|
|
109
|
+
|
|
110
|
+
constructor(
|
|
111
|
+
private readonly _exchange: string,
|
|
112
|
+
private readonly _httpURL: string,
|
|
113
|
+
private readonly _instruments: string[],
|
|
114
|
+
onError?: (error: Error) => void
|
|
115
|
+
) {
|
|
116
|
+
const minPollingIntervalMS = Math.max(
|
|
117
|
+
getExchangeScopedNumberEnv(_exchange, 'OPEN_INTEREST_POLLING_INTERVAL_MS', DEFAULT_OPEN_INTEREST_POLLING_INTERVAL_MS),
|
|
118
|
+
1000
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
super(_exchange, minPollingIntervalMS / 1000, onError)
|
|
122
|
+
|
|
123
|
+
this._minPollingIntervalMS = minPollingIntervalMS
|
|
124
|
+
this._maxPollingIntervalMS = Math.max(this._minPollingIntervalMS, OPEN_INTEREST_MAX_POLLING_INTERVAL_MS)
|
|
125
|
+
this._currentPollingIntervalMS = minPollingIntervalMS
|
|
126
|
+
this._requestWeightLimit = getExchangeScopedNumberEnv(_exchange, 'REQUEST_WEIGHT_LIMIT', 0)
|
|
127
|
+
this._minAvailableWeightBuffer = getExchangeScopedNumberEnv(
|
|
128
|
+
_exchange,
|
|
129
|
+
'MIN_AVAILABLE_WEIGHT_BUFFER',
|
|
130
|
+
DEFAULT_OPEN_INTEREST_MIN_AVAILABLE_WEIGHT_BUFFER
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
protected getPoolingDelayMS() {
|
|
135
|
+
return this._currentPollingIntervalMS
|
|
49
136
|
}
|
|
50
137
|
|
|
51
138
|
protected async poolDataToStream(outputStream: Writable) {
|
|
52
|
-
|
|
53
|
-
await Promise.allSettled(
|
|
54
|
-
instruments.map(async (instrument) => {
|
|
55
|
-
if (outputStream.destroyed) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
const openInterestResponse = (await httpClient
|
|
59
|
-
.get(`${this._httpURL}/openInterest?symbol=${instrument.toUpperCase()}`, binanceHttpOptions)
|
|
60
|
-
.json()) as any
|
|
139
|
+
let waitedForRateLimit = false
|
|
61
140
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
141
|
+
if (!this._requestWeightLimit) {
|
|
142
|
+
await this._initializeRateLimitInfo()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
for (let index = 0; index < this._instruments.length; ) {
|
|
146
|
+
if (outputStream.destroyed) {
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
waitedForRateLimit = (await this._waitForAvailableWeight()) || waitedForRateLimit
|
|
151
|
+
const batchSize = this._getBatchSize()
|
|
152
|
+
|
|
153
|
+
if (batchSize <= 0) {
|
|
154
|
+
break
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const instrumentsBatch = this._instruments.slice(index, index + batchSize)
|
|
158
|
+
index += instrumentsBatch.length
|
|
159
|
+
|
|
160
|
+
const results = await Promise.allSettled(
|
|
161
|
+
instrumentsBatch.map(async (instrument) => {
|
|
162
|
+
const openInterestResponse = await httpClient.get(
|
|
163
|
+
`${this._httpURL}/openInterest?symbol=${instrument.toUpperCase()}`,
|
|
164
|
+
binanceHttpOptions
|
|
165
|
+
)
|
|
67
166
|
|
|
68
|
-
|
|
69
|
-
|
|
167
|
+
return {
|
|
168
|
+
instrument,
|
|
169
|
+
usedWeight: parseBinanceWeightHeader(openInterestResponse.headers['x-mbx-used-weight-1m'] as string | string[] | undefined),
|
|
170
|
+
data: JSON.parse(openInterestResponse.body)
|
|
70
171
|
}
|
|
71
172
|
})
|
|
72
173
|
)
|
|
174
|
+
|
|
175
|
+
let maxUsedWeight: number | undefined
|
|
176
|
+
let fulfilledCount = 0
|
|
177
|
+
|
|
178
|
+
for (const result of results) {
|
|
179
|
+
if (result.status === 'rejected') {
|
|
180
|
+
this._notifyError(result.reason)
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
fulfilledCount++
|
|
185
|
+
maxUsedWeight = Math.max(maxUsedWeight ?? 0, result.value.usedWeight ?? 0)
|
|
186
|
+
|
|
187
|
+
if (outputStream.writable) {
|
|
188
|
+
outputStream.write({
|
|
189
|
+
stream: `${result.value.instrument.toLowerCase()}@openInterest`,
|
|
190
|
+
generated: true,
|
|
191
|
+
data: result.value.data
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
this._updateUsedWeight(maxUsedWeight || undefined, fulfilledCount * OPEN_INTEREST_REQUEST_WEIGHT)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (waitedForRateLimit) {
|
|
200
|
+
this._currentPollingIntervalMS = Math.min(this._currentPollingIntervalMS + this._minPollingIntervalMS, this._maxPollingIntervalMS)
|
|
201
|
+
} else {
|
|
202
|
+
this._currentPollingIntervalMS = Math.max(
|
|
203
|
+
this._minPollingIntervalMS,
|
|
204
|
+
this._currentPollingIntervalMS - OPEN_INTEREST_POLLING_RECOVERY_MS
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private async _waitForAvailableWeight() {
|
|
210
|
+
const available = getBinanceAvailableWeight(this._requestWeightLimit, this._usedWeight, this._minAvailableWeightBuffer)
|
|
211
|
+
|
|
212
|
+
if (available >= OPEN_INTEREST_REQUEST_WEIGHT) {
|
|
213
|
+
return false
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const delayMS = getDelayToNextMinuteMS()
|
|
217
|
+
this.debug(
|
|
218
|
+
'open interest reached rate limit (limit: %s, used: %s, minimum available buffer: %s), waiting %s ms',
|
|
219
|
+
this._requestWeightLimit,
|
|
220
|
+
this._usedWeight,
|
|
221
|
+
this._minAvailableWeightBuffer,
|
|
222
|
+
delayMS
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
await wait(delayMS)
|
|
226
|
+
|
|
227
|
+
// Binance request weight is tracked in a rolling 1-minute window. After waiting for the next minute
|
|
228
|
+
// we can resume and let the next REST response header refresh the exact current usage.
|
|
229
|
+
this._usedWeight = 0
|
|
230
|
+
|
|
231
|
+
return true
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private async _initializeRateLimitInfo() {
|
|
235
|
+
const exchangeInfoResponse = await httpClient.get(`${this._httpURL}/exchangeInfo`, binanceHttpOptions)
|
|
236
|
+
const exchangeInfo = JSON.parse(exchangeInfoResponse.body)
|
|
237
|
+
|
|
238
|
+
this._requestWeightLimit = getBinanceRequestWeightLimit(this._exchange, exchangeInfo)
|
|
239
|
+
|
|
240
|
+
this._updateUsedWeight(
|
|
241
|
+
parseBinanceWeightHeader(exchangeInfoResponse.headers['x-mbx-used-weight-1m'] as string | string[] | undefined),
|
|
242
|
+
OPEN_INTEREST_REQUEST_WEIGHT
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private _getBatchSize() {
|
|
247
|
+
const available = getBinanceAvailableWeight(this._requestWeightLimit, this._usedWeight, this._minAvailableWeightBuffer)
|
|
248
|
+
|
|
249
|
+
return Math.min(OPEN_INTEREST_BATCH_SIZE, Math.max(0, Math.floor(available)))
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private _notifyError(error: unknown) {
|
|
253
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error))
|
|
254
|
+
|
|
255
|
+
this.debug('open interest request error %o', normalizedError)
|
|
256
|
+
|
|
257
|
+
if (this.onError !== undefined) {
|
|
258
|
+
this.onError(normalizedError)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private _updateUsedWeight(usedWeight: number | undefined, fallbackIncrement = OPEN_INTEREST_REQUEST_WEIGHT) {
|
|
263
|
+
if (usedWeight !== undefined) {
|
|
264
|
+
this._usedWeight = usedWeight
|
|
265
|
+
return
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (this._requestWeightLimit > 0 && fallbackIncrement > 0) {
|
|
269
|
+
this._usedWeight += fallbackIncrement
|
|
73
270
|
}
|
|
74
271
|
}
|
|
75
272
|
}
|
|
@@ -133,23 +330,11 @@ class BinanceSingleConnectionRealTimeFeed extends RealTimeFeedBase {
|
|
|
133
330
|
return
|
|
134
331
|
}
|
|
135
332
|
|
|
136
|
-
let currentWeightLimit: number = 0
|
|
137
|
-
|
|
138
333
|
const exchangeInfoResponse = await httpClient.get(`${this._httpURL}/exchangeInfo`, binanceHttpOptions)
|
|
139
|
-
|
|
140
334
|
const exchangeInfo = JSON.parse(exchangeInfoResponse.body)
|
|
141
335
|
|
|
142
|
-
const REQUEST_WEIGHT_LIMIT_ENV = `${this._exchange.toUpperCase().replace(/-/g, '_')}_REQUEST_WEIGHT_LIMIT`
|
|
143
|
-
|
|
144
336
|
const DELAY_ENV = `${this._exchange.toUpperCase().replace(/-/g, '_')}_SNAPSHOTS_DELAY_MS`
|
|
145
|
-
|
|
146
|
-
if (process.env[REQUEST_WEIGHT_LIMIT_ENV] !== undefined) {
|
|
147
|
-
currentWeightLimit = Number.parseInt(process.env[REQUEST_WEIGHT_LIMIT_ENV] as string)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (!currentWeightLimit) {
|
|
151
|
-
currentWeightLimit = exchangeInfo.rateLimits.find((d: any) => d.rateLimitType === 'REQUEST_WEIGHT').limit as number
|
|
152
|
-
}
|
|
337
|
+
const currentWeightLimit = getBinanceRequestWeightLimit(this._exchange, exchangeInfo)
|
|
153
338
|
|
|
154
339
|
let usedWeight = Number.parseInt(exchangeInfoResponse.headers['x-mbx-used-weight-1m'] as string)
|
|
155
340
|
|
|
@@ -165,13 +350,11 @@ class BinanceSingleConnectionRealTimeFeed extends RealTimeFeedBase {
|
|
|
165
350
|
|
|
166
351
|
this.debug('current snapshots requests concurrency limit: %s', concurrencyLimit)
|
|
167
352
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
minWeightBuffer = Number.parseInt(process.env[MIN_WEIGHT_BUFFER_ENV] as string)
|
|
174
|
-
}
|
|
353
|
+
const minWeightBuffer = getExchangeScopedNumberEnv(
|
|
354
|
+
this._exchange,
|
|
355
|
+
'MIN_AVAILABLE_WEIGHT_BUFFER',
|
|
356
|
+
2 * concurrencyLimit * this._depthRequestRequestWeight
|
|
357
|
+
)
|
|
175
358
|
|
|
176
359
|
for (const symbolsBatch of batch(depthSnapshotFilter.symbols!, concurrencyLimit)) {
|
|
177
360
|
if (shouldCancel()) {
|
|
@@ -186,19 +369,19 @@ class BinanceSingleConnectionRealTimeFeed extends RealTimeFeedBase {
|
|
|
186
369
|
return 0
|
|
187
370
|
}
|
|
188
371
|
|
|
189
|
-
const isOverRateLimit = currentWeightLimit
|
|
372
|
+
const isOverRateLimit = getBinanceAvailableWeight(currentWeightLimit, usedWeight, minWeightBuffer) < 0
|
|
190
373
|
|
|
191
374
|
if (isOverRateLimit) {
|
|
192
|
-
const
|
|
375
|
+
const delayMS = getDelayToNextMinuteMS()
|
|
193
376
|
this.debug(
|
|
194
377
|
'reached rate limit (x-mbx-used-weight-1m limit: %s, used weight: %s, minimum available weight buffer: %s), waiting: %s seconds',
|
|
195
378
|
currentWeightLimit,
|
|
196
379
|
usedWeight,
|
|
197
380
|
minWeightBuffer,
|
|
198
|
-
|
|
381
|
+
Math.ceil(delayMS / 1000)
|
|
199
382
|
)
|
|
200
383
|
|
|
201
|
-
await wait(
|
|
384
|
+
await wait(delayMS)
|
|
202
385
|
}
|
|
203
386
|
|
|
204
387
|
const depthSnapshotResponse = await httpClient.get(
|
|
@@ -34,7 +34,6 @@ import { GateIORealTimeFeed } from './gateio'
|
|
|
34
34
|
import { GateIOFuturesRealTimeFeed } from './gateiofutures'
|
|
35
35
|
import { PoloniexRealTimeFeed } from './poloniex'
|
|
36
36
|
import { CoinflexRealTimeFeed } from './coinflex'
|
|
37
|
-
import { BinanceOptionsRealTimeFeed } from './binanceoptions'
|
|
38
37
|
import { UpbitRealTimeFeed } from './upbit'
|
|
39
38
|
import { AscendexRealTimeFeed } from './ascendex'
|
|
40
39
|
import { DydxRealTimeFeed } from './dydx'
|
|
@@ -94,7 +93,6 @@ const realTimeFeedsMap: {
|
|
|
94
93
|
'gate-io-futures': GateIOFuturesRealTimeFeed,
|
|
95
94
|
poloniex: PoloniexRealTimeFeed,
|
|
96
95
|
coinflex: CoinflexRealTimeFeed,
|
|
97
|
-
'binance-options': BinanceOptionsRealTimeFeed,
|
|
98
96
|
upbit: UpbitRealTimeFeed,
|
|
99
97
|
ascendex: AscendexRealTimeFeed,
|
|
100
98
|
dydx: DydxRealTimeFeed,
|
|
@@ -105,7 +103,6 @@ const realTimeFeedsMap: {
|
|
|
105
103
|
'bybit-spot': BybitSpotRealTimeDataFeed,
|
|
106
104
|
'bybit-options': BybitOptionsRealTimeDataFeed,
|
|
107
105
|
'crypto-com': CryptoComRealTimeFeed,
|
|
108
|
-
'crypto-com-derivatives': CryptoComRealTimeFeed,
|
|
109
106
|
kucoin: KucoinRealTimeFeed,
|
|
110
107
|
bitnomial: BitnomialRealTimeFeed,
|
|
111
108
|
'woo-x': WooxRealTimeFeed,
|
|
@@ -382,21 +382,29 @@ export abstract class PoolingClientBase implements RealTimeFeedIterable {
|
|
|
382
382
|
|
|
383
383
|
protected abstract poolDataToStream(outputStream: Writable): Promise<void>
|
|
384
384
|
|
|
385
|
-
|
|
386
|
-
|
|
385
|
+
protected getPoolingDelayMS() {
|
|
386
|
+
return this._poolingIntervalSeconds * ONE_SEC_IN_MS
|
|
387
|
+
}
|
|
387
388
|
|
|
389
|
+
private async _startPooling(outputStream: Writable) {
|
|
388
390
|
const pool = async () => {
|
|
389
391
|
try {
|
|
390
392
|
await this.poolDataToStream(outputStream)
|
|
391
393
|
} catch (e) {
|
|
392
|
-
|
|
394
|
+
const error = e instanceof Error ? e : new Error(String(e))
|
|
395
|
+
|
|
396
|
+
this.debug('pooling error %o', error)
|
|
397
|
+
|
|
398
|
+
if (this.onError !== undefined) {
|
|
399
|
+
this.onError(error)
|
|
400
|
+
}
|
|
393
401
|
}
|
|
394
402
|
}
|
|
395
403
|
|
|
396
404
|
const poolAndSchedule = () => {
|
|
397
405
|
pool().then(() => {
|
|
398
406
|
if (!outputStream.destroyed) {
|
|
399
|
-
this._tid = setTimeout(poolAndSchedule,
|
|
407
|
+
this._tid = setTimeout(poolAndSchedule, this.getPoolingDelayMS())
|
|
400
408
|
}
|
|
401
409
|
})
|
|
402
410
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { BookChange, OptionSummary, Trade } from '../types';
|
|
2
|
-
import { Mapper } from './mapper';
|
|
3
|
-
export declare class BinanceOptionsTradesMapper implements Mapper<'binance-options', Trade> {
|
|
4
|
-
private readonly _lastTradeId;
|
|
5
|
-
canHandle(message: BinanceResponse<any>): boolean;
|
|
6
|
-
getFilters(symbols?: string[]): {
|
|
7
|
-
readonly channel: "TRADE";
|
|
8
|
-
readonly symbols: string[] | undefined;
|
|
9
|
-
}[];
|
|
10
|
-
map(binanceTradeResponse: BinanceResponse<BinanceOptionsTradeData>, localTimestamp: Date): Generator<Trade, void, unknown>;
|
|
11
|
-
}
|
|
12
|
-
export declare class BinanceOptionsBookChangeMapper implements Mapper<'binance-options', BookChange> {
|
|
13
|
-
canHandle(message: BinanceResponse<any>): boolean;
|
|
14
|
-
getFilters(symbols?: string[]): {
|
|
15
|
-
readonly channel: "DEPTH100";
|
|
16
|
-
readonly symbols: string[] | undefined;
|
|
17
|
-
}[];
|
|
18
|
-
map(message: BinanceResponse<BinanceOptionsDepthData>, localTimestamp: Date): Generator<BookChange, void, unknown>;
|
|
19
|
-
protected mapBookLevel(level: BinanceBookLevel): {
|
|
20
|
-
price: number;
|
|
21
|
-
amount: number;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export declare class BinanceOptionSummaryMapper implements Mapper<'binance-options', OptionSummary> {
|
|
25
|
-
private readonly _indexPrices;
|
|
26
|
-
canHandle(message: BinanceResponse<any>): boolean;
|
|
27
|
-
getFilters(symbols?: string[]): ({
|
|
28
|
-
readonly channel: "TICKER";
|
|
29
|
-
readonly symbols: string[] | undefined;
|
|
30
|
-
} | {
|
|
31
|
-
readonly channel: "INDEX";
|
|
32
|
-
readonly symbols: string[] | undefined;
|
|
33
|
-
})[];
|
|
34
|
-
map(message: BinanceResponse<BinanceOptionsTickerData | BinanceOptionsIndexData>, localTimestamp: Date): Generator<OptionSummary, void, unknown>;
|
|
35
|
-
}
|
|
36
|
-
type BinanceResponse<T> = {
|
|
37
|
-
stream: string;
|
|
38
|
-
data: T;
|
|
39
|
-
};
|
|
40
|
-
type BinanceOptionsTradeData = {
|
|
41
|
-
e: 'trade';
|
|
42
|
-
E: number;
|
|
43
|
-
s: string;
|
|
44
|
-
t: {
|
|
45
|
-
t: string;
|
|
46
|
-
p: string;
|
|
47
|
-
q: string;
|
|
48
|
-
T: number;
|
|
49
|
-
s: '-1' | '1';
|
|
50
|
-
}[];
|
|
51
|
-
};
|
|
52
|
-
type BinanceOptionsDepthData = {
|
|
53
|
-
e: 'depth';
|
|
54
|
-
E: number;
|
|
55
|
-
s: string;
|
|
56
|
-
b: BinanceBookLevel[];
|
|
57
|
-
a: BinanceBookLevel[];
|
|
58
|
-
};
|
|
59
|
-
type BinanceOptionsTickerData = {
|
|
60
|
-
e: 'ticker';
|
|
61
|
-
E: 1591677962357;
|
|
62
|
-
s: 'BTC-200630-9000-P';
|
|
63
|
-
o: '1000';
|
|
64
|
-
h: '1000';
|
|
65
|
-
l: '1000';
|
|
66
|
-
c: '1000';
|
|
67
|
-
V: '2';
|
|
68
|
-
A: '0';
|
|
69
|
-
p: '0';
|
|
70
|
-
Q: '2000';
|
|
71
|
-
F: 1;
|
|
72
|
-
L: 1;
|
|
73
|
-
n: 1;
|
|
74
|
-
b: '0';
|
|
75
|
-
a: '0';
|
|
76
|
-
d: '0';
|
|
77
|
-
t: '0';
|
|
78
|
-
g: '0';
|
|
79
|
-
v: '0';
|
|
80
|
-
bo: '3.1';
|
|
81
|
-
ao: '90.36';
|
|
82
|
-
mp: '6.96';
|
|
83
|
-
};
|
|
84
|
-
type BinanceOptionsIndexData = {
|
|
85
|
-
e: 'index';
|
|
86
|
-
E: 1614556800182;
|
|
87
|
-
s: 'BTCUSDT';
|
|
88
|
-
p: '45160.127864';
|
|
89
|
-
};
|
|
90
|
-
type BinanceBookLevel = [string, string];
|
|
91
|
-
export {};
|
|
92
|
-
//# sourceMappingURL=binanceoptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binanceoptions.d.ts","sourceRoot":"","sources":["../../src/mappers/binanceoptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAIjC,qBAAa,0BAA2B,YAAW,MAAM,CAAC,iBAAiB,EAAE,KAAK,CAAC;IACjF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;IACzD,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC;IAQvC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE;;;;IAW5B,GAAG,CAAC,oBAAoB,EAAE,eAAe,CAAC,uBAAuB,CAAC,EAAE,cAAc,EAAE,IAAI;CAiC1F;AAED,qBAAa,8BAA+B,YAAW,MAAM,CAAC,iBAAiB,EAAE,UAAU,CAAC;IAC1F,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC;IAQvC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE;;;;IAW5B,GAAG,CAA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;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,GAAG,CAAA;IACN,CAAC,EAAE,GAAG,CAAA;IACN,CAAC,EAAE,GAAG,CAAA;IACN,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,CAAA;IACJ,CAAC,EAAE,GAAG,CAAA;IACN,CAAC,EAAE,GAAG,CAAA;IACN,CAAC,EAAE,GAAG,CAAA;IACN,CAAC,EAAE,GAAG,CAAA;IACN,CAAC,EAAE,GAAG,CAAA;IACN,CAAC,EAAE,GAAG,CAAA;IACN,EAAE,EAAE,KAAK,CAAA;IACT,EAAE,EAAE,OAAO,CAAA;IACX,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,KAAK,uBAAuB,GAAG;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,EAAE,aAAa,CAAC;IAAC,CAAC,EAAE,SAAS,CAAC;IAAC,CAAC,EAAE,cAAc,CAAA;CAAE,CAAA;AAEhG,KAAK,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BinanceOptionSummaryMapper = exports.BinanceOptionsBookChangeMapper = exports.BinanceOptionsTradesMapper = void 0;
|
|
4
|
-
const handy_1 = require("../handy");
|
|
5
|
-
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md
|
|
6
|
-
class BinanceOptionsTradesMapper {
|
|
7
|
-
_lastTradeId = new Map();
|
|
8
|
-
canHandle(message) {
|
|
9
|
-
if (message.stream === undefined) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return message.stream.endsWith('@TRADE');
|
|
13
|
-
}
|
|
14
|
-
getFilters(symbols) {
|
|
15
|
-
symbols = (0, handy_1.upperCaseSymbols)(symbols);
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
channel: 'TRADE',
|
|
19
|
-
symbols
|
|
20
|
-
}
|
|
21
|
-
];
|
|
22
|
-
}
|
|
23
|
-
*map(binanceTradeResponse, localTimestamp) {
|
|
24
|
-
const symbol = binanceTradeResponse.data.s;
|
|
25
|
-
for (const optionsTrade of binanceTradeResponse.data.t) {
|
|
26
|
-
// binance options does not only return real-time trade as it happens but just snapshot of last 'x' trades always
|
|
27
|
-
// so we need to decide which are real-time trades and which are stale/already processed
|
|
28
|
-
const timestamp = new Date(optionsTrade.T);
|
|
29
|
-
const tradeIdNumeric = Number(optionsTrade.t);
|
|
30
|
-
const lastProcessedTradeId = this._lastTradeId.get(symbol);
|
|
31
|
-
const isAlreadyProcessed = lastProcessedTradeId !== undefined && lastProcessedTradeId >= tradeIdNumeric;
|
|
32
|
-
const isStaleTrade = localTimestamp.valueOf() - timestamp.valueOf() > 10000;
|
|
33
|
-
if (isAlreadyProcessed || isStaleTrade) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
this._lastTradeId.set(symbol, Number(optionsTrade.t));
|
|
37
|
-
const trade = {
|
|
38
|
-
type: 'trade',
|
|
39
|
-
symbol,
|
|
40
|
-
exchange: 'binance-options',
|
|
41
|
-
id: optionsTrade.t,
|
|
42
|
-
price: Number(optionsTrade.p),
|
|
43
|
-
amount: Number(optionsTrade.q),
|
|
44
|
-
side: optionsTrade.s === '-1' ? 'sell' : 'buy',
|
|
45
|
-
timestamp,
|
|
46
|
-
localTimestamp: localTimestamp
|
|
47
|
-
};
|
|
48
|
-
yield trade;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.BinanceOptionsTradesMapper = BinanceOptionsTradesMapper;
|
|
53
|
-
class BinanceOptionsBookChangeMapper {
|
|
54
|
-
canHandle(message) {
|
|
55
|
-
if (message.stream === undefined) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
return message.stream.endsWith('@DEPTH100');
|
|
59
|
-
}
|
|
60
|
-
getFilters(symbols) {
|
|
61
|
-
symbols = (0, handy_1.upperCaseSymbols)(symbols);
|
|
62
|
-
return [
|
|
63
|
-
{
|
|
64
|
-
channel: 'DEPTH100',
|
|
65
|
-
symbols
|
|
66
|
-
}
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
*map(message, localTimestamp) {
|
|
70
|
-
const bookChange = {
|
|
71
|
-
type: 'book_change',
|
|
72
|
-
symbol: message.data.s,
|
|
73
|
-
exchange: 'binance-options',
|
|
74
|
-
isSnapshot: true,
|
|
75
|
-
bids: message.data.b.map(this.mapBookLevel),
|
|
76
|
-
asks: message.data.a.map(this.mapBookLevel),
|
|
77
|
-
timestamp: new Date(message.data.E),
|
|
78
|
-
localTimestamp
|
|
79
|
-
};
|
|
80
|
-
yield bookChange;
|
|
81
|
-
}
|
|
82
|
-
mapBookLevel(level) {
|
|
83
|
-
const price = Number(level[0]);
|
|
84
|
-
const amount = Number(level[1]);
|
|
85
|
-
return { price, amount };
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.BinanceOptionsBookChangeMapper = BinanceOptionsBookChangeMapper;
|
|
89
|
-
class BinanceOptionSummaryMapper {
|
|
90
|
-
_indexPrices = new Map();
|
|
91
|
-
canHandle(message) {
|
|
92
|
-
if (message.stream === undefined) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
return message.stream.endsWith('@TICKER') || message.stream.endsWith('@INDEX');
|
|
96
|
-
}
|
|
97
|
-
getFilters(symbols) {
|
|
98
|
-
symbols = (0, handy_1.upperCaseSymbols)(symbols);
|
|
99
|
-
const indexes = symbols !== undefined
|
|
100
|
-
? symbols.map((s) => {
|
|
101
|
-
const symbolParts = s.split('-');
|
|
102
|
-
return `${symbolParts[0]}USDT`;
|
|
103
|
-
})
|
|
104
|
-
: undefined;
|
|
105
|
-
return [
|
|
106
|
-
{
|
|
107
|
-
channel: 'TICKER',
|
|
108
|
-
symbols
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
channel: 'INDEX',
|
|
112
|
-
symbols: indexes
|
|
113
|
-
}
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
*map(message, localTimestamp) {
|
|
117
|
-
if (message.stream.endsWith('@INDEX')) {
|
|
118
|
-
const lastIndexPrice = Number(message.data.p);
|
|
119
|
-
if (lastIndexPrice > 0) {
|
|
120
|
-
this._indexPrices.set(message.data.s, lastIndexPrice);
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const optionInfo = message.data;
|
|
125
|
-
const [base, expiryPart, strikePrice, optionType] = optionInfo.s.split('-');
|
|
126
|
-
const expirationDate = new Date(`20${expiryPart.slice(0, 2)}-${expiryPart.slice(2, 4)}-${expiryPart.slice(4, 6)}Z`);
|
|
127
|
-
expirationDate.setUTCHours(8);
|
|
128
|
-
const isPut = optionType === 'P';
|
|
129
|
-
const underlyingIndex = `${base}USDT`;
|
|
130
|
-
let bestBidPrice = (0, handy_1.asNumberIfValid)(optionInfo.bo);
|
|
131
|
-
if (bestBidPrice === 0) {
|
|
132
|
-
bestBidPrice = undefined;
|
|
133
|
-
}
|
|
134
|
-
let bestAskPrice = (0, handy_1.asNumberIfValid)(optionInfo.ao);
|
|
135
|
-
if (bestAskPrice === 0) {
|
|
136
|
-
bestAskPrice = undefined;
|
|
137
|
-
}
|
|
138
|
-
let bestBidIV = bestBidPrice !== undefined ? (0, handy_1.asNumberIfValid)(optionInfo.b) : undefined;
|
|
139
|
-
if (bestBidIV === -1) {
|
|
140
|
-
bestBidIV = undefined;
|
|
141
|
-
}
|
|
142
|
-
let bestAskIV = bestAskPrice !== undefined ? (0, handy_1.asNumberIfValid)(optionInfo.a) : undefined;
|
|
143
|
-
if (bestAskIV === -1) {
|
|
144
|
-
bestAskIV = undefined;
|
|
145
|
-
}
|
|
146
|
-
const optionSummary = {
|
|
147
|
-
type: 'option_summary',
|
|
148
|
-
symbol: optionInfo.s,
|
|
149
|
-
exchange: 'binance-options',
|
|
150
|
-
optionType: isPut ? 'put' : 'call',
|
|
151
|
-
strikePrice: Number(strikePrice),
|
|
152
|
-
expirationDate,
|
|
153
|
-
bestBidPrice,
|
|
154
|
-
bestBidAmount: undefined,
|
|
155
|
-
bestBidIV,
|
|
156
|
-
bestAskPrice,
|
|
157
|
-
bestAskAmount: undefined,
|
|
158
|
-
bestAskIV,
|
|
159
|
-
lastPrice: (0, handy_1.asNumberIfValid)(optionInfo.c),
|
|
160
|
-
openInterest: undefined,
|
|
161
|
-
markPrice: (0, handy_1.asNumberIfValid)(optionInfo.mp),
|
|
162
|
-
markIV: undefined,
|
|
163
|
-
delta: (0, handy_1.asNumberIfValid)(optionInfo.d),
|
|
164
|
-
gamma: (0, handy_1.asNumberIfValid)(optionInfo.g),
|
|
165
|
-
vega: (0, handy_1.asNumberIfValid)(optionInfo.v),
|
|
166
|
-
theta: (0, handy_1.asNumberIfValid)(optionInfo.t),
|
|
167
|
-
rho: undefined,
|
|
168
|
-
underlyingPrice: this._indexPrices.get(underlyingIndex),
|
|
169
|
-
underlyingIndex,
|
|
170
|
-
timestamp: new Date(optionInfo.E),
|
|
171
|
-
localTimestamp: localTimestamp
|
|
172
|
-
};
|
|
173
|
-
yield optionSummary;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.BinanceOptionSummaryMapper = BinanceOptionSummaryMapper;
|
|
177
|
-
//# sourceMappingURL=binanceoptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binanceoptions.js","sourceRoot":"","sources":["../../src/mappers/binanceoptions.ts"],"names":[],"mappings":";;;AAAA,oCAA4D;AAI5D,kGAAkG;AAElG,MAAa,0BAA0B;IACpB,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAA;IACzD,SAAS,CAAC,OAA6B;Q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AM,aAAa,CAAA;IACrB,CAAC;CACF;AA9GD,gEA8GC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Filter } from '../types';
|
|
2
|
-
import { RealTimeFeedBase } from './realtimefeed';
|
|
3
|
-
export declare class BinanceOptionsRealTimeFeed extends RealTimeFeedBase {
|
|
4
|
-
protected wssURL: string;
|
|
5
|
-
protected httpURL: string;
|
|
6
|
-
protected mapToSubscribeMessages(filters: Filter<string>[]): any[];
|
|
7
|
-
protected messageIsError(message: any): boolean;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=binanceoptions.d.ts.map
|