@xapy/orderbook 0.1.9 → 0.1.21
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/exchanges/bitmart/index.cjs +12 -7
- package/dist/exchanges/bitmart/index.cjs.map +1 -1
- package/dist/exchanges/bitmart/index.d.cts +24 -12
- package/dist/exchanges/bitmart/index.d.ts +24 -12
- package/dist/exchanges/bitmart/index.js +12 -7
- package/dist/exchanges/bitmart/index.js.map +1 -1
- package/dist/index.cjs +12 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2633,7 +2633,9 @@ function streamBitmartOrderbook(opts) {
|
|
|
2633
2633
|
);
|
|
2634
2634
|
}
|
|
2635
2635
|
const symbol = toBitmartSymbol(opts.symbol);
|
|
2636
|
-
const
|
|
2636
|
+
const level = snapLevel(opts.depth);
|
|
2637
|
+
const interval = opts.interval ?? "200ms";
|
|
2638
|
+
const channelArg = `futures/depthAll${level}:${symbol}@${interval}`;
|
|
2637
2639
|
const merger = new BookMerger();
|
|
2638
2640
|
let ws = null;
|
|
2639
2641
|
const stream = new OrderbookStream(() => ws?.close());
|
|
@@ -2648,8 +2650,8 @@ function streamBitmartOrderbook(opts) {
|
|
|
2648
2650
|
kind: "snapshot",
|
|
2649
2651
|
bids: parseLevels4(frame.bids),
|
|
2650
2652
|
asks: parseLevels4(frame.asks),
|
|
2651
|
-
sequence: frame.
|
|
2652
|
-
timestamp: frame.
|
|
2653
|
+
sequence: frame.ms_t,
|
|
2654
|
+
timestamp: frame.ms_t
|
|
2653
2655
|
};
|
|
2654
2656
|
const r = merger.apply(event);
|
|
2655
2657
|
if (!r.ok) return;
|
|
@@ -2679,7 +2681,7 @@ function streamBitmartOrderbook(opts) {
|
|
|
2679
2681
|
);
|
|
2680
2682
|
return;
|
|
2681
2683
|
}
|
|
2682
|
-
if (msg.
|
|
2684
|
+
if (msg.group !== channelArg || !msg.data) return;
|
|
2683
2685
|
handleFrame(msg.data);
|
|
2684
2686
|
};
|
|
2685
2687
|
const onMessage = async (raw) => {
|
|
@@ -2707,12 +2709,15 @@ function streamBitmartOrderbook(opts) {
|
|
|
2707
2709
|
ws.connect().catch((e) => stream.emit("error", e));
|
|
2708
2710
|
return stream;
|
|
2709
2711
|
}
|
|
2712
|
+
function snapLevel(depth) {
|
|
2713
|
+
if (depth === 5) return 5;
|
|
2714
|
+
if (depth === 20) return 20;
|
|
2715
|
+
return 50;
|
|
2716
|
+
}
|
|
2710
2717
|
function parseLevels4(rows) {
|
|
2711
2718
|
if (!rows) return [];
|
|
2712
2719
|
const out = [];
|
|
2713
|
-
for (const
|
|
2714
|
-
out.push({ price: Number(row[0]), size: Number(row[1]) });
|
|
2715
|
-
}
|
|
2720
|
+
for (const r of rows) out.push({ price: Number(r.price), size: Number(r.vol) });
|
|
2716
2721
|
return out;
|
|
2717
2722
|
}
|
|
2718
2723
|
|