ccxt 4.1.9 → 4.1.10

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.
@@ -8627,7 +8627,7 @@ class Exchange {
8627
8627
  // string = true
8628
8628
  //
8629
8629
  // [
8630
- // { 'currency': 'BTC', 'cost': '0.3' },
8630
+ // { 'currency': 'BTC', 'cost': '0.4' },
8631
8631
  // { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
8632
8632
  // { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
8633
8633
  // { 'currency': 'USDT', 'cost': '12.3456' },
@@ -26861,8 +26861,9 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26861
26861
  'liquidationPrice': undefined,
26862
26862
  'entryPrice': this.safeNumber2(position, 'avgPrice', 'entryPrice'),
26863
26863
  'unrealizedPnl': this.safeNumber(position, 'unrealizedProfit'),
26864
+ 'realizedPnl': this.safeNumber(position, 'realisedProfit'),
26864
26865
  'percentage': undefined,
26865
- 'contracts': undefined,
26866
+ 'contracts': this.safeNumber(position, 'positionAmt'),
26866
26867
  'contractSize': undefined,
26867
26868
  'markPrice': undefined,
26868
26869
  'lastPrice': undefined,
@@ -26873,7 +26874,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26873
26874
  'lastUpdateTimestamp': undefined,
26874
26875
  'maintenanceMargin': undefined,
26875
26876
  'maintenanceMarginPercentage': undefined,
26876
- 'collateral': this.safeString(position, 'positionAmt'),
26877
+ 'collateral': this.safeNumber(position, 'positionAmt'),
26877
26878
  'initialMargin': this.safeNumber(position, 'initialMargin'),
26878
26879
  'initialMarginPercentage': undefined,
26879
26880
  'leverage': this.safeNumber(position, 'leverage'),
@@ -30880,9 +30881,12 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
30880
30881
  // note that "Money" stands for INR - the only fiat in bitbns
30881
30882
  return this.parseBalance(response);
30882
30883
  }
