Skip to content

Commit

Permalink
fix(v3.10.31, #411): demo trading wss should only be used for private…
Browse files Browse the repository at this point in the history
… topics. Fixes #411.
  • Loading branch information
tiagosiebler committed Feb 1, 2025
1 parent 1fa53ba commit bbf3a72
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/ws-public-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const logger = {
const wsClient = new WebsocketClient(
{
market: 'v5',
// demoTrading: true,
},
logger,
);
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": "3.10.30",
"version": "3.10.31",
"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
10 changes: 5 additions & 5 deletions src/util/websocket-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,7 @@ export function getWsUrl(
return wsUrl;
}

// https://bybit-exchange.github.io/docs/v5/demo
const isDemoTrading = wsClientOptions.demoTrading;
if (isDemoTrading) {
return 'wss://stream-demo.bybit.com/v5/private';
}

const isTestnet = wsClientOptions.testnet;
const networkKey = isTestnet ? 'testnet' : 'livenet';

Expand Down Expand Up @@ -475,6 +470,11 @@ export function getWsUrl(
return WS_BASE_URL_MAP.contractUSDT.public[networkKey];
}
case WS_KEY_MAP.v5Private: {
// https://bybit-exchange.github.io/docs/v5/demo
if (isDemoTrading) {
return 'wss://stream-demo.bybit.com/v5/private';
}

return WS_BASE_URL_MAP.v5.private[networkKey];
}
case WS_KEY_MAP.v5SpotPublic: {
Expand Down

0 comments on commit bbf3a72

Please sign in to comment.