@xapy/orderbook 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1054,10 +1054,14 @@ function toBingxSymbol(symbol) {
1054
1054
  if (!base || !quote) {
1055
1055
  throw new Error(`invalid symbol "${symbol}" \u2014 expected "BASE/QUOTE"`);
1056
1056
  }
1057
- return `${base}-${quote}`.toUpperCase();
1057
+ return `${base}_${quote}`.toUpperCase();
1058
+ }
1059
+ function toBingxTopic(symbol, market, depth = 0.1) {
1060
+ const prefix = market === "spot" ? "market-depth" : "swap-depth";
1061
+ return `${prefix}.${toBingxSymbol(symbol)}.${depth}`;
1058
1062
  }
1059
1063
  function fromBingxSymbol(s) {
1060
- return s.toUpperCase().replace("-", "/");
1064
+ return s.toUpperCase().replace("_", "/");
1061
1065
  }
1062
1066
 
1063
1067
  // src/exchanges/bingx/rest.ts
@@ -1121,8 +1125,8 @@ var WS_SWAP = "wss://open-api-swap.bingx.com/swap-market";
1121
1125
  function streamBingxOrderbook(opts) {
1122
1126
  const isSpot = opts.market === "spot";
1123
1127
  const bingxSymbol = toBingxSymbol(opts.symbol);
1124
- const depth = opts.depth ?? 20;
1125
- const dataType = `${bingxSymbol}@depth${depth}`;
1128
+ const depth = opts.depth ?? 0.1;
1129
+ const dataType = toBingxTopic(opts.symbol, opts.market, depth);
1126
1130
  const merger = new BookMerger();
1127
1131
  let ws = null;
1128
1132
  const stream = new OrderbookStream(() => ws?.close());