ccxt 4.4.90 → 4.4.91
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 +5 -6
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -4
- package/dist/cjs/src/base/Exchange.js +9 -11
- package/dist/cjs/src/base/ws/Client.js +4 -34
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/bitmex.js +2 -1
- package/dist/cjs/src/cex.js +61 -0
- package/dist/cjs/src/cryptocom.js +21 -2
- package/dist/cjs/src/cryptomus.js +1 -1
- package/dist/cjs/src/exmo.js +14 -7
- package/dist/cjs/src/fmfwio.js +1 -1
- package/dist/cjs/src/gate.js +2 -2
- package/dist/cjs/src/hyperliquid.js +115 -59
- package/dist/cjs/src/kraken.js +29 -1
- package/dist/cjs/src/mexc.js +1 -0
- package/dist/cjs/src/modetrade.js +2 -2
- package/dist/cjs/src/paradex.js +1 -1
- package/dist/cjs/src/pro/bitstamp.js +1 -1
- package/dist/cjs/src/pro/bybit.js +6 -143
- package/dist/cjs/src/pro/kraken.js +251 -264
- package/dist/cjs/src/pro/mexc.js +0 -1
- package/js/ccxt.d.ts +2 -5
- package/js/ccxt.js +2 -4
- package/js/src/base/Exchange.d.ts +2 -1
- package/js/src/base/Exchange.js +10 -12
- package/js/src/base/ws/Client.d.ts +0 -2
- package/js/src/base/ws/Client.js +4 -34
- package/js/src/binance.js +1 -1
- package/js/src/bitmex.js +2 -1
- package/js/src/cex.js +61 -0
- package/js/src/cryptocom.js +21 -2
- package/js/src/cryptomus.js +1 -1
- package/js/src/exmo.js +14 -7
- package/js/src/fmfwio.js +2 -2
- package/js/src/gate.js +2 -2
- package/js/src/hyperliquid.d.ts +1 -0
- package/js/src/hyperliquid.js +115 -59
- package/js/src/kraken.js +29 -1
- package/js/src/mexc.js +1 -0
- package/js/src/modetrade.js +2 -2
- package/js/src/p2b.d.ts +1 -2
- package/js/src/paradex.js +1 -1
- package/js/src/pro/bitstamp.js +1 -1
- package/js/src/pro/bybit.d.ts +0 -1
- package/js/src/pro/bybit.js +6 -143
- package/js/src/pro/kraken.d.ts +17 -17
- package/js/src/pro/kraken.js +251 -264
- package/js/src/pro/mexc.js +0 -1
- package/js/src/tradeogre.d.ts +1 -2
- package/package.json +1 -1
- package/js/src/abstract/coinlist.d.ts +0 -60
- package/js/src/abstract/coinlist.js +0 -11
- package/js/src/coinlist.d.ts +0 -384
- package/js/src/coinlist.js +0 -2610
package/js/src/hyperliquid.js
CHANGED
|
@@ -48,6 +48,7 @@ export default class hyperliquid extends Exchange {
|
|
|
48
48
|
'createMarketBuyOrderWithCost': false,
|
|
49
49
|
'createMarketOrderWithCost': false,
|
|
50
50
|
'createMarketSellOrderWithCost': false,
|
|
51
|
+
'createOrderWithTakeProfitAndStopLoss': true,
|
|
51
52
|
'createOrder': true,
|
|
52
53
|
'createOrders': true,
|
|
53
54
|
'createReduceOnlyOrder': true,
|
|
@@ -231,7 +232,16 @@ export default class hyperliquid extends Exchange {
|
|
|
231
232
|
'triggerDirection': false,
|
|
232
233
|
'stopLossPrice': false,
|
|
233
234
|
'takeProfitPrice': false,
|
|
234
|
-
'attachedStopLossTakeProfit':
|
|
235
|
+
'attachedStopLossTakeProfit': {
|
|
236
|
+
'triggerPriceType': {
|
|
237
|
+
'last': false,
|
|
238
|
+
'mark': false,
|
|
239
|
+
'index': false,
|
|
240
|
+
},
|
|
241
|
+
'triggerPrice': true,
|
|
242
|
+
'type': true,
|
|
243
|
+
'price': true,
|
|
244
|
+
},
|
|
235
245
|
'timeInForce': {
|
|
236
246
|
'IOC': true,
|
|
237
247
|
'FOK': false,
|
|
@@ -1421,6 +1431,74 @@ export default class hyperliquid extends Exchange {
|
|
|
1421
1431
|
const statuses = this.safeList(data, 'statuses', []);
|
|
1422
1432
|
return this.parseOrders(statuses, undefined);
|
|
1423
1433
|
}
|
|
1434
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1435
|
+
const market = this.market(symbol);
|
|
1436
|
+
type = type.toUpperCase();
|
|
1437
|
+
side = side.toUpperCase();
|
|
1438
|
+
const isMarket = (type === 'MARKET');
|
|
1439
|
+
const isBuy = (side === 'BUY');
|
|
1440
|
+
const clientOrderId = this.safeString2(params, 'clientOrderId', 'client_id');
|
|
1441
|
+
const slippage = this.safeString(params, 'slippage');
|
|
1442
|
+
let defaultTimeInForce = (isMarket) ? 'ioc' : 'gtc';
|
|
1443
|
+
const postOnly = this.safeBool(params, 'postOnly', false);
|
|
1444
|
+
if (postOnly) {
|
|
1445
|
+
defaultTimeInForce = 'alo';
|
|
1446
|
+
}
|
|
1447
|
+
let timeInForce = this.safeStringLower(params, 'timeInForce', defaultTimeInForce);
|
|
1448
|
+
timeInForce = this.capitalize(timeInForce);
|
|
1449
|
+
let triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
|
|
1450
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice', triggerPrice);
|
|
1451
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
1452
|
+
const isTrigger = (stopLossPrice || takeProfitPrice);
|
|
1453
|
+
let px = undefined;
|
|
1454
|
+
if (isMarket) {
|
|
1455
|
+
if (price === undefined) {
|
|
1456
|
+
throw new ArgumentsRequired(this.id + ' market orders require price to calculate the max slippage price. Default slippage can be set in options (default is 5%).');
|
|
1457
|
+
}
|
|
1458
|
+
px = (isBuy) ? Precise.stringMul(price, Precise.stringAdd('1', slippage)) : Precise.stringMul(price, Precise.stringSub('1', slippage));
|
|
1459
|
+
px = this.priceToPrecision(symbol, px); // round after adding slippage
|
|
1460
|
+
}
|
|
1461
|
+
else {
|
|
1462
|
+
px = this.priceToPrecision(symbol, price);
|
|
1463
|
+
}
|
|
1464
|
+
const sz = this.amountToPrecision(symbol, amount);
|
|
1465
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly', false);
|
|
1466
|
+
const orderType = {};
|
|
1467
|
+
if (isTrigger) {
|
|
1468
|
+
let isTp = false;
|
|
1469
|
+
if (takeProfitPrice !== undefined) {
|
|
1470
|
+
triggerPrice = this.priceToPrecision(symbol, takeProfitPrice);
|
|
1471
|
+
isTp = true;
|
|
1472
|
+
}
|
|
1473
|
+
else {
|
|
1474
|
+
triggerPrice = this.priceToPrecision(symbol, stopLossPrice);
|
|
1475
|
+
}
|
|
1476
|
+
orderType['trigger'] = {
|
|
1477
|
+
'isMarket': isMarket,
|
|
1478
|
+
'triggerPx': triggerPrice,
|
|
1479
|
+
'tpsl': (isTp) ? 'tp' : 'sl',
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
else {
|
|
1483
|
+
orderType['limit'] = {
|
|
1484
|
+
'tif': timeInForce,
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
params = this.omit(params, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id', 'reduceOnly', 'postOnly']);
|
|
1488
|
+
const orderObj = {
|
|
1489
|
+
'a': this.parseToInt(market['baseId']),
|
|
1490
|
+
'b': isBuy,
|
|
1491
|
+
'p': px,
|
|
1492
|
+
's': sz,
|
|
1493
|
+
'r': reduceOnly,
|
|
1494
|
+
't': orderType,
|
|
1495
|
+
// 'c': clientOrderId,
|
|
1496
|
+
};
|
|
1497
|
+
if (clientOrderId !== undefined) {
|
|
1498
|
+
orderObj['c'] = clientOrderId;
|
|
1499
|
+
}
|
|
1500
|
+
return orderObj;
|
|
1501
|
+
}
|
|
1424
1502
|
createOrdersRequest(orders, params = {}) {
|
|
1425
1503
|
/**
|
|
1426
1504
|
* @method
|
|
@@ -1455,79 +1533,57 @@ export default class hyperliquid extends Exchange {
|
|
|
1455
1533
|
params = this.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce']);
|
|
1456
1534
|
const nonce = this.milliseconds();
|
|
1457
1535
|
const orderReq = [];
|
|
1536
|
+
let grouping = 'na';
|
|
1458
1537
|
for (let i = 0; i < orders.length; i++) {
|
|
1459
1538
|
const rawOrder = orders[i];
|
|
1460
1539
|
const marketId = this.safeString(rawOrder, 'symbol');
|
|
1461
1540
|
const market = this.market(marketId);
|
|
1462
1541
|
const symbol = market['symbol'];
|
|
1463
1542
|
const type = this.safeStringUpper(rawOrder, 'type');
|
|
1464
|
-
const isMarket = (type === 'MARKET');
|
|
1465
1543
|
const side = this.safeStringUpper(rawOrder, 'side');
|
|
1466
|
-
const isBuy = (side === 'BUY');
|
|
1467
1544
|
const amount = this.safeString(rawOrder, 'amount');
|
|
1468
1545
|
const price = this.safeString(rawOrder, 'price');
|
|
1469
1546
|
let orderParams = this.safeDict(rawOrder, 'params', {});
|
|
1470
|
-
const clientOrderId = this.safeString2(orderParams, 'clientOrderId', 'client_id');
|
|
1471
1547
|
const slippage = this.safeString(orderParams, 'slippage', defaultSlippage);
|
|
1472
|
-
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
let triggerPrice = this.safeString2(orderParams, 'triggerPrice', 'stopPrice');
|
|
1480
|
-
const stopLossPrice = this.safeString(orderParams, 'stopLossPrice', triggerPrice);
|
|
1481
|
-
const takeProfitPrice = this.safeString(orderParams, 'takeProfitPrice');
|
|
1482
|
-
const isTrigger = (stopLossPrice || takeProfitPrice);
|
|
1483
|
-
let px = undefined;
|
|
1484
|
-
if (isMarket) {
|
|
1485
|
-
if (price === undefined) {
|
|
1486
|
-
throw new ArgumentsRequired(this.id + ' market orders require price to calculate the max slippage price. Default slippage can be set in options (default is 5%).');
|
|
1487
|
-
}
|
|
1488
|
-
px = (isBuy) ? Precise.stringMul(price, Precise.stringAdd('1', slippage)) : Precise.stringMul(price, Precise.stringSub('1', slippage));
|
|
1489
|
-
px = this.priceToPrecision(symbol, px); // round after adding slippage
|
|
1490
|
-
}
|
|
1491
|
-
else {
|
|
1492
|
-
px = this.priceToPrecision(symbol, price);
|
|
1493
|
-
}
|
|
1494
|
-
const sz = this.amountToPrecision(symbol, amount);
|
|
1495
|
-
const reduceOnly = this.safeBool(orderParams, 'reduceOnly', false);
|
|
1496
|
-
const orderType = {};
|
|
1548
|
+
orderParams['slippage'] = slippage;
|
|
1549
|
+
const stopLoss = this.safeValue(orderParams, 'stopLoss');
|
|
1550
|
+
const takeProfit = this.safeValue(orderParams, 'takeProfit');
|
|
1551
|
+
const isTrigger = (stopLoss || takeProfit);
|
|
1552
|
+
orderParams = this.omit(orderParams, ['stopLoss', 'takeProfit']);
|
|
1553
|
+
const mainOrderObj = this.createOrderRequest(symbol, type, side, amount, price, orderParams);
|
|
1554
|
+
orderReq.push(mainOrderObj);
|
|
1497
1555
|
if (isTrigger) {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1556
|
+
// grouping opposed orders for sl/tp
|
|
1557
|
+
const stopLossOrderTriggerPrice = this.safeStringN(stopLoss, ['triggerPrice', 'stopPrice']);
|
|
1558
|
+
const stopLossOrderType = this.safeString(stopLoss, 'type');
|
|
1559
|
+
const stopLossOrderLimitPrice = this.safeStringN(stopLoss, ['price', 'stopLossPrice'], stopLossOrderTriggerPrice);
|
|
1560
|
+
const takeProfitOrderTriggerPrice = this.safeStringN(takeProfit, ['triggerPrice', 'stopPrice']);
|
|
1561
|
+
const takeProfitOrderType = this.safeString(takeProfit, 'type');
|
|
1562
|
+
const takeProfitOrderLimitPrice = this.safeStringN(takeProfit, ['price', 'takeProfitPrice'], takeProfitOrderTriggerPrice);
|
|
1563
|
+
grouping = 'normalTpsl';
|
|
1564
|
+
orderParams = this.omit(orderParams, ['stopLoss', 'takeProfit']);
|
|
1565
|
+
let triggerOrderSide = '';
|
|
1566
|
+
if (side === 'BUY') {
|
|
1567
|
+
triggerOrderSide = 'sell';
|
|
1502
1568
|
}
|
|
1503
1569
|
else {
|
|
1504
|
-
|
|
1570
|
+
triggerOrderSide = 'buy';
|
|
1571
|
+
}
|
|
1572
|
+
if (takeProfit !== undefined) {
|
|
1573
|
+
const orderObj = this.createOrderRequest(symbol, takeProfitOrderType, triggerOrderSide, amount, takeProfitOrderLimitPrice, this.extend(orderParams, {
|
|
1574
|
+
'takeProfitPrice': takeProfitOrderTriggerPrice,
|
|
1575
|
+
'reduceOnly': true,
|
|
1576
|
+
}));
|
|
1577
|
+
orderReq.push(orderObj);
|
|
1578
|
+
}
|
|
1579
|
+
if (stopLoss !== undefined) {
|
|
1580
|
+
const orderObj = this.createOrderRequest(symbol, stopLossOrderType, triggerOrderSide, amount, stopLossOrderLimitPrice, this.extend(orderParams, {
|
|
1581
|
+
'stopLossPrice': stopLossOrderTriggerPrice,
|
|
1582
|
+
'reduceOnly': true,
|
|
1583
|
+
}));
|
|
1584
|
+
orderReq.push(orderObj);
|
|
1505
1585
|
}
|
|
1506
|
-
orderType['trigger'] = {
|
|
1507
|
-
'isMarket': isMarket,
|
|
1508
|
-
'triggerPx': triggerPrice,
|
|
1509
|
-
'tpsl': (isTp) ? 'tp' : 'sl',
|
|
1510
|
-
};
|
|
1511
|
-
}
|
|
1512
|
-
else {
|
|
1513
|
-
orderType['limit'] = {
|
|
1514
|
-
'tif': timeInForce,
|
|
1515
|
-
};
|
|
1516
|
-
}
|
|
1517
|
-
orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id', 'reduceOnly', 'postOnly']);
|
|
1518
|
-
const orderObj = {
|
|
1519
|
-
'a': this.parseToInt(market['baseId']),
|
|
1520
|
-
'b': isBuy,
|
|
1521
|
-
'p': px,
|
|
1522
|
-
's': sz,
|
|
1523
|
-
'r': reduceOnly,
|
|
1524
|
-
't': orderType,
|
|
1525
|
-
// 'c': clientOrderId,
|
|
1526
|
-
};
|
|
1527
|
-
if (clientOrderId !== undefined) {
|
|
1528
|
-
orderObj['c'] = clientOrderId;
|
|
1529
1586
|
}
|
|
1530
|
-
orderReq.push(orderObj);
|
|
1531
1587
|
}
|
|
1532
1588
|
let vaultAddress = undefined;
|
|
1533
1589
|
[vaultAddress, params] = this.handleOptionAndParams(params, 'createOrder', 'vaultAddress');
|
|
@@ -1535,7 +1591,7 @@ export default class hyperliquid extends Exchange {
|
|
|
1535
1591
|
const orderAction = {
|
|
1536
1592
|
'type': 'order',
|
|
1537
1593
|
'orders': orderReq,
|
|
1538
|
-
'grouping':
|
|
1594
|
+
'grouping': grouping,
|
|
1539
1595
|
// 'brokerCode': 1, // cant
|
|
1540
1596
|
};
|
|
1541
1597
|
if (vaultAddress === undefined) {
|
package/js/src/kraken.js
CHANGED
|
@@ -1383,7 +1383,20 @@ export default class kraken extends Exchange {
|
|
|
1383
1383
|
// "maker": false
|
|
1384
1384
|
// }
|
|
1385
1385
|
//
|
|
1386
|
+
// watchTrades
|
|
1387
|
+
//
|
|
1388
|
+
// {
|
|
1389
|
+
// "symbol": "BTC/USD",
|
|
1390
|
+
// "side": "buy",
|
|
1391
|
+
// "price": 109601.2,
|
|
1392
|
+
// "qty": 0.04561994,
|
|
1393
|
+
// "ord_type": "market",
|
|
1394
|
+
// "trade_id": 83449369,
|
|
1395
|
+
// "timestamp": "2025-05-27T11:24:03.847761Z"
|
|
1396
|
+
// }
|
|
1397
|
+
//
|
|
1386
1398
|
let timestamp = undefined;
|
|
1399
|
+
let datetime = undefined;
|
|
1387
1400
|
let side = undefined;
|
|
1388
1401
|
let type = undefined;
|
|
1389
1402
|
let price = undefined;
|
|
@@ -1434,6 +1447,15 @@ export default class kraken extends Exchange {
|
|
|
1434
1447
|
};
|
|
1435
1448
|
}
|
|
1436
1449
|
}
|
|
1450
|
+
else {
|
|
1451
|
+
symbol = this.safeString(trade, 'symbol');
|
|
1452
|
+
datetime = this.safeString(trade, 'timestamp');
|
|
1453
|
+
id = this.safeString(trade, 'trade_id');
|
|
1454
|
+
side = this.safeString(trade, 'side');
|
|
1455
|
+
type = this.safeString(trade, 'ord_type');
|
|
1456
|
+
price = this.safeString(trade, 'price');
|
|
1457
|
+
amount = this.safeString(trade, 'qty');
|
|
1458
|
+
}
|
|
1437
1459
|
if (market !== undefined) {
|
|
1438
1460
|
symbol = market['symbol'];
|
|
1439
1461
|
}
|
|
@@ -1443,12 +1465,18 @@ export default class kraken extends Exchange {
|
|
|
1443
1465
|
if (maker !== undefined) {
|
|
1444
1466
|
takerOrMaker = maker ? 'maker' : 'taker';
|
|
1445
1467
|
}
|
|
1468
|
+
if (datetime === undefined) {
|
|
1469
|
+
datetime = this.iso8601(timestamp);
|
|
1470
|
+
}
|
|
1471
|
+
else {
|
|
1472
|
+
timestamp = this.parse8601(datetime);
|
|
1473
|
+
}
|
|
1446
1474
|
return this.safeTrade({
|
|
1447
1475
|
'id': id,
|
|
1448
1476
|
'order': orderId,
|
|
1449
1477
|
'info': trade,
|
|
1450
1478
|
'timestamp': timestamp,
|
|
1451
|
-
'datetime':
|
|
1479
|
+
'datetime': datetime,
|
|
1452
1480
|
'symbol': symbol,
|
|
1453
1481
|
'type': type,
|
|
1454
1482
|
'side': side,
|
package/js/src/mexc.js
CHANGED
package/js/src/modetrade.js
CHANGED
|
@@ -1705,7 +1705,7 @@ export default class modetrade extends Exchange {
|
|
|
1705
1705
|
//
|
|
1706
1706
|
// {
|
|
1707
1707
|
// "success": true,
|
|
1708
|
-
// "timestamp":
|
|
1708
|
+
// "timestamp": 1702989203988,
|
|
1709
1709
|
// "data": {
|
|
1710
1710
|
// "status": "CANCEL_SENT"
|
|
1711
1711
|
// }
|
|
@@ -1713,7 +1713,7 @@ export default class modetrade extends Exchange {
|
|
|
1713
1713
|
//
|
|
1714
1714
|
// {
|
|
1715
1715
|
// "success": true,
|
|
1716
|
-
// "timestamp":
|
|
1716
|
+
// "timestamp": 1702989203988,
|
|
1717
1717
|
// "status": "CANCEL_SENT"
|
|
1718
1718
|
// }
|
|
1719
1719
|
//
|
package/js/src/p2b.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Market } from '../ccxt.js';
|
|
2
1
|
import Exchange from './abstract/p2b.js';
|
|
3
|
-
import type { Dict, Int, Num, OHLCV, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers, int } from './base/types.js';
|
|
2
|
+
import type { Dict, Int, Num, OHLCV, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers, int, Market } from './base/types.js';
|
|
4
3
|
/**
|
|
5
4
|
* @class p2b
|
|
6
5
|
* @augments Exchange
|
package/js/src/paradex.js
CHANGED
|
@@ -792,7 +792,7 @@ export default class paradex extends Exchange {
|
|
|
792
792
|
// "ask": "69578.2",
|
|
793
793
|
// "volume_24h": "5815541.397939004",
|
|
794
794
|
// "total_volume": "584031465.525259686",
|
|
795
|
-
// "created_at":
|
|
795
|
+
// "created_at": 1718170156581,
|
|
796
796
|
// "underlying_price": "67367.37268422",
|
|
797
797
|
// "open_interest": "162.272",
|
|
798
798
|
// "funding_rate": "0.01629574927887",
|
package/js/src/pro/bitstamp.js
CHANGED
|
@@ -523,7 +523,7 @@ export default class bitstamp extends bitstampRest {
|
|
|
523
523
|
//
|
|
524
524
|
const sessionToken = this.safeString(response, 'token');
|
|
525
525
|
if (sessionToken !== undefined) {
|
|
526
|
-
const userId = this.
|
|
526
|
+
const userId = this.safeString(response, 'user_id');
|
|
527
527
|
const validity = this.safeIntegerProduct(response, 'valid_sec', 1000);
|
|
528
528
|
this.options['expiresIn'] = this.sum(time, validity);
|
|
529
529
|
this.options['userId'] = userId;
|
package/js/src/pro/bybit.d.ts
CHANGED
|
@@ -360,7 +360,6 @@ export default class bybit extends bybitRest {
|
|
|
360
360
|
unWatchOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
361
361
|
handleOrderWs(client: Client, message: any): void;
|
|
362
362
|
handleOrder(client: Client, message: any): void;
|
|
363
|
-
parseWsSpotOrder(order: any, market?: any): Order;
|
|
364
363
|
/**
|
|
365
364
|
* @method
|
|
366
365
|
* @name bybit#watchBalance
|
package/js/src/pro/bybit.js
CHANGED
|
@@ -1870,13 +1870,12 @@ export default class bybit extends bybitRest {
|
|
|
1870
1870
|
}
|
|
1871
1871
|
const symbols = {};
|
|
1872
1872
|
for (let i = 0; i < rawOrders.length; i++) {
|
|
1873
|
-
|
|
1874
|
-
if (isSpot) {
|
|
1875
|
-
|
|
1876
|
-
}
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
}
|
|
1873
|
+
const parsed = this.parseOrder(rawOrders[i]);
|
|
1874
|
+
// if (isSpot) {
|
|
1875
|
+
// parsed = this.parseWsSpotOrder (rawOrders[i]);
|
|
1876
|
+
// } else {
|
|
1877
|
+
// parsed = this.parseOrder (rawOrders[i]);
|
|
1878
|
+
// }
|
|
1880
1879
|
const symbol = parsed['symbol'];
|
|
1881
1880
|
symbols[symbol] = true;
|
|
1882
1881
|
orders.append(parsed);
|
|
@@ -1889,142 +1888,6 @@ export default class bybit extends bybitRest {
|
|
|
1889
1888
|
const messageHash = 'orders';
|
|
1890
1889
|
client.resolve(orders, messageHash);
|
|
1891
1890
|
}
|
|
1892
|
-
parseWsSpotOrder(order, market = undefined) {
|
|
1893
|
-
//
|
|
1894
|
-
// {
|
|
1895
|
-
// "e": "executionReport",
|
|
1896
|
-
// "E": "1653297251061", // timestamp
|
|
1897
|
-
// "s": "LTCUSDT", // symbol
|
|
1898
|
-
// "c": "1653297250740", // user id
|
|
1899
|
-
// "S": "SELL", // side
|
|
1900
|
-
// "o": "MARKET_OF_BASE", // order type
|
|
1901
|
-
// "f": "GTC", // time in force
|
|
1902
|
-
// "q": "0.16233", // quantity
|
|
1903
|
-
// "p": "0", // price
|
|
1904
|
-
// "X": "NEW", // status
|
|
1905
|
-
// "i": "1162336018974750208", // order id
|
|
1906
|
-
// "M": "0",
|
|
1907
|
-
// "l": "0", // last filled
|
|
1908
|
-
// "z": "0", // total filled
|
|
1909
|
-
// "L": "0", // last traded price
|
|
1910
|
-
// "n": "0", // trading fee
|
|
1911
|
-
// "N": '', // fee asset
|
|
1912
|
-
// "u": true,
|
|
1913
|
-
// "w": true,
|
|
1914
|
-
// "m": false, // is limit_maker
|
|
1915
|
-
// "O": "1653297251042", // order creation
|
|
1916
|
-
// "Z": "0", // total filled
|
|
1917
|
-
// "A": "0", // account id
|
|
1918
|
-
// "C": false, // is close
|
|
1919
|
-
// "v": "0", // leverage
|
|
1920
|
-
// "d": "NO_LIQ"
|
|
1921
|
-
// }
|
|
1922
|
-
// v5
|
|
1923
|
-
// {
|
|
1924
|
-
// "category":"spot",
|
|
1925
|
-
// "symbol":"LTCUSDT",
|
|
1926
|
-
// "orderId":"1474764674982492160",
|
|
1927
|
-
// "orderLinkId":"1690541649154749",
|
|
1928
|
-
// "blockTradeId":"",
|
|
1929
|
-
// "side":"Buy",
|
|
1930
|
-
// "positionIdx":0,
|
|
1931
|
-
// "orderStatus":"Cancelled",
|
|
1932
|
-
// "cancelType":"UNKNOWN",
|
|
1933
|
-
// "rejectReason":"EC_NoError",
|
|
1934
|
-
// "timeInForce":"GTC",
|
|
1935
|
-
// "isLeverage":"0",
|
|
1936
|
-
// "price":"0",
|
|
1937
|
-
// "qty":"5.00000",
|
|
1938
|
-
// "avgPrice":"0",
|
|
1939
|
-
// "leavesQty":"0.00000",
|
|
1940
|
-
// "leavesValue":"5.0000000",
|
|
1941
|
-
// "cumExecQty":"0.00000",
|
|
1942
|
-
// "cumExecValue":"0.0000000",
|
|
1943
|
-
// "cumExecFee":"",
|
|
1944
|
-
// "orderType":"Market",
|
|
1945
|
-
// "stopOrderType":"",
|
|
1946
|
-
// "orderIv":"",
|
|
1947
|
-
// "triggerPrice":"0.000",
|
|
1948
|
-
// "takeProfit":"",
|
|
1949
|
-
// "stopLoss":"",
|
|
1950
|
-
// "triggerBy":"",
|
|
1951
|
-
// "tpTriggerBy":"",
|
|
1952
|
-
// "slTriggerBy":"",
|
|
1953
|
-
// "triggerDirection":0,
|
|
1954
|
-
// "placeType":"",
|
|
1955
|
-
// "lastPriceOnCreated":"0.000",
|
|
1956
|
-
// "closeOnTrigger":false,
|
|
1957
|
-
// "reduceOnly":false,
|
|
1958
|
-
// "smpGroup":0,
|
|
1959
|
-
// "smpType":"None",
|
|
1960
|
-
// "smpOrderId":"",
|
|
1961
|
-
// "createdTime":"1690541649160",
|
|
1962
|
-
// "updatedTime":"1690541649168"
|
|
1963
|
-
// }
|
|
1964
|
-
//
|
|
1965
|
-
const id = this.safeString2(order, 'i', 'orderId');
|
|
1966
|
-
const marketId = this.safeString2(order, 's', 'symbol');
|
|
1967
|
-
const symbol = this.safeSymbol(marketId, market, undefined, 'spot');
|
|
1968
|
-
const timestamp = this.safeInteger2(order, 'O', 'createdTime');
|
|
1969
|
-
let price = this.safeString2(order, 'p', 'price');
|
|
1970
|
-
if (price === '0') {
|
|
1971
|
-
price = undefined; // market orders
|
|
1972
|
-
}
|
|
1973
|
-
const filled = this.safeString2(order, 'z', 'cumExecQty');
|
|
1974
|
-
const status = this.parseOrderStatus(this.safeString2(order, 'X', 'orderStatus'));
|
|
1975
|
-
const side = this.safeStringLower2(order, 'S', 'side');
|
|
1976
|
-
const lastTradeTimestamp = this.safeString2(order, 'E', 'updatedTime');
|
|
1977
|
-
const timeInForce = this.safeString2(order, 'f', 'timeInForce');
|
|
1978
|
-
let amount = undefined;
|
|
1979
|
-
const cost = this.safeString2(order, 'Z', 'cumExecValue');
|
|
1980
|
-
let type = this.safeStringLower2(order, 'o', 'orderType');
|
|
1981
|
-
if ((type !== undefined) && (type.indexOf('market') >= 0)) {
|
|
1982
|
-
type = 'market';
|
|
1983
|
-
}
|
|
1984
|
-
if (type === 'market' && side === 'buy') {
|
|
1985
|
-
amount = filled;
|
|
1986
|
-
}
|
|
1987
|
-
else {
|
|
1988
|
-
amount = this.safeString2(order, 'orderQty', 'qty');
|
|
1989
|
-
}
|
|
1990
|
-
let fee = undefined;
|
|
1991
|
-
const feeCost = this.safeString2(order, 'n', 'cumExecFee');
|
|
1992
|
-
if (feeCost !== undefined && feeCost !== '0') {
|
|
1993
|
-
const feeCurrencyId = this.safeString(order, 'N');
|
|
1994
|
-
const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
1995
|
-
fee = {
|
|
1996
|
-
'cost': feeCost,
|
|
1997
|
-
'currency': feeCurrencyCode,
|
|
1998
|
-
};
|
|
1999
|
-
}
|
|
2000
|
-
const triggerPrice = this.omitZero(this.safeString(order, 'triggerPrice'));
|
|
2001
|
-
return this.safeOrder({
|
|
2002
|
-
'info': order,
|
|
2003
|
-
'id': id,
|
|
2004
|
-
'clientOrderId': this.safeString2(order, 'c', 'orderLinkId'),
|
|
2005
|
-
'timestamp': timestamp,
|
|
2006
|
-
'datetime': this.iso8601(timestamp),
|
|
2007
|
-
'lastTradeTimestamp': lastTradeTimestamp,
|
|
2008
|
-
'symbol': symbol,
|
|
2009
|
-
'type': type,
|
|
2010
|
-
'timeInForce': timeInForce,
|
|
2011
|
-
'postOnly': undefined,
|
|
2012
|
-
'side': side,
|
|
2013
|
-
'price': price,
|
|
2014
|
-
'stopPrice': triggerPrice,
|
|
2015
|
-
'triggerPrice': triggerPrice,
|
|
2016
|
-
'takeProfitPrice': this.safeString(order, 'takeProfit'),
|
|
2017
|
-
'stopLossPrice': this.safeString(order, 'stopLoss'),
|
|
2018
|
-
'reduceOnly': this.safeValue(order, 'reduceOnly'),
|
|
2019
|
-
'amount': amount,
|
|
2020
|
-
'cost': cost,
|
|
2021
|
-
'average': this.safeString(order, 'avgPrice'),
|
|
2022
|
-
'filled': filled,
|
|
2023
|
-
'remaining': undefined,
|
|
2024
|
-
'status': status,
|
|
2025
|
-
'fee': fee,
|
|
2026
|
-
}, market);
|
|
2027
|
-
}
|
|
2028
1891
|
/**
|
|
2029
1892
|
* @method
|
|
2030
1893
|
* @name bybit#watchBalance
|
package/js/src/pro/kraken.d.ts
CHANGED
|
@@ -37,8 +37,8 @@ export default class kraken extends krakenRest {
|
|
|
37
37
|
/**
|
|
38
38
|
* @method
|
|
39
39
|
* @name kraken#cancelOrdersWs
|
|
40
|
-
* @see https://docs.kraken.com/api/docs/websocket-v1/cancelorder
|
|
41
40
|
* @description cancel multiple orders
|
|
41
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/cancel_order
|
|
42
42
|
* @param {string[]} ids order ids
|
|
43
43
|
* @param {string} [symbol] unified market symbol, default is undefined
|
|
44
44
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -48,8 +48,8 @@ export default class kraken extends krakenRest {
|
|
|
48
48
|
/**
|
|
49
49
|
* @method
|
|
50
50
|
* @name kraken#cancelOrderWs
|
|
51
|
-
* @see https://docs.kraken.com/api/docs/websocket-v1/cancelorder
|
|
52
51
|
* @description cancels an open order
|
|
52
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/cancel_order
|
|
53
53
|
* @param {string} id order id
|
|
54
54
|
* @param {string} [symbol] unified symbol of the market the order was made in
|
|
55
55
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -60,16 +60,16 @@ export default class kraken extends krakenRest {
|
|
|
60
60
|
/**
|
|
61
61
|
* @method
|
|
62
62
|
* @name kraken#cancelAllOrdersWs
|
|
63
|
-
* @see https://docs.kraken.com/api/docs/websocket-v1/cancelall
|
|
64
63
|
* @description cancel all open orders
|
|
64
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/cancel_all
|
|
65
65
|
* @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
66
66
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
67
67
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
68
68
|
*/
|
|
69
69
|
cancelAllOrdersWs(symbol?: Str, params?: {}): Promise<any>;
|
|
70
70
|
handleCancelAllOrders(client: any, message: any): void;
|
|
71
|
-
handleTicker(client: any, message: any
|
|
72
|
-
handleTrades(client: Client, message: any
|
|
71
|
+
handleTicker(client: any, message: any): void;
|
|
72
|
+
handleTrades(client: Client, message: any): void;
|
|
73
73
|
handleOHLCV(client: Client, message: any, subscription: any): void;
|
|
74
74
|
requestId(): any;
|
|
75
75
|
watchPublic(name: any, symbol: any, params?: {}): Promise<any>;
|
|
@@ -77,7 +77,7 @@ export default class kraken extends krakenRest {
|
|
|
77
77
|
* @method
|
|
78
78
|
* @name kraken#watchTicker
|
|
79
79
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
80
|
-
* @see https://docs.kraken.com/api/docs/websocket-
|
|
80
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/ticker
|
|
81
81
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
82
82
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
83
83
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -87,7 +87,7 @@ export default class kraken extends krakenRest {
|
|
|
87
87
|
* @method
|
|
88
88
|
* @name kraken#watchTickers
|
|
89
89
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
90
|
-
* @see https://docs.kraken.com/api/docs/websocket-
|
|
90
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/ticker
|
|
91
91
|
* @param {string[]} symbols
|
|
92
92
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
93
93
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -96,20 +96,18 @@ export default class kraken extends krakenRest {
|
|
|
96
96
|
/**
|
|
97
97
|
* @method
|
|
98
98
|
* @name kraken#watchBidsAsks
|
|
99
|
-
* @see https://docs.kraken.com/api/docs/websocket-v1/spread
|
|
100
99
|
* @description watches best bid & ask for symbols
|
|
100
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/ticker
|
|
101
101
|
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
102
102
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
103
103
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
104
104
|
*/
|
|
105
105
|
watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
106
|
-
handleBidAsk(client: Client, message: any, subscription: any): void;
|
|
107
|
-
parseWsBidAsk(ticker: any, market?: any): Ticker;
|
|
108
106
|
/**
|
|
109
107
|
* @method
|
|
110
108
|
* @name kraken#watchTrades
|
|
111
109
|
* @description get the list of most recent trades for a particular symbol
|
|
112
|
-
* @see https://docs.kraken.com/api/docs/websocket-
|
|
110
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/trade
|
|
113
111
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
114
112
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
115
113
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -120,8 +118,8 @@ export default class kraken extends krakenRest {
|
|
|
120
118
|
/**
|
|
121
119
|
* @method
|
|
122
120
|
* @name kraken#watchTradesForSymbols
|
|
123
|
-
* @see https://docs.kraken.com/api/docs/websocket-v1/trade
|
|
124
121
|
* @description get the list of most recent trades for a list of symbols
|
|
122
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/trade
|
|
125
123
|
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
126
124
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
127
125
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -133,7 +131,7 @@ export default class kraken extends krakenRest {
|
|
|
133
131
|
* @method
|
|
134
132
|
* @name kraken#watchOrderBook
|
|
135
133
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
136
|
-
* @see https://docs.kraken.com/api/docs/websocket-
|
|
134
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/book
|
|
137
135
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
138
136
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
139
137
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -144,7 +142,7 @@ export default class kraken extends krakenRest {
|
|
|
144
142
|
* @method
|
|
145
143
|
* @name kraken#watchOrderBookForSymbols
|
|
146
144
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
147
|
-
* @see https://docs.kraken.com/api/docs/websocket-
|
|
145
|
+
* @see https://docs.kraken.com/api/docs/websocket-v2/book
|
|
148
146
|
* @param {string[]} symbols unified array of symbols
|
|
149
147
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
150
148
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -165,11 +163,13 @@ export default class kraken extends krakenRest {
|
|
|
165
163
|
*/
|
|
166
164
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
167
165
|
loadMarkets(reload?: boolean, params?: {}): Promise<import("../base/types.js").Dictionary<import("../base/types.js").MarketInterface>>;
|
|
166
|
+
ping(client: Client): {};
|
|
167
|
+
handlePong(client: Client, message: any): any;
|
|
168
168
|
watchHeartbeat(params?: {}): Promise<any>;
|
|
169
169
|
handleHeartbeat(client: Client, message: any): void;
|
|
170
|
-
handleOrderBook(client: Client, message: any
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
handleOrderBook(client: Client, message: any): void;
|
|
171
|
+
customHandleDeltas(bookside: any, deltas: any): void;
|
|
172
|
+
formatNumber(data: any): string;
|
|
173
173
|
handleSystemStatus(client: Client, message: any): any;
|
|
174
174
|
authenticate(params?: {}): Promise<string>;
|
|
175
175
|
watchPrivate(name: any, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|