@tradejs/connectors 3.1.26 → 3.1.27-beta.245

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
@@ -1341,6 +1341,34 @@ var ByBitConnectorCreator = async (config, runtime) => {
1341
1341
  capturedAt: Date.now()
1342
1342
  };
1343
1343
  },
1344
+ getTopOfBookTicker: async (symbol) => {
1345
+ const client = await getPublicClient();
1346
+ const normalizedSymbol = String(symbol ?? "").trim().toUpperCase();
1347
+ if (!client || !normalizedSymbol) return null;
1348
+ const response = await client.getTickers({
1349
+ category: BYBIT_CATEGORY2,
1350
+ symbol: normalizedSymbol
1351
+ });
1352
+ if (response.retCode !== 0) return null;
1353
+ const row = response.result?.list?.find(
1354
+ (item) => String(item.symbol ?? "").toUpperCase() === normalizedSymbol
1355
+ );
1356
+ const bidPrice = toFiniteNumberOrNull(row?.bid1Price);
1357
+ const bidQty = toFiniteNumberOrNull(row?.bid1Size);
1358
+ const askPrice = toFiniteNumberOrNull(row?.ask1Price);
1359
+ const askQty = toFiniteNumberOrNull(row?.ask1Size);
1360
+ if (bidPrice == null || bidPrice <= 0 || bidQty == null || bidQty < 0 || askPrice == null || askPrice <= 0 || askQty == null || askQty < 0) {
1361
+ return null;
1362
+ }
1363
+ return {
1364
+ symbol: normalizedSymbol,
1365
+ bidPrice,
1366
+ bidQty,
1367
+ askPrice,
1368
+ askQty,
1369
+ timestamp: toFiniteNumberOrNull(response.time) ?? Date.now()
1370
+ };
1371
+ },
1344
1372
  getTickers: async (query = {}) => {
1345
1373
  const client = await getPublicClient();
1346
1374
  if (!client) {
package/dist/index.mjs CHANGED
@@ -1293,6 +1293,34 @@ var ByBitConnectorCreator = async (config, runtime) => {
1293
1293
  capturedAt: Date.now()
1294
1294
  };
1295
1295
  },
1296
+ getTopOfBookTicker: async (symbol) => {
1297
+ const client = await getPublicClient();
1298
+ const normalizedSymbol = String(symbol ?? "").trim().toUpperCase();
1299
+ if (!client || !normalizedSymbol) return null;
1300
+ const response = await client.getTickers({
1301
+ category: BYBIT_CATEGORY2,
1302
+ symbol: normalizedSymbol
1303
+ });
1304
+ if (response.retCode !== 0) return null;
1305
+ const row = response.result?.list?.find(
1306
+ (item) => String(item.symbol ?? "").toUpperCase() === normalizedSymbol
1307
+ );
1308
+ const bidPrice = toFiniteNumberOrNull(row?.bid1Price);
1309
+ const bidQty = toFiniteNumberOrNull(row?.bid1Size);
1310
+ const askPrice = toFiniteNumberOrNull(row?.ask1Price);
1311
+ const askQty = toFiniteNumberOrNull(row?.ask1Size);
1312
+ if (bidPrice == null || bidPrice <= 0 || bidQty == null || bidQty < 0 || askPrice == null || askPrice <= 0 || askQty == null || askQty < 0) {
1313
+ return null;
1314
+ }
1315
+ return {
1316
+ symbol: normalizedSymbol,
1317
+ bidPrice,
1318
+ bidQty,
1319
+ askPrice,
1320
+ askQty,
1321
+ timestamp: toFiniteNumberOrNull(response.time) ?? Date.now()
1322
+ };
1323
+ },
1296
1324
  getTickers: async (query = {}) => {
1297
1325
  const client = await getPublicClient();
1298
1326
  if (!client) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradejs/connectors",
3
- "version": "3.1.26",
3
+ "version": "3.1.27-beta.245",
4
4
  "description": "MIT-licensed exchange connectors and market data providers for the TradeJS framework.",
5
5
  "keywords": [
6
6
  "tradejs",
@@ -39,8 +39,8 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@tradejs/core": "^3.1.26",
43
- "@tradejs/types": "^3.1.26",
42
+ "@tradejs/core": "^3.1.27-beta.245",
43
+ "@tradejs/types": "^3.1.27-beta.245",
44
44
  "bybit-api": "^4.7.1",
45
45
  "chalk": "4.1.2",
46
46
  "lodash": "^4.18.1"