ccxt 4.1.2 → 4.1.4

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.
@@ -8206,6 +8206,9 @@ class Exchange {
8206
8206
  if (!tradesAreParsed) {
8207
8207
  trades = this.parseTrades(rawTrades, market);
8208
8208
  }
8209
+ else {
8210
+ trades = rawTrades;
8211
+ }
8209
8212
  this.number = oldNumber;
8210
8213
  let tradesLength = 0;
8211
8214
  const isArray = Array.isArray(trades);
@@ -26465,6 +26468,8 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26465
26468
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
26466
26469
  * @param {object} [params] extra parameters specific to the bingx api endpoint
26467
26470
  * @param {bool} [params.postOnly] true to place a post only order
26471
+ * @param {string} [params.timeInForce] spot supports 'PO' and 'IOC', swap supports 'PO', 'GTC', 'IOC' and 'FOK'
26472
+ * @param {bool} [params.reduceOnly] *swap only* true or false whether the order is reduce only
26468
26473
  * @param {float} [params.triggerPrice] *swap only* triggerPrice at which the attached take profit / stop loss order will be triggered
26469
26474
  * @param {float} [params.stopLossPrice] *swap only* stop loss trigger price
26470
26475
  * @param {float} [params.takeProfitPrice] *swap only* take profit trigger price
@@ -26472,8 +26477,10 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26472
26477
  */
26473
26478
  await this.loadMarkets();
26474
26479
  const market = this.market(symbol);
26480
+ let postOnly = undefined;
26475
26481
  let response = undefined;
26476
- const [marketType, query] = this.handleMarketTypeAndParams('createOrder', market, params);
26482
+ let marketType = undefined;
26483
+ [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
26477
26484
  type = type.toUpperCase();
26478
26485
  const request = {
26479
26486
  'symbol': market['id'],
@@ -26481,51 +26488,16 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26481
26488
  'side': side.toUpperCase(),
26482
26489
  };
26483
26490
  const isMarketOrder = type === 'MARKET';
26484
- const isSpotMarket = marketType === 'spot';
26485
- let stopPriceRaw = undefined;
26486
- let stopPrice = undefined;
26487
- let stopLossPrice = undefined;
26488
- let takeProfitPrice = undefined;
26489
- if (!isSpotMarket) {
26490
- stopPriceRaw = this.safeValue2(params, 'stopPrice', 'triggerPrice');
26491
- if (stopPriceRaw !== undefined) {
26492
- stopPrice = this.priceToPrecision(symbol, stopPriceRaw);
26493
- }
26494
- stopLossPrice = this.safeValue(params, 'stopLossPrice');
26495
- takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
26496
- }
26497
- if ((stopLossPrice !== undefined) && (takeProfitPrice !== undefined)) {
26498
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder('Order is either a takeProfit order or a stopLoss order');
26499
- }
26500
- if ((type === 'LIMIT') || (type === 'TRIGGER_LIMIT')) {
26501
- request['price'] = this.priceToPrecision(symbol, price);
26502
- if ((stopPrice !== undefined)) {
26503
- request['type'] = 'TRIGGER_LIMIT';
26504
- request['stopPrice'] = stopPrice;
26505
- }
26506
- if (type === 'TRIGGER_LIMIT') {
26507
- if (stopPrice === undefined) {
26508
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder('TRIGGER_LIMIT requires a triggerPrice / stopPrice');
26509
- }
26510
- request['stopPrice'] = stopPrice;
26511
- }
26491
+ const isSpot = marketType === 'spot';
26492
+ const timeInForce = this.safeStringUpper(params, 'timeInForce');
26493
+ if (timeInForce === 'IOC') {
26494
+ request['timeInForce'] = 'IOC';
26512
26495
  }
26513
- if (isMarketOrder || (type === 'TRIGGER_MARKET')) {
26514
- if ((stopPrice !== undefined)) {
26515
- request['type'] = 'TRIGGER_MARKET';
26516
- request['stopPrice'] = stopPrice;
26517
- }
26518
- if (type === 'TRIGGER_MARKET') {
26519
- if (stopPrice === undefined) {
26520
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder('TRIGGER_MARKET requires a triggerPrice / stopPrice');
26521
- }
26522
- request['stopPrice'] = stopPrice;
26496
+ if (isSpot) {
26497
+ [postOnly, params] = this.handlePostOnly(isMarketOrder, timeInForce === 'POC', params);
26498
+ if (postOnly || (timeInForce === 'POC')) {
26499
+ request['timeInForce'] = 'POC';
26523
26500
  }
26524
- }
26525
- const exchangeSpecificTifParam = this.safeStringUpperN(params, ['force', 'timeInForce']);
26526
- let postOnly = undefined;
26527
- [postOnly, params] = this.handlePostOnly(isMarketOrder, exchangeSpecificTifParam === 'POC', params);
26528
- if (isSpotMarket) {
26529
26501
  const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
26530
26502
  if (createMarketBuyOrderRequiresPrice && isMarketOrder && (side === 'buy')) {
26531
26503
  if (price === undefined) {
@@ -26541,35 +26513,77 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26541
26513
  else {
26542
26514
  request['quantity'] = this.amountToPrecision(symbol, amount);
26543
26515
  }
26516
+ if (!isMarketOrder) {
26517
+ request['price'] = this.priceToPrecision(symbol, price);
26518
+ }
26519
+ response = await this.spotV1PrivatePostTradeOrder(this.extend(request, params));
26544
26520
  }
26545
26521
  else {
26522
+ [postOnly, params] = this.handlePostOnly(isMarketOrder, timeInForce === 'PostOnly', params);
26523
+ if (postOnly || (timeInForce === 'PostOnly')) {
26524
+ request['timeInForce'] = 'PostOnly';
26525
+ }
26526
+ else if (timeInForce === 'GTC') {
26527
+ request['timeInForce'] = 'GTC';
26528
+ }
26529
+ else if (timeInForce === 'FOK') {
26530
+ request['timeInForce'] = 'FOK';
26531
+ }
26532
+ if ((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) {
26533
+ request['price'] = this.priceToPrecision(symbol, price);
26534
+ }
26535
+ const triggerPrice = this.safeNumber2(params, 'stopPrice', 'triggerPrice');
26536
+ const stopLossPrice = this.safeNumber(params, 'stopLossPrice');
26537
+ const takeProfitPrice = this.safeNumber(params, 'takeProfitPrice');
26538
+ const isTriggerOrder = triggerPrice !== undefined;
26539
+ const isStopLossPriceOrder = stopLossPrice !== undefined;
26540
+ const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
26541
+ if (isTriggerOrder) {
26542
+ request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
26543
+ if (isMarketOrder || (type === 'TRIGGER_MARKET')) {
26544
+ request['type'] = 'TRIGGER_MARKET';
26545
+ }
26546
+ else if ((type === 'LIMIT') || (type === 'TRIGGER_LIMIT')) {
26547
+ request['type'] = 'TRIGGER_LIMIT';
26548
+ }
26549
+ }
26550
+ else if (isStopLossPriceOrder || isTakeProfitPriceOrder) {
26551
+ // This can be used to set the stop loss and take profit, but the position needs to be opened first
26552
+ if (isStopLossPriceOrder) {
26553
+ request['stopPrice'] = this.priceToPrecision(symbol, stopLossPrice);
26554
+ if (isMarketOrder || (type === 'STOP_MARKET')) {
26555
+ request['type'] = 'STOP_MARKET';
26556
+ }
26557
+ else if ((type === 'LIMIT') || (type === 'STOP')) {
26558
+ request['type'] = 'STOP';
26559
+ }
26560
+ }
26561
+ else if (isTakeProfitPriceOrder) {
26562
+ request['stopPrice'] = this.priceToPrecision(symbol, takeProfitPrice);
26563
+ if (isMarketOrder || (type === 'TAKE_PROFIT_MARKET')) {
26564
+ request['type'] = 'TAKE_PROFIT_MARKET';
26565
+ }
26566
+ else if ((type === 'LIMIT') || (type === 'TAKE_PROFIT')) {
26567
+ request['type'] = 'TAKE_PROFIT';
26568
+ }
26569
+ }
26570
+ }
26571
+ const reduceOnly = this.safeValue(params, 'reduceOnly', false);
26572
+ let positionSide = undefined;
26573
+ if (reduceOnly) {
26574
+ positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
26575
+ }
26576
+ else {
26577
+ positionSide = (side === 'buy') ? 'LONG' : 'SHORT';
26578
+ }
26579
+ request['positionSide'] = positionSide;
26546
26580
  request['quantity'] = this.amountToPrecision(symbol, amount);
26547
- }
26548
- if ((stopLossPrice !== undefined)) {
26549
- request['type'] = 'STOP_MARKET';
26550
- request['stopPrice'] = this.priceToPrecision(symbol, stopLossPrice);
26551
- }
26552
- if ((takeProfitPrice !== undefined)) {
26553
- request['type'] = 'TAKE_PROFIT_MARKET';
26554
- request['stopPrice'] = this.priceToPrecision(symbol, takeProfitPrice);
26555
- }
26556
- if (postOnly) {
26557
- request['timeInForce'] = 'POC';
26558
- }
26559
- else if (exchangeSpecificTifParam === 'POC') {
26560
- request['timeInForce'] = 'POC';
26561
- }
26562
- else if (!isSpotMarket) {
26563
- request['timeInForce'] = 'GTC';
26564
- }
26565
- if (isSpotMarket) {
26566
- response = await this.spotV1PrivatePostTradeOrder(this.extend(request, query));
26567
- }
26568
- else {
26569
- response = await this.swapV2PrivatePostTradeOrder(this.extend(request, query));
26581
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
26582
+ response = await this.swapV2PrivatePostTradeOrder(this.extend(request, params));
26570
26583
  }
26571
26584
  //
26572
26585
  // spot
26586
+ //
26573
26587
  // {
26574
26588
  // "code": 0,
26575
26589
  // "msg": "",
@@ -26589,23 +26603,25 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26589
26603
  //
26590
26604
  // swap
26591
26605
  //
26592
- // {
26593
- // "code": 0,
26594
- // "msg": "",
26595
- // "data": {
26596
- // "order": {
26597
- // "symbol": "BTC-USDT",
26598
- // "orderId": 1590973236294713344,
26599
- // "side": "BUY",
26600
- // "positionSide": "LONG",
26601
- // "type": "LIMIT"
26602
- // }
26603
- // }
26604
- // }
26606
+ // {
26607
+ // "code": 0,
26608
+ // "msg": "",
26609
+ // "data": {
26610
+ // "order": {
26611
+ // "symbol": "BTC-USDT",
26612
+ // "orderId": 1709036527545438208,
26613
+ // "side": "BUY",
26614
+ // "positionSide": "LONG",
26615
+ // "type": "TRIGGER_LIMIT",
26616
+ // "clientOrderID": "",
26617
+ // "workingType": ""
26618
+ // }
26619
+ // }
26620
+ // }
26605
26621
  //
26606
- const data = this.safeValue(response, 'data');
26607
- const first = this.safeValue(data, 'order', data);
26608
- return this.parseOrder(first, market);
26622
+ const data = this.safeValue(response, 'data', {});
26623
+ const order = this.safeValue(data, 'order', data);
26624
+ return this.parseOrder(order, market);
26609
26625
  }
26610
26626
  parseOrder(order, market = undefined) {
26611
26627
  //
@@ -26675,65 +26691,68 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26675
26691
  //
26676
26692
  // fetchOrder, fetchOpenOrders, fetchClosedOrders
26677
26693
  //
26678
- // {
26679
- // "symbol": "LINK-USDT",
26680
- // "orderId": 1585839271162413056,
26681
- // "side": "BUY",
26682
- // "positionSide": "LONG",
26683
- // "type": "TRIGGER_MARKET",
26684
- // "origQty": "5.0",
26685
- // "price": "9",
26686
- // "executedQty": "0.0",
26687
- // "avgPrice": "0",
26688
- // "cumQuote": "0",
26689
- // "stopPrice": "5",
26690
- // "profit": "0.0000",
26691
- // "commission": "0.000000",
26692
- // "status": "CANCELLED",
26693
- // "time": 1667631605000,
26694
- // "updateTime": 1667631605000
26695
- // }
26694
+ // {
26695
+ // "symbol": "BTC-USDT",
26696
+ // "orderId": 1709036527545438208,
26697
+ // "side": "BUY",
26698
+ // "positionSide": "LONG",
26699
+ // "type": "TRIGGER_LIMIT",
26700
+ // "origQty": "0.0010",
26701
+ // "price": "22000.0",
26702
+ // "executedQty": "0.0000",
26703
+ // "avgPrice": "0.0",
26704
+ // "cumQuote": "",
26705
+ // "stopPrice": "23000.0",
26706
+ // "profit": "",
26707
+ // "commission": "",
26708
+ // "status": "NEW",
26709
+ // "time": 1696301035187,
26710
+ // "updateTime": 1696301035187,
26711
+ // "clientOrderId": "",
26712
+ // "leverage": "",
26713
+ // "takeProfit": "",
26714
+ // "stopLoss": "",
26715
+ // "advanceAttr": 0,
26716
+ // "positionID": 0,
26717
+ // "takeProfitEntrustPrice": 0,
26718
+ // "stopLossEntrustPrice": 0,
26719
+ // "orderType": "",
26720
+ // "workingType": "MARK_PRICE"
26721
+ // }
26696
26722
  //
26697
26723
  const positionSide = this.safeString(order, 'positionSide');
26698
26724
  const marketType = (positionSide === undefined) ? 'spot' : 'swap';
26699
26725
  const marketId = this.safeString(order, 'symbol');
26700
26726
  const symbol = this.safeSymbol(marketId, market, '-', marketType);
26701
- const orderId = this.safeString(order, 'orderId');
26702
- const side = this.safeStringLower(order, 'side');
26703
- const type = this.safeStringLower(order, 'type');
26704
26727
  const timestamp = this.safeInteger2(order, 'time', 'transactTime');
26705
- const lastTradeTimestamp = this.safeInteger(order, 'updateTime');
26706
- const price = this.safeString(order, 'price');
26707
- const average = this.safeString(order, 'avgPrice');
26708
- const amount = this.safeString(order, 'origQty');
26709
- const filled = this.safeString(order, 'executedQty');
26710
- const statusId = this.safeString(order, 'status');
26711
26728
  const fee = {
26712
26729
  'currency': this.safeString(order, 'feeAsset'),
26713
26730
  'rate': this.safeString2(order, 'fee', 'commission'),
26714
26731
  };
26715
- const clientOrderId = this.safeString(order, 'clientOrderId');
26716
26732
  return this.safeOrder({
26717
26733
  'info': order,
26718
- 'id': orderId,
26719
- 'clientOrderId': clientOrderId,
26734
+ 'id': this.safeString(order, 'orderId'),
26735
+ 'clientOrderId': this.safeString(order, 'clientOrderId'),
26720
26736
  'timestamp': timestamp,
26721
26737
  'datetime': this.iso8601(timestamp),
26722
- 'lastTradeTimestamp': lastTradeTimestamp,
26738
+ 'lastTradeTimestamp': this.safeInteger(order, 'updateTime'),
26739
+ 'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
26723
26740
  'symbol': symbol,
26724
- 'type': type,
26741
+ 'type': this.safeStringLower(order, 'type'),
26725
26742
  'timeInForce': undefined,
26726
26743
  'postOnly': undefined,
26727
- 'side': side,
26728
- 'price': price,
26729
- 'stopPrice': this.safeNumber(order, 'triggerPrice'),
26730
- 'triggerPrice': this.safeNumber(order, 'triggerPrice'),
26731
- 'average': average,
26744
+ 'side': this.safeStringLower(order, 'side'),
26745
+ 'price': this.safeString(order, 'price'),
26746
+ 'stopPrice': this.safeNumber(order, 'stopPrice'),
26747
+ 'triggerPrice': this.safeNumber(order, 'stopPrice'),
26748
+ 'stopLossPrice': this.safeNumber(order, 'stopLoss'),
26749
+ 'takeProfitPrice': this.safeNumber(order, 'takeProfit'),
26750
+ 'average': this.safeString(order, 'avgPrice'),
26732
26751
  'cost': undefined,
26733
- 'amount': amount,
26734
- 'filled': filled,
26752
+ 'amount': this.safeString(order, 'origQty'),
26753
+ 'filled': this.safeString(order, 'executedQty'),
26735
26754
  'remaining': undefined,
26736
- 'status': this.parseOrderStatus(statusId),
26755
+ 'status': this.parseOrderStatus(this.safeString(order, 'status')),
26737
26756
  'fee': fee,
26738
26757
  'trades': undefined,
26739
26758
  }, market);
@@ -41476,7 +41495,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41476
41495
  //
41477
41496
  const data = this.safeValue(response, 'data');
41478
41497
  if (data !== undefined) {
41479
- return this.safeValue2(data, 'orderList', 'data', []);
41498
+ return this.safeValue(data, 'orderList', data);
41480
41499
  }
41481
41500
  const parsedData = JSON.parse(response);
41482
41501
  return this.safeValue(parsedData, 'data', []);
@@ -44007,7 +44026,9 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
44007
44026
  'fetchOrderBook': true,
44008
44027
  'fetchOrders': false,
44009
44028
  'fetchOrderTrades': true,
44029
+ 'fetchPosition': true,
44010
44030
  'fetchPositionMode': false,
44031
+ 'fetchPositions': true,
44011
44032
  'fetchStatus': true,
44012
44033
  'fetchTicker': true,
44013
44034
  'fetchTickers': true,
@@ -47692,6 +47713,180 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
47692
47713
  'previousFundingDatetime': undefined,
47693
47714
  };
47694
47715
  }
47716
+ async fetchPosition(symbol, params = {}) {
47717
+ /**
47718
+ * @method
47719
+ * @name bitmart#fetchPosition
47720
+ * @description fetch data on a single open contract trade position
47721
+ * @see https://developer-pro.bitmart.com/en/futures/#get-current-position-keyed
47722
+ * @param {string} symbol unified market symbol of the market the position is held in
47723
+ * @param {object} [params] extra parameters specific to the bitmart api endpoint
47724
+ * @returns {object} a [position structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#position-structure}
47725
+ */
47726
+ await this.loadMarkets();
47727
+ const market = this.market(symbol);
47728
+ const request = {
47729
+ 'symbol': market['id'],
47730
+ };
47731
+ const response = await this.privateGetContractPrivatePosition(this.extend(request, params));
47732
+ //
47733
+ // {
47734
+ // "code": 1000,
47735
+ // "message": "Ok",
47736
+ // "data": [
47737
+ // {
47738
+ // "symbol": "BTCUSDT",
47739
+ // "leverage": "10",
47740
+ // "timestamp": 1696392515269,
47741
+ // "current_fee": "0.0014250028",
47742
+ // "open_timestamp": 1696392256998,
47743
+ // "current_value": "27.4039",
47744
+ // "mark_price": "27.4039",
47745
+ // "position_value": "27.4079",
47746
+ // "position_cross": "3.75723474",
47747
+ // "maintenance_margin": "0.1370395",
47748
+ // "close_vol": "0",
47749
+ // "close_avg_price": "0",
47750
+ // "open_avg_price": "27407.9",
47751
+ // "entry_price": "27407.9",
47752
+ // "current_amount": "1",
47753
+ // "unrealized_value": "-0.004",
47754
+ // "realized_value": "-0.01644474",
47755
+ // "position_type": 1
47756
+ // }
47757
+ // ],
47758
+ // "trace":"4cad855074664097ac5ba5257c47305d.67.16963925142065945"
47759
+ // }
47760
+ //
47761
+ const data = this.safeValue(response, 'data', []);
47762
+ const first = this.safeValue(data, 0, {});
47763
+ return this.parsePosition(first, market);
47764
+ }
47765
+ async fetchPositions(symbols = undefined, params = {}) {
47766
+ /**
47767
+ * @method
47768
+ * @name bitmart#fetchPositions
47769
+ * @description fetch all open contract positions
47770
+ * @see https://developer-pro.bitmart.com/en/futures/#get-current-position-keyed
47771
+ * @param {string[]|undefined} symbols list of unified market symbols
47772
+ * @param {object} [params] extra parameters specific to the bitmart api endpoint
47773
+ * @returns {object[]} a list of [position structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#position-structure}
47774
+ */
47775
+ await this.loadMarkets();
47776
+ let market = undefined;
47777
+ let symbolsLength = undefined;
47778
+ if (symbols !== undefined) {
47779
+ symbolsLength = symbols.length;
47780
+ const first = this.safeString(symbols, 0);
47781
+ market = this.market(first);
47782
+ }
47783
+ const request = {};
47784
+ if (symbolsLength === 1) {
47785
+ // only supports symbols as undefined or sending one symbol
47786
+ request['symbol'] = market['id'];
47787
+ }
47788
+ const response = await this.privateGetContractPrivatePosition(this.extend(request, params));
47789
+ //
47790
+ // {
47791
+ // "code": 1000,
47792
+ // "message": "Ok",
47793
+ // "data": [
47794
+ // {
47795
+ // "symbol": "BTCUSDT",
47796
+ // "leverage": "10",
47797
+ // "timestamp": 1696392515269,
47798
+ // "current_fee": "0.0014250028",
47799
+ // "open_timestamp": 1696392256998,
47800
+ // "current_value": "27.4039",
47801
+ // "mark_price": "27.4039",
47802
+ // "position_value": "27.4079",
47803
+ // "position_cross": "3.75723474",
47804
+ // "maintenance_margin": "0.1370395",
47805
+ // "close_vol": "0",
47806
+ // "close_avg_price": "0",
47807
+ // "open_avg_price": "27407.9",
47808
+ // "entry_price": "27407.9",
47809
+ // "current_amount": "1",
47810
+ // "unrealized_value": "-0.004",
47811
+ // "realized_value": "-0.01644474",
47812
+ // "position_type": 1
47813
+ // },
47814
+ // ],
47815
+ // "trace":"4cad855074664097ac5ba5257c47305d.67.16963925142065945"
47816
+ // }
47817
+ //
47818
+ const positions = this.safeValue(response, 'data', []);
47819
+ const result = [];
47820
+ for (let i = 0; i < positions.length; i++) {
47821
+ result.push(this.parsePosition(positions[i]));
47822
+ }
47823
+ symbols = this.marketSymbols(symbols);
47824
+ return this.filterByArrayPositions(result, 'symbol', symbols, false);
47825
+ }
47826
+ parsePosition(position, market = undefined) {
47827
+ //
47828
+ // {
47829
+ // "symbol": "BTCUSDT",
47830
+ // "leverage": "10",
47831
+ // "timestamp": 1696392515269,
47832
+ // "current_fee": "0.0014250028",
47833
+ // "open_timestamp": 1696392256998,
47834
+ // "current_value": "27.4039",
47835
+ // "mark_price": "27.4039",
47836
+ // "position_value": "27.4079",
47837
+ // "position_cross": "3.75723474",
47838
+ // "maintenance_margin": "0.1370395",
47839
+ // "close_vol": "0",
47840
+ // "close_avg_price": "0",
47841
+ // "open_avg_price": "27407.9",
47842
+ // "entry_price": "27407.9",
47843
+ // "current_amount": "1",
47844
+ // "unrealized_value": "-0.004",
47845
+ // "realized_value": "-0.01644474",
47846
+ // "position_type": 1
47847
+ // }
47848
+ //
47849
+ const marketId = this.safeString(position, 'symbol');
47850
+ market = this.safeMarket(marketId, market);
47851
+ const symbol = market['symbol'];
47852
+ const timestamp = this.safeInteger(position, 'timestamp');
47853
+ const side = this.safeInteger(position, 'position_type');
47854
+ const maintenanceMargin = this.safeString(position, 'maintenance_margin');
47855
+ const notional = this.safeString(position, 'current_value');
47856
+ const collateral = this.safeString(position, 'position_cross');
47857
+ const maintenanceMarginPercentage = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringDiv */ .O.stringDiv(maintenanceMargin, notional);
47858
+ const marginRatio = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringDiv */ .O.stringDiv(maintenanceMargin, collateral);
47859
+ return this.safePosition({
47860
+ 'info': position,
47861
+ 'id': undefined,
47862
+ 'symbol': symbol,
47863
+ 'timestamp': timestamp,
47864
+ 'datetime': this.iso8601(timestamp),
47865
+ 'lastUpdateTimestamp': undefined,
47866
+ 'hedged': undefined,
47867
+ 'side': (side === 1) ? 'long' : 'short',
47868
+ 'contracts': this.safeNumber(position, 'current_amount'),
47869
+ 'contractSize': this.safeNumber(market, 'contractSize'),
47870
+ 'entryPrice': this.safeNumber(position, 'entry_price'),
47871
+ 'markPrice': this.safeNumber(position, 'mark_price'),
47872
+ 'lastPrice': undefined,
47873
+ 'notional': this.parseNumber(notional),
47874
+ 'leverage': this.safeNumber(position, 'leverage'),
47875
+ 'collateral': this.parseNumber(collateral),
47876
+ 'initialMargin': undefined,
47877
+ 'initialMarginPercentage': undefined,
47878
+ 'maintenanceMargin': this.parseNumber(maintenanceMargin),
47879
+ 'maintenanceMarginPercentage': this.parseNumber(maintenanceMarginPercentage),
47880
+ 'unrealizedPnl': this.safeNumber(position, 'unrealized_value'),
47881
+ 'realizedPnl': this.safeNumber(position, 'realized_value'),
47882
+ 'liquidationPrice': undefined,
47883
+ 'marginMode': undefined,
47884
+ 'percentage': undefined,
47885
+ 'marginRatio': this.parseNumber(marginRatio),
47886
+ 'stopLossPrice': undefined,
47887
+ 'takeProfitPrice': undefined,
47888
+ });
47889
+ }
47695
47890
  nonce() {
47696
47891
  return this.milliseconds();
47697
47892
  }
@@ -104367,7 +104562,7 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
104367
104562
  const defaultCode = this.safeValue(this.options, 'code', 'BTC');
104368
104563
  const options = this.safeValue(this.options, methodName, {});
104369
104564
  const code = this.safeValue(options, 'code', defaultCode);
104370
- return this.safeValue(params, 'code', code);
104565
+ return this.safeValue2(params, 'code', code);
104371
104566
  }
104372
104567
  async fetchStatus(params = {}) {
104373
104568
  /**
@@ -138210,7 +138405,7 @@ class idex extends _abstract_idex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
138210
138405
  //
138211
138406
  // { serverTime: '1655258263236' }
138212
138407
  //
138213
- return this.safeNumber(response, 'serverTime');
138408
+ return this.safeInteger(response, 'serverTime');
138214
138409
  }
138215
138410
  async fetchWithdrawal(id, code = undefined, params = {}) {
138216
138411
  /**
@@ -140654,6 +140849,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140654
140849
  * @method
140655
140850
  * @name kraken#fetchMarkets
140656
140851
  * @description retrieves data on all markets for kraken
140852
+ * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTradableAssetPairs
140657
140853
  * @param {object} [params] extra parameters specific to the exchange api endpoint
140658
140854
  * @returns {object[]} an array of objects representing market data
140659
140855
  */
@@ -140839,6 +141035,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140839
141035
  * @method
140840
141036
  * @name kraken#fetchCurrencies
140841
141037
  * @description fetches all available currencies on an exchange
141038
+ * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getAssetInfo
140842
141039
  * @param {object} [params] extra parameters specific to the kraken api endpoint
140843
141040
  * @returns {object} an associative dictionary of currencies
140844
141041
  */
@@ -140897,6 +141094,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140897
141094
  * @method
140898
141095
  * @name kraken#fetchTradingFee
140899
141096
  * @description fetch the trading fees for a market
141097
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradeVolume
140900
141098
  * @param {string} symbol unified market symbol
140901
141099
  * @param {object} [params] extra parameters specific to the kraken api endpoint
140902
141100
  * @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
@@ -140965,6 +141163,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140965
141163
  * @method
140966
141164
  * @name kraken#fetchOrderBook
140967
141165
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
141166
+ * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getOrderBook
140968
141167
  * @param {string} symbol unified symbol of the market to fetch the order book for
140969
141168
  * @param {int} [limit] the maximum amount of order book entries to return
140970
141169
  * @param {object} [params] extra parameters specific to the kraken api endpoint
@@ -141067,6 +141266,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141067
141266
  * @method
141068
141267
  * @name kraken#fetchTickers
141069
141268
  * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
141269
+ * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTickerInformation
141070
141270
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
141071
141271
  * @param {object} [params] extra parameters specific to the kraken api endpoint
141072
141272
  * @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -141103,6 +141303,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141103
141303
  * @method
141104
141304
  * @name kraken#fetchTicker
141105
141305
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
141306
+ * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTickerInformation
141106
141307
  * @param {string} symbol unified symbol of the market to fetch the ticker for
141107
141308
  * @param {object} [params] extra parameters specific to the kraken api endpoint
141108
141309
  * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -141147,6 +141348,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141147
141348
  * @method
141148
141349
  * @name kraken#fetchOHLCV
141149
141350
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
141351
+ * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getOHLCData
141150
141352
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
141151
141353
  * @param {string} timeframe the length of time each candle represents
141152
141354
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -141259,6 +141461,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141259
141461
  * @method
141260
141462
  * @name kraken#fetchLedger
141261
141463
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
141464
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getLedgers
141262
141465
  * @param {string} code unified currency code, default is undefined
141263
141466
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
141264
141467
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
@@ -141437,6 +141640,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141437
141640
  * @method
141438
141641
  * @name kraken#fetchTrades
141439
141642
  * @description get the list of most recent trades for a particular symbol
141643
+ * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getRecentTrades
141440
141644
  * @param {string} symbol unified symbol of the market to fetch trades for
141441
141645
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
141442
141646
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -141510,6 +141714,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141510
141714
  * @method
141511
141715
  * @name kraken#fetchBalance
141512
141716
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
141717
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getAccountBalance
141513
141718
  * @param {object} [params] extra parameters specific to the kraken api endpoint
141514
141719
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
141515
141720
  */
@@ -141753,6 +141958,16 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141753
141958
  }
141754
141959
  const clientOrderId = this.safeString(order, 'userref');
141755
141960
  const rawTrades = this.safeValue(order, 'trades');
141961
+ const trades = [];
141962
+ for (let i = 0; i < rawTrades.length; i++) {
141963
+ const rawTrade = rawTrades[i];
141964
+ if (typeof rawTrade === 'string') {
141965
+ trades.push(this.safeTrade({ 'id': rawTrade, 'orderId': id, 'symbol': symbol, 'info': {} }));
141966
+ }
141967
+ else {
141968
+ trades.push(rawTrade);
141969
+ }
141970
+ }
141756
141971
  stopPrice = this.safeNumber(order, 'stopprice', stopPrice);
141757
141972
  return this.safeOrder({
141758
141973
  'id': id,
@@ -141776,7 +141991,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141776
141991
  'average': average,
141777
141992
  'remaining': undefined,
141778
141993
  'fee': fee,
141779
- 'trades': rawTrades,
141994
+ 'trades': trades,
141780
141995
  }, market);
141781
141996
  }
141782
141997
  orderRequest(method, symbol, type, request, price = undefined, params = {}) {
@@ -141912,6 +142127,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141912
142127
  * @method
141913
142128
  * @name kraken#fetchOrder
141914
142129
  * @description fetches information on an order made by the user
142130
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOrdersInfo
141915
142131
  * @param {string} symbol not used by kraken fetchOrder
141916
142132
  * @param {object} [params] extra parameters specific to the kraken api endpoint
141917
142133
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -141981,6 +142197,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141981
142197
  * @method
141982
142198
  * @name kraken#fetchOrderTrades
141983
142199
  * @description fetch all the trades made from a single order
142200
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradesInfo
141984
142201
  * @param {string} id order id
141985
142202
  * @param {string} symbol unified market symbol
141986
142203
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -142080,6 +142297,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142080
142297
  * @method
142081
142298
  * @name kraken#fetchMyTrades
142082
142299
  * @description fetch all trades made by the user
142300
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradeHistory
142083
142301
  * @param {string} symbol unified market symbol
142084
142302
  * @param {int} [since] the earliest time in ms to fetch trades for
142085
142303
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -142139,6 +142357,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142139
142357
  * @method
142140
142358
  * @name kraken#cancelOrder
142141
142359
  * @description cancels an open order
142360
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/cancelOrder
142142
142361
  * @param {string} id order id
142143
142362
  * @param {string} symbol unified symbol of the market the order was made in
142144
142363
  * @param {object} [params] extra parameters specific to the kraken api endpoint
@@ -142169,6 +142388,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142169
142388
  * @method
142170
142389
  * @name kraken#cancelOrders
142171
142390
  * @description cancel multiple orders
142391
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/cancelOrderBatch
142172
142392
  * @param {string[]} ids open orders transaction ID (txid) or user reference (userref)
142173
142393
  * @param {string} symbol unified market symbol
142174
142394
  * @param {object} [params] extra parameters specific to the kraken api endpoint
@@ -142193,6 +142413,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142193
142413
  * @method
142194
142414
  * @name kraken#cancelAllOrders
142195
142415
  * @description cancel all open orders
142416
+ * @see https://docs.kraken.com/rest/#tag/Trading/operation/cancelAllOrders
142196
142417
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
142197
142418
  * @param {object} [params] extra parameters specific to the kraken api endpoint
142198
142419
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -142205,6 +142426,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142205
142426
  * @method
142206
142427
  * @name kraken#fetchOpenOrders
142207
142428
  * @description fetch all unfilled currently open orders
142429
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenOrders
142208
142430
  * @param {string} symbol unified market symbol
142209
142431
  * @param {int} [since] the earliest time in ms to fetch open orders for
142210
142432
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -142236,6 +142458,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142236
142458
  * @method
142237
142459
  * @name kraken#fetchClosedOrders
142238
142460
  * @description fetches information on multiple closed orders made by the user
142461
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
142239
142462
  * @param {string} symbol unified market symbol of the market orders were made in
142240
142463
  * @param {int} [since] the earliest time in ms to fetch orders for
142241
142464
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -142433,6 +142656,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142433
142656
  * @method
142434
142657
  * @name kraken#fetchDeposits
142435
142658
  * @description fetch all deposits made to an account
142659
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getStatusRecentDeposits
142436
142660
  * @param {string} code unified currency code
142437
142661
  * @param {int} [since] the earliest time in ms to fetch deposits for
142438
142662
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -142469,6 +142693,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142469
142693
  * @method
142470
142694
  * @name kraken#fetchTime
142471
142695
  * @description fetches the current integer timestamp in milliseconds from the exchange server
142696
+ * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getServerTime
142472
142697
  * @param {object} [params] extra parameters specific to the kraken api endpoint
142473
142698
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
142474
142699
  */
@@ -142491,6 +142716,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142491
142716
  * @method
142492
142717
  * @name kraken#fetchWithdrawals
142493
142718
  * @description fetch all withdrawals made from an account
142719
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getStatusRecentWithdrawals
142494
142720
  * @param {string} code unified currency code
142495
142721
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
142496
142722
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -142527,6 +142753,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142527
142753
  * @method
142528
142754
  * @name kraken#createDepositAddress
142529
142755
  * @description create a currency deposit address
142756
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositAddresses
142530
142757
  * @param {string} code unified currency code of the currency for the deposit address
142531
142758
  * @param {object} [params] extra parameters specific to the kraken api endpoint
142532
142759
  * @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
@@ -142573,6 +142800,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142573
142800
  * @method
142574
142801
  * @name kraken#fetchDepositAddress
142575
142802
  * @description fetch the deposit address for a currency associated with this account
142803
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositAddresses
142576
142804
  * @param {string} code unified currency code
142577
142805
  * @param {object} [params] extra parameters specific to the kraken api endpoint
142578
142806
  * @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
@@ -142654,6 +142882,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142654
142882
  * @method
142655
142883
  * @name kraken#withdraw
142656
142884
  * @description make a withdrawal
142885
+ * @see https://docs.kraken.com/rest/#tag/Funding/operation/withdrawFunds
142657
142886
  * @param {string} code unified currency code
142658
142887
  * @param {float} amount the amount to withdraw
142659
142888
  * @param {string} address the address to withdraw to
@@ -142690,6 +142919,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142690
142919
  * @method
142691
142920
  * @name kraken#fetchPositions
142692
142921
  * @description fetch all open positions
142922
+ * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenPositions
142693
142923
  * @param {string[]|undefined} symbols not used by kraken fetchPositions ()
142694
142924
  * @param {object} [params] extra parameters specific to the kraken api endpoint
142695
142925
  * @returns {object[]} a list of [position structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#position-structure}
@@ -142761,6 +142991,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142761
142991
  async transferOut(code, amount, params = {}) {
142762
142992
  /**
142763
142993
  * @description transfer from spot wallet to futures wallet
142994
+ * @see https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
142764
142995
  * @param {str} code Unified currency code
142765
142996
  * @param {float} amount Size of the transfer
142766
142997
  * @param {dict} [params] Exchange specific parameters
@@ -149821,7 +150052,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
149821
150052
  // data: 1637385119302,
149822
150053
  // }
149823
150054
  //
149824
- return this.safeNumber(response, 'data');
150055
+ return this.safeInteger(response, 'data');
149825
150056
  }
149826
150057
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
149827
150058
  /**
@@ -176596,6 +176827,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
176596
176827
  * @method
176597
176828
  * @name okx#fetchStatus
176598
176829
  * @description the latest known information on the availability of the exchange API
176830
+ * @see https://www.okx.com/docs-v5/en/#status-get-status
176599
176831
  * @param {object} [params] extra parameters specific to the okx api endpoint
176600
176832
  * @returns {object} a [status structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#exchange-status-structure}
176601
176833
  */
@@ -176644,6 +176876,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
176644
176876
  * @method
176645
176877
  * @name okx#fetchTime
176646
176878
  * @description fetches the current integer timestamp in milliseconds from the exchange server
176879
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-system-time
176647
176880
  * @param {object} [params] extra parameters specific to the okx api endpoint
176648
176881
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
176649
176882
  */
@@ -176666,6 +176899,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
176666
176899
  * @method
176667
176900
  * @name okx#fetchAccounts
176668
176901
  * @description fetch all the accounts associated with a profile
176902
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-account-configuration
176669
176903
  * @param {object} [params] extra parameters specific to the okx api endpoint
176670
176904
  * @returns {object} a dictionary of [account structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#account-structure} indexed by the account type
176671
176905
  */
@@ -177090,6 +177324,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
177090
177324
  * @method
177091
177325
  * @name okx#fetchOrderBook
177092
177326
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
177327
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-order-book
177093
177328
  * @param {string} symbol unified symbol of the market to fetch the order book for
177094
177329
  * @param {int} [limit] the maximum amount of order book entries to return
177095
177330
  * @param {object} [params] extra parameters specific to the okx api endpoint
@@ -177191,6 +177426,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
177191
177426
  * @method
177192
177427
  * @name okx#fetchTicker
177193
177428
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
177429
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-ticker
177194
177430
  * @param {string} symbol unified symbol of the market to fetch the ticker for
177195
177431
  * @param {object} [params] extra parameters specific to the okx api endpoint
177196
177432
  * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -177281,6 +177517,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
177281
177517
  * @method
177282
177518
  * @name okx#fetchTickers
177283
177519
  * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
177520
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
177284
177521
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
177285
177522
  * @param {object} [params] extra parameters specific to the okx api endpoint
177286
177523
  * @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -177593,6 +177830,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
177593
177830
  * @method
177594
177831
  * @name okx#fetchFundingRateHistory
177595
177832
  * @description fetches historical funding rate prices
177833
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate-history
177596
177834
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
177597
177835
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
177598
177836
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
@@ -177731,6 +177969,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
177731
177969
  * @method
177732
177970
  * @name okx#fetchTradingFee
177733
177971
  * @description fetch the trading fees for a market
177972
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-fee-rates
177734
177973
  * @param {string} symbol unified market symbol
177735
177974
  * @param {object} [params] extra parameters specific to the okx api endpoint
177736
177975
  * @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
@@ -177780,6 +178019,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
177780
178019
  * @method
177781
178020
  * @name okx#fetchBalance
177782
178021
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
178022
+ * @see https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-balance
178023
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-balance
177783
178024
  * @param {object} [params] extra parameters specific to the okx api endpoint
177784
178025
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
177785
178026
  */
@@ -178315,6 +178556,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
178315
178556
  * @method
178316
178557
  * @name okx#cancelOrder
178317
178558
  * @description cancels an open order
178559
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-order
178318
178560
  * @param {string} id order id
178319
178561
  * @param {string} symbol unified symbol of the market the order was made in
178320
178562
  * @param {object} [params] extra parameters specific to the okx api endpoint
@@ -178369,6 +178611,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
178369
178611
  * @method
178370
178612
  * @name okx#cancelOrders
178371
178613
  * @description cancel multiple orders
178614
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-multiple-orders
178615
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
178372
178616
  * @param {string[]} ids order ids
178373
178617
  * @param {string} symbol unified market symbol
178374
178618
  * @param {object} [params] extra parameters specific to the okx api endpoint
@@ -178671,6 +178915,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
178671
178915
  * @method
178672
178916
  * @name okx#fetchOrder
178673
178917
  * @description fetch an order by the id
178918
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-details
178919
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-details
178674
178920
  * @param {string} id the order id
178675
178921
  * @param {string} symbol unified market symbol
178676
178922
  * @param {object} [params] extra and exchange specific parameters
@@ -178817,6 +179063,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
178817
179063
  * @name okx#fetchOpenOrders
178818
179064
  * @description Fetch orders that are still open
178819
179065
  * @description fetch all unfilled currently open orders
179066
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-list
179067
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-list
178820
179068
  * @param {string} symbol unified market symbol
178821
179069
  * @param {int} [since] the earliest time in ms to fetch open orders for
178822
179070
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -178965,6 +179213,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
178965
179213
  * @method
178966
179214
  * @name okx#fetchCanceledOrders
178967
179215
  * @description fetches information on multiple canceled orders made by the user
179216
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
179217
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-history
178968
179218
  * @param {string} symbol unified market symbol of the market orders were made in
178969
179219
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
178970
179220
  * @param {int} [limit] max number of orders to return, default is undefined
@@ -179139,6 +179389,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
179139
179389
  * @method
179140
179390
  * @name okx#fetchClosedOrders
179141
179391
  * @description fetches information on multiple closed orders made by the user
179392
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
179393
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-history
179142
179394
  * @param {string} symbol unified market symbol of the market orders were made in
179143
179395
  * @param {int} [since] the earliest time in ms to fetch orders for
179144
179396
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -179304,6 +179556,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
179304
179556
  * @method
179305
179557
  * @name okx#fetchMyTrades
179306
179558
  * @description fetch all trades made by the user
179559
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-transaction-details-last-3-months
179307
179560
  * @param {string} symbol unified market symbol
179308
179561
  * @param {int} [since] the earliest time in ms to fetch trades for
179309
179562
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -179364,6 +179617,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
179364
179617
  * @method
179365
179618
  * @name okx#fetchOrderTrades
179366
179619
  * @description fetch all the trades made from a single order
179620
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-transaction-details-last-3-months
179367
179621
  * @param {string} id order id
179368
179622
  * @param {string} symbol unified market symbol
179369
179623
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -179682,6 +179936,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
179682
179936
  * @method
179683
179937
  * @name okx#fetchDepositAddressesByNetwork
179684
179938
  * @description fetch a dictionary of addresses for a currency, indexed by network
179939
+ * @see https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-deposit-address
179685
179940
  * @param {string} code unified currency code of the currency for the deposit address
179686
179941
  * @param {object} [params] extra parameters specific to the okx api endpoint
179687
179942
  * @returns {object} a dictionary of [address structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure} indexed by the network
@@ -179723,6 +179978,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
179723
179978
  * @method
179724
179979
  * @name okx#fetchDepositAddress
179725
179980
  * @description fetch the deposit address for a currency associated with this account
179981
+ * @see https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-deposit-address
179726
179982
  * @param {string} code unified currency code
179727
179983
  * @param {object} [params] extra parameters specific to the okx api endpoint
179728
179984
  * @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
@@ -179763,6 +180019,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
179763
180019
  * @method
179764
180020
  * @name okx#withdraw
179765
180021
  * @description make a withdrawal
180022
+ * @see https://www.okx.com/docs-v5/en/#funding-account-rest-api-withdrawal
179766
180023
  * @param {string} code unified currency code
179767
180024
  * @param {float} amount the amount to withdraw
179768
180025
  * @param {string} address the address to withdraw to
@@ -180707,6 +180964,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
180707
180964
  * @method
180708
180965
  * @name okx#fetchTransfers
180709
180966
  * @description fetch a history of internal transfers made on an account
180967
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months
180710
180968
  * @param {string} code unified currency code of the currency transferred
180711
180969
  * @param {int} [since] the earliest time in ms to fetch transfers for
180712
180970
  * @param {int} [limit] the maximum number of transfers structures to retrieve
@@ -180873,6 +181131,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
180873
181131
  * @method
180874
181132
  * @name okx#fetchFundingRate
180875
181133
  * @description fetch the current funding rate
181134
+ * @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
180876
181135
  * @param {string} symbol unified market symbol
180877
181136
  * @param {object} [params] extra parameters specific to the okx api endpoint
180878
181137
  * @returns {object} a [funding rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure}
@@ -180911,6 +181170,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
180911
181170
  * @method
180912
181171
  * @name okx#fetchFundingHistory
180913
181172
  * @description fetch the history of funding payments paid and received on this account
181173
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months
180914
181174
  * @param {string} symbol unified market symbol
180915
181175
  * @param {int} [since] the earliest time in ms to fetch funding history for
180916
181176
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -181131,6 +181391,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181131
181391
  * @method
181132
181392
  * @name okx#setPositionMode
181133
181393
  * @description set hedged to true or false for a market
181394
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-position-mode
181134
181395
  * @param {bool} hedged set to true to use long_short_mode, false for net_mode
181135
181396
  * @param {string} symbol not used by okx setPositionMode
181136
181397
  * @param {object} [params] extra parameters specific to the okx api endpoint
@@ -181165,6 +181426,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181165
181426
  * @method
181166
181427
  * @name okx#setMarginMode
181167
181428
  * @description set margin mode to 'cross' or 'isolated'
181429
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-leverage
181168
181430
  * @param {string} marginMode 'cross' or 'isolated'
181169
181431
  * @param {string} symbol unified market symbol
181170
181432
  * @param {object} [params] extra parameters specific to the okx api endpoint
@@ -181213,6 +181475,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181213
181475
  * @method
181214
181476
  * @name okx#fetchBorrowRates
181215
181477
  * @description fetch the borrow interest rates of all currencies
181478
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-interest-rate
181216
181479
  * @param {object} [params] extra parameters specific to the okx api endpoint
181217
181480
  * @returns {object} a list of [borrow rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure}
181218
181481
  */
@@ -181252,6 +181515,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181252
181515
  * @method
181253
181516
  * @name okx#fetchBorrowRate
181254
181517
  * @description fetch the rate of interest to borrow a currency for margin trading
181518
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-interest-rate
181255
181519
  * @param {string} code unified currency code
181256
181520
  * @param {object} [params] extra parameters specific to the okx api endpoint
181257
181521
  * @returns {object} a [borrow rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure}
@@ -181345,6 +181609,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181345
181609
  * @method
181346
181610
  * @name okx#fetchBorrowRateHistories
181347
181611
  * @description retrieves a history of a multiple currencies borrow interest rate at specific time slots, returns all currencies if no symbols passed, default is undefined
181612
+ * @see https://www.okx.com/docs-v5/en/#financial-product-savings-get-public-borrow-history-public
181348
181613
  * @param {string[]|undefined} codes list of unified currency codes, default is undefined
181349
181614
  * @param {int} [since] timestamp in ms of the earliest borrowRate, default is undefined
181350
181615
  * @param {int} [limit] max number of borrow rate prices to return, default is undefined
@@ -181387,6 +181652,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181387
181652
  * @method
181388
181653
  * @name okx#fetchBorrowRateHistory
181389
181654
  * @description retrieves a history of a currencies borrow interest rate at specific time slots
181655
+ * @see https://www.okx.com/docs-v5/en/#financial-product-savings-get-public-borrow-history-public
181390
181656
  * @param {string} code unified currency code
181391
181657
  * @param {int} [since] timestamp for the earliest borrow rate
181392
181658
  * @param {int} [limit] the maximum number of [borrow rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure} to retrieve
@@ -181478,6 +181744,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181478
181744
  * @method
181479
181745
  * @name okx#reduceMargin
181480
181746
  * @description remove margin from a position
181747
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-increase-decrease-margin
181481
181748
  * @param {string} symbol unified market symbol
181482
181749
  * @param {float} amount the amount of margin to remove
181483
181750
  * @param {object} [params] extra parameters specific to the okx api endpoint
@@ -181490,6 +181757,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
181490
181757
  * @method
181491
181758
  * @name okx#addMargin
181492
181759
  * @description add margin
181760
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-increase-decrease-margin
181493
181761
  * @param {string} symbol unified market symbol
181494
181762
  * @param {float} amount amount of margin to add
181495
181763
  * @param {object} [params] extra parameters specific to the okx api endpoint
@@ -193273,14 +193541,20 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
193273
193541
  // valid <levels> are 5, 10, or 20
193274
193542
  //
193275
193543
  // default 100, max 1000, valid limits 5, 10, 20, 50, 100, 500, 1000
193544
+ await this.loadMarkets();
193545
+ const market = this.market(symbol);
193276
193546
  if (limit !== undefined) {
193277
- if ((limit !== 5) && (limit !== 10) && (limit !== 20) && (limit !== 50) && (limit !== 100) && (limit !== 500) && (limit !== 1000)) {
193278
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' watchOrderBook limit argument must be undefined, 5, 10, 20, 50, 100, 500 or 1000');
193547
+ if (market['contract']) {
193548
+ if ((limit !== 5) && (limit !== 10) && (limit !== 20) && (limit !== 50) && (limit !== 100) && (limit !== 500) && (limit !== 1000)) {
193549
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' watchOrderBook limit argument must be undefined, 5, 10, 20, 50, 100, 500 or 1000');
193550
+ }
193551
+ }
193552
+ else {
193553
+ if (limit > 5000) {
193554
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' watchOrderBook limit argument must be less than or equal to 5000');
193555
+ }
193279
193556
  }
193280
193557
  }
193281
- //
193282
- await this.loadMarkets();
193283
- const market = this.market(symbol);
193284
193558
  let type = market['type'];
193285
193559
  if (market['contract']) {
193286
193560
  type = market['linear'] ? 'future' : 'delivery';
@@ -260241,7 +260515,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
260241
260515
  // ]
260242
260516
  // }
260243
260517
  //
260244
- const timestamp = this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(this.safeString(response, 'timestamp'), '1000'));
260518
+ const timestamp = this.parseToInt(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(this.safeString(response, 'timestamp'), '1000'));
260245
260519
  return this.parseOrderBook(response, symbol, timestamp);
260246
260520
  }
260247
260521
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -273795,7 +274069,7 @@ SOFTWARE.
273795
274069
 
273796
274070
  //-----------------------------------------------------------------------------
273797
274071
  // this is updated by vss.js when building
273798
- const version = '4.1.2';
274072
+ const version = '4.1.4';
273799
274073
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
273800
274074
  //-----------------------------------------------------------------------------
273801
274075