Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

Commit

Permalink
deribit: convert to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
bmancini55 committed Jun 10, 2021
1 parent a581d64 commit 0acf590
Show file tree
Hide file tree
Showing 5 changed files with 590 additions and 571 deletions.
121 changes: 121 additions & 0 deletions __tests__/exchanges/DeribitClient.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { testClient } from "../TestRunner";
import { DeribitClient } from "../../src/exchanges/DeribitClient";
import * as https from "../../src/Https";

const assertions = {
hasTickers: true,
hasTrades: true,
hasCandles: true,
hasLevel2Snapshots: false,
hasLevel2Updates: true,
hasLevel3Snapshots: false,
hasLevel3Updates: false,

ticker: {
hasTimestamp: true,
hasLast: true,
hasOpen: false,
hasHigh: true,
hasLow: true,
hasVolume: true,
hasQuoteVolume: false,
hasChange: false,
hasChangePercent: true,
hasAsk: true,
hasBid: true,
hasAskVolume: true,
hasBidVolume: true,
},

trade: {
hasTradeId: true,
},

candle: {},

l2snapshot: {
hasTimestampMs: true,
hasSequenceId: true,
hasCount: false,
},

l2update: {
hasSnapshot: true,
hasSequenceId: true,
hasTimestampMs: true,
},
};

testClient({
clientFactory: () => new DeribitClient(),
clientName: "DeribitClient - Swaps",
exchangeName: "Deribit",
markets: [
{
id: "BTC-PERPETUAL",
base: "BTC",
quote: "USD",
},
],

testConnectEvents: true,
testDisconnectEvents: true,
testReconnectionEvents: true,
testCloseEvents: true,

...assertions,
});

testClient({
clientFactory: () => new DeribitClient(),
clientName: "DeribitClient - Futures",
exchangeName: "Deribit",

async fetchMarkets() {
const res: any = await https.get(
"https://www.deribit.com/api/v2/public/get_instruments?currency=BTC&expired=false&kind=future",
);
return res.result.map(p => ({
id: p.instrument_name,
base: p.base_currency,
quote: "USD",
type: "futures",
}));
},

...assertions,
});

testClient({
clientFactory: () => new DeribitClient(),
clientName: "DeribitClient - Options",
exchangeName: "Deribit",

async fetchMarkets() {
const res: any = await https.get(
"https://www.deribit.com/api/v2/public/get_instruments?currency=BTC&expired=false&kind=option",
);
return res.result
.map(p => ({
id: p.instrument_name,
base: p.base_currency,
quote: "USD",
type: "option",
}))
.slice(0, 10);
},

async fetchTradeMarkets() {
const res: any = await https.get(
"https://www.deribit.com/api/v2/public/get_instruments?currency=BTC&expired=false&kind=option",
);
return res.result.map(p => ({
id: p.instrument_name,
base: p.base_currency,
quote: "USD",
type: "option",
}));
},

...assertions,
});
121 changes: 0 additions & 121 deletions __tests__/exchanges/deribit-client.spec.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/CandlePeriod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ export enum CandlePeriod {
_2m = "_2m",
_3m = "_3m",
_5m = "_5m",
_10m = "_10m",
_15m = "_15m",
_30m = "_30m",
_1h = "_1h",
_2h = "_2h",
_3h = "_3h",
_4h = "_4h",
_6h = "_6h",
_8h = "_8h",
Expand Down
Loading

0 comments on commit 0acf590

Please sign in to comment.