30883
- parseOrderStatus(status) {
30884
+ parseStatus(status) {
30884
30885
  const statuses = {
30886
+ '-1': 'cancelled',
30885
30887
  '0': 'open',
30888
+ '1': 'open',
30889
+ '2': 'done',
30886
30890
  // 'PARTIALLY_FILLED': 'open',
30887
30891
  // 'FILLED': 'closed',
30888
30892
  // 'CANCELED': 'canceled',
@@ -30897,90 +30901,78 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
30897
30901
  // createOrder
30898
30902
  //
30899
30903
  // {
30900
- // "data":"Successfully placed bid to purchase currency",
30901
- // "status":1,
30902
- // "error":null,
30903
- // "id":5424475,
30904
- // "code":200
30904
+ // "data": "Successfully placed bid to purchase currency",
30905
+ // "status": 1,
30906
+ // "error": null,
30907
+ // "id": 5424475,
30908
+ // "code": 200
30905
30909
  // }
30906
30910
  //
30907
- // fetchOrder
30911
+ // fetchOpenOrders, fetchOrder
30908
30912
  //
30909
- // {
30910
- // "entry_id":5424475,
30911
- // "btc":0.01,
30912
- // "rate":2000,
30913
- // "time":"2021-04-25T17:05:42.000Z",
30914
- // "type":0,
30915
- // "status":0,
30916
- // "total":0.01,
30917
- // "avg_cost":null,
30918
- // "side":"BUY",
30919
- // "amount":0.01,
30920
- // "remaining":0.01,
30921
- // "filled":0,
30922
- // "cost":null,
30923
- // "fee":0.05
30924
- // }
30913
+ // {
30914
+ // "entry_id": 5424475,
30915
+ // "btc": 0.01,
30916
+ // "rate": 2000,
30917
+ // "time": "2021-04-25T17:05:42.000Z",
30918
+ // "type": 0,
30919
+ // "status": 0
30920
+ // "t_rate": 0.45, // only stop orders
30921
+ // "trail": 0 // only stop orders
30922
+ // }
30925
30923
  //
30926
- // fetchOpenOrders
30924
+ // cancelOrder
30927
30925
  //
30928
- // {
30929
- // "entry_id":5424475,
30930
- // "btc":0.01,
30931
- // "rate":2000,
30932
- // "time":"2021-04-25T17:05:42.000Z",
30933
- // "type":0,
30934
- // "status":0
30935
- // }
30926
+ // {
30927
+ // "data": "Successfully cancelled the order",
30928
+ // "status": 1,
30929
+ // "error": null,
30930
+ // "code": 200
30931
+ // }
30936
30932
  //
30937
30933
  const id = this.safeString2(order, 'id', 'entry_id');
30938
- const marketId = this.safeString(order, 'symbol');
30939
- const symbol = this.safeSymbol(marketId, market);
30940
- const timestamp = this.parse8601(this.safeString(order, 'time'));
30941
- const price = this.safeString(order, 'rate');
30942
- const amount = this.safeString2(order, 'amount', 'btc');
30943
- const filled = this.safeString(order, 'filled');
30944
- const remaining = this.safeString(order, 'remaining');
30945
- const average = this.safeString(order, 'avg_cost');
30946
- const cost = this.safeString(order, 'cost');
30947
- let type = this.safeStringLower(order, 'type');
30948
- if (type === '0') {
30949
- type = 'limit';
30934
+ const datetime = this.safeString(order, 'time');
30935
+ const triggerPrice = this.safeString(order, 't_rate');
30936
+ let side = this.safeString(order, 'type');
30937
+ if (side === '0') {
30938
+ side = 'buy';
30950
30939
  }
30951
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
30952
- const side = this.safeStringLower(order, 'side');
30953
- const feeCost = this.safeNumber(order, 'fee');
30954
- let fee = undefined;
30955
- if (feeCost !== undefined) {
30956
- const feeCurrencyCode = undefined;
30957
- fee = {
30958
- 'cost': feeCost,
30959
- 'currency': feeCurrencyCode,
30960
- };
30940
+ else if (side === '1') {
30941
+ side = 'sell';
30942
+ }
30943
+ const data = this.safeString(order, 'data');
30944
+ let status = this.safeString(order, 'status');
30945
+ if (data === 'Successfully cancelled the order') {
30946
+ status = 'cancelled';
30947
+ }
30948
+ else {
30949
+ status = this.parseStatus(status);
30961
30950
  }
30962
30951
  return this.safeOrder({
30963
30952
  'info': order,
30964
30953
  'id': id,
30965
30954
  'clientOrderId': undefined,
30966
- 'timestamp': timestamp,
30967
- 'datetime': this.iso8601(timestamp),
30955
+ 'timestamp': this.parse8601(datetime),
30956
+ 'datetime': datetime,
30968
30957
  'lastTradeTimestamp': undefined,
30969
- 'symbol': symbol,
30970
- 'type': type,
30958
+ 'symbol': this.safeString(market, 'symbol'),
30971
30959
  'timeInForce': undefined,
30972
30960
  'postOnly': undefined,
30973
30961
  'side': side,
30974
- 'price': price,
30975
- 'stopPrice': undefined,
30976
- 'triggerPrice': undefined,
30977
- 'amount': amount,
30978
- 'cost': cost,
30979
- 'average': average,
30980
- 'filled': filled,
30981
- 'remaining': remaining,
30962
+ 'price': this.safeString(order, 'rate'),
30963
+ 'stopPrice': triggerPrice,
30964
+ 'triggerPrice': triggerPrice,
30965
+ 'amount': this.safeString(order, 'btc'),
30966
+ 'cost': undefined,
30967
+ 'average': undefined,
30968
+ 'filled': undefined,
30969
+ 'remaining': undefined,
30982
30970
  'status': status,
30983
- 'fee': fee,
30971
+ 'fee': {
30972
+ 'cost': undefined,
30973
+ 'currency': undefined,
30974
+ 'rate': undefined,
30975
+ },
30984
30976
  'trades': undefined,
30985
30977
  }, market);
30986
30978
  }
@@ -30989,19 +30981,27 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
30989
30981
  * @method
30990
30982
  * @name bitbns#createOrder
30991
30983
  * @description create a trade order
30984
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/place-orders
30985
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/market-orders-quantity // market orders
30992
30986
  * @param {string} symbol unified symbol of the market to create an order in
30993
30987
  * @param {string} type 'market' or 'limit'
30994
30988
  * @param {string} side 'buy' or 'sell'
30995
30989
  * @param {float} amount how much of currency you want to trade in units of base currency
30996
30990
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
30997
30991
  * @param {object} [params] extra parameters specific to the bitbns api endpoint
30992
+ * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
30993
+ *
30994
+ * EXCHANGE SPECIFIC PARAMETERS
30995
+ * @param {float} [params.target_rate] *requires params.trail_rate when set, type must be 'limit'* a bracket order is placed when set
30996
+ * @param {float} [params.trail_rate] *requires params.target_rate when set, type must be 'limit'* a bracket order is placed when set
30998
30997
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
30999
30998
  */
31000
- if (type !== 'limit' && type !== 'market') {
31001
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' allows limit and market orders only');
31002
- }
31003
30999
  await this.loadMarkets();
31004
31000
  const market = this.market(symbol);
31001
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 't_rate']);
31002
+ const targetRate = this.safeString(params, 'target_rate');
31003
+ const trailRate = this.safeString(params, 'trail_rate');
31004
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'trail_rate', 'target_rate', 't_rate']);
31005
31005
  const request = {
31006
31006
  'side': side.toUpperCase(),
31007
31007
  'symbol': market['uppercaseId'],
@@ -31009,20 +31009,23 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31009
31009
  // 'target_rate': this.priceToPrecision (symbol, targetRate),
31010
31010
  // 't_rate': this.priceToPrecision (symbol, stopPrice),
31011
31011
  // 'trail_rate': this.priceToPrecision (symbol, trailRate),
31012
- // To Place Simple Buy or Sell Order use rate
31013
- // To Place Stoploss Buy or Sell Order use rate & t_rate
31014
- // To Place Bracket Buy or Sell Order use rate , t_rate, target_rate & trail_rate
31015
31012
  };
