@xapy/orderbook 0.1.25 → 0.1.26
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/README.md +0 -1
- package/dist/exchanges/binance/index.d.cts +1 -1
- package/dist/exchanges/binance/index.d.ts +1 -1
- package/dist/exchanges/bingx/index.d.cts +1 -1
- package/dist/exchanges/bingx/index.d.ts +1 -1
- package/dist/exchanges/bitget/index.d.cts +1 -1
- package/dist/exchanges/bitget/index.d.ts +1 -1
- package/dist/exchanges/bybit/index.d.cts +1 -1
- package/dist/exchanges/bybit/index.d.ts +1 -1
- package/dist/exchanges/coinex/index.d.cts +1 -1
- package/dist/exchanges/coinex/index.d.ts +1 -1
- package/dist/exchanges/deribit/index.d.cts +1 -1
- package/dist/exchanges/deribit/index.d.ts +1 -1
- package/dist/exchanges/edgex/index.d.cts +1 -1
- package/dist/exchanges/edgex/index.d.ts +1 -1
- package/dist/exchanges/gate/index.d.cts +1 -1
- package/dist/exchanges/gate/index.d.ts +1 -1
- package/dist/exchanges/grvt/index.d.cts +1 -1
- package/dist/exchanges/grvt/index.d.ts +1 -1
- package/dist/exchanges/hyperliquid/index.d.cts +1 -1
- package/dist/exchanges/hyperliquid/index.d.ts +1 -1
- package/dist/exchanges/kucoin/index.d.cts +1 -1
- package/dist/exchanges/kucoin/index.d.ts +1 -1
- package/dist/exchanges/lighter/index.d.cts +1 -1
- package/dist/exchanges/lighter/index.d.ts +1 -1
- package/dist/exchanges/okx/index.d.cts +1 -1
- package/dist/exchanges/okx/index.d.ts +1 -1
- package/dist/index.cjs +8 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +9 -168
- package/dist/index.js.map +1 -1
- package/dist/{stream-CrvepB6m.d.cts → stream-YYPvjMV4.d.cts} +1 -1
- package/dist/{stream-CrvepB6m.d.ts → stream-YYPvjMV4.d.ts} +1 -1
- package/package.json +1 -11
- package/dist/exchanges/huobi/index.cjs +0 -589
- package/dist/exchanges/huobi/index.cjs.map +0 -1
- package/dist/exchanges/huobi/index.d.cts +0 -37
- package/dist/exchanges/huobi/index.d.ts +0 -37
- package/dist/exchanges/huobi/index.js +0 -585
- package/dist/exchanges/huobi/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -70,7 +70,6 @@ WebSocket connections are not subject to CORS and work directly in the browser.
|
|
|
70
70
|
| Gate | `@xapy/orderbook/gate` | ✅ | ✅ |
|
|
71
71
|
| CoinEx | `@xapy/orderbook/coinex` | ✅ | ✅ |
|
|
72
72
|
| BingX | `@xapy/orderbook/bingx` | ✅ | ✅ |
|
|
73
|
-
| Huobi | `@xapy/orderbook/huobi` | ✅ | ✅ |
|
|
74
73
|
| KuCoin | `@xapy/orderbook/kucoin` | ✅ | ✅ |
|
|
75
74
|
| Binance | `@xapy/orderbook/binance` | ✅ | ✅ (USDT-M) |
|
|
76
75
|
| Hyperliquid | `@xapy/orderbook/hyperliquid` | — | ✅ (USDC) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchBinanceOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchBinanceOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchBingxOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchBingxOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchBitgetOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchBitgetOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchBybitOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchBybitOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchCoinexOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchCoinexOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchDeribitOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchDeribitOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface EdgexMarketOptions {
|
|
4
4
|
timeoutMs?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface EdgexMarketOptions {
|
|
4
4
|
timeoutMs?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchGateOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchGateOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchGrvtOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchGrvtOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchHyperliquidOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchHyperliquidOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchKucoinOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchKucoinOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface LighterMarketOptions {
|
|
4
4
|
timeoutMs?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface LighterMarketOptions {
|
|
4
4
|
timeoutMs?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.cjs';
|
|
2
2
|
|
|
3
3
|
interface FetchOkxOrderbookOptions {
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-YYPvjMV4.js';
|
|
2
2
|
|
|
3
3
|
interface FetchOkxOrderbookOptions {
|
|
4
4
|
symbol: string;
|
package/dist/index.cjs
CHANGED
|
@@ -1440,167 +1440,8 @@ var BingxClient = class {
|
|
|
1440
1440
|
}
|
|
1441
1441
|
};
|
|
1442
1442
|
|
|
1443
|
-
// src/exchanges/huobi/symbols.ts
|
|
1444
|
-
var QUOTES3 = ["USDT", "USDC", "USD", "BTC", "ETH"];
|
|
1445
|
-
function toHuobiSymbol(symbol, market) {
|
|
1446
|
-
const [base, quote] = symbol.split("/");
|
|
1447
|
-
if (!base || !quote) {
|
|
1448
|
-
throw new Error(`invalid symbol "${symbol}" \u2014 expected "BASE/QUOTE"`);
|
|
1449
|
-
}
|
|
1450
|
-
return market === "spot" ? `${base}${quote}`.toLowerCase() : `${base}-${quote}`.toUpperCase();
|
|
1451
|
-
}
|
|
1452
|
-
function fromHuobiSymbol(s, market) {
|
|
1453
|
-
if (market === "spot") {
|
|
1454
|
-
const upper = s.toUpperCase();
|
|
1455
|
-
for (const q of QUOTES3) {
|
|
1456
|
-
if (upper.endsWith(q)) return `${upper.slice(0, -q.length)}/${q}`;
|
|
1457
|
-
}
|
|
1458
|
-
return upper;
|
|
1459
|
-
}
|
|
1460
|
-
return s.toUpperCase().replace("-", "/");
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
// src/exchanges/huobi/rest.ts
|
|
1464
|
-
var SPOT_BASE = "https://api.huobi.pro";
|
|
1465
|
-
var PERP_BASE = "https://api.hbdm.com";
|
|
1466
|
-
async function fetchHuobiOrderbook(opts) {
|
|
1467
|
-
const symbol = toHuobiSymbol(opts.symbol, opts.market);
|
|
1468
|
-
const step = opts.step ?? "step0";
|
|
1469
|
-
const url = opts.market === "spot" ? `${SPOT_BASE}/market/depth?symbol=${symbol}&type=${step}` : `${PERP_BASE}/linear-swap-ex/market/depth?contract_code=${symbol}&type=${step}`;
|
|
1470
|
-
const res = await httpJson({
|
|
1471
|
-
url,
|
|
1472
|
-
timeoutMs: opts.timeoutMs,
|
|
1473
|
-
transformUrl: opts.transformUrl
|
|
1474
|
-
});
|
|
1475
|
-
if (res.status !== "ok" || !res.tick) {
|
|
1476
|
-
throw new ExchangeError(
|
|
1477
|
-
"huobi",
|
|
1478
|
-
res["err-msg"] ?? res["err-code"] ?? "missing tick"
|
|
1479
|
-
);
|
|
1480
|
-
}
|
|
1481
|
-
const ts = res.tick.ts;
|
|
1482
|
-
return {
|
|
1483
|
-
exchange: "huobi",
|
|
1484
|
-
symbol: fromHuobiSymbol(symbol, opts.market),
|
|
1485
|
-
market: opts.market,
|
|
1486
|
-
bids: res.tick.bids.map(([p, s]) => ({ price: Number(p), size: Number(s) })),
|
|
1487
|
-
asks: res.tick.asks.map(([p, s]) => ({ price: Number(p), size: Number(s) })),
|
|
1488
|
-
timestamp: ts,
|
|
1489
|
-
sequence: res.tick.version ?? ts
|
|
1490
|
-
};
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
// src/exchanges/huobi/ws.ts
|
|
1494
|
-
var WS_SPOT4 = "wss://api.huobi.pro/ws";
|
|
1495
|
-
var WS_PERP = "wss://api.hbdm.com/linear-swap-ws";
|
|
1496
|
-
function streamHuobiOrderbook(opts) {
|
|
1497
|
-
const huobiSymbol = toHuobiSymbol(opts.symbol, opts.market);
|
|
1498
|
-
const step = opts.step ?? "step0";
|
|
1499
|
-
const channel = `market.${huobiSymbol}.depth.${step}`;
|
|
1500
|
-
const merger = new BookMerger();
|
|
1501
|
-
let ws = null;
|
|
1502
|
-
const stream = new OrderbookStream(() => ws?.close());
|
|
1503
|
-
const subscribePayload = JSON.stringify({
|
|
1504
|
-
sub: channel,
|
|
1505
|
-
id: `sub-${Date.now()}`
|
|
1506
|
-
});
|
|
1507
|
-
const handlePayload = (text) => {
|
|
1508
|
-
let msg;
|
|
1509
|
-
try {
|
|
1510
|
-
msg = JSON.parse(text);
|
|
1511
|
-
} catch {
|
|
1512
|
-
return;
|
|
1513
|
-
}
|
|
1514
|
-
if (typeof msg.ping === "number") {
|
|
1515
|
-
ws?.send(JSON.stringify({ pong: msg.ping }));
|
|
1516
|
-
return;
|
|
1517
|
-
}
|
|
1518
|
-
if (msg.status === "ok" && msg.subbed) return;
|
|
1519
|
-
if (msg.ch !== channel || !msg.tick) return;
|
|
1520
|
-
const ts = msg.tick.ts;
|
|
1521
|
-
const sequence = msg.tick.version ?? ts;
|
|
1522
|
-
const event = {
|
|
1523
|
-
kind: "snapshot",
|
|
1524
|
-
bids: msg.tick.bids.map(([p, s]) => ({
|
|
1525
|
-
price: Number(p),
|
|
1526
|
-
size: Number(s)
|
|
1527
|
-
})),
|
|
1528
|
-
asks: msg.tick.asks.map(([p, s]) => ({
|
|
1529
|
-
price: Number(p),
|
|
1530
|
-
size: Number(s)
|
|
1531
|
-
})),
|
|
1532
|
-
sequence,
|
|
1533
|
-
timestamp: ts
|
|
1534
|
-
};
|
|
1535
|
-
const r = merger.apply(event);
|
|
1536
|
-
if (!r.ok) return;
|
|
1537
|
-
const book = {
|
|
1538
|
-
exchange: "huobi",
|
|
1539
|
-
symbol: fromHuobiSymbol(huobiSymbol, opts.market),
|
|
1540
|
-
market: opts.market,
|
|
1541
|
-
bids: r.bids,
|
|
1542
|
-
asks: r.asks,
|
|
1543
|
-
timestamp: r.timestamp,
|
|
1544
|
-
sequence: r.sequence
|
|
1545
|
-
};
|
|
1546
|
-
stream.emit("update", book);
|
|
1547
|
-
};
|
|
1548
|
-
const onMessage = async (raw) => {
|
|
1549
|
-
if (typeof raw === "string") {
|
|
1550
|
-
handlePayload(raw);
|
|
1551
|
-
return;
|
|
1552
|
-
}
|
|
1553
|
-
const inflate = await getGzipInflate();
|
|
1554
|
-
handlePayload(inflate(raw));
|
|
1555
|
-
};
|
|
1556
|
-
ws = new WSClient({
|
|
1557
|
-
url: opts.market === "spot" ? WS_SPOT4 : WS_PERP,
|
|
1558
|
-
onOpen: (sock) => {
|
|
1559
|
-
merger.reset();
|
|
1560
|
-
sock.send(subscribePayload);
|
|
1561
|
-
},
|
|
1562
|
-
onMessage
|
|
1563
|
-
// Huobi heartbeat is server-initiated; we reply inline above. No client ping.
|
|
1564
|
-
});
|
|
1565
|
-
ws.on("open", () => stream.emit("connected"));
|
|
1566
|
-
ws.on("close", (r) => stream.emit("disconnected", r));
|
|
1567
|
-
ws.on("reconnecting", (a, w) => stream.emit("reconnecting", a, w));
|
|
1568
|
-
ws.on("error", (e) => stream.emit("error", e));
|
|
1569
|
-
ws.connect().catch((e) => stream.emit("error", e));
|
|
1570
|
-
return stream;
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
// src/exchanges/huobi/index.ts
|
|
1574
|
-
var HuobiClient = class {
|
|
1575
|
-
exchange = "huobi";
|
|
1576
|
-
transformUrl;
|
|
1577
|
-
timeoutMs;
|
|
1578
|
-
constructor(opts = {}) {
|
|
1579
|
-
this.transformUrl = opts.transformUrl;
|
|
1580
|
-
this.timeoutMs = opts.timeoutMs;
|
|
1581
|
-
}
|
|
1582
|
-
fetchOrderbook(symbol, _opts = {}) {
|
|
1583
|
-
const { pair, market } = parseSymbol(symbol);
|
|
1584
|
-
return fetchHuobiOrderbook({
|
|
1585
|
-
symbol: pair,
|
|
1586
|
-
market,
|
|
1587
|
-
timeoutMs: this.timeoutMs,
|
|
1588
|
-
transformUrl: this.transformUrl
|
|
1589
|
-
});
|
|
1590
|
-
}
|
|
1591
|
-
streamOrderbook(symbol, _opts = {}) {
|
|
1592
|
-
const { pair, market } = parseSymbol(symbol);
|
|
1593
|
-
return streamHuobiOrderbook({
|
|
1594
|
-
symbol: pair,
|
|
1595
|
-
market,
|
|
1596
|
-
transformUrl: this.transformUrl,
|
|
1597
|
-
timeoutMs: this.timeoutMs
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
};
|
|
1601
|
-
|
|
1602
1443
|
// src/exchanges/coinex/symbols.ts
|
|
1603
|
-
var
|
|
1444
|
+
var QUOTES3 = ["USDT", "USDC", "USD"];
|
|
1604
1445
|
function toCoinexSymbol(symbol) {
|
|
1605
1446
|
const [base, quote] = symbol.split("/");
|
|
1606
1447
|
if (!base || !quote) {
|
|
@@ -1610,7 +1451,7 @@ function toCoinexSymbol(symbol) {
|
|
|
1610
1451
|
}
|
|
1611
1452
|
function fromCoinexSymbol(s) {
|
|
1612
1453
|
const upper = s.toUpperCase();
|
|
1613
|
-
for (const q of
|
|
1454
|
+
for (const q of QUOTES3) {
|
|
1614
1455
|
if (upper.endsWith(q)) {
|
|
1615
1456
|
return `${upper.slice(0, -q.length)}/${q}`;
|
|
1616
1457
|
}
|
|
@@ -1645,7 +1486,7 @@ async function fetchCoinexOrderbook(opts) {
|
|
|
1645
1486
|
}
|
|
1646
1487
|
|
|
1647
1488
|
// src/exchanges/coinex/ws.ts
|
|
1648
|
-
var
|
|
1489
|
+
var WS_SPOT4 = "wss://socket.coinex.com/v2/spot";
|
|
1649
1490
|
var WS_FUTURES2 = "wss://socket.coinex.com/v2/futures";
|
|
1650
1491
|
function streamCoinexOrderbook(opts) {
|
|
1651
1492
|
const market = toCoinexSymbol(opts.symbol);
|
|
@@ -1757,7 +1598,7 @@ function streamCoinexOrderbook(opts) {
|
|
|
1757
1598
|
handlePayload(inflate(raw));
|
|
1758
1599
|
};
|
|
1759
1600
|
ws = new WSClient({
|
|
1760
|
-
url: opts.market === "spot" ?
|
|
1601
|
+
url: opts.market === "spot" ? WS_SPOT4 : WS_FUTURES2,
|
|
1761
1602
|
onOpen: (sock) => {
|
|
1762
1603
|
merger.reset();
|
|
1763
1604
|
lastMerged = null;
|
|
@@ -2028,7 +1869,7 @@ var OkxClient = class {
|
|
|
2028
1869
|
};
|
|
2029
1870
|
|
|
2030
1871
|
// src/exchanges/binance/symbols.ts
|
|
2031
|
-
var
|
|
1872
|
+
var QUOTES4 = [
|
|
2032
1873
|
"USDT",
|
|
2033
1874
|
"USDC",
|
|
2034
1875
|
"FDUSD",
|
|
@@ -2048,7 +1889,7 @@ function toBinanceSymbol(symbol) {
|
|
|
2048
1889
|
}
|
|
2049
1890
|
function fromBinanceSymbol(s) {
|
|
2050
1891
|
const upper = s.toUpperCase();
|
|
2051
|
-
for (const q of
|
|
1892
|
+
for (const q of QUOTES4) {
|
|
2052
1893
|
if (upper.endsWith(q) && upper.length > q.length) {
|
|
2053
1894
|
return `${upper.slice(0, -q.length)}/${q}`;
|
|
2054
1895
|
}
|
|
@@ -2080,13 +1921,13 @@ async function fetchBinanceOrderbook(opts) {
|
|
|
2080
1921
|
}
|
|
2081
1922
|
|
|
2082
1923
|
// src/exchanges/binance/ws.ts
|
|
2083
|
-
var
|
|
1924
|
+
var WS_SPOT5 = "wss://stream.binance.com:9443/ws";
|
|
2084
1925
|
var WS_FUTURES3 = "wss://fstream.binance.com/ws";
|
|
2085
1926
|
function streamBinanceOrderbook(opts) {
|
|
2086
1927
|
const symbol = toBinanceSymbol(opts.symbol);
|
|
2087
1928
|
const isSpot = opts.market === "spot";
|
|
2088
1929
|
const interval = opts.interval ?? "100ms";
|
|
2089
|
-
const wsBase = isSpot ?
|
|
1930
|
+
const wsBase = isSpot ? WS_SPOT5 : WS_FUTURES3;
|
|
2090
1931
|
const wsUrl = `${wsBase}/${symbol.toLowerCase()}@depth@${interval}`;
|
|
2091
1932
|
const merger = new BookMerger();
|
|
2092
1933
|
let snapshotId = -1;
|
|
@@ -3617,7 +3458,6 @@ exports.EdgexClient = EdgexClient;
|
|
|
3617
3458
|
exports.ExchangeError = ExchangeError;
|
|
3618
3459
|
exports.GateClient = GateClient;
|
|
3619
3460
|
exports.GrvtClient = GrvtClient;
|
|
3620
|
-
exports.HuobiClient = HuobiClient;
|
|
3621
3461
|
exports.HyperliquidClient = HyperliquidClient;
|
|
3622
3462
|
exports.KucoinClient = KucoinClient;
|
|
3623
3463
|
exports.LighterClient = LighterClient;
|