Skip to content

Commit fcb6ac8

Browse files
authored
Merge pull request #629 from tiagosiebler/optionsws
fix(v3.2.0): update options ws connectivity and example, audit dependency bump
2 parents 230ee73 + d9a107f commit fcb6ac8

File tree

4 files changed

+44
-27
lines changed

4 files changed

+44
-27
lines changed

examples/WebSockets/ws-public.ts

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -279,29 +279,45 @@ import {
279279
);
280280

281281
/**
282-
* Subscribe to each available european options market data websocket topic, the new way:
283-
*
284-
* https://developers.binance.com/docs/derivatives/option/websocket-market-streams/New-Symbol-Info
282+
* Subscribe to each available options market data websocket topic, the new way:
285283
*
284+
* https://developers.binance.com/docs/derivatives/options-trading/websocket-market-streams/New-Symbol-Info
286285
* https://eapi.binance.com/eapi/v1/exchangeInfo
287286
*/
288-
const optionsAsset = 'ETH';
289-
const optionsExpiration = '250328';
290-
const optionsSymbol = 'BTC-250328-140000-C';
287+
288+
const optionsAsset = 'ethusdt';
289+
const optionsExpiration = '260128'; // YYMMDD
290+
const optionsSymbol = 'ETH-260128-3000-C';
291+
const optionsSymbol2 = 'ETH-260129-2950-C';
292+
const KlineInterval = '1m';
291293
await wsClient.subscribe(
292294
[
293-
'option_pair',
295+
'!optionSymbol',
294296
`${optionsAsset}@openInterest@${optionsExpiration}`,
295-
`${optionsAsset}@markPrice`,
296-
`${optionsSymbol}@kline_1m`,
297-
`${optionsAsset}@ticker@${optionsExpiration}`,
298-
`${symbol}@index`,
299-
`${optionsAsset}@trade`,
300-
`${optionsSymbol}@depth100`,
297+
`${optionsAsset}@optionMarkPrice`,
298+
`${optionsSymbol}@kline_${KlineInterval}`,
299+
`${optionsSymbol2}@kline_${KlineInterval}`,
300+
'!index@arr',
301+
`${symbol}@bookTicker`,
302+
`${symbol}@optionTicker`,
303+
`${symbol}@optionTrade`,
304+
`${symbol}@depth5@100ms`,
305+
`${symbol}@depth@100ms`,
301306
],
302307
'eoptions',
303308
);
304309

310+
// You can send raw commands, such as asking for list of active subscriptions after 5 seconds. Use with caution:
311+
// setTimeout(() => {
312+
// wsClient.tryWsSend(
313+
// 'eoptions',
314+
// JSON.stringify({
315+
// method: 'LIST_SUBSCRIPTIONS',
316+
// id: Date.now(),
317+
// }),
318+
// );
319+
// }, 1000 * 5);
320+
305321
// /**
306322
// *
307323
// * For those that used the Node.js Binance SDK before the v3 release, you can

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "binance",
3-
"version": "3.1.9",
3+
"version": "3.2.0",
44
"description": "Professional Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/util/websockets/websocket-util.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ export const WS_KEY_URL_MAP: Record<WsKey, string> = {
167167
coinmWSAPI: 'wss://ws-dapi.binance.com',
168168
coinmWSAPITestnet: 'coinmWSAPITestnet',
169169

170-
// https://developers.binance.com/docs/derivatives/option/websocket-market-streams
171-
// https://developers.binance.com/docs/derivatives/option/user-data-streams
172-
eoptions: 'wss://nbstream.binance.com/eoptions',
170+
// https://developers.binance.com/docs/derivatives/options-trading/websocket-market-streams
171+
// https://developers.binance.com/docs/derivatives/options-trading/user-data-streams
172+
eoptions: 'wss://fstream.binance.com',
173+
// eoptions: 'wss://nbstream.binance.com/eoptions',
173174
// optionsTestnet: 'wss://testnetws.binanceops.com',
174175

175176
// https://developers.binance.com/docs/derivatives/portfolio-margin/user-data-streams
@@ -303,9 +304,9 @@ export function getWsURLSuffix(
303304
case 'eoptions':
304305
switch (connectionType) {
305306
case 'market':
306-
return '/stream';
307+
return '/market/stream';
307308
case 'userData':
308-
return '/ws';
309+
return '/private/ws';
309310
default: {
310311
throw neverGuard(
311312
connectionType,

0 commit comments

Comments
 (0)