Skip to content

Commit

Permalink
fix(v4.0.0-beta.4): demo trading wss should only be used for private …
Browse files Browse the repository at this point in the history
…connections
  • Loading branch information
tiagosiebler committed Feb 6, 2025
2 parents d051142 + 646fecc commit a8f8d6b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
7 changes: 6 additions & 1 deletion examples/ws-public-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ 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({}, logger);
const wsClient = new WebsocketClient(
{
// demoTrading: true,
},
logger,
);

wsClient.on('update', (data) => {
console.log('raw message received ', JSON.stringify(data));
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bybit-api",
"version": "4.0.0-beta.3",
"version": "4.0.0-beta.4",
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/util/websockets/websocket-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export function getWsUrl(
}

// https://bybit-exchange.github.io/docs/v5/demo
const demoTradingPrivateEndpoint = 'wss://stream-demo.bybit.com/v5/private';
const DEMO_TRADING_ENDPOINT = 'wss://stream-demo.bybit.com/v5/private';

const isDemoTrading = wsClientOptions.demoTrading;
const isTestnet = wsClientOptions.testnet;
Expand All @@ -250,13 +250,13 @@ export function getWsUrl(
switch (wsKey) {
case WS_KEY_MAP.v5Private: {
if (isDemoTrading) {
return demoTradingPrivateEndpoint;
return DEMO_TRADING_ENDPOINT;
}
return WS_BASE_URL_MAP.v5.private[networkKey];
}
case WS_KEY_MAP.v5PrivateTrade: {
if (isDemoTrading) {
return demoTradingPrivateEndpoint;
return DEMO_TRADING_ENDPOINT;
}
return WS_BASE_URL_MAP[wsKey].private[networkKey];
}
Expand Down

0 comments on commit a8f8d6b

Please sign in to comment.