cleaning around tests

This commit is contained in:
tiagosiebler
2022-09-15 19:06:35 +01:00
parent 27bd81593c
commit f61e79934d
10 changed files with 323 additions and 76 deletions

View File

@@ -1,4 +1,4 @@
import { WsKey } from '../types';
import { APIMarket, WsKey } from '../types';
interface NetworkMapV3 {
livenet: string;
@@ -10,42 +10,52 @@ interface NetworkMapV3 {
type PublicPrivateNetwork = 'public' | 'private';
export const WS_BASE_URL_MAP: Record<
string,
APIMarket,
Record<PublicPrivateNetwork, NetworkMapV3>
> = {
inverse: {
private: {
public: {
livenet: 'wss://stream.bybit.com/realtime',
testnet: 'wss://stream-testnet.bybit.com/realtime',
},
public: {
private: {
livenet: 'wss://stream.bybit.com/realtime',
testnet: 'wss://stream-testnet.bybit.com/realtime',
},
},
linear: {
private: {
livenet: 'wss://stream.bybit.com/realtime_private',
livenet2: 'wss://stream.bytick.com/realtime_private',
testnet: 'wss://stream-testnet.bybit.com/realtime_private',
},
public: {
livenet: 'wss://stream.bybit.com/realtime_public',
livenet2: 'wss://stream.bytick.com/realtime_public',
testnet: 'wss://stream-testnet.bybit.com/realtime_public',
},
private: {
livenet: 'wss://stream.bybit.com/realtime_private',
livenet2: 'wss://stream.bytick.com/realtime_private',
testnet: 'wss://stream-testnet.bybit.com/realtime_private',
},
},
spot: {
private: {
livenet: 'wss://stream.bybit.com/spot/ws',
testnet: 'wss://stream-testnet.bybit.com/spot/ws',
},
public: {
livenet: 'wss://stream.bybit.com/spot/quote/ws/v1',
livenet2: 'wss://stream.bybit.com/spot/quote/ws/v2',
testnet: 'wss://stream-testnet.bybit.com/spot/quote/ws/v1',
testnet2: 'wss://stream-testnet.bybit.com/spot/quote/ws/v2',
},
private: {
livenet: 'wss://stream.bybit.com/spot/ws',
testnet: 'wss://stream-testnet.bybit.com/spot/ws',
},
},
spotV3: {
public: {
livenet: 'wss://stream.bybit.com/spot/public/v3',
testnet: 'wss://stream-testnet.bybit.com/spot/public/v3',
},
private: {
livenet: 'wss://stream.bybit.com/spot/private/v3',
testnet: 'wss://stream-testnet.bybit.com/spot/private/v3',
},
},
};
@@ -55,6 +65,8 @@ export const WS_KEY_MAP = {
linearPublic: 'linearPublic',
spotPrivate: 'spotPrivate',
spotPublic: 'spotPublic',
spotV3Private: 'spotV3Private',
spotV3Public: 'spotV3Public',
} as const;
export const PUBLIC_WS_KEYS = [
@@ -77,7 +89,10 @@ export function getLinearWsKeyForTopic(topic: string): WsKey {
return WS_KEY_MAP.linearPublic;
}
export function getSpotWsKeyForTopic(topic: string): WsKey {
export function getSpotWsKeyForTopic(
topic: string,
apiVersion: 'v1' | 'v3'
): WsKey {
const privateTopics = [
'position',
'execution',
@@ -88,6 +103,13 @@ export function getSpotWsKeyForTopic(topic: string): WsKey {
'ticketInfo',
];
if (apiVersion === 'v3') {
if (privateTopics.includes(topic)) {
return WS_KEY_MAP.spotV3Private;
}
return WS_KEY_MAP.spotV3Public;
}
if (privateTopics.includes(topic)) {
return WS_KEY_MAP.spotPrivate;
}