ccxt 4.3.5 → 4.3.7
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 +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +5 -0
- package/dist/cjs/src/alpaca.js +6 -0
- package/dist/cjs/src/base/Exchange.js +37 -0
- package/dist/cjs/src/binance.js +4 -0
- package/dist/cjs/src/bingx.js +47 -0
- package/dist/cjs/src/bitbank.js +3 -0
- package/dist/cjs/src/bitget.js +74 -1
- package/dist/cjs/src/bithumb.js +4 -0
- package/dist/cjs/src/bitmex.js +26 -0
- package/dist/cjs/src/bitopro.js +5 -0
- package/dist/cjs/src/bitso.js +3 -0
- package/dist/cjs/src/bitstamp.js +3 -0
- package/dist/cjs/src/bitteam.js +4 -0
- package/dist/cjs/src/bitvavo.js +3 -0
- package/dist/cjs/src/bl3p.js +3 -0
- package/dist/cjs/src/btcalpha.js +3 -0
- package/dist/cjs/src/btcbox.js +3 -0
- package/dist/cjs/src/btcmarkets.js +3 -0
- package/dist/cjs/src/btcturk.js +3 -0
- package/dist/cjs/src/bybit.js +209 -12
- package/dist/cjs/src/cex.js +6 -0
- package/dist/cjs/src/coinbase.js +100 -21
- package/dist/cjs/src/coinbaseinternational.js +2 -0
- package/dist/cjs/src/coinbasepro.js +6 -0
- package/dist/cjs/src/coincheck.js +3 -0
- package/dist/cjs/src/coinex.js +180 -75
- package/dist/cjs/src/coinlist.js +4 -0
- package/dist/cjs/src/coinmate.js +3 -0
- package/dist/cjs/src/coinone.js +3 -0
- package/dist/cjs/src/coinsph.js +4 -0
- package/dist/cjs/src/coinspot.js +3 -0
- package/dist/cjs/src/cryptocom.js +34 -0
- package/dist/cjs/src/exmo.js +5 -0
- package/dist/cjs/src/gate.js +124 -22
- package/dist/cjs/src/hitbtc.js +4 -3
- package/dist/cjs/src/htx.js +30 -0
- package/dist/cjs/src/hyperliquid.js +40 -0
- package/dist/cjs/src/idex.js +3 -0
- package/dist/cjs/src/independentreserve.js +3 -0
- package/dist/cjs/src/indodax.js +3 -0
- package/dist/cjs/src/kraken.js +30 -0
- package/dist/cjs/src/krakenfutures.js +28 -0
- package/dist/cjs/src/kucoin.js +2 -0
- package/dist/cjs/src/kucoinfutures.js +4 -2
- package/dist/cjs/src/latoken.js +6 -0
- package/dist/cjs/src/luno.js +3 -0
- package/dist/cjs/src/lykke.js +5 -0
- package/dist/cjs/src/mercado.js +3 -0
- package/dist/cjs/src/mexc.js +111 -0
- package/dist/cjs/src/ndax.js +4 -0
- package/dist/cjs/src/novadax.js +4 -0
- package/dist/cjs/src/okx.js +196 -0
- package/dist/cjs/src/onetrading.js +3 -0
- package/dist/cjs/src/p2b.js +3 -0
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/coinbase.js +30 -29
- package/dist/cjs/src/probit.js +3 -0
- package/dist/cjs/src/timex.js +3 -0
- package/dist/cjs/src/tradeogre.js +3 -0
- package/dist/cjs/src/wavesexchange.js +3 -0
- package/dist/cjs/src/wazirx.js +3 -0
- package/dist/cjs/src/whitebit.js +42 -0
- package/dist/cjs/src/woo.js +31 -0
- package/dist/cjs/src/yobit.js +3 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/abstract/coinbase.d.ts +5 -0
- package/js/src/abstract/woo.d.ts +1 -0
- package/js/src/ace.js +5 -0
- package/js/src/alpaca.js +6 -0
- package/js/src/ascendex.d.ts +2 -2
- package/js/src/base/Exchange.d.ts +5 -0
- package/js/src/base/Exchange.js +37 -0
- package/js/src/bigone.d.ts +1 -1
- package/js/src/binance.d.ts +3 -3
- package/js/src/binance.js +4 -0
- package/js/src/bingx.d.ts +2 -1
- package/js/src/bingx.js +47 -0
- package/js/src/bitbank.d.ts +1 -1
- package/js/src/bitbank.js +3 -0
- package/js/src/bitfinex.d.ts +1 -1
- package/js/src/bitfinex2.d.ts +1 -1
- package/js/src/bitflyer.d.ts +1 -1
- package/js/src/bitget.d.ts +4 -3
- package/js/src/bitget.js +74 -1
- package/js/src/bithumb.d.ts +1 -1
- package/js/src/bithumb.js +4 -0
- package/js/src/bitmart.d.ts +1 -1
- package/js/src/bitmex.d.ts +2 -1
- package/js/src/bitmex.js +26 -0
- package/js/src/bitopro.d.ts +1 -1
- package/js/src/bitopro.js +5 -0
- package/js/src/bitrue.d.ts +1 -1
- package/js/src/bitso.d.ts +1 -1
- package/js/src/bitso.js +3 -0
- package/js/src/bitstamp.d.ts +1 -1
- package/js/src/bitstamp.js +3 -0
- package/js/src/bitteam.js +4 -0
- package/js/src/bitvavo.d.ts +1 -1
- package/js/src/bitvavo.js +3 -0
- package/js/src/bl3p.js +3 -0
- package/js/src/blockchaincom.d.ts +1 -1
- package/js/src/btcalpha.js +3 -0
- package/js/src/btcbox.js +3 -0
- package/js/src/btcmarkets.d.ts +1 -1
- package/js/src/btcmarkets.js +3 -0
- package/js/src/btcturk.js +3 -0
- package/js/src/bybit.d.ts +8 -6
- package/js/src/bybit.js +209 -12
- package/js/src/cex.js +6 -0
- package/js/src/coinbase.d.ts +1 -1
- package/js/src/coinbase.js +100 -21
- package/js/src/coinbaseinternational.d.ts +1 -1
- package/js/src/coinbaseinternational.js +2 -0
- package/js/src/coinbasepro.d.ts +1 -1
- package/js/src/coinbasepro.js +6 -0
- package/js/src/coincheck.js +3 -0
- package/js/src/coinex.d.ts +8 -7
- package/js/src/coinex.js +180 -75
- package/js/src/coinlist.d.ts +1 -1
- package/js/src/coinlist.js +4 -0
- package/js/src/coinmate.d.ts +1 -1
- package/js/src/coinmate.js +3 -0
- package/js/src/coinone.js +3 -0
- package/js/src/coinsph.d.ts +1 -1
- package/js/src/coinsph.js +4 -0
- package/js/src/coinspot.js +3 -0
- package/js/src/cryptocom.d.ts +3 -2
- package/js/src/cryptocom.js +34 -0
- package/js/src/delta.d.ts +2 -2
- package/js/src/deribit.d.ts +1 -1
- package/js/src/digifinex.d.ts +3 -3
- package/js/src/exmo.d.ts +3 -3
- package/js/src/exmo.js +5 -0
- package/js/src/gate.d.ts +8 -7
- package/js/src/gate.js +124 -22
- package/js/src/gemini.d.ts +1 -1
- package/js/src/hitbtc.d.ts +3 -3
- package/js/src/hitbtc.js +4 -3
- package/js/src/hollaex.d.ts +1 -1
- package/js/src/htx.d.ts +2 -1
- package/js/src/htx.js +30 -0
- package/js/src/huobijp.d.ts +1 -1
- package/js/src/hyperliquid.d.ts +3 -2
- package/js/src/hyperliquid.js +40 -0
- package/js/src/idex.d.ts +1 -1
- package/js/src/idex.js +3 -0
- package/js/src/independentreserve.js +3 -0
- package/js/src/indodax.d.ts +1 -1
- package/js/src/indodax.js +3 -0
- package/js/src/kraken.d.ts +2 -1
- package/js/src/kraken.js +30 -0
- package/js/src/krakenfutures.d.ts +1 -0
- package/js/src/krakenfutures.js +28 -0
- package/js/src/kucoin.d.ts +1 -1
- package/js/src/kucoin.js +2 -0
- package/js/src/kucoinfutures.d.ts +1 -1
- package/js/src/kucoinfutures.js +4 -2
- package/js/src/kuna.d.ts +1 -1
- package/js/src/latoken.js +6 -0
- package/js/src/lbank.d.ts +1 -1
- package/js/src/luno.js +3 -0
- package/js/src/lykke.d.ts +1 -1
- package/js/src/lykke.js +5 -0
- package/js/src/mercado.d.ts +1 -1
- package/js/src/mercado.js +3 -0
- package/js/src/mexc.d.ts +4 -3
- package/js/src/mexc.js +111 -0
- package/js/src/ndax.d.ts +1 -1
- package/js/src/ndax.js +4 -0
- package/js/src/novadax.d.ts +1 -1
- package/js/src/novadax.js +4 -0
- package/js/src/okcoin.d.ts +1 -1
- package/js/src/okx.d.ts +11 -8
- package/js/src/okx.js +196 -0
- package/js/src/onetrading.d.ts +1 -1
- package/js/src/onetrading.js +3 -0
- package/js/src/p2b.js +3 -0
- package/js/src/phemex.d.ts +1 -1
- package/js/src/poloniex.d.ts +1 -1
- package/js/src/pro/bitget.d.ts +1 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/coinbase.js +30 -29
- package/js/src/probit.d.ts +1 -1
- package/js/src/probit.js +3 -0
- package/js/src/timex.js +3 -0
- package/js/src/tokocrypto.d.ts +1 -1
- package/js/src/tradeogre.js +3 -0
- package/js/src/upbit.d.ts +1 -1
- package/js/src/wavesexchange.d.ts +1 -1
- package/js/src/wavesexchange.js +3 -0
- package/js/src/wazirx.js +3 -0
- package/js/src/whitebit.d.ts +2 -1
- package/js/src/whitebit.js +42 -0
- package/js/src/woo.d.ts +3 -2
- package/js/src/woo.js +31 -0
- package/js/src/yobit.d.ts +1 -1
- package/js/src/yobit.js +3 -0
- package/js/src/zaif.d.ts +1 -1
- package/js/src/zonda.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -35,6 +35,8 @@ class bybit extends bybit$1 {
|
|
|
35
35
|
'borrowCrossMargin': true,
|
|
36
36
|
'cancelAllOrders': true,
|
|
37
37
|
'cancelOrder': true,
|
|
38
|
+
'cancelOrders': true,
|
|
39
|
+
'cancelOrdersForSymbols': true,
|
|
38
40
|
'closeAllPositions': false,
|
|
39
41
|
'closePosition': false,
|
|
40
42
|
'createMarketBuyOrderWithCost': true,
|
|
@@ -100,7 +102,9 @@ class bybit extends bybit$1 {
|
|
|
100
102
|
'fetchOrders': false,
|
|
101
103
|
'fetchOrderTrades': true,
|
|
102
104
|
'fetchPosition': true,
|
|
105
|
+
'fetchPositionHistory': 'emulated',
|
|
103
106
|
'fetchPositions': true,
|
|
107
|
+
'fetchPositionsHistory': true,
|
|
104
108
|
'fetchPremiumIndexOHLCV': true,
|
|
105
109
|
'fetchSettlementHistory': true,
|
|
106
110
|
'fetchTicker': true,
|
|
@@ -4382,6 +4386,90 @@ class bybit extends bybit$1 {
|
|
|
4382
4386
|
const row = this.safeList(result, 'list', []);
|
|
4383
4387
|
return this.parseOrders(row, market);
|
|
4384
4388
|
}
|
|
4389
|
+
async cancelOrdersForSymbols(orders, params = {}) {
|
|
4390
|
+
/**
|
|
4391
|
+
* @method
|
|
4392
|
+
* @name bybit#cancelOrdersForSymbols
|
|
4393
|
+
* @description cancel multiple orders for multiple symbols
|
|
4394
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/batch-cancel
|
|
4395
|
+
* @param {string[]} ids order ids
|
|
4396
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
4397
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4398
|
+
* @param {string[]} [params.clientOrderIds] client order ids
|
|
4399
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4400
|
+
*/
|
|
4401
|
+
await this.loadMarkets();
|
|
4402
|
+
const ordersRequests = [];
|
|
4403
|
+
let category = undefined;
|
|
4404
|
+
for (let i = 0; i < orders.length; i++) {
|
|
4405
|
+
const order = orders[i];
|
|
4406
|
+
const symbol = this.safeString(order, 'symbol');
|
|
4407
|
+
const market = this.market(symbol);
|
|
4408
|
+
let currentCategory = undefined;
|
|
4409
|
+
[currentCategory, params] = this.getBybitType('cancelOrders', market, params);
|
|
4410
|
+
if (currentCategory === 'inverse') {
|
|
4411
|
+
throw new errors.NotSupported(this.id + ' cancelOrdersForSymbols does not allow inverse orders');
|
|
4412
|
+
}
|
|
4413
|
+
if ((category !== undefined) && (category !== currentCategory)) {
|
|
4414
|
+
throw new errors.ExchangeError(this.id + ' cancelOrdersForSymbols requires all orders to be of the same category (linear, spot or option))');
|
|
4415
|
+
}
|
|
4416
|
+
category = currentCategory;
|
|
4417
|
+
const id = this.safeString(order, 'id');
|
|
4418
|
+
const clientOrderId = this.safeString(order, 'clientOrderId');
|
|
4419
|
+
let idKey = 'orderId';
|
|
4420
|
+
if (clientOrderId !== undefined) {
|
|
4421
|
+
idKey = 'orderLinkId';
|
|
4422
|
+
}
|
|
4423
|
+
const orderItem = {
|
|
4424
|
+
'symbol': market['id'],
|
|
4425
|
+
};
|
|
4426
|
+
orderItem[idKey] = (idKey === 'orderId') ? id : clientOrderId;
|
|
4427
|
+
ordersRequests.push(orderItem);
|
|
4428
|
+
}
|
|
4429
|
+
const request = {
|
|
4430
|
+
'category': category,
|
|
4431
|
+
'request': ordersRequests,
|
|
4432
|
+
};
|
|
4433
|
+
const response = await this.privatePostV5OrderCancelBatch(this.extend(request, params));
|
|
4434
|
+
//
|
|
4435
|
+
// {
|
|
4436
|
+
// "retCode": "0",
|
|
4437
|
+
// "retMsg": "OK",
|
|
4438
|
+
// "result": {
|
|
4439
|
+
// "list": [
|
|
4440
|
+
// {
|
|
4441
|
+
// "category": "spot",
|
|
4442
|
+
// "symbol": "BTCUSDT",
|
|
4443
|
+
// "orderId": "1636282505818800896",
|
|
4444
|
+
// "orderLinkId": "1636282505818800897"
|
|
4445
|
+
// },
|
|
4446
|
+
// {
|
|
4447
|
+
// "category": "spot",
|
|
4448
|
+
// "symbol": "BTCUSDT",
|
|
4449
|
+
// "orderId": "1636282505818800898",
|
|
4450
|
+
// "orderLinkId": "1636282505818800899"
|
|
4451
|
+
// }
|
|
4452
|
+
// ]
|
|
4453
|
+
// },
|
|
4454
|
+
// "retExtInfo": {
|
|
4455
|
+
// "list": [
|
|
4456
|
+
// {
|
|
4457
|
+
// "code": "0",
|
|
4458
|
+
// "msg": "OK"
|
|
4459
|
+
// },
|
|
4460
|
+
// {
|
|
4461
|
+
// "code": "0",
|
|
4462
|
+
// "msg": "OK"
|
|
4463
|
+
// }
|
|
4464
|
+
// ]
|
|
4465
|
+
// },
|
|
4466
|
+
// "time": "1709796158501"
|
|
4467
|
+
// }
|
|
4468
|
+
//
|
|
4469
|
+
const result = this.safeDict(response, 'result', {});
|
|
4470
|
+
const row = this.safeList(result, 'list', []);
|
|
4471
|
+
return this.parseOrders(row, undefined);
|
|
4472
|
+
}
|
|
4385
4473
|
async cancelAllUsdcOrders(symbol = undefined, params = {}) {
|
|
4386
4474
|
if (symbol === undefined) {
|
|
4387
4475
|
throw new errors.ArgumentsRequired(this.id + ' cancelAllUsdcOrders() requires a symbol argument');
|
|
@@ -6371,37 +6459,64 @@ class bybit extends bybit$1 {
|
|
|
6371
6459
|
// "tradeMode": 0
|
|
6372
6460
|
// }
|
|
6373
6461
|
//
|
|
6462
|
+
// fetchPositionsHistory
|
|
6463
|
+
//
|
|
6464
|
+
// {
|
|
6465
|
+
// symbol: 'XRPUSDT',
|
|
6466
|
+
// orderType: 'Market',
|
|
6467
|
+
// leverage: '10',
|
|
6468
|
+
// updatedTime: '1712717265572',
|
|
6469
|
+
// side: 'Sell',
|
|
6470
|
+
// orderId: '071749f3-a9fa-427b-b5ca-27b2f52b81de',
|
|
6471
|
+
// closedPnl: '-0.00049568',
|
|
6472
|
+
// avgEntryPrice: '0.6045',
|
|
6473
|
+
// qty: '3',
|
|
6474
|
+
// cumEntryValue: '1.8135',
|
|
6475
|
+
// createdTime: '1712717265566',
|
|
6476
|
+
// orderPrice: '0.5744',
|
|
6477
|
+
// closedSize: '3',
|
|
6478
|
+
// avgExitPrice: '0.605',
|
|
6479
|
+
// execType: 'Trade',
|
|
6480
|
+
// fillCount: '1',
|
|
6481
|
+
// cumExitValue: '1.815'
|
|
6482
|
+
// }
|
|
6483
|
+
//
|
|
6484
|
+
const closedSize = this.safeString(position, 'closedSize');
|
|
6485
|
+
const isHistory = (closedSize !== undefined);
|
|
6374
6486
|
const contract = this.safeString(position, 'symbol');
|
|
6375
6487
|
market = this.safeMarket(contract, market, undefined, 'contract');
|
|
6376
|
-
const size = Precise["default"].stringAbs(this.
|
|
6488
|
+
const size = Precise["default"].stringAbs(this.safeString2(position, 'size', 'qty'));
|
|
6377
6489
|
let side = this.safeString(position, 'side');
|
|
6378
6490
|
if (side !== undefined) {
|
|
6379
6491
|
if (side === 'Buy') {
|
|
6380
|
-
side = 'long';
|
|
6492
|
+
side = isHistory ? 'short' : 'long';
|
|
6381
6493
|
}
|
|
6382
6494
|
else if (side === 'Sell') {
|
|
6383
|
-
side = 'short';
|
|
6495
|
+
side = isHistory ? 'long' : 'short';
|
|
6384
6496
|
}
|
|
6385
6497
|
else {
|
|
6386
6498
|
side = undefined;
|
|
6387
6499
|
}
|
|
6388
6500
|
}
|
|
6389
|
-
const notional = this.
|
|
6501
|
+
const notional = this.safeString2(position, 'positionValue', 'cumExitValue');
|
|
6390
6502
|
const unrealisedPnl = this.omitZero(this.safeString(position, 'unrealisedPnl'));
|
|
6391
|
-
let initialMarginString = this.
|
|
6503
|
+
let initialMarginString = this.safeStringN(position, ['positionIM', 'cumEntryValue']);
|
|
6392
6504
|
let maintenanceMarginString = this.safeString(position, 'positionMM');
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6505
|
+
const timestamp = this.safeIntegerN(position, ['createdTime', 'createdAt']);
|
|
6506
|
+
let lastUpdateTimestamp = this.parse8601(this.safeString(position, 'updated_at'));
|
|
6507
|
+
if (lastUpdateTimestamp === undefined) {
|
|
6508
|
+
lastUpdateTimestamp = this.safeIntegerN(position, ['updatedTime', 'updatedAt', 'updatedTime']);
|
|
6396
6509
|
}
|
|
6397
6510
|
const tradeMode = this.safeInteger(position, 'tradeMode', 0);
|
|
6398
6511
|
let marginMode = undefined;
|
|
6399
6512
|
if ((!this.options['enableUnifiedAccount']) || (this.options['enableUnifiedAccount'] && market['inverse'])) {
|
|
6400
6513
|
// tradeMode would work for classic and UTA(inverse)
|
|
6401
|
-
marginMode
|
|
6514
|
+
if (!isHistory) { // cannot tell marginMode for fetchPositionsHistory, and closedSize will only be defined for fetchPositionsHistory response
|
|
6515
|
+
marginMode = (tradeMode === 1) ? 'isolated' : 'cross';
|
|
6516
|
+
}
|
|
6402
6517
|
}
|
|
6403
6518
|
let collateralString = this.safeString(position, 'positionBalance');
|
|
6404
|
-
const entryPrice = this.omitZero(this.
|
|
6519
|
+
const entryPrice = this.omitZero(this.safeStringN(position, ['entryPrice', 'avgPrice', 'avgEntryPrice']));
|
|
6405
6520
|
const liquidationPrice = this.omitZero(this.safeString(position, 'liqPrice'));
|
|
6406
6521
|
const leverage = this.safeString(position, 'leverage');
|
|
6407
6522
|
if (liquidationPrice !== undefined) {
|
|
@@ -6447,7 +6562,7 @@ class bybit extends bybit$1 {
|
|
|
6447
6562
|
'symbol': market['symbol'],
|
|
6448
6563
|
'timestamp': timestamp,
|
|
6449
6564
|
'datetime': this.iso8601(timestamp),
|
|
6450
|
-
'lastUpdateTimestamp':
|
|
6565
|
+
'lastUpdateTimestamp': lastUpdateTimestamp,
|
|
6451
6566
|
'initialMargin': this.parseNumber(initialMarginString),
|
|
6452
6567
|
'initialMarginPercentage': this.parseNumber(Precise["default"].stringDiv(initialMarginString, notional)),
|
|
6453
6568
|
'maintenanceMargin': this.parseNumber(maintenanceMarginString),
|
|
@@ -6456,12 +6571,13 @@ class bybit extends bybit$1 {
|
|
|
6456
6571
|
'notional': this.parseNumber(notional),
|
|
6457
6572
|
'leverage': this.parseNumber(leverage),
|
|
6458
6573
|
'unrealizedPnl': this.parseNumber(unrealisedPnl),
|
|
6574
|
+
'realizedPnl': this.safeNumber(position, 'closedPnl'),
|
|
6459
6575
|
'contracts': this.parseNumber(size),
|
|
6460
6576
|
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
6461
6577
|
'marginRatio': this.parseNumber(marginRatio),
|
|
6462
6578
|
'liquidationPrice': this.parseNumber(liquidationPrice),
|
|
6463
6579
|
'markPrice': this.safeNumber(position, 'markPrice'),
|
|
6464
|
-
'lastPrice':
|
|
6580
|
+
'lastPrice': this.safeNumber(position, 'avgExitPrice'),
|
|
6465
6581
|
'collateral': this.parseNumber(collateralString),
|
|
6466
6582
|
'marginMode': marginMode,
|
|
6467
6583
|
'side': side,
|
|
@@ -8384,6 +8500,87 @@ class bybit extends bybit$1 {
|
|
|
8384
8500
|
'quoteVolume': undefined,
|
|
8385
8501
|
};
|
|
8386
8502
|
}
|
|
8503
|
+
async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
8504
|
+
/**
|
|
8505
|
+
* @method
|
|
8506
|
+
* @name bybit#fetchPositionsHistory
|
|
8507
|
+
* @description fetches historical positions
|
|
8508
|
+
* @see https://bybit-exchange.github.io/docs/v5/position/close-pnl
|
|
8509
|
+
* @param {string} [symbol] unified market symbols, symbols must have the same subType (must all be linear or all be inverse)
|
|
8510
|
+
* @param {int} [since] timestamp in ms of the earliest position to fetch, params["until"] - since <= 7 days
|
|
8511
|
+
* @param {int} [limit] the maximum amount of records to fetch, default=50, max=100
|
|
8512
|
+
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
8513
|
+
* @param {int} [params.until] timestamp in ms of the latest position to fetch, params["until"] - since <= 7 days
|
|
8514
|
+
* @param {string} [params.subType] 'linear' or 'inverse'
|
|
8515
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
8516
|
+
*/
|
|
8517
|
+
await this.loadMarkets();
|
|
8518
|
+
let market = undefined;
|
|
8519
|
+
let subType = undefined;
|
|
8520
|
+
let symbolsLength = 0;
|
|
8521
|
+
if (symbols !== undefined) {
|
|
8522
|
+
symbolsLength = symbols.length;
|
|
8523
|
+
if (symbolsLength > 0) {
|
|
8524
|
+
market = this.market(symbols[0]);
|
|
8525
|
+
}
|
|
8526
|
+
}
|
|
8527
|
+
const until = this.safeInteger(params, 'until');
|
|
8528
|
+
[subType, params] = this.handleSubTypeAndParams('fetchPositionsHistory', market, params, 'linear');
|
|
8529
|
+
params = this.omit(params, 'until');
|
|
8530
|
+
const request = {
|
|
8531
|
+
'category': subType,
|
|
8532
|
+
};
|
|
8533
|
+
if ((symbols !== undefined) && (symbolsLength === 1)) {
|
|
8534
|
+
request['symbol'] = market['id'];
|
|
8535
|
+
}
|
|
8536
|
+
if (since !== undefined) {
|
|
8537
|
+
request['startTime'] = since;
|
|
8538
|
+
}
|
|
8539
|
+
if (limit !== undefined) {
|
|
8540
|
+
request['limit'] = limit;
|
|
8541
|
+
}
|
|
8542
|
+
if (until !== undefined) {
|
|
8543
|
+
request['endTime'] = until;
|
|
8544
|
+
}
|
|
8545
|
+
const response = await this.privateGetV5PositionClosedPnl(this.extend(request, params));
|
|
8546
|
+
//
|
|
8547
|
+
// {
|
|
8548
|
+
// retCode: '0',
|
|
8549
|
+
// retMsg: 'OK',
|
|
8550
|
+
// result: {
|
|
8551
|
+
// nextPageCursor: '071749f3-a9fa-427b-b5ca-27b2f52b81de%3A1712717265566520788%2C071749f3-a9fa-427b-b5ca-27b2f52b81de%3A1712717265566520788',
|
|
8552
|
+
// category: 'linear',
|
|
8553
|
+
// list: [
|
|
8554
|
+
// {
|
|
8555
|
+
// symbol: 'XRPUSDT',
|
|
8556
|
+
// orderType: 'Market',
|
|
8557
|
+
// leverage: '10',
|
|
8558
|
+
// updatedTime: '1712717265572',
|
|
8559
|
+
// side: 'Sell',
|
|
8560
|
+
// orderId: '071749f3-a9fa-427b-b5ca-27b2f52b81de',
|
|
8561
|
+
// closedPnl: '-0.00049568',
|
|
8562
|
+
// avgEntryPrice: '0.6045',
|
|
8563
|
+
// qty: '3',
|
|
8564
|
+
// cumEntryValue: '1.8135',
|
|
8565
|
+
// createdTime: '1712717265566',
|
|
8566
|
+
// orderPrice: '0.5744',
|
|
8567
|
+
// closedSize: '3',
|
|
8568
|
+
// avgExitPrice: '0.605',
|
|
8569
|
+
// execType: 'Trade',
|
|
8570
|
+
// fillCount: '1',
|
|
8571
|
+
// cumExitValue: '1.815'
|
|
8572
|
+
// }
|
|
8573
|
+
// ]
|
|
8574
|
+
// },
|
|
8575
|
+
// retExtInfo: {},
|
|
8576
|
+
// time: '1712717286073'
|
|
8577
|
+
// }
|
|
8578
|
+
//
|
|
8579
|
+
const result = this.safeDict(response, 'result');
|
|
8580
|
+
const rawPositions = this.safeList(result, 'list');
|
|
8581
|
+
const positions = this.parsePositions(rawPositions, symbols, params);
|
|
8582
|
+
return this.filterBySinceLimit(positions, since, limit);
|
|
8583
|
+
}
|
|
8387
8584
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
8388
8585
|
let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
|
|
8389
8586
|
if (api === 'public') {
|
package/dist/cjs/src/cex.js
CHANGED
|
@@ -62,7 +62,13 @@ class cex extends cex$1 {
|
|
|
62
62
|
'fetchOrder': true,
|
|
63
63
|
'fetchOrderBook': true,
|
|
64
64
|
'fetchOrders': true,
|
|
65
|
+
'fetchPosition': false,
|
|
66
|
+
'fetchPositionHistory': false,
|
|
65
67
|
'fetchPositionMode': false,
|
|
68
|
+
'fetchPositions': false,
|
|
69
|
+
'fetchPositionsForSymbol': false,
|
|
70
|
+
'fetchPositionsHistory': false,
|
|
71
|
+
'fetchPositionsRisk': false,
|
|
66
72
|
'fetchPremiumIndexOHLCV': false,
|
|
67
73
|
'fetchTicker': true,
|
|
68
74
|
'fetchTickers': true,
|
package/dist/cjs/src/coinbase.js
CHANGED
|
@@ -202,6 +202,11 @@ class coinbase extends coinbase$1 {
|
|
|
202
202
|
'public': {
|
|
203
203
|
'get': {
|
|
204
204
|
'brokerage/time': 3,
|
|
205
|
+
'brokerage/market/product_book': 3,
|
|
206
|
+
'brokerage/market/products': 3,
|
|
207
|
+
'brokerage/market/products/{product_id}': 3,
|
|
208
|
+
'brokerage/market/products/{product_id}/candles': 3,
|
|
209
|
+
'brokerage/market/products/{product_id}/ticker': 3,
|
|
205
210
|
},
|
|
206
211
|
},
|
|
207
212
|
'private': {
|
|
@@ -1091,7 +1096,7 @@ class coinbase extends coinbase$1 {
|
|
|
1091
1096
|
/**
|
|
1092
1097
|
* @method
|
|
1093
1098
|
* @name coinbase#fetchMarkets
|
|
1094
|
-
* @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/
|
|
1099
|
+
* @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicproducts
|
|
1095
1100
|
* @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies#get-fiat-currencies
|
|
1096
1101
|
* @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates
|
|
1097
1102
|
* @description retrieves data on all markets for coinbase
|
|
@@ -1178,20 +1183,92 @@ class coinbase extends coinbase$1 {
|
|
|
1178
1183
|
}
|
|
1179
1184
|
async fetchMarketsV3(params = {}) {
|
|
1180
1185
|
const spotUnresolvedPromises = [
|
|
1181
|
-
this.
|
|
1182
|
-
|
|
1186
|
+
this.v3PublicGetBrokerageMarketProducts(params),
|
|
1187
|
+
//
|
|
1188
|
+
// {
|
|
1189
|
+
// products: [
|
|
1190
|
+
// {
|
|
1191
|
+
// product_id: 'BTC-USD',
|
|
1192
|
+
// price: '67060',
|
|
1193
|
+
// price_percentage_change_24h: '3.30054960636883',
|
|
1194
|
+
// volume_24h: '10967.87426597',
|
|
1195
|
+
// volume_percentage_change_24h: '141.73048325503036',
|
|
1196
|
+
// base_increment: '0.00000001',
|
|
1197
|
+
// quote_increment: '0.01',
|
|
1198
|
+
// quote_min_size: '1',
|
|
1199
|
+
// quote_max_size: '150000000',
|
|
1200
|
+
// base_min_size: '0.00000001',
|
|
1201
|
+
// base_max_size: '3400',
|
|
1202
|
+
// base_name: 'Bitcoin',
|
|
1203
|
+
// quote_name: 'US Dollar',
|
|
1204
|
+
// watched: false,
|
|
1205
|
+
// is_disabled: false,
|
|
1206
|
+
// new: false,
|
|
1207
|
+
// status: 'online',
|
|
1208
|
+
// cancel_only: false,
|
|
1209
|
+
// limit_only: false,
|
|
1210
|
+
// post_only: false,
|
|
1211
|
+
// trading_disabled: false,
|
|
1212
|
+
// auction_mode: false,
|
|
1213
|
+
// product_type: 'SPOT',
|
|
1214
|
+
// quote_currency_id: 'USD',
|
|
1215
|
+
// base_currency_id: 'BTC',
|
|
1216
|
+
// fcm_trading_session_details: null,
|
|
1217
|
+
// mid_market_price: '',
|
|
1218
|
+
// alias: '',
|
|
1219
|
+
// alias_to: [ 'BTC-USDC' ],
|
|
1220
|
+
// base_display_symbol: 'BTC',
|
|
1221
|
+
// quote_display_symbol: 'USD',
|
|
1222
|
+
// view_only: false,
|
|
1223
|
+
// price_increment: '0.01',
|
|
1224
|
+
// display_name: 'BTC-USD',
|
|
1225
|
+
// product_venue: 'CBE'
|
|
1226
|
+
// },
|
|
1227
|
+
// ...
|
|
1228
|
+
// ],
|
|
1229
|
+
// num_products: '646'
|
|
1230
|
+
// }
|
|
1231
|
+
//
|
|
1183
1232
|
];
|
|
1233
|
+
if (this.checkRequiredCredentials(false)) {
|
|
1234
|
+
spotUnresolvedPromises.push(this.v3PrivateGetBrokerageTransactionSummary(params));
|
|
1235
|
+
}
|
|
1236
|
+
//
|
|
1237
|
+
// {
|
|
1238
|
+
// total_volume: '9.995989116664404',
|
|
1239
|
+
// total_fees: '0.07996791093331522',
|
|
1240
|
+
// fee_tier: {
|
|
1241
|
+
// pricing_tier: 'Advanced 1',
|
|
1242
|
+
// usd_from: '0',
|
|
1243
|
+
// usd_to: '1000',
|
|
1244
|
+
// taker_fee_rate: '0.008',
|
|
1245
|
+
// maker_fee_rate: '0.006',
|
|
1246
|
+
// aop_from: '',
|
|
1247
|
+
// aop_to: ''
|
|
1248
|
+
// },
|
|
1249
|
+
// margin_rate: null,
|
|
1250
|
+
// goods_and_services_tax: null,
|
|
1251
|
+
// advanced_trade_only_volume: '9.995989116664404',
|
|
1252
|
+
// advanced_trade_only_fees: '0.07996791093331522',
|
|
1253
|
+
// coinbase_pro_volume: '0',
|
|
1254
|
+
// coinbase_pro_fees: '0',
|
|
1255
|
+
// total_balance: '',
|
|
1256
|
+
// has_promo_fee: false
|
|
1257
|
+
// }
|
|
1258
|
+
//
|
|
1184
1259
|
let unresolvedContractPromises = [];
|
|
1185
1260
|
try {
|
|
1186
1261
|
unresolvedContractPromises = [
|
|
1187
|
-
this.
|
|
1188
|
-
this.
|
|
1189
|
-
this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE' })),
|
|
1190
|
-
this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
|
|
1262
|
+
this.v3PublicGetBrokerageMarketProducts(this.extend(params, { 'product_type': 'FUTURE' })),
|
|
1263
|
+
this.v3PublicGetBrokerageMarketProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
|
|
1191
1264
|
];
|
|
1265
|
+
if (this.checkRequiredCredentials(false)) {
|
|
1266
|
+
unresolvedContractPromises.push(this.extend(params, { 'product_type': 'FUTURE' }));
|
|
1267
|
+
unresolvedContractPromises.push(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' }));
|
|
1268
|
+
}
|
|
1192
1269
|
}
|
|
1193
1270
|
catch (e) {
|
|
1194
|
-
unresolvedContractPromises = []; // the sync version of ccxt won't have the promise.all line so the request is made here
|
|
1271
|
+
unresolvedContractPromises = []; // the sync version of ccxt won't have the promise.all line so the request is made here. Some users can't access perpetual products
|
|
1195
1272
|
}
|
|
1196
1273
|
const promises = await Promise.all(spotUnresolvedPromises);
|
|
1197
1274
|
let contractPromises = undefined;
|
|
@@ -1460,6 +1537,7 @@ class coinbase extends coinbase$1 {
|
|
|
1460
1537
|
const contractSize = this.safeNumber(futureProductDetails, 'contract_size');
|
|
1461
1538
|
const contractExpire = this.safeString(futureProductDetails, 'contract_expiry');
|
|
1462
1539
|
const expireTimestamp = this.parse8601(contractExpire);
|
|
1540
|
+
const expireDateTime = this.iso8601(expireTimestamp);
|
|
1463
1541
|
const isSwap = (contractExpiryType === 'PERPETUAL');
|
|
1464
1542
|
const baseId = this.safeString(futureProductDetails, 'contract_root_unit');
|
|
1465
1543
|
const quoteId = this.safeString(market, 'quote_currency_id');
|
|
@@ -1503,7 +1581,7 @@ class coinbase extends coinbase$1 {
|
|
|
1503
1581
|
'maker': maker,
|
|
1504
1582
|
'contractSize': contractSize,
|
|
1505
1583
|
'expiry': expireTimestamp,
|
|
1506
|
-
'expiryDatetime':
|
|
1584
|
+
'expiryDatetime': expireDateTime,
|
|
1507
1585
|
'strike': undefined,
|
|
1508
1586
|
'optionType': undefined,
|
|
1509
1587
|
'precision': {
|
|
@@ -1728,7 +1806,7 @@ class coinbase extends coinbase$1 {
|
|
|
1728
1806
|
if (symbols !== undefined) {
|
|
1729
1807
|
request['product_ids'] = this.marketIds(symbols);
|
|
1730
1808
|
}
|
|
1731
|
-
const response = await this.
|
|
1809
|
+
const response = await this.v3PublicGetBrokerageMarketProducts(this.extend(request, params));
|
|
1732
1810
|
//
|
|
1733
1811
|
// {
|
|
1734
1812
|
// "products": [
|
|
@@ -1831,7 +1909,7 @@ class coinbase extends coinbase$1 {
|
|
|
1831
1909
|
'product_id': market['id'],
|
|
1832
1910
|
'limit': 1,
|
|
1833
1911
|
};
|
|
1834
|
-
const response = await this.
|
|
1912
|
+
const response = await this.v3PublicGetBrokerageMarketProductsProductIdTicker(this.extend(request, params));
|
|
1835
1913
|
//
|
|
1836
1914
|
// {
|
|
1837
1915
|
// "trades": [
|
|
@@ -3392,7 +3470,7 @@ class coinbase extends coinbase$1 {
|
|
|
3392
3470
|
* @method
|
|
3393
3471
|
* @name coinbase#fetchOHLCV
|
|
3394
3472
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
3395
|
-
* @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/
|
|
3473
|
+
* @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpubliccandles
|
|
3396
3474
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
3397
3475
|
* @param {string} timeframe the length of time each candle represents
|
|
3398
3476
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -3428,13 +3506,14 @@ class coinbase extends coinbase$1 {
|
|
|
3428
3506
|
sinceString = Precise["default"].stringSub(now, requestedDuration.toString());
|
|
3429
3507
|
}
|
|
3430
3508
|
request['start'] = sinceString;
|
|
3431
|
-
|
|
3432
|
-
|
|
3509
|
+
if (until !== undefined) {
|
|
3510
|
+
request['end'] = this.numberToString(this.parseToInt(until / 1000));
|
|
3511
|
+
}
|
|
3512
|
+
else {
|
|
3433
3513
|
// 300 candles max
|
|
3434
|
-
|
|
3514
|
+
request['end'] = Precise["default"].stringAdd(sinceString, requestedDuration.toString());
|
|
3435
3515
|
}
|
|
3436
|
-
|
|
3437
|
-
const response = await this.v3PrivateGetBrokerageProductsProductIdCandles(this.extend(request, params));
|
|
3516
|
+
const response = await this.v3PublicGetBrokerageMarketProductsProductIdCandles(this.extend(request, params));
|
|
3438
3517
|
//
|
|
3439
3518
|
// {
|
|
3440
3519
|
// "candles": [
|
|
@@ -3479,7 +3558,7 @@ class coinbase extends coinbase$1 {
|
|
|
3479
3558
|
* @method
|
|
3480
3559
|
* @name coinbase#fetchTrades
|
|
3481
3560
|
* @description get the list of most recent trades for a particular symbol
|
|
3482
|
-
* @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/
|
|
3561
|
+
* @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicmarkettrades
|
|
3483
3562
|
* @param {string} symbol unified market symbol of the trades
|
|
3484
3563
|
* @param {int} [since] not used by coinbase fetchTrades
|
|
3485
3564
|
* @param {int} [limit] the maximum number of trade structures to fetch
|
|
@@ -3505,7 +3584,7 @@ class coinbase extends coinbase$1 {
|
|
|
3505
3584
|
else if (since !== undefined) {
|
|
3506
3585
|
throw new errors.ArgumentsRequired(this.id + ' fetchTrades() requires a `until` parameter when you use `since` argument');
|
|
3507
3586
|
}
|
|
3508
|
-
const response = await this.
|
|
3587
|
+
const response = await this.v3PublicGetBrokerageMarketProductsProductIdTicker(this.extend(request, params));
|
|
3509
3588
|
//
|
|
3510
3589
|
// {
|
|
3511
3590
|
// "trades": [
|
|
@@ -3602,7 +3681,7 @@ class coinbase extends coinbase$1 {
|
|
|
3602
3681
|
* @method
|
|
3603
3682
|
* @name coinbase#fetchOrderBook
|
|
3604
3683
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
3605
|
-
* @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/
|
|
3684
|
+
* @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicproductbook
|
|
3606
3685
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
3607
3686
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
3608
3687
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -3616,7 +3695,7 @@ class coinbase extends coinbase$1 {
|
|
|
3616
3695
|
if (limit !== undefined) {
|
|
3617
3696
|
request['limit'] = limit;
|
|
3618
3697
|
}
|
|
3619
|
-
const response = await this.
|
|
3698
|
+
const response = await this.v3PublicGetBrokerageMarketProductBook(this.extend(request, params));
|
|
3620
3699
|
//
|
|
3621
3700
|
// {
|
|
3622
3701
|
// "pricebook": {
|
|
@@ -90,8 +90,10 @@ class coinbaseinternational extends coinbaseinternational$1 {
|
|
|
90
90
|
'fetchOrderBook': false,
|
|
91
91
|
'fetchOrders': false,
|
|
92
92
|
'fetchPosition': true,
|
|
93
|
+
'fetchPositionHistory': false,
|
|
93
94
|
'fetchPositionMode': false,
|
|
94
95
|
'fetchPositions': true,
|
|
96
|
+
'fetchPositionsHistory': false,
|
|
95
97
|
'fetchPositionsRisk': false,
|
|
96
98
|
'fetchPremiumIndexOHLCV': false,
|
|
97
99
|
'fetchTicker': true,
|
|
@@ -53,7 +53,13 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
53
53
|
'fetchOrderBook': true,
|
|
54
54
|
'fetchOrders': true,
|
|
55
55
|
'fetchOrderTrades': true,
|
|
56
|
+
'fetchPosition': false,
|
|
57
|
+
'fetchPositionHistory': false,
|
|
56
58
|
'fetchPositionMode': false,
|
|
59
|
+
'fetchPositions': false,
|
|
60
|
+
'fetchPositionsForSymbol': false,
|
|
61
|
+
'fetchPositionsHistory': false,
|
|
62
|
+
'fetchPositionsRisk': false,
|
|
57
63
|
'fetchTicker': true,
|
|
58
64
|
'fetchTickers': true,
|
|
59
65
|
'fetchTime': true,
|
|
@@ -52,8 +52,11 @@ class coincheck extends coincheck$1 {
|
|
|
52
52
|
'fetchOpenOrders': true,
|
|
53
53
|
'fetchOrderBook': true,
|
|
54
54
|
'fetchPosition': false,
|
|
55
|
+
'fetchPositionHistory': false,
|
|
55
56
|
'fetchPositionMode': false,
|
|
56
57
|
'fetchPositions': false,
|
|
58
|
+
'fetchPositionsForSymbol': false,
|
|
59
|
+
'fetchPositionsHistory': false,
|
|
57
60
|
'fetchPositionsRisk': false,
|
|
58
61
|
'fetchPremiumIndexOHLCV': false,
|
|
59
62
|
'fetchTicker': true,
|