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.
package/js/src/gemini.js CHANGED
@@ -30,7 +30,7 @@ export default class gemini extends Exchange {
30
30
  'CORS': undefined,
31
31
  'spot': true,
32
32
  'margin': false,
33
- 'swap': false,
33
+ 'swap': true,
34
34
  'future': false,
35
35
  'option': false,
36
36
  'addMargin': false,
@@ -255,11 +255,11 @@ export default class gemini extends Exchange {
255
255
  },
256
256
  },
257
257
  'options': {
258
- 'fetchMarketsMethod': 'fetch_markets_from_web',
258
+ 'fetchMarketsMethod': 'fetch_markets_from_api',
259
259
  'fetchMarketFromWebRetries': 10,
260
260
  'fetchMarketsFromAPI': {
261
261
  'fetchDetailsForAllSymbols': false,
262
- 'fetchDetailsForMarketIds': [],
262
+ 'quoteCurrencies': ['USDT', 'GUSD', 'USD', 'DAI', 'EUR', 'GBP', 'SGD', 'BTC', 'ETH', 'LTC', 'BCH'],
263
263
  },
264
264
  'fetchMarkets': {
265
265
  'webApiEnable': true,
@@ -315,10 +315,7 @@ export default class gemini extends Exchange {
315
315
  }
316
316
  //
317
317
  // {
318
- // "tradingPairs": [
319
- // [ "BTCAUD", 2, 8, "0.00001", 10, true ],
320
- // ...
321
- // ],
318
+ // "tradingPairs": [ [ 'BTCUSD', 2, 8, '0.00001', 10, true ], ... ],
322
319
  // "currencies": [
323
320
  // [ "ORCA", "Orca", 204, 6, 0, 6, 8, false, null, "solana" ], // as confirmed, precisions seem to be the 5th index
324
321
  // [ "ATOM", "Cosmos", 44, 6, 0, 6, 8, false, null, "cosmos" ],
@@ -337,6 +334,7 @@ export default class gemini extends Exchange {
337
334
  // }
338
335
  //
339
336
  const result = {};
337
+ this.options['tradingPairs'] = this.safeList(data, 'tradingPairs');
340
338
  const currenciesArray = this.safeValue(data, 'currencies', []);
341
339
  for (let i = 0; i < currenciesArray.length; i++) {
342
340
  const currency = currenciesArray[i];
@@ -546,7 +544,7 @@ export default class gemini extends Exchange {
546
544
  return result;
547
545
  }
548
546
  async fetchMarketsFromAPI(params = {}) {
549
- const response = await this.publicGetV1Symbols(params);
547
+ const marketIdsRaw = await this.publicGetV1Symbols(params);
550
548
  //
551
549
  // [
552
550
  // "btcusd",
@@ -554,93 +552,185 @@ export default class gemini extends Exchange {
554
552
  // ...
555
553
  // ]
556
554
  //
557
- const result = {};
558
- for (let i = 0; i < response.length; i++) {
559
- const marketId = response[i];
560
- const market = {
561
- 'symbol': marketId,
562
- };
563
- result[marketId] = this.parseMarket(market);
555
+ const result = [];
556
+ const options = this.safeDict(this.options, 'fetchMarketsFromAPI', {});
557
+ const bugSymbol = 'efilfil'; // we skip this inexistent test symbol, which bugs other functions
558
+ const marketIds = [];
559
+ for (let i = 0; i < marketIdsRaw.length; i++) {
560
+ if (marketIdsRaw[i] !== bugSymbol) {
561
+ marketIds.push(marketIdsRaw[i]);
562
+ }
564
563
  }
565
- const options = this.safeValue(this.options, 'fetchMarketsFromAPI', {});
566
- const fetchDetailsForAllSymbols = this.safeBool(options, 'fetchDetailsForAllSymbols', false);
567
- const fetchDetailsForMarketIds = this.safeValue(options, 'fetchDetailsForMarketIds', []);
568
- let promises = [];
569
- let marketIds = [];
570
- if (fetchDetailsForAllSymbols) {
571
- marketIds = response;
564
+ if (this.safeBool(options, 'fetchDetailsForAllSymbols', false)) {
565
+ const promises = [];
566
+ for (let i = 0; i < marketIds.length; i++) {
567
+ const marketId = marketIds[i];
568
+ const request = {
569
+ 'symbol': marketId,
570
+ };
571
+ promises.push(this.publicGetV1SymbolsDetailsSymbol(this.extend(request, params)));
572
+ //
573
+ // {
574
+ // "symbol": "BTCUSD",
575
+ // "base_currency": "BTC",
576
+ // "quote_currency": "USD",
577
+ // "tick_size": 1E-8,
578
+ // "quote_increment": 0.01,
579
+ // "min_order_size": "0.00001",
580
+ // "status": "open",
581
+ // "wrap_enabled": false
582
+ // }
583
+ //
584
+ }
585
+ const responses = await Promise.all(promises);
586
+ for (let i = 0; i < responses.length; i++) {
587
+ result.push(this.parseMarket(responses[i]));
588
+ }
572
589
  }
573
590
  else {
574
- marketIds = fetchDetailsForMarketIds;
575
- }
576
- for (let i = 0; i < marketIds.length; i++) {
577
- const marketId = marketIds[i];
578
- const request = {
579
- 'symbol': marketId,
580
- };
581
- promises.push(this.publicGetV1SymbolsDetailsSymbol(this.extend(request, params)));
582
- //
583
- // {
584
- // "symbol": "BTCUSD",
585
- // "base_currency": "BTC",
586
- // "quote_currency": "USD",
587
- // "tick_size": 1E-8,
588
- // "quote_increment": 0.01,
589
- // "min_order_size": "0.00001",
590
- // "status": "open",
591
- // "wrap_enabled": false
592
- // }
593
- //
594
- }
595
- promises = await Promise.all(promises);
596
- for (let i = 0; i < promises.length; i++) {
597
- const responseInner = promises[i];
598
- const marketId = this.safeStringLower(responseInner, 'symbol');
599
- result[marketId] = this.parseMarket(responseInner);
591
+ // use trading-pairs info, if it was fetched
592
+ const tradingPairs = this.safeList(this.options, 'tradingPairs');
593
+ if (tradingPairs !== undefined) {
594
+ const indexedTradingPairs = this.indexBy(tradingPairs, 0);
595
+ for (let i = 0; i < marketIds.length; i++) {
596
+ const marketId = marketIds[i];
597
+ const tradingPair = this.safeList(indexedTradingPairs, marketId.toUpperCase());
598
+ if (tradingPair !== undefined) {
599
+ result.push(this.parseMarket(tradingPair));
600
+ }
601
+ }
602
+ }
603
+ else {
604
+ for (let i = 0; i < marketIds.length; i++) {
605
+ result.push(this.parseMarket(marketIds[i]));
606
+ }
607
+ }
600
608
  }
601
- return this.toArray(result);
609
+ return result;
602
610
  }
603
611
  parseMarket(response) {
604
- const marketId = this.safeStringLower(response, 'symbol');
605
- let baseId = this.safeString(response, 'base_currency');
606
- let quoteId = this.safeString(response, 'quote_currency');
607
- if (baseId === undefined) {
608
- const idLength = marketId.length - 0;
609
- const isUSDT = marketId.indexOf('usdt') >= 0;
610
- const quoteSize = isUSDT ? 4 : 3;
611
- baseId = marketId.slice(0, idLength - quoteSize); // Not true for all markets
612
- quoteId = marketId.slice(idLength - quoteSize, idLength);
612
+ //
613
+ // response might be:
614
+ //
615
+ // btcusd
616
+ //
617
+ // or
618
+ //
619
+ // [
620
+ // 'BTCUSD', // symbol
621
+ // 2, // priceTickDecimalPlaces
622
+ // 8, // quantityTickDecimalPlaces
623
+ // '0.00001', // quantityMinimum
624
+ // 10, // quantityRoundDecimalPlaces
625
+ // true // minimumsAreInclusive
626
+ // ],
627
+ //
628
+ // or
629
+ //
630
+ // {
631
+ // "symbol": "BTCUSD", // perpetuals have 'PERP' suffix, i.e. DOGEUSDPERP
632
+ // "base_currency": "BTC",
633
+ // "quote_currency": "USD",
634
+ // "tick_size": 1E-8,
635
+ // "quote_increment": 0.01,
636
+ // "min_order_size": "0.00001",
637
+ // "status": "open",
638
+ // "wrap_enabled": false
639
+ // "product_type": "swap", // only in perps
640
+ // "contract_type": "linear", // only in perps
641
+ // "contract_price_currency": "GUSD" // only in perps
642
+ // }
643
+ //
644
+ let marketId = undefined;
645
+ let baseId = undefined;
646
+ let quoteId = undefined;
647
+ let settleId = undefined;
648
+ let tickSize = undefined;
649
+ let increment = undefined;
650
+ let minSize = undefined;
651
+ let status = undefined;
652
+ let swap = false;
653
+ let contractSize = undefined;
654
+ let linear = undefined;
655
+ let inverse = undefined;
656
+ const isString = (typeof response === 'string');
657
+ const isArray = (Array.isArray(response));
658
+ if (!isString && !isArray) {
659
+ marketId = this.safeStringLower(response, 'symbol');
660
+ minSize = this.safeNumber(response, 'min_order_size');
661
+ tickSize = this.safeNumber(response, 'tick_size');
662
+ increment = this.safeNumber(response, 'quote_increment');
663
+ status = this.parseMarketActive(this.safeString(response, 'status'));
664
+ baseId = this.safeString(response, 'base_currency');
665
+ quoteId = this.safeString(response, 'quote_currency');
666
+ settleId = this.safeString(response, 'contract_price_currency');
667
+ }
668
+ else {
669
+ // if no detailed API was called, then parse either string or array
670
+ if (isString) {
671
+ marketId = response;
672
+ }
673
+ else {
674
+ marketId = this.safeStringLower(response, 0);
675
+ minSize = this.safeNumber(response, 3);
676
+ tickSize = this.parseNumber(this.parsePrecision(this.safeString(response, 1)));
677
+ increment = this.parseNumber(this.parsePrecision(this.safeString(response, 2)));
678
+ }
679
+ const marketIdUpper = marketId.toUpperCase();
680
+ const isPerp = (marketIdUpper.indexOf('PERP') >= 0);
681
+ const marketIdWithoutPerp = marketIdUpper.replace('PERP', '');
682
+ const quoteQurrencies = this.handleOption('fetchMarketsFromAPI', 'quoteCurrencies', []);
683
+ for (let i = 0; i < quoteQurrencies.length; i++) {
684
+ const quoteCurrency = quoteQurrencies[i];
685
+ if (marketIdWithoutPerp.endsWith(quoteCurrency)) {
686
+ baseId = marketIdWithoutPerp.replace(quoteCurrency, '');
687
+ quoteId = quoteCurrency;
688
+ if (isPerp) {
689
+ settleId = quoteCurrency; // always same
690
+ }
691
+ break;
692
+ }
693
+ }
613
694
  }
614
695
  const base = this.safeCurrencyCode(baseId);
615
696
  const quote = this.safeCurrencyCode(quoteId);
616
- const status = this.safeString(response, 'status');
697
+ const settle = this.safeCurrencyCode(settleId);
698
+ let symbol = base + '/' + quote;
699
+ if (settleId !== undefined) {
700
+ symbol = symbol + ':' + settle;
701
+ swap = true;
702
+ contractSize = tickSize; // always same
703
+ linear = true; // always linear
704
+ inverse = false;
705
+ }
706
+ const type = swap ? 'swap' : 'spot';
617
707
  return {
618
708
  'id': marketId,
619
- 'symbol': base + '/' + quote,
709
+ 'symbol': symbol,
620
710
  'base': base,
621
711
  'quote': quote,
622
- 'settle': undefined,
712
+ 'settle': settle,
623
713
  'baseId': baseId,
624
714
  'quoteId': quoteId,
625
- 'settleId': undefined,
626
- 'type': 'spot',
627
- 'spot': true,
715
+ 'settleId': settleId,
716
+ 'type': type,
717
+ 'spot': !swap,
628
718
  'margin': false,
629
- 'swap': false,
719
+ 'swap': swap,
630
720
  'future': false,
631
721
  'option': false,
632
- 'active': this.parseMarketActive(status),
633
- 'contract': false,
634
- 'linear': undefined,
635
- 'inverse': undefined,
636
- 'contractSize': undefined,
722
+ 'active': status,
723
+ 'contract': swap,
724
+ 'linear': linear,
725
+ 'inverse': inverse,
726
+ 'contractSize': contractSize,
637
727
  'expiry': undefined,
638
728
  'expiryDatetime': undefined,
639
729
  'strike': undefined,
640
730
  'optionType': undefined,
641
731
  'precision': {
642
- 'price': this.safeNumber(response, 'quote_increment'),
643
- 'amount': this.safeNumber(response, 'tick_size'),
732
+ 'price': increment,
733
+ 'amount': tickSize,
644
734
  },
645
735
  'limits': {
646
736
  'leverage': {
@@ -648,7 +738,7 @@ export default class gemini extends Exchange {
648
738
  'max': undefined,
649
739
  },
650
740
  'amount': {
651
- 'min': this.safeNumber(response, 'min_order_size'),
741
+ 'min': minSize,
652
742
  'max': undefined,
653
743
  },
654
744
  'price': {
package/js/src/hitbtc.js CHANGED
@@ -318,6 +318,7 @@ export default class hitbtc extends Exchange {
318
318
  '2012': BadRequest,
319
319
  '2020': BadRequest,
320
320
  '2022': BadRequest,
321
+ '2024': InvalidOrder,
321
322
  '10001': BadRequest,
322
323
  '10021': AccountSuspended,
323
324
  '10022': BadRequest,
@@ -335,6 +336,7 @@ export default class hitbtc extends Exchange {
335
336
  '20012': ExchangeError,
336
337
  '20014': ExchangeError,
337
338
  '20016': ExchangeError,
339
+ '20018': ExchangeError,
338
340
  '20031': ExchangeError,
339
341
  '20032': ExchangeError,
340
342
  '20033': ExchangeError,
@@ -345,10 +347,15 @@ export default class hitbtc extends Exchange {
345
347
  '20043': ExchangeError,
346
348
  '20044': PermissionDenied,
347
349
  '20045': InvalidOrder,
350
+ '20047': InvalidOrder,
351
+ '20048': InvalidOrder,
352
+ '20049': InvalidOrder,
348
353
  '20080': ExchangeError,
349
354
  '21001': ExchangeError,
350
355
  '21003': AccountSuspended,
351
356
  '21004': AccountSuspended,
357
+ '22004': ExchangeError,
358
+ '22008': ExchangeError, // Gateway timeout exceeded.
352
359
  },
353
360
  'broad': {},
354
361
  },
package/js/src/htx.js CHANGED
@@ -470,6 +470,7 @@ export default class htx extends Exchange {
470
470
  'v2/sub-user/api-key-modification': 1,
471
471
  'v2/sub-user/api-key-deletion': 1,
472
472
  'v1/subuser/transfer': 10,
473
+ 'v1/trust/user/active/credit': 10,
473
474
  // Trading
474
475
  'v1/order/orders/place': 0.2,
475
476
  'v1/order/batch-orders': 0.4,
@@ -885,13 +885,16 @@ export default class hyperliquid extends Exchange {
885
885
  }
886
886
  orderReq.push(orderObj);
887
887
  }
888
+ const vaultAddress = this.safeString(params, 'vaultAddress');
888
889
  const orderAction = {
889
890
  'type': 'order',
890
891
  'orders': orderReq,
891
892
  'grouping': 'na',
892
- 'brokerCode': 1,
893
+ // 'brokerCode': 1, // cant
893
894
  };
894
- const vaultAddress = this.safeString(params, 'vaultAddress');
895
+ if (vaultAddress === undefined) {
896
+ orderAction['brokerCode'] = 1;
897
+ }
895
898
  const signature = this.signL1Action(orderAction, nonce, vaultAddress);
896
899
  const request = {
897
900
  'action': orderAction,
@@ -251,6 +251,9 @@ export default class krakenfutures extends Exchange {
251
251
  },
252
252
  },
253
253
  },
254
+ 'fetchTrades': {
255
+ 'method': 'historyGetMarketSymbolExecutions', // historyGetMarketSymbolExecutions, publicGetHistory
256
+ },
254
257
  },
255
258
  'timeframes': {
256
259
  '1m': '1m',
@@ -700,6 +703,7 @@ export default class krakenfutures extends Exchange {
700
703
  * @method
701
704
  * @name krakenfutures#fetchTrades
702
705
  * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-trade-history
706
+ * @see https://docs.futures.kraken.com/#http-api-history-market-history-get-public-execution-events
703
707
  * @description Fetch a history of filled trades that this account has made
704
708
  * @param {string} symbol Unified CCXT market symbol
705
709
  * @param {int} [since] Timestamp in ms of earliest trade. Not used by krakenfutures except in combination with params.until
@@ -707,6 +711,7 @@ export default class krakenfutures extends Exchange {
707
711
  * @param {object} [params] Exchange specific params
708
712
  * @param {int} [params.until] Timestamp in ms of latest trade
709
713
  * @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)
714
+ * @param {string} [params.method] The method to use to fetch trades. Can be 'historyGetMarketSymbolExecutions' or 'publicGetHistory' default is 'historyGetMarketSymbolExecutions'
710
715
  * @returns An array of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
711
716
  */
712
717
  await this.loadMarkets();
@@ -716,38 +721,113 @@ export default class krakenfutures extends Exchange {
716
721
  return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
717
722
  }
718
723
  const market = this.market(symbol);
719
- const request = {
724
+ let request = {
720
725
  'symbol': market['id'],
721
726
  };
722
- const until = this.safeInteger(params, 'until');
723
- if (until !== undefined) {
724
- request['lastTime'] = this.iso8601(until);
727
+ let method = undefined;
728
+ [method, params] = this.handleOptionAndParams(params, 'fetchTrades', 'method', 'historyGetMarketSymbolExecutions');
729
+ let rawTrades = undefined;
730
+ const isFullHistoryEndpoint = (method === 'historyGetMarketSymbolExecutions');
731
+ if (isFullHistoryEndpoint) {
732
+ [request, params] = this.handleUntilOption('before', request, params);
733
+ if (since !== undefined) {
734
+ request['since'] = since;
735
+ request['sort'] = 'asc';
736
+ }
737
+ if (limit !== undefined) {
738
+ request['count'] = limit;
739
+ }
740
+ const response = await this.historyGetMarketSymbolExecutions(this.extend(request, params));
741
+ //
742
+ // {
743
+ // "elements": [
744
+ // {
745
+ // "uid": "a5105030-f054-44cc-98ab-30d5cae96bef",
746
+ // "timestamp": "1710150778607",
747
+ // "event": {
748
+ // "Execution": {
749
+ // "execution": {
750
+ // "uid": "2d485b71-cd28-4a1e-9364-371a127550d2",
751
+ // "makerOrder": {
752
+ // "uid": "0a25f66b-1109-49ec-93a3-d17bf9e9137e",
753
+ // "tradeable": "PF_XBTUSD",
754
+ // "direction": "Buy",
755
+ // "quantity": "0.26500",
756
+ // "timestamp": "1710150778570",
757
+ // "limitPrice": "71907",
758
+ // "orderType": "Post",
759
+ // "reduceOnly": false,
760
+ // "lastUpdateTimestamp": "1710150778570"
761
+ // },
762
+ // "takerOrder": {
763
+ // "uid": "04de3ee0-9125-4960-bf8f-f63b577b6790",
764
+ // "tradeable": "PF_XBTUSD",
765
+ // "direction": "Sell",
766
+ // "quantity": "0.0002",
767
+ // "timestamp": "1710150778607",
768
+ // "limitPrice": "71187.00",
769
+ // "orderType": "Market",
770
+ // "reduceOnly": false,
771
+ // "lastUpdateTimestamp": "1710150778607"
772
+ // },
773
+ // "timestamp": "1710150778607",
774
+ // "quantity": "0.0002",
775
+ // "price": "71907",
776
+ // "markPrice": "71903.32715463147",
777
+ // "limitFilled": false,
778
+ // "usdValue": "14.38"
779
+ // },
780
+ // "takerReducedQuantity": ""
781
+ // }
782
+ // }
783
+ // },
784
+ // ... followed by older items
785
+ // ],
786
+ // "len": "1000",
787
+ // "continuationToken": "QTexMDE0OTe33NTcyXy8xNDIzAjc1NjY5MwI="
788
+ // }
789
+ //
790
+ const elements = this.safeList(response, 'elements', []);
791
+ // we need to reverse the list to fix chronology
792
+ rawTrades = [];
793
+ const length = elements.length;
794
+ for (let i = 0; i < length; i++) {
795
+ const index = length - 1 - i;
796
+ const element = elements[index];
797
+ const event = this.safeDict(element, 'event', {});
798
+ const executionContainer = this.safeDict(event, 'Execution', {});
799
+ const rawTrade = this.safeDict(executionContainer, 'execution', {});
800
+ rawTrades.push(rawTrade);
801
+ }
725
802
  }
726
- //
727
- // {
728
- // "result": "success",
729
- // "history": [
730
- // {
731
- // "time": "2022-03-18T04:55:37.692Z",
732
- // "trade_id": 100,
733
- // "price": 0.7921,
734
- // "size": 1068,
735
- // "side": "sell",
736
- // "type": "fill",
737
- // "uid": "6c5da0b0-f1a8-483f-921f-466eb0388265"
738
- // },
739
- // ...
740
- // ],
741
- // "serverTime": "2022-03-18T06:39:18.056Z"
742
- // }
743
- //
744
- const response = await this.publicGetHistory(this.extend(request, params));
745
- const history = this.safeValue(response, 'history');
746
- return this.parseTrades(history, market, since, limit);
803
+ else {
804
+ [request, params] = this.handleUntilOption('lastTime', request, params);
805
+ const response = await this.publicGetHistory(this.extend(request, params));
806
+ //
807
+ // {
808
+ // "result": "success",
809
+ // "history": [
810
+ // {
811
+ // "time": "2022-03-18T04:55:37.692Z",
812
+ // "trade_id": 100,
813
+ // "price": 0.7921,
814
+ // "size": 1068,
815
+ // "side": "sell",
816
+ // "type": "fill",
817
+ // "uid": "6c5da0b0-f1a8-483f-921f-466eb0388265"
818
+ // },
819
+ // ...
820
+ // ],
821
+ // "serverTime": "2022-03-18T06:39:18.056Z"
822
+ // }
823
+ //
824
+ rawTrades = this.safeList(response, 'history', []);
825
+ }
826
+ return this.parseTrades(rawTrades, market, since, limit);
747
827
  }
748
828
  parseTrade(trade, market = undefined) {
749
829
  //
750
- // fetchTrades (public)
830
+ // fetchTrades (recent trades)
751
831
  //
752
832
  // {
753
833
  // "time": "2019-02-14T09:25:33.920Z",
@@ -755,10 +835,24 @@ export default class krakenfutures extends Exchange {
755
835
  // "price": 3574,
756
836
  // "size": 100,
757
837
  // "side": "buy",
758
- // "type": "fill" // fill, liquidation, assignment, termination
838
+ // "type": "fill" // fill, liquidation, assignment, termination
759
839
  // "uid": "11c3d82c-9e70-4fe9-8115-f643f1b162d4"
760
840
  // }
761
841
  //
842
+ // fetchTrades (executions history)
843
+ //
844
+ // {
845
+ // "timestamp": "1710152516830",
846
+ // "price": "71927.0",
847
+ // "quantity": "0.0695",
848
+ // "markPrice": "71936.38701675525",
849
+ // "limitFilled": true,
850
+ // "usdValue": "4998.93",
851
+ // "uid": "116ae634-253f-470b-bd20-fa9d429fb8b1",
852
+ // "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" },
853
+ // "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" }
854
+ // }
855
+ //
762
856
  // fetchMyTrades (private)
763
857
  //
764
858
  // {
@@ -797,9 +891,9 @@ export default class krakenfutures extends Exchange {
797
891
  // "type": "EXECUTION"
798
892
  // }
799
893
  //
800
- const timestamp = this.parse8601(this.safeString2(trade, 'time', 'fillTime'));
894
+ let timestamp = this.parse8601(this.safeString2(trade, 'time', 'fillTime'));
801
895
  const price = this.safeString(trade, 'price');
802
- const amount = this.safeString2(trade, 'size', 'amount', '0.0');
896
+ const amount = this.safeStringN(trade, ['size', 'amount', 'quantity'], '0.0');
803
897
  let id = this.safeString2(trade, 'uid', 'fill_id');
804
898
  if (id === undefined) {
805
899
  id = this.safeString(trade, 'executionId');
@@ -848,6 +942,15 @@ export default class krakenfutures extends Exchange {
848
942
  takerOrMaker = 'maker';
849
943
  }
850
944
  }
945
+ const isHistoricalExecution = ('takerOrder' in trade);
946
+ if (isHistoricalExecution) {
947
+ timestamp = this.safeInteger(trade, 'timestamp');
948
+ const taker = this.safeDict(trade, 'takerOrder', {});
949
+ if (taker !== undefined) {
950
+ side = this.safeStringLower(taker, 'direction');
951
+ takerOrMaker = 'taker';
952
+ }
953
+ }
851
954
  return this.safeTrade({
852
955
  'info': trade,
853
956
  'id': id,
package/js/src/kucoin.js CHANGED
@@ -413,6 +413,7 @@ export default class kucoin extends Exchange {
413
413
  '12h': '12hour',
414
414
  '1d': '1day',
415
415
  '1w': '1week',
416
+ '1M': '1month',
416
417
  },
417
418
  'precisionMode': TICK_SIZE,
418
419
  'exceptions': {
@@ -4462,7 +4463,7 @@ export default class kucoin extends Exchange {
4462
4463
  url = url + endpoint;
4463
4464
  const isFuturePrivate = (api === 'futuresPrivate');
4464
4465
  const isPrivate = (api === 'private');
4465
- const isBroker = (api === 'private');
4466
+ const isBroker = (api === 'broker');
4466
4467
  if (isPrivate || isFuturePrivate || isBroker) {
4467
4468
  this.checkRequiredCredentials();
4468
4469
  const timestamp = this.nonce().toString();
@@ -4494,7 +4495,9 @@ export default class kucoin extends Exchange {
4494
4495
  }
4495
4496
  if (isBroker) {
4496
4497
  const brokerName = this.safeString(partner, 'name');
4497
- headers['KC-BROKER-NAME'] = brokerName;
4498
+ if (brokerName !== undefined) {
4499
+ headers['KC-BROKER-NAME'] = brokerName;
4500
+ }
4498
4501
  }
4499
4502
  }
4500
4503
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };