Skip to content

Commit

Permalink
chore(): update default logger examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Jan 24, 2025
1 parent a4945d1 commit 0d20822
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 26 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-trading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/fasterHmacSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions examples/ws-private-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 2 additions & 8 deletions examples/ws-public-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

/**
Expand All @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions test/v5/public.ws.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit 0d20822

Please sign in to comment.