31016
31013
  let method = 'v2PostOrders';
31017
31014
  if (type === 'limit') {
31018
31015
  request['rate'] = this.priceToPrecision(symbol, price);
31019
31016
  }
31020
- else if (type === 'market') {
31017
+ else {
31021
31018
  method = 'v1PostPlaceMarketOrderQntySymbol';
31022
31019
  request['market'] = market['quoteId'];
31023
31020
  }
31024
- else {
31025
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' allows limit and market orders only');
31021
+ if (triggerPrice !== undefined) {
31022
+ request['t_rate'] = this.priceToPrecision(symbol, triggerPrice);
31023
+ }
31024
+ if (targetRate !== undefined) {
31025
+ request['target_rate'] = this.priceToPrecision(symbol, targetRate);
31026
+ }
31027
+ if (trailRate !== undefined) {
31028
+ request['trail_rate'] = this.priceToPrecision(symbol, trailRate);
31026
31029
  }
31027
31030
  const response = await this[method](this.extend(request, params));
31028
31031
  //
@@ -31041,9 +31044,12 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31041
31044
  * @method
31042
31045
  * @name bitbns#cancelOrder
31043
31046
  * @description cancels an open order
31047
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/cancel-orders
31048
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/cancel-stop-loss-orders
31044
31049
  * @param {string} id order id
31045
31050
  * @param {string} symbol unified symbol of the market the order was made in
31046
31051
  * @param {object} [params] extra parameters specific to the bitbns api endpoint
31052
+ * @param {boolean} [params.trigger] true if cancelling a trigger order
31047
31053
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
31048
31054
  */
31049
31055
  if (symbol === undefined) {
@@ -31051,13 +31057,18 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31051
31057
  }
31052
31058
  await this.loadMarkets();
31053
31059
  const market = this.market(symbol);
31054
- const quoteSide = (market['quoteId'] === 'USDT') ? 'usdtcancelOrder' : 'cancelOrder';
31060
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
31061
+ params = this.omit(params, ['trigger', 'stop']);
31055
31062
  const request = {
31056
31063
  'entry_id': id,
31057
31064
  'symbol': market['uppercaseId'],
31058
- 'side': quoteSide,
31059
31065
  };
31060
- const response = await this.v2PostCancel(this.extend(request, params));
31066
+ let response = undefined;
31067
+ const tail = isTrigger ? 'StopLossOrder' : 'Order';
31068
+ let quoteSide = (market['quoteId'] === 'USDT') ? 'usdtcancel' : 'cancel';
31069
+ quoteSide += tail;
31070
+ request['side'] = quoteSide;
31071
+ response = await this.v2PostCancel(this.extend(request, params));
31061
31072
  return this.parseOrder(response, market);
31062
31073
  }
