From 0d208224833b495eb981e133bc4ddeb222cae717 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Fri, 24 Jan 2025 15:41:34 +0000 Subject: [PATCH] chore(): update default logger examples --- README.md | 9 --------- examples/demo-trading.ts | 4 ++-- examples/fasterHmacSign.ts | 4 ++-- examples/ws-private-v5.ts | 4 ++-- examples/ws-public-v5.ts | 10 ++-------- test/v5/public.ws.test.ts | 4 +--- 6 files changed, 9 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 52c7927..8f94d49 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,6 @@ Node.js, JavaScript & TypeScript SDK for the Bybit REST APIs and WebSockets: - [WebSockets](#websockets) - [WebSocket Subscriptions - Consuming Events](#websocket-subscriptions---consuming-events) - [Websocket API - Sending Orders via WebSockets](#websocket-api---sending-orders-via-websockets) -- [Specifying Other Markets](#specifying-other-markets) - [Consumer Load Balancing](#balancing-load-across-multiple-connections) ## Additional Features @@ -485,14 +484,6 @@ See the [examples/ws-api-promises.ts](./examples/ws-api-promises.ts) example for --- -### Specifying other markets - -The WebsocketClient can be configured to a specific API group using the market parameter. These are the currently available API groups: -| API Category | Market | Description | -|:----------------------------: |:-------------------: |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| V5 Subscriptions | `market: 'v5'` | The [v5](https://bybit-exchange.github.io/docs/v5/ws/connect) websocket topics for all categories under one market. Use the subscribeV5 method when subscribing to v5 topics. | - - ### Balancing load across multiple connections The WebsocketClient will automatically prepare one connection per API group, for all topics in that API group. Any topics that you subscribe to on that WebSocket client will automatically be added to the same connection. diff --git a/examples/demo-trading.ts b/examples/demo-trading.ts index 36a0aaa..190e41c 100644 --- a/examples/demo-trading.ts +++ b/examples/demo-trading.ts @@ -29,14 +29,14 @@ const restClient = new RestClientV5({ // Optional, uncomment the "silly" override to log a lot more info about what the WS client is doing const customLogger = { ...DefaultLogger, - // silly: (...params) => console.log('trace', ...params), + // trace: (...params) => console.log('trace', ...params), }; const wsClient = new WebsocketClient( { key: key, secret: secret, - market: 'v5', + /** * Set this to true to enable demo trading for the private account data WS * Topics: order,execution,position,wallet,greeks diff --git a/examples/fasterHmacSign.ts b/examples/fasterHmacSign.ts index 818087d..d9dcca2 100644 --- a/examples/fasterHmacSign.ts +++ b/examples/fasterHmacSign.ts @@ -46,10 +46,10 @@ const restClient = new RestClientV5({ }, }); -// Optional, uncomment the "silly" override to log a lot more info about what the WS client is doing +// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing const customLogger = { ...DefaultLogger, - // silly: (...params) => console.log('trace', ...params), + // trace: (...params) => console.log('trace', ...params), }; const wsClient = new WebsocketClient( diff --git a/examples/ws-private-v5.ts b/examples/ws-private-v5.ts index e4bb3f1..f9a4f1a 100644 --- a/examples/ws-private-v5.ts +++ b/examples/ws-private-v5.ts @@ -4,10 +4,10 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src'; // or // import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api'; -// Create & inject a custom logger to disable the silly logging level (empty function) +// Create & inject a custom logger to enable the trace logging level (empty function) const logger = { ...DefaultLogger, - silly: () => {}, + // trace: (...params) => console.log('trace', ...params), }; const key = process.env.API_KEY; diff --git a/examples/ws-public-v5.ts b/examples/ws-public-v5.ts index 6f3e7ca..118181d 100644 --- a/examples/ws-public-v5.ts +++ b/examples/ws-public-v5.ts @@ -5,7 +5,7 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src'; const logger = { ...DefaultLogger, - silly: (...params) => console.log('silly', ...params), + trace: (...params) => console.log('trace', ...params), }; /** @@ -17,13 +17,7 @@ const logger = { * - Heartbeats/ping/pong/reconnects are all handled automatically. * If a connection drops, the client will clean it up, respawn a fresh connection and resubscribe for you. */ -const wsClient = new WebsocketClient( - { - // Previously required, this parameter is now optional: - // market: 'v5', - }, - logger, -); +const wsClient = new WebsocketClient({}, logger); wsClient.on('update', (data) => { console.log('raw message received ', JSON.stringify(data)); diff --git a/test/v5/public.ws.test.ts b/test/v5/public.ws.test.ts index d86205d..f389411 100644 --- a/test/v5/public.ws.test.ts +++ b/test/v5/public.ws.test.ts @@ -1,9 +1,7 @@ import { WebsocketClient } from '../../src'; describe.skip('Public V5 Websocket client', () => { - const api = new WebsocketClient({ - market: 'v5', - }); + const api = new WebsocketClient({}); const linearSymbol = 'BTCUSDT'; const linearCategory = 'linear';