Skip to content

Commit

Permalink
improvement: deribit mapper tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
thaaddeus committed Sep 9, 2022
1 parent 0222f67 commit 51a2788
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/mappers/deribit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ export class DeribitDerivativeTickerMapper implements Mapper<'deribit', Derivati
return false
}

// exclude options tickers
return channel.startsWith('ticker') && message.params.data.greeks === undefined
return channel.startsWith('ticker') && (message.params.data.greeks === undefined || message.params.data.combo_state === 'active')
}

getFilters(symbols?: string[]) {
Expand Down Expand Up @@ -150,8 +149,6 @@ export class DeribitOptionSummaryMapper implements Mapper<'deribit', OptionSumma
return false
}

// options ticker has greeks

return (
channel.startsWith('ticker') &&
(message.params.data.instrument_name.endsWith('-P') || message.params.data.instrument_name.endsWith('-C'))
Expand Down
74 changes: 74 additions & 0 deletions test/__snapshots__/mappers.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4545,6 +4545,20 @@ Array [

exports[`mappers map deribit messages 15`] = `
Array [
Object {
"exchange": "deribit",
"fundingRate": undefined,
"fundingTimestamp": undefined,
"indexPrice": 21478.45,
"lastPrice": undefined,
"localTimestamp": 2019-06-01T00:00:28.619Z,
"markPrice": 0.1922,
"openInterest": 0,
"predictedFundingRate": undefined,
"symbol": "BTC-STRD-30SEP22-20000",
"timestamp": 2022-08-23T17:03:00.291Z,
"type": "derivative_ticker",
},
Object {
"askAmount": undefined,
"askPrice": undefined,
Expand All @@ -4559,6 +4573,66 @@ Array [
]
`;

exports[`mappers map deribit messages 16`] = `
Array [
Object {
"exchange": "deribit",
"fundingRate": undefined,
"fundingTimestamp": undefined,
"indexPrice": 19320.68,
"lastPrice": -13.5,
"localTimestamp": 2019-06-01T00:00:28.619Z,
"markPrice": 10.12,
"openInterest": 0,
"predictedFundingRate": undefined,
"symbol": "BTC-FS-30SEP22_PERP",
"timestamp": 2022-09-09T00:00:59.203Z,
"type": "derivative_ticker",
},
Object {
"askAmount": 300000,
"askPrice": -5,
"bidAmount": 300000,
"bidPrice": -7,
"exchange": "deribit",
"localTimestamp": 2019-06-01T00:00:28.619Z,
"symbol": "BTC-FS-30SEP22_PERP",
"timestamp": 2022-09-09T00:00:59.203Z,
"type": "book_ticker",
},
]
`;

exports[`mappers map deribit messages 17`] = `
Array [
Object {
"exchange": "deribit",
"fundingRate": undefined,
"fundingTimestamp": undefined,
"indexPrice": 19322.48,
"lastPrice": undefined,
"localTimestamp": 2019-06-01T00:00:28.619Z,
"markPrice": 0.0053,
"openInterest": 0,
"predictedFundingRate": undefined,
"symbol": "BTC-CSR12-16SEP22-21000_23000",
"timestamp": 2022-09-09T00:00:56.186Z,
"type": "derivative_ticker",
},
Object {
"askAmount": 18,
"askPrice": 0.008,
"bidAmount": 18,
"bidPrice": 0.003,
"exchange": "deribit",
"localTimestamp": 2019-06-01T00:00:28.619Z,
"symbol": "BTC-CSR12-16SEP22-21000_23000",
"timestamp": 2022-09-09T00:00:56.186Z,
"type": "book_ticker",
},
]
`;

exports[`mappers map dydx messages 1`] = `Array []`;

exports[`mappers map dydx messages 2`] = `
Expand Down

0 comments on commit 51a2788

Please sign in to comment.