31063
31074
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -31065,6 +31076,8 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31065
31076
  * @method
31066
31077
  * @name bitbns#fetchOrder
31067
31078
  * @description fetches information on an order made by the user
31079
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/order-status
31080
+ * @param {string} id order id
31068
31081
  * @param {string} symbol unified symbol of the market the order was made in
31069
31082
  * @param {object} [params] extra parameters specific to the bitbns api endpoint
31070
31083
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -31078,6 +31091,10 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31078
31091
  'symbol': market['id'],
31079
31092
  'entry_id': id,
31080
31093
  };
31094
+ const trigger = this.safeValue2(params, 'trigger', 'stop');
31095
+ if (trigger) {
31096
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOrder cannot fetch stop orders');
31097
+ }
31081
31098
  const response = await this.v1PostOrderStatusSymbol(this.extend(request, params));
31082
31099
  //
31083
31100
  // {
@@ -31113,10 +31130,13 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31113
31130
  * @method
31114
31131
  * @name bitbns#fetchOpenOrders
31115
31132
  * @description fetch all unfilled currently open orders
31133
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/order-status-limit
31134
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/order-status-limit/order-status-stop-limit
31116
31135
  * @param {string} symbol unified market symbol
31117
31136
  * @param {int} [since] the earliest time in ms to fetch open orders for
31118
- * @param {int} [limit] the maximum number of open orders structures to retrieve
31137
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
31119
31138
  * @param {object} [params] extra parameters specific to the bitbns api endpoint
31139
+ * @param {boolean} [params.trigger] true if fetching trigger orders
31120
31140
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
31121
31141
  */
31122
31142
  if (symbol === undefined) {
@@ -31124,11 +31144,13 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31124
31144
  }
31125
31145
  await this.loadMarkets();
31126
31146
  const market = this.market(symbol);
31127
- const quoteSide = (market['quoteId'] === 'USDT') ? 'usdtListOpenOrders' : 'listOpenOrders';
31147
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
31148
+ params = this.omit(params, ['trigger', 'stop']);
31149
+ const quoteSide = (market['quoteId'] === 'USDT') ? 'usdtListOpen' : 'listOpen';
31128
31150
  const request = {
31129
31151
  'symbol': market['uppercaseId'],
31130
- 'side': quoteSide,
31131
31152
  'page': 0,
31153
+ 'side': isTrigger ? (quoteSide + 'StopOrders') : (quoteSide + 'Orders'),
31132
31154
  };
31133
31155
  const response = await this.v2PostGetordersnew(this.extend(request, params));
31134
31156
  //
@@ -31141,6 +31163,9 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31141
31163
  // "time":"2021-04-25T17:05:42.000Z",
31142
31164
  // "type":0,
31143
31165
  // "status":0
31166
+ // "t_rate":0.45, // only stop orders
31167
+ // "type":1, // only stop orders
31168
+ // "trail":0 // only stop orders
31144
31169
  // }
31145
31170
  // ],
31146
31171
  // "status":1,
@@ -31563,7 +31588,7 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31563
31588
  'body': body,
31564
31589
  };
31565
31590
  const payload = this.stringToBase64(this.json(auth));
31566
- const signature = this.hmac(payload, this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__/* .sha512 */ .o);
31591
+ const signature = this.hmac(this.encode(payload), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__/* .sha512 */ .o);
31567
31592
  headers['X-BITBNS-PAYLOAD'] = payload;
