tardis-dev 14.1.5 → 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 +46 -17
- package/dist/consts.js.map +1 -1
- package/dist/mappers/binanceeuropeanoptions.d.ts +108 -1
- package/dist/mappers/binanceeuropeanoptions.d.ts.map +1 -1
- package/dist/mappers/binanceeuropeanoptions.js +231 -1
- package/dist/mappers/binanceeuropeanoptions.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 +5 -12
- package/dist/mappers/index.d.ts.map +1 -1
- package/dist/mappers/index.js +15 -12
- 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/binanceeuropeanoptions.d.ts +8 -2
- package/dist/realtimefeeds/binanceeuropeanoptions.d.ts.map +1 -1
- package/dist/realtimefeeds/binanceeuropeanoptions.js +62 -14
- package/dist/realtimefeeds/binanceeuropeanoptions.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 +46 -19
- package/src/mappers/binanceeuropeanoptions.ts +351 -2
- package/src/mappers/cryptocom.ts +4 -4
- package/src/mappers/index.ts +25 -13
- package/src/realtimefeeds/binance.ts +226 -43
- package/src/realtimefeeds/binanceeuropeanoptions.ts +88 -13
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { asNumberIfValid, upperCaseSymbols } from '../handy'
|
|
2
|
-
import { BookChange, OptionSummary, Trade } from '../types'
|
|
1
|
+
import { asNumberIfValid, lowerCaseSymbols, upperCaseSymbols } from '../handy'
|
|
2
|
+
import { BookChange, BookTicker, OptionSummary, Trade } from '../types'
|
|
3
3
|
import { Mapper } from './mapper'
|
|
4
4
|
|
|
5
5
|
// https://binance-docs.github.io/apidocs/voptions/en/#websocket-market-streams
|
|
@@ -41,6 +41,43 @@ export class BinanceEuropeanOptionsTradesMapper implements Mapper<'binance-europ
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export class BinanceEuropeanOptionsTradesMapperV2 implements Mapper<'binance-european-options', Trade> {
|
|
45
|
+
canHandle(message: BinanceResponse<any>) {
|
|
46
|
+
if (message.stream === undefined) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return message.stream.endsWith('@optionTrade')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getFilters(symbols?: string[]) {
|
|
54
|
+
symbols = lowerCaseSymbols(symbols)
|
|
55
|
+
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
channel: 'optionTrade',
|
|
59
|
+
symbols
|
|
60
|
+
} as const
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
*map(binanceTradeResponse: BinanceResponse<BinanceOptionsTradeDataV2>, localTimestamp: Date) {
|
|
65
|
+
const trade: Trade = {
|
|
66
|
+
type: 'trade',
|
|
67
|
+
symbol: binanceTradeResponse.data.s,
|
|
68
|
+
exchange: 'binance-european-options',
|
|
69
|
+
id: String(binanceTradeResponse.data.t),
|
|
70
|
+
price: Number(binanceTradeResponse.data.p),
|
|
71
|
+
amount: Number(binanceTradeResponse.data.q),
|
|
72
|
+
side: binanceTradeResponse.data.m ? 'sell' : 'buy',
|
|
73
|
+
timestamp: new Date(binanceTradeResponse.data.T),
|
|
74
|
+
localTimestamp: localTimestamp
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
yield trade
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
44
81
|
export class BinanceEuropeanOptionsBookChangeMapper implements Mapper<'binance-european-options', BookChange> {
|
|
45
82
|
canHandle(message: BinanceResponse<any>) {
|
|
46
83
|
if (message.stream === undefined) {
|
|
@@ -83,6 +120,90 @@ export class BinanceEuropeanOptionsBookChangeMapper implements Mapper<'binance-e
|
|
|
83
120
|
}
|
|
84
121
|
}
|
|
85
122
|
|
|
123
|
+
export class BinanceEuropeanOptionsBookChangeMapperV2 implements Mapper<'binance-european-options', BookChange> {
|
|
124
|
+
canHandle(message: BinanceResponse<any>) {
|
|
125
|
+
if (message.stream === undefined) {
|
|
126
|
+
return false
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return message.stream.includes('@depth20')
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
getFilters(symbols?: string[]) {
|
|
133
|
+
symbols = lowerCaseSymbols(symbols)
|
|
134
|
+
|
|
135
|
+
return [
|
|
136
|
+
{
|
|
137
|
+
channel: 'depth20',
|
|
138
|
+
symbols
|
|
139
|
+
} as const
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
*map(message: BinanceResponse<BinanceOptionsDepthDataV2>, localTimestamp: Date) {
|
|
144
|
+
const bookChange: BookChange = {
|
|
145
|
+
type: 'book_change',
|
|
146
|
+
symbol: message.data.s,
|
|
147
|
+
exchange: 'binance-european-options',
|
|
148
|
+
isSnapshot: true,
|
|
149
|
+
bids: message.data.b.map(this.mapBookLevel),
|
|
150
|
+
asks: message.data.a.map(this.mapBookLevel),
|
|
151
|
+
timestamp: new Date(message.data.T),
|
|
152
|
+
localTimestamp
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
yield bookChange
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
protected mapBookLevel(level: BinanceBookLevel) {
|
|
159
|
+
const price = Number(level[0])
|
|
160
|
+
const amount = Number(level[1])
|
|
161
|
+
return { price, amount }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export class BinanceEuropeanOptionsBookTickerMapper implements Mapper<'binance-european-options', BookTicker> {
|
|
166
|
+
canHandle(message: BinanceResponse<any>) {
|
|
167
|
+
if (message.stream === undefined) {
|
|
168
|
+
return false
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return message.stream.endsWith('@bookTicker')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
getFilters(symbols?: string[]) {
|
|
175
|
+
symbols = lowerCaseSymbols(symbols)
|
|
176
|
+
|
|
177
|
+
return [
|
|
178
|
+
{
|
|
179
|
+
channel: 'bookTicker',
|
|
180
|
+
symbols
|
|
181
|
+
} as const
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
*map(message: BinanceResponse<BinanceOptionsBookTickerData>, localTimestamp: Date) {
|
|
186
|
+
const bestBidPrice = Number(message.data.b)
|
|
187
|
+
const bestBidAmount = Number(message.data.B)
|
|
188
|
+
const bestAskPrice = Number(message.data.a)
|
|
189
|
+
const bestAskAmount = Number(message.data.A)
|
|
190
|
+
|
|
191
|
+
const bookTicker: BookTicker = {
|
|
192
|
+
type: 'book_ticker',
|
|
193
|
+
symbol: message.data.s,
|
|
194
|
+
exchange: 'binance-european-options',
|
|
195
|
+
bidPrice: bestBidPrice > 0 ? bestBidPrice : undefined,
|
|
196
|
+
bidAmount: bestBidAmount > 0 ? bestBidAmount : undefined,
|
|
197
|
+
askPrice: bestAskPrice > 0 ? bestAskPrice : undefined,
|
|
198
|
+
askAmount: bestAskAmount > 0 ? bestAskAmount : undefined,
|
|
199
|
+
timestamp: new Date(message.data.T),
|
|
200
|
+
localTimestamp
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
yield bookTicker
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
86
207
|
export class BinanceEuropeanOptionSummaryMapper implements Mapper<'binance-european-options', OptionSummary> {
|
|
87
208
|
private readonly _indexPrices = new Map<string, number>()
|
|
88
209
|
private readonly _openInterests = new Map<string, number>()
|
|
@@ -233,6 +354,165 @@ export class BinanceEuropeanOptionSummaryMapper implements Mapper<'binance-europ
|
|
|
233
354
|
}
|
|
234
355
|
}
|
|
235
356
|
|
|
357
|
+
export class BinanceEuropeanOptionSummaryMapperV2 implements Mapper<'binance-european-options', OptionSummary> {
|
|
358
|
+
private readonly _lastPrices = new Map<string, number>()
|
|
359
|
+
private readonly _openInterests = new Map<string, number>()
|
|
360
|
+
|
|
361
|
+
canHandle(message: BinanceResponse<any>) {
|
|
362
|
+
if (message.stream === undefined) {
|
|
363
|
+
return false
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return (
|
|
367
|
+
message.stream.endsWith('@optionMarkPrice') ||
|
|
368
|
+
message.stream.endsWith('@optionTicker') ||
|
|
369
|
+
message.stream.includes('@optionOpenInterest')
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
getFilters(symbols?: string[]) {
|
|
374
|
+
symbols = lowerCaseSymbols(symbols)
|
|
375
|
+
|
|
376
|
+
const underlyings =
|
|
377
|
+
symbols !== undefined
|
|
378
|
+
? symbols.map((s) => {
|
|
379
|
+
const symbolParts = s.split('-')
|
|
380
|
+
return `${symbolParts[0]}usdt`
|
|
381
|
+
})
|
|
382
|
+
: undefined
|
|
383
|
+
|
|
384
|
+
return [
|
|
385
|
+
{
|
|
386
|
+
channel: 'optionMarkPrice',
|
|
387
|
+
symbols: underlyings
|
|
388
|
+
} as const,
|
|
389
|
+
{
|
|
390
|
+
channel: 'optionTicker',
|
|
391
|
+
symbols
|
|
392
|
+
} as const,
|
|
393
|
+
{
|
|
394
|
+
channel: 'optionOpenInterest',
|
|
395
|
+
symbols: underlyings
|
|
396
|
+
} as const
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
*map(
|
|
401
|
+
message: BinanceResponse<BinanceOptionsMarkPriceData[] | BinanceOptionsTickerData | BinanceOptionsOpenInterestDataV2[]>,
|
|
402
|
+
localTimestamp: Date
|
|
403
|
+
) {
|
|
404
|
+
// Handle optionTicker messages to track last prices
|
|
405
|
+
if (message.stream.endsWith('@optionTicker')) {
|
|
406
|
+
const tickerData = message.data as BinanceOptionsTickerData
|
|
407
|
+
const lastPrice = Number(tickerData.c)
|
|
408
|
+
if (lastPrice > 0) {
|
|
409
|
+
this._lastPrices.set(tickerData.s, lastPrice)
|
|
410
|
+
}
|
|
411
|
+
return
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Handle optionOpenInterest messages to track open interest
|
|
415
|
+
if (message.stream.includes('@optionOpenInterest')) {
|
|
416
|
+
const openInterestArray = message.data as BinanceOptionsOpenInterestDataV2[]
|
|
417
|
+
for (let oi of openInterestArray) {
|
|
418
|
+
const openInterest = Number(oi.o)
|
|
419
|
+
if (openInterest >= 0) {
|
|
420
|
+
this._openInterests.set(oi.s, openInterest)
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// optionMarkPrice contains all data needed: greeks, IV, best bid/ask, mark price, and index price
|
|
427
|
+
const markPriceArray = message.data as BinanceOptionsMarkPriceData[]
|
|
428
|
+
for (let markData of markPriceArray) {
|
|
429
|
+
const [base, expiryPart, strikePrice, optionType] = markData.s.split('-')
|
|
430
|
+
|
|
431
|
+
const expirationDate = new Date(`20${expiryPart.slice(0, 2)}-${expiryPart.slice(2, 4)}-${expiryPart.slice(4, 6)}Z`)
|
|
432
|
+
expirationDate.setUTCHours(8)
|
|
433
|
+
|
|
434
|
+
const isPut = optionType === 'P'
|
|
435
|
+
const underlyingIndex = `${base}USDT`
|
|
436
|
+
|
|
437
|
+
let bestBidPrice = asNumberIfValid(markData.bo)
|
|
438
|
+
if (bestBidPrice === 0) {
|
|
439
|
+
bestBidPrice = undefined
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
let bestBidAmount = asNumberIfValid(markData.bq)
|
|
443
|
+
if (bestBidAmount === 0) {
|
|
444
|
+
bestBidAmount = undefined
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
let bestAskPrice = asNumberIfValid(markData.ao)
|
|
448
|
+
if (bestAskPrice === 0) {
|
|
449
|
+
bestAskPrice = undefined
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
let bestAskAmount = asNumberIfValid(markData.aq)
|
|
453
|
+
if (bestAskAmount === 0) {
|
|
454
|
+
bestAskAmount = undefined
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
let bestBidIV = bestBidPrice !== undefined ? asNumberIfValid(markData.b) : undefined
|
|
458
|
+
if (bestBidIV === -1) {
|
|
459
|
+
bestBidIV = undefined
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
let bestAskIV = bestAskPrice !== undefined ? asNumberIfValid(markData.a) : undefined
|
|
463
|
+
if (bestAskIV === -1) {
|
|
464
|
+
bestAskIV = undefined
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const markPrice = asNumberIfValid(markData.mp)
|
|
468
|
+
const markIV = asNumberIfValid(markData.vo)
|
|
469
|
+
const delta = asNumberIfValid(markData.d)
|
|
470
|
+
const gamma = asNumberIfValid(markData.g)
|
|
471
|
+
const vega = asNumberIfValid(markData.v)
|
|
472
|
+
const theta = asNumberIfValid(markData.t)
|
|
473
|
+
const underlyingPrice = asNumberIfValid(markData.i) // Index price is included in mark price data
|
|
474
|
+
|
|
475
|
+
const optionSummary: OptionSummary = {
|
|
476
|
+
type: 'option_summary',
|
|
477
|
+
symbol: markData.s,
|
|
478
|
+
exchange: 'binance-european-options',
|
|
479
|
+
optionType: isPut ? 'put' : 'call',
|
|
480
|
+
strikePrice: Number(strikePrice),
|
|
481
|
+
expirationDate,
|
|
482
|
+
|
|
483
|
+
bestBidPrice,
|
|
484
|
+
bestBidAmount,
|
|
485
|
+
bestBidIV,
|
|
486
|
+
|
|
487
|
+
bestAskPrice,
|
|
488
|
+
bestAskAmount,
|
|
489
|
+
bestAskIV,
|
|
490
|
+
|
|
491
|
+
lastPrice: this._lastPrices.get(markData.s),
|
|
492
|
+
|
|
493
|
+
openInterest: this._openInterests.get(markData.s),
|
|
494
|
+
|
|
495
|
+
markPrice,
|
|
496
|
+
markIV,
|
|
497
|
+
|
|
498
|
+
delta,
|
|
499
|
+
gamma,
|
|
500
|
+
vega,
|
|
501
|
+
theta,
|
|
502
|
+
rho: undefined,
|
|
503
|
+
|
|
504
|
+
underlyingPrice,
|
|
505
|
+
underlyingIndex,
|
|
506
|
+
|
|
507
|
+
timestamp: new Date(markData.E),
|
|
508
|
+
localTimestamp: localTimestamp
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
yield optionSummary
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
236
516
|
type BinanceResponse<T> = {
|
|
237
517
|
stream: string
|
|
238
518
|
data: T
|
|
@@ -301,3 +581,72 @@ type BinanceOptionsIndexData = { e: 'index'; E: 1696118400040; s: 'BNBUSDT'; p:
|
|
|
301
581
|
type BinanceOptionsOpenInterestData = { e: 'openInterest'; E: 1696118400042; s: 'XRP-231006-0.46-P'; o: '39480.0'; h: '20326.64319' }
|
|
302
582
|
|
|
303
583
|
type BinanceBookLevel = [string, string]
|
|
584
|
+
|
|
585
|
+
// V2 Types for new format (Dec 17, 2025+)
|
|
586
|
+
type BinanceOptionsTradeDataV2 = {
|
|
587
|
+
e: 'trade'
|
|
588
|
+
E: number // event time
|
|
589
|
+
T: number // trade completed time
|
|
590
|
+
s: string // option symbol
|
|
591
|
+
t: number // trade ID
|
|
592
|
+
p: string // price
|
|
593
|
+
q: string // quantity
|
|
594
|
+
X: 'MARKET' | 'BLOCK' // trade type
|
|
595
|
+
S: 'BUY' | 'SELL' // direction
|
|
596
|
+
m: boolean // is buyer market maker
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
type BinanceOptionsDepthDataV2 = {
|
|
600
|
+
e: 'depthUpdate'
|
|
601
|
+
E: number // event time
|
|
602
|
+
T: number // transaction time
|
|
603
|
+
s: string // symbol
|
|
604
|
+
U: number // first update ID
|
|
605
|
+
u: number // final update ID
|
|
606
|
+
pu: number // previous final update ID
|
|
607
|
+
b: [string, string][] // bids
|
|
608
|
+
a: [string, string][] // asks
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
type BinanceOptionsBookTickerData = {
|
|
612
|
+
e: 'bookTicker'
|
|
613
|
+
u: number // order book update ID
|
|
614
|
+
s: string // symbol
|
|
615
|
+
b: string // best bid price
|
|
616
|
+
B: string // best bid qty
|
|
617
|
+
a: string // best ask price
|
|
618
|
+
A: string // best ask qty
|
|
619
|
+
T: number // transaction time
|
|
620
|
+
E: number // event time
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
type BinanceOptionsOpenInterestDataV2 = {
|
|
624
|
+
e: 'openInterest'
|
|
625
|
+
E: number // event time
|
|
626
|
+
s: string // symbol
|
|
627
|
+
o: string // open interest (quantity)
|
|
628
|
+
h: string // open interest in notional value (USD)
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
type BinanceOptionsMarkPriceData = {
|
|
632
|
+
s: string // option symbol
|
|
633
|
+
mp: string // mark price
|
|
634
|
+
E: number // event time
|
|
635
|
+
e: 'markPrice'
|
|
636
|
+
i: string // index price
|
|
637
|
+
P: string // premium
|
|
638
|
+
bo: string // best bid price
|
|
639
|
+
ao: string // best ask price
|
|
640
|
+
bq: string // best bid quantity
|
|
641
|
+
aq: string // best ask quantity
|
|
642
|
+
b: string // bid IV
|
|
643
|
+
a: string // ask IV
|
|
644
|
+
hl: string // high limit price
|
|
645
|
+
ll: string // low limit price
|
|
646
|
+
vo: string // mark IV
|
|
647
|
+
rf: string // risk free rate
|
|
648
|
+
d: string // delta
|
|
649
|
+
t: string // theta
|
|
650
|
+
g: string // gamma
|
|
651
|
+
v: string // vega
|
|
652
|
+
}
|
package/src/mappers/cryptocom.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { upperCaseSymbols } from '../handy'
|
|
|
2
2
|
import { BookChange, Exchange, BookTicker, Trade, DerivativeTicker } from '../types'
|
|
3
3
|
import { Mapper, PendingTickerInfoHelper } from './mapper'
|
|
4
4
|
|
|
5
|
-
export class CryptoComTradesMapper implements Mapper<'crypto-com'
|
|
5
|
+
export class CryptoComTradesMapper implements Mapper<'crypto-com', Trade> {
|
|
6
6
|
constructor(private readonly _exchange: Exchange) {}
|
|
7
7
|
canHandle(message: CryptoComTradeMessage) {
|
|
8
8
|
return message.result !== undefined && message.result.channel === 'trade'
|
|
@@ -40,7 +40,7 @@ export class CryptoComTradesMapper implements Mapper<'crypto-com' | 'crypto-com-
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export class CryptoComBookChangeMapper implements Mapper<'crypto-com'
|
|
43
|
+
export class CryptoComBookChangeMapper implements Mapper<'crypto-com', BookChange> {
|
|
44
44
|
constructor(protected readonly _exchange: Exchange) {}
|
|
45
45
|
|
|
46
46
|
canHandle(message: CryptoComBookMessage) {
|
|
@@ -82,7 +82,7 @@ export class CryptoComBookChangeMapper implements Mapper<'crypto-com' | 'crypto-
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export class CryptoComBookTickerMapper implements Mapper<'crypto-com'
|
|
85
|
+
export class CryptoComBookTickerMapper implements Mapper<'crypto-com', BookTicker> {
|
|
86
86
|
constructor(protected readonly _exchange: Exchange) {}
|
|
87
87
|
|
|
88
88
|
canHandle(message: CryptoComTickerMessage) {
|
|
@@ -119,7 +119,7 @@ export class CryptoComBookTickerMapper implements Mapper<'crypto-com' | 'crypto-
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export class CryptoComDerivativeTickerMapper implements Mapper<'crypto-com
|
|
122
|
+
export class CryptoComDerivativeTickerMapper implements Mapper<'crypto-com', DerivativeTicker> {
|
|
123
123
|
private readonly pendingTickerInfoHelper = new PendingTickerInfoHelper()
|
|
124
124
|
private readonly _indexPrices = new Map<string, number>()
|
|
125
125
|
|
package/src/mappers/index.ts
CHANGED
|
@@ -12,10 +12,13 @@ import {
|
|
|
12
12
|
import { binanceDexBookChangeMapper, binanceDexBookTickerMapper, binanceDexTradesMapper } from './binancedex'
|
|
13
13
|
import {
|
|
14
14
|
BinanceEuropeanOptionsBookChangeMapper,
|
|
15
|
+
BinanceEuropeanOptionsBookChangeMapperV2,
|
|
16
|
+
BinanceEuropeanOptionsBookTickerMapper,
|
|
15
17
|
BinanceEuropeanOptionsTradesMapper,
|
|
16
|
-
|
|
18
|
+
BinanceEuropeanOptionsTradesMapperV2,
|
|
19
|
+
BinanceEuropeanOptionSummaryMapper,
|
|
20
|
+
BinanceEuropeanOptionSummaryMapperV2
|
|
17
21
|
} from './binanceeuropeanoptions'
|
|
18
|
-
import { BinanceOptionsBookChangeMapper, BinanceOptionsTradesMapper, BinanceOptionSummaryMapper } from './binanceoptions'
|
|
19
22
|
import {
|
|
20
23
|
BitfinexBookChangeMapper,
|
|
21
24
|
BitfinexDerivativeTickerMapper,
|
|
@@ -221,6 +224,12 @@ const shouldUseOKXTradesAllChannel = (localTimestamp: Date) => {
|
|
|
221
224
|
return isRealTime(localTimestamp) || localTimestamp.valueOf() >= new Date('2023-10-19T00:00:00.000Z').valueOf()
|
|
222
225
|
}
|
|
223
226
|
|
|
227
|
+
const BINANCE_EUROPEAN_OPTIONS_V2_API_SWITCH_DATE = new Date('2025-12-17T00:00:00.000Z')
|
|
228
|
+
|
|
229
|
+
const shouldUseBinanceEuropeanOptionsV2Mappers = (localTimestamp: Date) => {
|
|
230
|
+
return isRealTime(localTimestamp) || localTimestamp.valueOf() >= BINANCE_EUROPEAN_OPTIONS_V2_API_SWITCH_DATE.valueOf()
|
|
231
|
+
}
|
|
232
|
+
|
|
224
233
|
const tradesMappers = {
|
|
225
234
|
bitmex: () => bitmexTradesMapper,
|
|
226
235
|
binance: () => new BinanceTradesMapper('binance'),
|
|
@@ -278,7 +287,6 @@ const tradesMappers = {
|
|
|
278
287
|
poloniex: (localTimestamp: Date) =>
|
|
279
288
|
shouldUsePoloniexV2Mappers(localTimestamp) ? new PoloniexV2TradesMapper() : new PoloniexTradesMapper(),
|
|
280
289
|
coinflex: () => coinflexTradesMapper,
|
|
281
|
-
'binance-options': () => new BinanceOptionsTradesMapper(),
|
|
282
290
|
upbit: () => new UpbitTradesMapper(),
|
|
283
291
|
ascendex: () => new AscendexTradesMapper(),
|
|
284
292
|
dydx: () => new DydxTradesMapper(),
|
|
@@ -289,14 +297,16 @@ const tradesMappers = {
|
|
|
289
297
|
'bybit-spot': (localTimestamp: Date) =>
|
|
290
298
|
shouldUseBybitV5Mappers(localTimestamp) ? new BybitV5TradesMapper('bybit-spot') : new BybitSpotTradesMapper('bybit-spot'),
|
|
291
299
|
'crypto-com': () => new CryptoComTradesMapper('crypto-com'),
|
|
292
|
-
'crypto-com-derivatives': () => new CryptoComTradesMapper('crypto-com-derivatives'),
|
|
293
300
|
kucoin: () => new KucoinTradesMapper('kucoin'),
|
|
294
301
|
'kucoin-futures': () => new KucoinFuturesTradesMapper(),
|
|
295
302
|
bitnomial: () => bitnomialTradesMapper,
|
|
296
303
|
'woo-x': () => wooxTradesMapper,
|
|
297
304
|
'blockchain-com': () => new BlockchainComTradesMapper(),
|
|
298
305
|
'bybit-options': () => new BybitV5TradesMapper('bybit-options'),
|
|
299
|
-
'binance-european-options': () =>
|
|
306
|
+
'binance-european-options': (localTimestamp: Date) =>
|
|
307
|
+
shouldUseBinanceEuropeanOptionsV2Mappers(localTimestamp)
|
|
308
|
+
? new BinanceEuropeanOptionsTradesMapperV2()
|
|
309
|
+
: new BinanceEuropeanOptionsTradesMapper(),
|
|
300
310
|
'okex-spreads': () => new OkexSpreadsTradesMapper(),
|
|
301
311
|
bitget: () => new BitgetTradesMapper('bitget'),
|
|
302
312
|
'bitget-futures': () => new BitgetTradesMapper('bitget-futures'),
|
|
@@ -374,7 +384,6 @@ const bookChangeMappers = {
|
|
|
374
384
|
poloniex: (localTimestamp: Date) =>
|
|
375
385
|
shouldUsePoloniexV2Mappers(localTimestamp) ? new PoloniexV2BookChangeMapper() : new PoloniexBookChangeMapper(),
|
|
376
386
|
coinflex: () => coinflexBookChangeMapper,
|
|
377
|
-
'binance-options': () => new BinanceOptionsBookChangeMapper(),
|
|
378
387
|
upbit: () => new UpbitBookChangeMapper(),
|
|
379
388
|
ascendex: () => new AscendexBookChangeMapper(),
|
|
380
389
|
dydx: () => new DydxBookChangeMapper(),
|
|
@@ -383,14 +392,16 @@ const bookChangeMappers = {
|
|
|
383
392
|
'star-atlas': () => new SerumBookChangeMapper('star-atlas'),
|
|
384
393
|
mango: () => new SerumBookChangeMapper('mango'),
|
|
385
394
|
'crypto-com': () => new CryptoComBookChangeMapper('crypto-com'),
|
|
386
|
-
'crypto-com-derivatives': () => new CryptoComBookChangeMapper('crypto-com-derivatives'),
|
|
387
395
|
kucoin: (localTimestamp: Date) => new KucoinBookChangeMapper('kucoin', isRealTime(localTimestamp) === false),
|
|
388
396
|
'kucoin-futures': (localTimestamp: Date) => new KucoinFuturesBookChangeMapper(isRealTime(localTimestamp) === false),
|
|
389
397
|
bitnomial: () => new BitnomialBookChangMapper(),
|
|
390
398
|
'woo-x': () => new WooxBookChangeMapper(),
|
|
391
399
|
'blockchain-com': () => new BlockchainComBookChangeMapper(),
|
|
392
400
|
'bybit-options': () => new BybitV5BookChangeMapper('bybit-options', 25),
|
|
393
|
-
'binance-european-options': () =>
|
|
401
|
+
'binance-european-options': (localTimestamp: Date) =>
|
|
402
|
+
shouldUseBinanceEuropeanOptionsV2Mappers(localTimestamp)
|
|
403
|
+
? new BinanceEuropeanOptionsBookChangeMapperV2()
|
|
404
|
+
: new BinanceEuropeanOptionsBookChangeMapper(),
|
|
394
405
|
'okex-spreads': () => new OkexSpreadsBookChangeMapper(),
|
|
395
406
|
bitget: () => new BitgetBookChangeMapper('bitget'),
|
|
396
407
|
'bitget-futures': () => new BitgetBookChangeMapper('bitget-futures'),
|
|
@@ -426,7 +437,6 @@ const derivativeTickersMappers = {
|
|
|
426
437
|
ascendex: () => new AscendexDerivativeTickerMapper(),
|
|
427
438
|
dydx: () => new DydxDerivativeTickerMapper(),
|
|
428
439
|
'dydx-v4': () => new DydxV4DerivativeTickerMapper(),
|
|
429
|
-
'crypto-com-derivatives': () => new CryptoComDerivativeTickerMapper('crypto-com-derivatives'),
|
|
430
440
|
'crypto-com': () => new CryptoComDerivativeTickerMapper('crypto-com'),
|
|
431
441
|
'woo-x': () => new WooxDerivativeTickerMapper(),
|
|
432
442
|
'kucoin-futures': () => new KucoinFuturesDerivativeTickerMapper(),
|
|
@@ -439,10 +449,12 @@ const optionsSummaryMappers = {
|
|
|
439
449
|
deribit: () => new DeribitOptionSummaryMapper(),
|
|
440
450
|
'okex-options': (localTimestamp: Date) =>
|
|
441
451
|
shouldUseOkexV5Mappers(localTimestamp) ? new OkexV5OptionSummaryMapper() : new OkexOptionSummaryMapper(),
|
|
442
|
-
'binance-options': () => new BinanceOptionSummaryMapper(),
|
|
443
452
|
'huobi-dm-options': () => new HuobiOptionsSummaryMapper(),
|
|
444
453
|
'bybit-options': () => new BybitV5OptionSummaryMapper(),
|
|
445
|
-
'binance-european-options': () =>
|
|
454
|
+
'binance-european-options': (localTimestamp: Date) =>
|
|
455
|
+
shouldUseBinanceEuropeanOptionsV2Mappers(localTimestamp)
|
|
456
|
+
? new BinanceEuropeanOptionSummaryMapperV2()
|
|
457
|
+
: new BinanceEuropeanOptionSummaryMapper()
|
|
446
458
|
}
|
|
447
459
|
|
|
448
460
|
const liquidationsMappers = {
|
|
@@ -521,7 +533,6 @@ const bookTickersMappers = {
|
|
|
521
533
|
'bybit-spot': (localTimestamp: Date) =>
|
|
522
534
|
shouldUseBybitV5Mappers(localTimestamp) ? new BybitV5BookTickerMapper('bybit-spot') : new BybitSpotBookTickerMapper('bybit-spot'),
|
|
523
535
|
'crypto-com': () => new CryptoComBookTickerMapper('crypto-com'),
|
|
524
|
-
'crypto-com-derivatives': () => new CryptoComBookTickerMapper('crypto-com-derivatives'),
|
|
525
536
|
kucoin: () => new KucoinBookTickerMapper('kucoin'),
|
|
526
537
|
'woo-x': () => new WooxBookTickerMapper(),
|
|
527
538
|
delta: () => new DeltaBookTickerMapper(),
|
|
@@ -532,7 +543,8 @@ const bookTickersMappers = {
|
|
|
532
543
|
bitget: () => new BitgetBookTickerMapper('bitget'),
|
|
533
544
|
'bitget-futures': () => new BitgetBookTickerMapper('bitget-futures'),
|
|
534
545
|
'coinbase-international': () => coinbaseInternationalBookTickerMapper,
|
|
535
|
-
hyperliquid: () => new HyperliquidBookTickerMapper()
|
|
546
|
+
hyperliquid: () => new HyperliquidBookTickerMapper(),
|
|
547
|
+
'binance-european-options': () => new BinanceEuropeanOptionsBookTickerMapper()
|
|
536
548
|
}
|
|
537
549
|
|
|
538
550
|
export const normalizeTrades = <T extends keyof typeof tradesMappers>(exchange: T, localTimestamp: Date): Mapper<T, Trade> => {
|