ccxt 4.2.67 → 4.2.69

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.
@@ -10561,6 +10561,13 @@ class Exchange {
10561
10561
  }
10562
10562
  return [value, params];
10563
10563
  }
10564
+ handleParamInteger(params, paramName, defaultValue = undefined) {
10565
+ const value = this.safeInteger(params, paramName, defaultValue);
10566
+ if (value !== undefined) {
10567
+ params = this.omit(params, paramName);
10568
+ }
10569
+ return [value, params];
10570
+ }
10564
10571
  resolvePath(path, params) {
10565
10572
  return [
10566
10573
  this.implodeParams(path, params),
@@ -68847,6 +68854,7 @@ class bitstamp extends _abstract_bitstamp_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68847
68854
  'setLeverage': false,
68848
68855
  'setMarginMode': false,
68849
68856
  'setPositionMode': false,
68857
+ 'transfer': true,
68850
68858
  'withdraw': true,
68851
68859
  },
68852
68860
  'urls': {
@@ -70881,6 +70889,73 @@ class bitstamp extends _abstract_bitstamp_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
70881
70889
  const response = await this[method](this.extend(request, params));
70882
70890
  return this.parseTransaction(response, currency);
70883
70891
  }
70892
+ async transfer(code, amount, fromAccount, toAccount, params = {}) {
70893
+ /**
70894
+ * @method
70895
+ * @name bitstamp#transfer
70896
+ * @description transfer currency internally between wallets on the same account
70897
+ * @see https://www.bitstamp.net/api/#tag/Sub-account/operation/TransferFromMainToSub
70898
+ * @see https://www.bitstamp.net/api/#tag/Sub-account/operation/TransferFromSubToMain
70899
+ * @param {string} code unified currency code
70900
+ * @param {float} amount amount to transfer
70901
+ * @param {string} fromAccount account to transfer from
70902
+ * @param {string} toAccount account to transfer to
70903
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
70904
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
70905
+ */
70906
+ await this.loadMarkets();
70907
+ const currency = this.currency(code);
70908
+ amount = this.currencyToPrecision(code, amount);
70909
+ amount = this.parseToNumeric(amount);
70910
+ const request = {
70911
+ 'amount': amount,
70912
+ 'currency': currency['id'].toUpperCase(),
70913
+ };
70914
+ let response = undefined;
70915
+ if (fromAccount === 'main') {
70916
+ request['subAccount'] = toAccount;
70917
+ response = await this.privatePostTransferFromMain(this.extend(request, params));
70918
+ }
70919
+ else if (toAccount === 'main') {
70920
+ request['subAccount'] = fromAccount;
70921
+ response = await this.privatePostTransferToMain(this.extend(request, params));
70922
+ }
70923
+ else {
70924
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' transfer() only supports from or to main');
70925
+ }
70926
+ //
70927
+ // { status: 'ok' }
70928
+ //
70929
+ const transfer = this.parseTransfer(response, currency);
70930
+ transfer['amount'] = amount;
70931
+ transfer['fromAccount'] = fromAccount;
70932
+ transfer['toAccount'] = toAccount;
70933
+ return transfer;
70934
+ }
70935
+ parseTransfer(transfer, currency = undefined) {
70936
+ //
70937
+ // { status: 'ok' }
70938
+ //
70939
+ const status = this.safeString(transfer, 'status');
70940
+ return {
70941
+ 'info': transfer,
70942
+ 'id': undefined,
70943
+ 'timestamp': undefined,
70944
+ 'datetime': undefined,
70945
+ 'currency': currency['code'],
70946
+ 'amount': undefined,
70947
+ 'fromAccount': undefined,
70948
+ 'toAccount': undefined,
70949
+ 'status': this.parseTransferStatus(status),
70950
+ };
70951
+ }
70952
+ parseTransferStatus(status) {
70953
+ const statuses = {
70954
+ 'ok': 'ok',
70955
+ 'error': 'failed',
70956
+ };
70957
+ return this.safeString(statuses, status, status);
70958
+ }
70884
70959
  nonce() {
70885
70960
  return this.milliseconds();
70886
70961
  }
@@ -137729,7 +137804,10 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
137729
137804
  if (lastTradeTimestamp === undefined) {
137730
137805
  lastTradeTimestamp = this.safeTimestamp2(order, 'update_time', 'finish_time');
137731
137806
  }