31568
31593
  headers['X-BITBNS-SIGNATURE'] = signature;
31569
31594
  headers['Content-Type'] = 'application/x-www-form-urlencoded';
@@ -41510,7 +41535,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41510
41535
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#cancel-all-trigger-order-tpsl
41511
41536
  * @param {string} symbol unified market symbol
41512
41537
  * @param {object} [params] extra parameters specific to the bitget api endpoint
41513
- * @param {string} [params.code] marginCoin unified currency code
41514
41538
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
41515
41539
  */
41516
41540
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
@@ -41525,33 +41549,28 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41525
41549
  if (sandboxMode) {
41526
41550
  productType = 'S' + productType;
41527
41551
  }
41528
- const [marketType, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
41552
+ let marketType = undefined;
41553
+ [marketType, params] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
41529
41554
  if (marketType === 'spot') {
41530
41555
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' cancelAllOrders () does not support spot markets');
41531
41556
  }
41532
41557
  const request = {
41533
41558
  'productType': productType,
41559
+ 'marginCoin': market['settleId'],
41534
41560
  };
41535
- let method = undefined;
41536
- const stop = this.safeValue(query, 'stop');
41537
- const planType = this.safeString(query, 'planType');
41561
+ const stop = this.safeValue2(params, 'stop', 'trigger');
41562
+ const planType = this.safeString(params, 'planType');
41563
+ params = this.omit(params, ['stop', 'trigger']);
41564
+ let response = undefined;
41538
41565
  if (stop !== undefined || planType !== undefined) {
41539
41566
  if (planType === undefined) {
41540
41567
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrder() requires a planType parameter for stop orders, either normal_plan, profit_plan, loss_plan, pos_profit, pos_loss, moving_plan or track_plan');
41541
41568
  }
41542
- method = 'privateMixPostPlanCancelAllPlan';
41569
+ response = await this.privateMixPostPlanCancelAllPlan(this.extend(request, params));
41543
41570
  }
41544
41571
  else {
41545
- const code = this.safeString2(params, 'code', 'marginCoin');
41546
- if (code === undefined) {
41547
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelAllOrders () requires a code argument [marginCoin] in the params');
41548
- }
41549
- const currency = this.currency(code);
41550
- request['marginCoin'] = this.safeCurrencyCode(code, currency);
41551
- method = 'privateMixPostOrderCancelAllOrders';
41572
+ response = await this.privateMixPostOrderCancelAllOrders(this.extend(request, params));
41552
41573
  }
41553
- const ommitted = this.omit(query, ['stop', 'code', 'marginCoin']);
41554
- const response = await this[method](this.extend(request, ommitted));
41555
41574
  //
41556
41575
  // {
41557
41576
  // "code": "00000",
@@ -67668,6 +67687,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
67668
67687
  /**
67669
67688
  * @method
67670
67689
  * @name btcalpha#fetchOrderBook
67690
+ * @see https://btc-alpha.github.io/api-docs/#get-orderbook
67671
67691
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
67672
67692
  * @param {string} symbol unified symbol of the market to fetch the order book for
67673
67693
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -68048,15 +68068,19 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68048
68068
  /**
68049
68069
  * @method
68050
68070
  * @name btcalpha#createOrder
68071
+ * @see https://btc-alpha.github.io/api-docs/#create-order
68051
68072
  * @description create a trade order
68052
68073
  * @param {string} symbol unified symbol of the market to create an order in
68053
- * @param {string} type 'market' or 'limit'
68074
+ * @param {string} type 'limit'
68054
68075
  * @param {string} side 'buy' or 'sell'
68055
68076
  * @param {float} amount how much of currency you want to trade in units of base currency
68056
68077
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
68057
68078
  * @param {object} [params] extra parameters specific to the btcalpha api endpoint
68058
68079
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
68059
68080
  */
68081
+ if (type === 'market') {
68082
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' only limits orders are supported');
68083
+ }
68060
68084
  await this.loadMarkets();
