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

Commit

Permalink
all: convert Bibox and Bitfinex to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
bmancini55 committed May 25, 2021
1 parent 5f1f523 commit a7d3220
Show file tree
Hide file tree
Showing 13 changed files with 1,256 additions and 554 deletions.
56 changes: 32 additions & 24 deletions __tests__/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,52 +59,60 @@ export type TestSpec = {
candle?: CandleOptions;
l2snapshot?: L2SnapshotOptions;
l2update?: L2UpdateOptions;
l3snapshot?: L3SnapshotOptions;
l3update?: L3UpdateOptions;
};

export type TickerOptions = {
hasTimestamp: boolean;
hasLast: boolean;
hasOpen: boolean;
hasHigh: boolean;
hasLow: boolean;
hasVolume: boolean;
hasQuoteVolume: boolean;
hasChange: boolean;
hasChangePercent: boolean;
hasBid: boolean;
hasBidVolume: boolean;
hasAsk: boolean;
hasAskVolume: boolean;
hasTimestamp?: boolean;
hasLast?: boolean;
hasOpen?: boolean;
hasHigh?: boolean;
hasLow?: boolean;
hasVolume?: boolean;
hasQuoteVolume?: boolean;
hasChange?: boolean;
hasChangePercent?: boolean;
hasBid?: boolean;
hasBidVolume?: boolean;
hasAsk?: boolean;
hasAskVolume?: boolean;
hasSequenceId?: boolean;
};

export type TradeOptions = {
hasTradeId: boolean;
hasTradeId?: boolean;
hasSequenceId?: boolean;
};

export type CandleOptions = {
//
hasSequenceId?: boolean;
};

export type L2SnapshotOptions = {
hasTimestampMs: boolean;
hasSequenceId: boolean;
hasCount: boolean;
hasTimestampMs?: boolean;
hasSequenceId?: boolean;
hasCount?: boolean;
};

export type L2UpdateOptions = {
hasSnapshot: boolean;
hasTimestampMs: boolean;
hasSequenceId: boolean;
hasLastSequenceId: boolean;
hasEventMs: boolean;
hasCount: boolean;
hasSnapshot?: boolean;
hasTimestampMs?: boolean;
hasSequenceId?: boolean;
hasLastSequenceId?: boolean;
hasEventMs?: boolean;
hasCount?: boolean;
};

export type L3UpdateOptions = {
//
};

export type L3SnapshotOptions = {
hasTimestampMs?: boolean;
hasSequenceId?: boolean;
};

export type TestRunnerState = {
client?: IClient;
};
Expand Down
83 changes: 83 additions & 0 deletions __tests__/exchanges/BiboxClient.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { testClient } from "../TestRunner";
import { BiboxClient } from "../../src/exchanges/BiboxClient";
import * as https from "../../src/Https";

testClient({
clientFactory: () => new BiboxClient(),
clientName: "BiboxClient",
exchangeName: "Bibox",
markets: [
{
id: "BTC_USDT",
base: "BTC",
quote: "USDT",
},
{
id: "ETH_USDT",
base: "ETH",
quote: "USDT",
},
{
id: "ETH_BTC",
base: "ETH",
quote: "BTC",
},
],

async fetchAllMarkets() {
const res = (await https.get("https://api.bibox.com/v1/mdata?cmd=pairList")) as any;
return res.result.map(p => ({
id: p.pair,
base: p.pair.split("_")[0],
quote: p.pair.split("_")[1],
}));
},

getEventingSocket(client) {
return (client as any)._clients[0]._wss;
},

testAllMarketsTrades: true,
testAllMarketsTradesSuccess: 50,

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

hasTickers: true,
hasTrades: true,
hasCandles: true,
hasLevel2Snapshots: true,
hasLevel2Updates: false,
hasLevel3Snapshots: false,
hasLevel3Updates: false,

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

trade: {
hasTradeId: false,
},

candle: {},

l2snapshot: {
hasTimestampMs: true,
hasSequenceId: false,
hasCount: false,
},
});
87 changes: 87 additions & 0 deletions __tests__/exchanges/BitfinexClient.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* eslint-disable @typescript-eslint/no-var-requires */

import { testClient } from "../TestRunner";
import { BitfinexClient } from "../../src/exchanges/BitfinexClient";

testClient({
clientFactory: () => new BitfinexClient(),
clientName: "BitfinexClient",
exchangeName: "Bitfinex",
markets: [
{
id: "BTCUSD",
base: "BTC",
quote: "USDT",
},
{
id: "ETHUSD",
base: "ETH",
quote: "USD",
},
{
id: "ETHBTC",
base: "ETH",
quote: "BTC",
},
],

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

hasTickers: true,
hasTrades: true,
hasCandles: false,
hasLevel2Snapshots: false,
hasLevel2Updates: true,
hasLevel3Snapshots: false,
hasLevel3Updates: true,

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

trade: {
hasTradeId: true,
hasSequenceId: true,
},

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

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

l3snapshot: {
hasTimestampMs: true,
hasSequenceId: true,
},

l3update: {
hasSnapshot: true,
hasTimestampMs: true,
hasSequenceId: true,
hasCount: true,
},
});
83 changes: 0 additions & 83 deletions __tests__/exchanges/bibox-client.spec.js

This file was deleted.

Loading

0 comments on commit a7d3220

Please sign in to comment.