137732
- const marketType = ('currency_pair' in order) ? 'spot' : 'contract';
137807
+ let marketType = 'contract';
137808
+ if (('currency_pair' in order) || ('market' in order)) {
137809
+ marketType = 'spot';
137810
+ }
137733
137811
  const exchangeSymbol = this.safeString2(order, 'currency_pair', 'market', contract);
137734
137812
  const symbol = this.safeSymbol(exchangeSymbol, market, '_', marketType);
137735
137813
  // Everything below this(above return) is related to fees
@@ -140344,7 +140422,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140344
140422
  'CORS': undefined,
140345
140423
  'spot': true,
140346
140424
  'margin': false,
140347
- 'swap': false,
140425
+ 'swap': true,
140348
140426
  'future': false,
140349
140427
  'option': false,
140350
140428
  'addMargin': false,
@@ -140569,11 +140647,11 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140569
140647
  },
140570
140648
  },
140571
140649
  'options': {
140572
- 'fetchMarketsMethod': 'fetch_markets_from_web',
140650
+ 'fetchMarketsMethod': 'fetch_markets_from_api',
140573
140651
  'fetchMarketFromWebRetries': 10,
140574
140652
  'fetchMarketsFromAPI': {
140575
140653
  'fetchDetailsForAllSymbols': false,
140576
- 'fetchDetailsForMarketIds': [],
140654
+ 'quoteCurrencies': ['USDT', 'GUSD', 'USD', 'DAI', 'EUR', 'GBP', 'SGD', 'BTC', 'ETH', 'LTC', 'BCH'],
140577
140655
  },
140578
140656
  'fetchMarkets': {
140579
140657
  'webApiEnable': true,
@@ -140629,10 +140707,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140629
140707
  }
140630
140708
  //
140631
140709
  // {
140632
- // "tradingPairs": [
140633
- // [ "BTCAUD", 2, 8, "0.00001", 10, true ],
140634
- // ...
140635
- // ],
140710
+ // "tradingPairs": [ [ 'BTCUSD', 2, 8, '0.00001', 10, true ], ... ],
140636
140711
  // "currencies": [
140637
140712
  // [ "ORCA", "Orca", 204, 6, 0, 6, 8, false, null, "solana" ], // as confirmed, precisions seem to be the 5th index
140638
140713
  // [ "ATOM", "Cosmos", 44, 6, 0, 6, 8, false, null, "cosmos" ],
@@ -140651,6 +140726,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140651
140726
  // }
140652
140727
  //
140653
140728
  const result = {};
140729
+ this.options['tradingPairs'] = this.safeList(data, 'tradingPairs');
140654
140730
  const currenciesArray = this.safeValue(data, 'currencies', []);
140655
140731
  for (let i = 0; i < currenciesArray.length; i++) {
140656
140732
  const currency = currenciesArray[i];
@@ -140860,7 +140936,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140860
140936
  return result;
140861
140937
  }
140862
140938
  async fetchMarketsFromAPI(params = {}) {
140863
- const response = await this.publicGetV1Symbols(params);
140939
+ const marketIdsRaw = await this.publicGetV1Symbols(params);
140864
140940
  //
140865
140941
  // [
140866
140942
  // "btcusd",
@@ -140868,93 +140944,185 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140868
140944
  // ...
140869
140945
  // ]
140870
140946
  //
140871
- const result = {};
140872
- for (let i = 0; i < response.length; i++) {
140873
- const marketId = response[i];
140874
- const market = {
140875
- 'symbol': marketId,
140876
- };
140877
- result[marketId] = this.parseMarket(market);
140947
+ const result = [];
140948
+ const options = this.safeDict(this.options, 'fetchMarketsFromAPI', {});
140949
+ const bugSymbol = 'efilfil'; // we skip this inexistent test symbol, which bugs other functions
140950
+ const marketIds = [];
140951
+ for (let i = 0; i < marketIdsRaw.length; i++) {
140952
+ if (marketIdsRaw[i] !== bugSymbol) {
140953
+ marketIds.push(marketIdsRaw[i]);
140954
+ }
140878
140955
  }
140879
- const options = this.safeValue(this.options, 'fetchMarketsFromAPI', {});
140880
- const fetchDetailsForAllSymbols = this.safeBool(options, 'fetchDetailsForAllSymbols', false);
140881
- const fetchDetailsForMarketIds = this.safeValue(options, 'fetchDetailsForMarketIds', []);
140882
- let promises = [];
140883
- let marketIds = [];
140884
- if (fetchDetailsForAllSymbols) {
140885
- marketIds = response;
140956
+ if (this.safeBool(options, 'fetchDetailsForAllSymbols', false)) {
140957
+ const promises = [];
140958
+ for (let i = 0; i < marketIds.length; i++) {
140959
+ const marketId = marketIds[i];
140960
+ const request = {
140961
+ 'symbol': marketId,
140962
+ };
140963
+ promises.push(this.publicGetV1SymbolsDetailsSymbol(this.extend(request, params)));
140964
+ //
140965
+ // {
140966
+ // "symbol": "BTCUSD",
140967
+ // "base_currency": "BTC",
140968
+ // "quote_currency": "USD",
140969
+ // "tick_size": 1E-8,
140970
+ // "quote_increment": 0.01,
140971
+ // "min_order_size": "0.00001",
140972
+ // "status": "open",
140973
+ // "wrap_enabled": false
140974
+ // }
140975
+ //
140976
+ }
140977
+ const responses = await Promise.all(promises);
140978
+ for (let i = 0; i < responses.length; i++) {
140979
+ result.push(this.parseMarket(responses[i]));
140980
+ }
140886
140981
  }
140887
140982
  else {
140888
- marketIds = fetchDetailsForMarketIds;
140889
- }
140890
- for (let i = 0; i < marketIds.length; i++) {
140891
- const marketId = marketIds[i];
140892
- const request = {
140893
- 'symbol': marketId,
140894
- };
140895
- promises.push(this.publicGetV1SymbolsDetailsSymbol(this.extend(request, params)));
140896
- //
140897
- // {
140898
- // "symbol": "BTCUSD",
140899
- // "base_currency": "BTC",
140900
- // "quote_currency": "USD",
140901
- // "tick_size": 1E-8,
140902
- // "quote_increment": 0.01,
140903
- // "min_order_size": "0.00001",
140904
- // "status": "open",
140905
- // "wrap_enabled": false
140906
- // }
140907
- //
140908
- }
140909
- promises = await Promise.all(promises);
140910
- for (let i = 0; i < promises.length; i++) {
140911
- const responseInner = promises[i];
140912
- const marketId = this.safeStringLower(responseInner, 'symbol');
140913
- result[marketId] = this.parseMarket(responseInner);
140983
+ // use trading-pairs info, if it was fetched
140984
+ const tradingPairs = this.safeList(this.options, 'tradingPairs');
140985
+ if (tradingPairs !== undefined) {
140986
+ const indexedTradingPairs = this.indexBy(tradingPairs, 0);
140987
+ for (let i = 0; i < marketIds.length; i++) {
140988
+ const marketId = marketIds[i];
140989
+ const tradingPair = this.safeList(indexedTradingPairs, marketId.toUpperCase());
140990
+ if (tradingPair !== undefined) {
140991
+ result.push(this.parseMarket(tradingPair));
140992
+ }
140993
+ }
140994
+ }
140995
+ else {
140996
+ for (let i = 0; i < marketIds.length; i++) {
140997
+ result.push(this.parseMarket(marketIds[i]));
140998
+ }
140999
+ }
140914
141000
  }
140915
- return this.toArray(result);
141001
+ return result;
140916
141002
  }
140917
141003
  parseMarket(response) {
140918
- const marketId = this.safeStringLower(response, 'symbol');
140919
- let baseId = this.safeString(response, 'base_currency');
140920
- let quoteId = this.safeString(response, 'quote_currency');
140921
- if (baseId === undefined) {
140922
- const idLength = marketId.length - 0;
140923
- const isUSDT = marketId.indexOf('usdt') >= 0;
140924
- const quoteSize = isUSDT ? 4 : 3;
140925
- baseId = marketId.slice(0, idLength - quoteSize); // Not true for all markets
140926
- quoteId = marketId.slice(idLength - quoteSize, idLength);
141004
+ //
141005
+ // response might be:
141006
+ //
141007
+ // btcusd
141008
+ //
141009
+ // or
141010
+ //
141011
+ // [
141012
+ // 'BTCUSD', // symbol
141013
+ // 2, // priceTickDecimalPlaces
141014
+ // 8, // quantityTickDecimalPlaces
141015
+ // '0.00001', // quantityMinimum
141016
+ // 10, // quantityRoundDecimalPlaces
141017
+ // true // minimumsAreInclusive
141018
+ // ],
141019
+ //
141020
+ // or
141021
+ //
141022
+ // {
141023
+ // "symbol": "BTCUSD", // perpetuals have 'PERP' suffix, i.e. DOGEUSDPERP
141024
+ // "base_currency": "BTC",
141025
+ // "quote_currency": "USD",
141026
+ // "tick_size": 1E-8,
141027
+ // "quote_increment": 0.01,
141028
+ // "min_order_size": "0.00001",
141029
+ // "status": "open",
141030
+ // "wrap_enabled": false
141031
+ // "product_type": "swap", // only in perps
141032
+ // "contract_type": "linear", // only in perps
141033
+ // "contract_price_currency": "GUSD" // only in perps
141034
+ // }
141035
+ //
141036
+ let marketId = undefined;
141037
+ let baseId = undefined;
141038
+ let quoteId = undefined;
141039
+ let settleId = undefined;
141040
+ let tickSize = undefined;
141041
+ let increment = undefined;
141042
+ let minSize = undefined;
141043
+ let status = undefined;
141044
+ let swap = false;
141045
+ let contractSize = undefined;
141046
+ let linear = undefined;
141047
+ let inverse = undefined;
141048
+ const isString = (typeof response === 'string');
141049
+ const isArray = (Array.isArray(response));
141050
+ if (!isString && !isArray) {
141051
+ marketId = this.safeStringLower(response, 'symbol');
141052
+ minSize = this.safeNumber(response, 'min_order_size');
141053
+ tickSize = this.safeNumber(response, 'tick_size');
141054
+ increment = this.safeNumber(response, 'quote_increment');
141055
+ status = this.parseMarketActive(this.safeString(response, 'status'));
141056
+ baseId = this.safeString(response, 'base_currency');
141057
+ quoteId = this.safeString(response, 'quote_currency');
141058
+ settleId = this.safeString(response, 'contract_price_currency');
141059
+ }
141060
+ else {
141061
+ // if no detailed API was called, then parse either string or array
141062
+ if (isString) {
141063
+ marketId = response;
141064
+ }
141065
+ else {
141066
+ marketId = this.safeStringLower(response, 0);
141067
+ minSize = this.safeNumber(response, 3);
141068
+ tickSize = this.parseNumber(this.parsePrecision(this.safeString(response, 1)));
141069
+ increment = this.parseNumber(this.parsePrecision(this.safeString(response, 2)));
141070
+ }
141071
+ const marketIdUpper = marketId.toUpperCase();
141072
+ const isPerp = (marketIdUpper.indexOf('PERP') >= 0);
141073
+ const marketIdWithoutPerp = marketIdUpper.replace('PERP', '');
141074
+ const quoteQurrencies = this.handleOption('fetchMarketsFromAPI', 'quoteCurrencies', []);
141075
+ for (let i = 0; i < quoteQurrencies.length; i++) {
141076
+ const quoteCurrency = quoteQurrencies[i];
141077
+ if (marketIdWithoutPerp.endsWith(quoteCurrency)) {
141078
+ baseId = marketIdWithoutPerp.replace(quoteCurrency, '');
141079
+ quoteId = quoteCurrency;
141080
+ if (isPerp) {
141081
+ settleId = quoteCurrency; // always same
141082
+ }
141083
+ break;
141084
+ }
141085
+ }
140927
141086
  }
140928
141087
  const base = this.safeCurrencyCode(baseId);
140929
141088
  const quote = this.safeCurrencyCode(quoteId);
140930
- const status = this.safeString(response, 'status');
141089
+ const settle = this.safeCurrencyCode(settleId);
141090
+ let symbol = base + '/' + quote;
141091
+ if (settleId !== undefined) {
141092
+ symbol = symbol + ':' + settle;
141093
+ swap = true;
141094
+ contractSize = tickSize; // always same
141095
+ linear = true; // always linear
141096
+ inverse = false;
141097
+ }
141098
+ const type = swap ? 'swap' : 'spot';
140931
141099
  return {
140932
141100
  'id': marketId,
140933
- 'symbol': base + '/' + quote,
141101
+ 'symbol': symbol,
140934
141102
  'base': base,
140935
141103
  'quote': quote,
140936
- 'settle': undefined,
141104
+ 'settle': settle,
140937
141105
  'baseId': baseId,
140938
141106
  'quoteId': quoteId,
140939
- 'settleId': undefined,
140940
- 'type': 'spot',
140941
- 'spot': true,
141107
+ 'settleId': settleId,
141108
+ 'type': type,
141109
+ 'spot': !swap,
140942
141110
  'margin': false,
140943
- 'swap': false,
141111
+ 'swap': swap,
140944
141112
  'future': false,
140945
141113
  'option': false,
140946
- 'active': this.parseMarketActive(status),
140947
- 'contract': false,
140948
- 'linear': undefined,
140949
- 'inverse': undefined,
140950
- 'contractSize': undefined,
141114
+ 'active': status,
141115
+ 'contract': swap,
141116
+ 'linear': linear,
141117
+ 'inverse': inverse,
141118
+ 'contractSize': contractSize,
140951
141119
  'expiry': undefined,
140952
141120
  'expiryDatetime': undefined,
140953
141121
  'strike': undefined,
140954
141122
  'optionType': undefined,
140955
141123
  'precision': {
140956
- 'price': this.safeNumber(response, 'quote_increment'),
140957
- 'amount': this.safeNumber(response, 'tick_size'),
141124
+ 'price': increment,
141125
+ 'amount': tickSize,
140958
141126
  },
140959
141127
  'limits': {
140960
141128
  'leverage': {
@@ -140962,7 +141130,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
140962
141130
  'max': undefined,
140963
141131
  },
140964
141132
  'amount': {
140965
- 'min': this.safeNumber(response, 'min_order_size'),
141133
+ 'min': minSize,
140966
141134
  'max': undefined,
140967
141135
  },
140968
141136
  'price': {
@@ -142466,6 +142634,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142466
142634
  '2012': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
142467
142635
  '2020': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
142468
142636
  '2022': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
142637
+ '2024': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
142469
142638
  '10001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
142470
142639
  '10021': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
142471
142640
  '10022': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
@@ -142483,6 +142652,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142483
142652
  '20012': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142484
142653
  '20014': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142485
142654
  '20016': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142655
+ '20018': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142486
142656
  '20031': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142487
142657
  '20032': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142488
142658
  '20033': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
@@ -142493,10 +142663,15 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
142493
142663
  '20043': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142494
142664
  '20044': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
142495
142665
  '20045': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
142666
+ '20047': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
142667
+ '20048': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
142668
+ '20049': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
142496
142669
  '20080': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142497
142670
  '21001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142498
142671
  '21003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
142499
142672
  '21004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended,
142673
+ '22004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
142674
+ '22008': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError, // Gateway timeout exceeded.
142500
142675
  },
142501
142676
  'broad': {},
142502
142677
  },
@@ -148235,6 +148410,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
148235
148410
  'v2/sub-user/api-key-modification': 1,
148236
148411
  'v2/sub-user/api-key-deletion': 1,
148237
148412
  'v1/subuser/transfer': 10,
148413
+ 'v1/trust/user/active/credit': 10,
148238
148414
  // Trading
148239
148415
  'v1/order/orders/place': 0.2,
148240
148416
  'v1/order/batch-orders': 0.4,
@@ -159798,13 +159974,16 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
159798
159974
  }
159799
159975
  orderReq.push(orderObj);
159800
159976
  }
159977
+ const vaultAddress = this.safeString(params, 'vaultAddress');
159801
159978
  const orderAction = {
159802
159979
  'type': 'order',
159803
159980
  'orders': orderReq,
159804
159981
  'grouping': 'na',
159805
- 'brokerCode': 1,
159982
+ // 'brokerCode': 1, // cant
159806
159983
  };
159807
- const vaultAddress = this.safeString(params, 'vaultAddress');
159984
+ if (vaultAddress === undefined) {
159985
+ orderAction['brokerCode'] = 1;
159986
+ }
159808
159987
  const signature = this.signL1Action(orderAction, nonce, vaultAddress);
159809
159988
  const request = {
159810
159989
  'action': orderAction,
@@ -168158,6 +168337,9 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
168158
168337
  },
168159
168338
  },
168160
168339
  },
168340
+ 'fetchTrades': {
168341
+ 'method': 'historyGetMarketSymbolExecutions', // historyGetMarketSymbolExecutions, publicGetHistory
168342
+ },
168161
168343
  },
168162
168344
  'timeframes': {
168163
168345
  '1m': '1m',
@@ -168607,6 +168789,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
168607
168789
  * @method
168608
168790
  * @name krakenfutures#fetchTrades
168609
168791
  * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-trade-history
168792
+ * @see https://docs.futures.kraken.com/#http-api-history-market-history-get-public-execution-events
168610
168793
  * @description Fetch a history of filled trades that this account has made
168611
168794
  * @param {string} symbol Unified CCXT market symbol
168612
168795
  * @param {int} [since] Timestamp in ms of earliest trade. Not used by krakenfutures except in combination with params.until
@@ -168614,6 +168797,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
168614
168797
  * @param {object} [params] Exchange specific params
168615
168798
  * @param {int} [params.until] Timestamp in ms of latest trade
168616
168799
  * @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)
168800
+ * @param {string} [params.method] The method to use to fetch trades. Can be 'historyGetMarketSymbolExecutions' or 'publicGetHistory' default is 'historyGetMarketSymbolExecutions'
168617
168801
  * @returns An array of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
168618
168802
  */
168619
168803
  await this.loadMarkets();
@@ -168623,38 +168807,113 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
168623
168807
  return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
168624
168808
  }