68061
68085
  const market = this.market(symbol);
68062
68086
  const request = {
@@ -68080,6 +68104,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68080
68104
  /**
68081
68105
  * @method
68082
68106
  * @name btcalpha#cancelOrder
68107
+ * @see https://btc-alpha.github.io/api-docs/#cancel-order
68083
68108
  * @description cancels an open order
68084
68109
  * @param {string} id order id
68085
68110
  * @param {string} symbol unified symbol of the market the order was made in
@@ -68096,6 +68121,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68096
68121
  /**
68097
68122
  * @method
68098
68123
  * @name btcalpha#fetchOrder
68124
+ * @see https://btc-alpha.github.io/api-docs/#retrieve-single-order
68099
68125
  * @description fetches information on an order made by the user
68100
68126
  * @param {string} symbol not used by btcalpha fetchOrder
68101
68127
  * @param {object} [params] extra parameters specific to the btcalpha api endpoint
@@ -68112,6 +68138,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68112
68138
  /**
68113
68139
  * @method
68114
68140
  * @name btcalpha#fetchOrders
68141
+ * @see https://btc-alpha.github.io/api-docs/#list-own-orders
68115
68142
  * @description fetches information on multiple orders made by the user
68116
68143
  * @param {string} symbol unified market symbol of the market orders were made in
68117
68144
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -69142,13 +69169,13 @@ class btcmarkets extends _abstract_btcmarkets_js__WEBPACK_IMPORTED_MODULE_0__/*
69142
69169
  const tagTo = tag;
69143
69170
  const addressFrom = undefined;
69144
69171
  const tagFrom = undefined;
69145
- const fee = this.safeNumber(transaction, 'fee');
69172
+ const fee = this.safeString(transaction, 'fee');
69146
69173
  const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
69147
69174
  const currencyId = this.safeString(transaction, 'assetName');
69148
69175
  const code = this.safeCurrencyCode(currencyId);
69149
- let amount = this.safeNumber(transaction, 'amount');
69176
+ let amount = this.safeString(transaction, 'amount');
69150
69177
  if (fee) {
69151
- amount -= fee;
69178
+ amount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringSub */ .O.stringSub(amount, fee);
69152
69179
  }
69153
69180
  return {
69154
69181
  'id': this.safeString(transaction, 'id'),
@@ -69163,14 +69190,14 @@ class btcmarkets extends _abstract_btcmarkets_js__WEBPACK_IMPORTED_MODULE_0__/*
69163
69190
  'tagTo': tagTo,
69164
69191
  'tagFrom': tagFrom,
69165
69192
  'type': type,
69166
- 'amount': amount,
69193
+ 'amount': this.parseNumber(amount),
69167
69194
  'currency': code,
69168
69195
  'status': status,
69169
69196
  'updated': lastUpdate,
69170
69197
  'comment': undefined,
69171
69198
  'fee': {
69172
69199
  'currency': code,
69173
- 'cost': fee,
69200
+ 'cost': this.parseNumber(fee),
69174
69201
  'rate': undefined,
69175
69202
  },
69176
69203
  'info': transaction,
@@ -90405,23 +90432,34 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90405
90432
  };
90406
90433
  return this.safeString(statuses, status, status);
90407
90434
  }
90408
- async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = 100, params = {}) {
90435
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
90409
90436
  /**
90410
90437
  * @method
90411
90438
  * @name coinex#fetchFundingRateHistory
90439
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http038_funding_history
90412
90440
  * @description fetches historical funding rate prices
90413
90441
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
90414
90442
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
90415
90443
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
90416
90444
  * @param {object} [params] extra parameters specific to the coinex api endpoint
90445
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
90446
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
90417
90447
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
90418
90448
  */
90419
90449
  if (symbol === undefined) {
90420
90450
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
90421
90451
  }
90422
90452
  await this.loadMarkets();
90453
+ let paginate = false;
90454
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
90455
+ if (paginate) {
90456
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000);
90457
+ }
90458
+ if (limit === undefined) {
90459
+ limit = 100;
90460
+ }
90423
90461
  const market = this.market(symbol);
