1
- import { asNumberIfValid , upperCaseSymbols } from '../handy'
1
+ import { asNumberIfValid } from '../handy'
2
2
import { BookChange , BookTicker , DerivativeTicker , Liquidation , OptionSummary , Trade } from '../types'
3
3
import { Mapper , PendingTickerInfoHelper } from './mapper'
4
4
5
5
// https://docs.deribit.com/v2/#subscriptions
6
6
7
+ function deribitCasing ( symbols ?: string [ ] ) {
8
+ if ( symbols !== undefined ) {
9
+ return symbols . map ( ( symbol ) => {
10
+ if ( symbol . endsWith ( '-C' ) || symbol . endsWith ( '-P' ) ) {
11
+ const parts = symbol . split ( '-' )
12
+ if ( parts [ 2 ] !== undefined && parts [ 2 ] . toUpperCase ( ) . includes ( 'D' ) ) {
13
+ parts [ 2 ] = parts [ 2 ] . replace ( 'D' , 'd' )
14
+ return parts . join ( '-' )
15
+ } else {
16
+ return symbol . toUpperCase ( )
17
+ }
18
+ } else {
19
+ return symbol . toUpperCase ( )
20
+ }
21
+ } )
22
+ }
23
+
24
+ return
25
+ }
26
+
7
27
export const deribitTradesMapper : Mapper < 'deribit' , Trade > = {
8
28
canHandle ( message : any ) {
9
29
const channel = message . params !== undefined ? ( message . params . channel as string | undefined ) : undefined
@@ -15,7 +35,7 @@ export const deribitTradesMapper: Mapper<'deribit', Trade> = {
15
35
} ,
16
36
17
37
getFilters ( symbols ?: string [ ] ) {
18
- symbols = upperCaseSymbols ( symbols )
38
+ symbols = deribitCasing ( symbols )
19
39
20
40
return [
21
41
{
@@ -60,7 +80,7 @@ export const deribitBookChangeMapper: Mapper<'deribit', BookChange> = {
60
80
} ,
61
81
62
82
getFilters ( symbols ?: string [ ] ) {
63
- symbols = upperCaseSymbols ( symbols )
83
+ symbols = deribitCasing ( symbols )
64
84
65
85
return [
66
86
{
@@ -78,6 +98,7 @@ export const deribitBookChangeMapper: Mapper<'deribit', BookChange> = {
78
98
deribitBookChange . prev_change_id === undefined ||
79
99
deribitBookChange . prev_change_id === 0
80
100
101
+ console . log ( JSON . stringify ( message ) )
81
102
yield {
82
103
type : 'book_change' ,
83
104
symbol : deribitBookChange . instrument_name . toUpperCase ( ) ,
@@ -104,7 +125,7 @@ export class DeribitDerivativeTickerMapper implements Mapper<'deribit', Derivati
104
125
}
105
126
106
127
getFilters ( symbols ?: string [ ] ) {
107
- symbols = upperCaseSymbols ( symbols )
128
+ symbols = deribitCasing ( symbols )
108
129
109
130
return [
110
131
{
@@ -133,7 +154,7 @@ export class DeribitDerivativeTickerMapper implements Mapper<'deribit', Derivati
133
154
134
155
export class DeribitOptionSummaryMapper implements Mapper < 'deribit' , OptionSummary > {
135
156
getFilters ( symbols ?: string [ ] ) {
136
- symbols = upperCaseSymbols ( symbols )
157
+ symbols = deribitCasing ( symbols )
137
158
138
159
return [
139
160
{
@@ -222,7 +243,7 @@ export const deribitLiquidationsMapper: Mapper<'deribit', Liquidation> = {
222
243
} ,
223
244
224
245
getFilters ( symbols ?: string [ ] ) {
225
- symbols = upperCaseSymbols ( symbols )
246
+ symbols = deribitCasing ( symbols )
226
247
227
248
return [
228
249
{
@@ -270,7 +291,7 @@ export const deribitBookTickerMapper: Mapper<'deribit', BookTicker> = {
270
291
} ,
271
292
272
293
getFilters ( symbols ?: string [ ] ) {
273
- symbols = upperCaseSymbols ( symbols )
294
+ symbols = deribitCasing ( symbols )
274
295
275
296
return [
276
297
{
0 commit comments