168625
168809
  const market = this.market(symbol);
168626
- const request = {
168810
+ let request = {
168627
168811
  'symbol': market['id'],
168628
168812
  };
168629
- const until = this.safeInteger(params, 'until');
168630
- if (until !== undefined) {
168631
- request['lastTime'] = this.iso8601(until);
168813
+ let method = undefined;
168814
+ [method, params] = this.handleOptionAndParams(params, 'fetchTrades', 'method', 'historyGetMarketSymbolExecutions');
168815
+ let rawTrades = undefined;
168816
+ const isFullHistoryEndpoint = (method === 'historyGetMarketSymbolExecutions');
168817
+ if (isFullHistoryEndpoint) {
168818
+ [request, params] = this.handleUntilOption('before', request, params);
168819
+ if (since !== undefined) {
168820
+ request['since'] = since;
168821
+ request['sort'] = 'asc';
168822
+ }
168823
+ if (limit !== undefined) {
168824
+ request['count'] = limit;
168825
+ }
168826
+ const response = await this.historyGetMarketSymbolExecutions(this.extend(request, params));
168827
+ //
168828
+ // {
168829
+ // "elements": [
168830
+ // {
168831
+ // "uid": "a5105030-f054-44cc-98ab-30d5cae96bef",
168832
+ // "timestamp": "1710150778607",
168833
+ // "event": {
168834
+ // "Execution": {
168835
+ // "execution": {
168836
+ // "uid": "2d485b71-cd28-4a1e-9364-371a127550d2",
168837
+ // "makerOrder": {
168838
+ // "uid": "0a25f66b-1109-49ec-93a3-d17bf9e9137e",
168839
+ // "tradeable": "PF_XBTUSD",
168840
+ // "direction": "Buy",
168841
+ // "quantity": "0.26500",
168842
+ // "timestamp": "1710150778570",
168843
+ // "limitPrice": "71907",
168844
+ // "orderType": "Post",
168845
+ // "reduceOnly": false,
168846
+ // "lastUpdateTimestamp": "1710150778570"
168847
+ // },
168848
+ // "takerOrder": {
168849
+ // "uid": "04de3ee0-9125-4960-bf8f-f63b577b6790",
168850
+ // "tradeable": "PF_XBTUSD",
168851
+ // "direction": "Sell",
168852
+ // "quantity": "0.0002",
168853
+ // "timestamp": "1710150778607",
168854
+ // "limitPrice": "71187.00",
168855
+ // "orderType": "Market",
168856
+ // "reduceOnly": false,
168857
+ // "lastUpdateTimestamp": "1710150778607"
168858
+ // },
168859
+ // "timestamp": "1710150778607",
168860
+ // "quantity": "0.0002",
168861
+ // "price": "71907",
168862
+ // "markPrice": "71903.32715463147",
168863
+ // "limitFilled": false,
168864
+ // "usdValue": "14.38"
168865
+ // },
168866
+ // "takerReducedQuantity": ""
168867
+ // }
168868
+ // }
168869
+ // },
168870
+ // ... followed by older items
168871
+ // ],
168872
+ // "len": "1000",
168873
+ // "continuationToken": "QTexMDE0OTe33NTcyXy8xNDIzAjc1NjY5MwI="
168874
+ // }
168875
+ //
168876
+ const elements = this.safeList(response, 'elements', []);
168877
+ // we need to reverse the list to fix chronology
168878
+ rawTrades = [];
168879
+ const length = elements.length;
168880
+ for (let i = 0; i < length; i++) {
168881
+ const index = length - 1 - i;
168882
+ const element = elements[index];
168883
+ const event = this.safeDict(element, 'event', {});
168884
+ const executionContainer = this.safeDict(event, 'Execution', {});
168885
+ const rawTrade = this.safeDict(executionContainer, 'execution', {});
168886
+ rawTrades.push(rawTrade);
168887
+ }
168632
168888
  }
168633
- //
168634
- // {
168635
- // "result": "success",
168636
- // "history": [
168637
- // {
168638
- // "time": "2022-03-18T04:55:37.692Z",
168639
- // "trade_id": 100,
168640
- // "price": 0.7921,
168641
- // "size": 1068,
168642
- // "side": "sell",
168643
- // "type": "fill",
168644
- // "uid": "6c5da0b0-f1a8-483f-921f-466eb0388265"
168645
- // },
168646
- // ...
168647
- // ],
168648
- // "serverTime": "2022-03-18T06:39:18.056Z"
168649
- // }
168650
- //
168651
- const response = await this.publicGetHistory(this.extend(request, params));
168652
- const history = this.safeValue(response, 'history');
168653
- return this.parseTrades(history, market, since, limit);
168889
+ else {
168890
+ [request, params] = this.handleUntilOption('lastTime', request, params);
168891
+ const response = await this.publicGetHistory(this.extend(request, params));
168892
+ //
168893
+ // {
168894
+ // "result": "success",
168895
+ // "history": [
168896
+ // {
168897
+ // "time": "2022-03-18T04:55:37.692Z",
168898
+ // "trade_id": 100,
168899
+ // "price": 0.7921,
168900
+ // "size": 1068,
168901
+ // "side": "sell",
168902
+ // "type": "fill",
168903
+ // "uid": "6c5da0b0-f1a8-483f-921f-466eb0388265"
168904
+ // },
168905
+ // ...
168906
+ // ],
168907
+ // "serverTime": "2022-03-18T06:39:18.056Z"
168908
+ // }
168909
+ //
168910
+ rawTrades = this.safeList(response, 'history', []);
168911
+ }
168912
+ return this.parseTrades(rawTrades, market, since, limit);
168654
168913
  }
168655
168914
  parseTrade(trade, market = undefined) {
168656
168915
  //
168657
- // fetchTrades (public)
168916
+ // fetchTrades (recent trades)
168658
168917
  //
168659
168918
  // {
168660
168919
  // "time": "2019-02-14T09:25:33.920Z",
@@ -168662,10 +168921,24 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
168662
168921
  // "price": 3574,
168663
168922
  // "size": 100,
168664
168923
  // "side": "buy",
168665
- // "type": "fill" // fill, liquidation, assignment, termination
168924
+ // "type": "fill" // fill, liquidation, assignment, termination
168666
168925
  // "uid": "11c3d82c-9e70-4fe9-8115-f643f1b162d4"
168667
168926
  // }
168668
168927
  //
168928
+ // fetchTrades (executions history)
168929
+ //
168930
+ // {
168931
+ // "timestamp": "1710152516830",
168932
+ // "price": "71927.0",
168933
+ // "quantity": "0.0695",
168934
+ // "markPrice": "71936.38701675525",
168935
+ // "limitFilled": true,
168936
+ // "usdValue": "4998.93",
168937
+ // "uid": "116ae634-253f-470b-bd20-fa9d429fb8b1",
168938
+ // "makerOrder": { "uid": "17bfe4de-c01e-4938-926c-617d2a2d0597", "tradeable": "PF_XBTUSD", "direction": "Buy", "quantity": "0.0695", "timestamp": "1710152515836", "limitPrice": "71927.0", "orderType": "Post", "reduceOnly": false, "lastUpdateTimestamp": "1710152515836" },
168939
+ // "takerOrder": { "uid": "d3e437b4-aa70-4108-b5cf-b1eecb9845b5", "tradeable": "PF_XBTUSD", "direction": "Sell", "quantity": "0.940100", "timestamp": "1710152516830", "limitPrice": "71915", "orderType": "IoC", "reduceOnly": false, "lastUpdateTimestamp": "1710152516830" }
168940
+ // }
168941
+ //
168669
168942
  // fetchMyTrades (private)
168670
168943
  //
168671
168944
  // {
@@ -168704,9 +168977,9 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
168704
168977
  // "type": "EXECUTION"
168705
168978
  // }
168706
168979
  //
168707
- const timestamp = this.parse8601(this.safeString2(trade, 'time', 'fillTime'));
168980
+ let timestamp = this.parse8601(this.safeString2(trade, 'time', 'fillTime'));
168708
168981
  const price = this.safeString(trade, 'price');
168709
- const amount = this.safeString2(trade, 'size', 'amount', '0.0');
168982
+ const amount = this.safeStringN(trade, ['size', 'amount', 'quantity'], '0.0');
168710
168983
  let id = this.safeString2(trade, 'uid', 'fill_id');
168711
168984
  if (id === undefined) {
168712
168985
  id = this.safeString(trade, 'executionId');
@@ -168755,6 +169028,15 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
168755
169028
  takerOrMaker = 'maker';
168756
169029
  }
168757
169030
  }
169031
+ const isHistoricalExecution = ('takerOrder' in trade);
169032
+ if (isHistoricalExecution) {
169033
+ timestamp = this.safeInteger(trade, 'timestamp');
169034
+ const taker = this.safeDict(trade, 'takerOrder', {});
169035
+ if (taker !== undefined) {
169036
+ side = this.safeStringLower(taker, 'direction');
169037
+ takerOrMaker = 'taker';
169038
+ }
169039
+ }
168758
169040
  return this.safeTrade({
168759
169041
  'info': trade,
168760
169042
  'id': id,
@@ -170924,6 +171206,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
170924
171206
  '12h': '12hour',
170925
171207
  '1d': '1day',
170926
171208
  '1w': '1week',
171209
+ '1M': '1month',
170927
171210
  },
170928
171211
  'precisionMode': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__/* .TICK_SIZE */ .sh,
170929
171212
  'exceptions': {
@@ -174973,7 +175256,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
174973
175256
  url = url + endpoint;
174974
175257
  const isFuturePrivate = (api === 'futuresPrivate');
174975
175258
  const isPrivate = (api === 'private');
174976
- const isBroker = (api === 'private');
175259
+ const isBroker = (api === 'broker');
174977
175260
  if (isPrivate || isFuturePrivate || isBroker) {
174978
175261
  this.checkRequiredCredentials();
174979
175262
  const timestamp = this.nonce().toString();
@@ -175005,7 +175288,9 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
175005
175288
  }
175006
175289
  if (isBroker) {
175007
175290
  const brokerName = this.safeString(partner, 'name');
175008
- headers['KC-BROKER-NAME'] = brokerName;
175291
+ if (brokerName !== undefined) {
175292
+ headers['KC-BROKER-NAME'] = brokerName;
175293
+ }
175009
175294
  }
175010
175295
  }
175011
175296
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
@@ -261776,7 +262061,7 @@ class lbank extends _lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
261776
262061
  // "volume":6.3607,
261777
262062
  // "amount":77148.9303,
261778
262063
  // "price":12129,
261779
- // "direction":"sell",
262064
+ // "direction":"sell", // or "sell_market"
261780
262065
  // "TS":"2019-06-28T19:55:49.460"
261781
262066
  // },
261782
262067
  // "type":"trade",
@@ -261816,7 +262101,7 @@ class lbank extends _lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
261816
262101
  // "volume":6.3607,
261817
262102
  // "amount":77148.9303,
261818
262103
  // "price":12129,
261819
- // "direction":"sell",
262104
+ // "direction":"sell", // or "sell_market"
261820
262105
  // "TS":"2019-06-28T19:55:49.460"
261821
262106
  // }
261822
262107
  //
@@ -261825,6 +262110,8 @@ class lbank extends _lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
261825
262110
  if (timestamp === undefined) {
261826
262111
  timestamp = this.parse8601(datetime);
261827
262112
  }
262113
+ let side = this.safeString2(trade, 'direction', 3);
262114
+ side = side.replace('_market', '');
261828
262115
  return this.safeTrade({
261829
262116
  'timestamp': timestamp,
261830
262117
  'datetime': datetime,
@@ -261833,7 +262120,7 @@ class lbank extends _lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
261833
262120
  'order': undefined,
261834
262121
  'type': undefined,
261835
262122
  'takerOrMaker': undefined,
261836
- 'side': this.safeString2(trade, 'direction', 3),
262123
+ 'side': side,
261837
262124
  'price': this.safeString2(trade, 'price', 1),
261838
262125
  'amount': this.safeString2(trade, 'volume', 2),
261839
262126
  'cost': this.safeString(trade, 'amount'),
@@ -316814,7 +317101,7 @@ SOFTWARE.
316814
317101
 
316815
317102
  //-----------------------------------------------------------------------------
316816
317103
  // this is updated by vss.js when building
316817
- const version = '4.2.67';
317104
+ const version = '4.2.69';
316818
317105
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
316819
317106
  //-----------------------------------------------------------------------------
316820
317107