90424
- const request = {
90462
+ let request = {
90425
90463
  'market': market['id'],
90426
90464
  'limit': limit,
90427
90465
  'offset': 0,
@@ -90430,6 +90468,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90430
90468
  if (since !== undefined) {
90431
90469
  request['start_time'] = since;
90432
90470
  }
90471
+ [request, params] = this.handleUntilOption('end_time', request, params);
90433
90472
  const response = await this.perpetualPublicGetMarketFundingHistory(this.extend(request, params));
90434
90473
  //
90435
90474
  // {
@@ -107769,10 +107808,16 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
107769
107808
  * @param {string} symbol unified market symbol
107770
107809
  * @param {object} [params] extra parameters specific to the deribit api endpoint
107771
107810
  * @param {int} [params.end_timestamp] fetch funding rate ending at this timestamp
107811
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
107772
107812
  * @returns {object} a [funding rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure}
107773
107813
  */
107774
107814
  await this.loadMarkets();
107775
107815
  const market = this.market(symbol);
107816
+ let paginate = false;
107817
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
107818
+ if (paginate) {
107819
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 720);
107820
+ }
107776
107821
  const time = this.milliseconds();
107777
107822
  const month = 30 * 24 * 60 * 60 * 1000;
107778
107823
  if (since === undefined) {
@@ -124257,19 +124302,28 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
124257
124302
  * @method
124258
124303
  * @name hitbtc#fetchOHLCV
124259
124304
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
124305
+ * @see https://api.hitbtc.com/#candles
124260
124306
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
124261
124307
  * @param {string} timeframe the length of time each candle represents
124262
124308
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
124263
124309
  * @param {int} [limit] the maximum amount of candles to fetch
124264
124310
  * @param {object} [params] extra parameters specific to the hitbtc api endpoint
124311
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
124312
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
124265
124313
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
124266
124314
  */
124267
124315
  await this.loadMarkets();
124316
+ let paginate = false;
124317
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
124318
+ if (paginate) {
124319
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
124320
+ }
124268
124321
  const market = this.market(symbol);
124269
- const request = {
124322
+ let request = {
124270
124323
  'symbols': market['id'],
124271
124324
  'period': this.safeString(this.timeframes, timeframe, timeframe),
124272
124325
  };
124326
+ [request, params] = this.handleUntilOption('till', request, params);
124273
124327
  if (since !== undefined) {
124274
124328
  request['from'] = this.iso8601(since);
124275
124329
  }
@@ -125064,16 +125118,24 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
125064
125118
  /**
125065
125119
  * @method
125066
125120
  * @name hitbtc#fetchFundingRateHistory
125121
+ * @see https://api.hitbtc.com/#funding-history
125067
125122
  * @description fetches historical funding rate prices
125068
125123
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
125069
125124
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
125070
125125
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
125071
125126
  * @param {object} [params] extra parameters specific to the hitbtc api endpoint
125127
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
125128
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
125072
125129
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
125073
125130
  */
125074
125131
  await this.loadMarkets();
125132
+ let paginate = false;
125133
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
125134
+ if (paginate) {
125135
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000);
125136
+ }
125075
125137
  let market = undefined;
125076
- const request = {
125138
+ let request = {
125077
125139
  // all arguments are optional
125078
125140
  // 'symbols': Comma separated list of symbol codes,
125079
125141
  // 'sort': 'DESC' or 'ASC'
@@ -125082,6 +125144,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
125082
125144
  // 'limit': 100,
125083
125145
  // 'offset': 0,
125084
125146
  };
125147
+ [request, params] = this.handleUntilOption('till', request, params);
125085
125148
  if (symbol !== undefined) {
125086
125149
  market = this.market(symbol);
125087
125150
  symbol = market['symbol'];
@@ -188790,6 +188853,19 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
188790
188853
  return this.safeString(statuses, status, status);
188791
188854
  }
188792
188855
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
188856
+ /**
188857
+ * @method
188858
+ * @name phemex#fetchFundingRateHistory
188859
+ * @description fetches historical funding rate prices
188860
+ * @see https://phemex-docs.github.io/#query-funding-rate-history-2
188861
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
188862
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
188863
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
188864
+ * @param {object} [params] extra parameters specific to the phemex api endpoint
188865
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
188866
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
188867
+ * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
188868
+ */
188793
188869
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
188794
188870
  await this.loadMarkets();
188795
188871
  const market = this.market(symbol);
@@ -188797,6 +188873,11 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
188797
188873
  if (!market['swap']) {
188798
188874
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchFundingRateHistory() supports swap contracts only');
188799
188875
  }
188876
+ let paginate = false;
188877
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
188878
+ if (paginate) {
188879
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 100);
188880
+ }
188800
188881
  let customSymbol = undefined;
188801
188882
  if (isUsdtSettled) {
188802
188883
  customSymbol = '.' + market['id'] + 'FR8H'; // phemex requires a custom symbol for funding rate history
@@ -188804,7 +188885,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
188804
188885
  else {
188805
188886
  customSymbol = '.' + market['baseId'] + 'FR8H';
188806
188887
  }
188807
- const request = {
188888
+ let request = {
188808
188889
  'symbol': customSymbol,
188809
188890
  };
188810
188891
  if (since !== undefined) {
@@ -188813,6 +188894,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
188813
188894
  if (limit !== undefined) {
188814
188895
  request['limit'] = limit;
188815
188896
  }
188897
+ [request, params] = this.handleUntilOption('end', request, params);
188816
188898
  let response = undefined;
188817
188899
  if (isUsdtSettled) {
188818
188900
  response = await this.v2GetApiDataPublicDataFundingRateHistory(this.extend(request, params));
@@ -242077,6 +242159,9 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
242077
242159
  if (limit !== undefined) {
242078
242160
  request['limit'] = limit;
242079
242161
  }
242162
+ else {
242163
+ request['limit'] = 100;
242164
+ }
242080
242165
  const response = await this.privateGetTransferPayment(this.extend(request, params));
242081
242166
  //
242082
242167
  // {
@@ -265581,6 +265666,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
265581
265666
  /**
265582
265667
  * @method
265583
265668
  * @name woo#fetchOHLCV
265669
+ * @see https://docs.woo.org/#kline-public
265584
265670
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
265585
265671
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
265586
265672
  * @param {string} timeframe the length of time each candle represents
@@ -266547,8 +266633,26 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
266547
266633
  return this.filterByArray(result, 'symbol', symbols);
266548
266634
  }
266549
266635
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
266636
+ /**
266637
+ * @method
266638
+ * @name woo#fetchFundingRateHistory
266639
+ * @description fetches historical funding rate prices
266640
+ * @see https://docs.woo.org/#get-funding-rate-history-for-one-market-public
266641
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
266642
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
266643
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
266644
+ * @param {object} [params] extra parameters specific to the woo api endpoint
266645
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
266646
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
266647
+ * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
266648
+ */
266550
266649
  await this.loadMarkets();
266551
- const request = {};
266650
+ let paginate = false;
266651
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
266652
+ if (paginate) {
266653
+ return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'page', 25);
266654
+ }
266655
+ let request = {};
266552
266656
  if (symbol !== undefined) {
266553
266657
  const market = this.market(symbol);
266554
266658
  symbol = market['symbol'];
@@ -266557,6 +266661,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
266557
266661
  if (since !== undefined) {
266558
266662
  request['start_t'] = this.parseToInt(since / 1000);
266559
266663
  }
266664
+ [request, params] = this.handleUntilOption('end_t', request, params, 0.001);
266560
266665
  const response = await this.v1PublicGetFundingRateHistory(this.extend(request, params));
266561
266666
  //
266562
266667
  // {
@@ -276313,7 +276418,7 @@ SOFTWARE.
276313
276418
 
276314
276419
  //-----------------------------------------------------------------------------
276315
276420
  // this is updated by vss.js when building
276316
- const version = '4.1.9';
276421
+ const version = '4.1.10';
276317
276422
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
276318
276423
  //-----------------------------------------------------------------------------
276319
276424