ccxt 4.2.66 → 4.2.68

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/dist/cjs/ccxt.js CHANGED
@@ -177,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
177
177
 
178
178
  //-----------------------------------------------------------------------------
179
179
  // this is updated by vss.js when building
180
- const version = '4.2.66';
180
+ const version = '4.2.68';
181
181
  Exchange["default"].ccxtVersion = version;
182
182
  const exchanges = {
183
183
  'ace': ace,
@@ -3535,6 +3535,13 @@ class Exchange {
3535
3535
  }
3536
3536
  return [value, params];
3537
3537
  }
3538
+ handleParamInteger(params, paramName, defaultValue = undefined) {
3539
+ const value = this.safeInteger(params, paramName, defaultValue);
3540
+ if (value !== undefined) {
3541
+ params = this.omit(params, paramName);
3542
+ }
3543
+ return [value, params];
3544
+ }
3538
3545
  resolvePath(path, params) {
3539
3546
  return [
3540
3547
  this.implodeParams(path, params),
@@ -5330,7 +5337,10 @@ class Exchange {
5330
5337
  const response = await this[method](symbol, undefined, maxEntriesPerRequest, params);
5331
5338
  const responseLength = response.length;
5332
5339
  if (this.verbose) {
5333
- const backwardMessage = 'Dynamic pagination call ' + calls + ' method ' + method + ' response length ' + responseLength + ' timestamp ' + paginationTimestamp;
5340
+ let backwardMessage = 'Dynamic pagination call ' + this.numberToString(calls) + ' method ' + method + ' response length ' + this.numberToString(responseLength);
5341
+ if (paginationTimestamp !== undefined) {
5342
+ backwardMessage += ' timestamp ' + this.numberToString(paginationTimestamp);
5343
+ }
5334
5344
  this.log(backwardMessage);
5335
5345
  }
5336
5346
  if (responseLength === 0) {
@@ -5349,7 +5359,10 @@ class Exchange {
5349
5359
  const response = await this[method](symbol, paginationTimestamp, maxEntriesPerRequest, params);
5350
5360
  const responseLength = response.length;
5351
5361
  if (this.verbose) {
5352
- const forwardMessage = 'Dynamic pagination call ' + calls + ' method ' + method + ' response length ' + responseLength + ' timestamp ' + paginationTimestamp;
5362
+ let forwardMessage = 'Dynamic pagination call ' + this.numberToString(calls) + ' method ' + method + ' response length ' + this.numberToString(responseLength);
5363
+ if (paginationTimestamp !== undefined) {
5364
+ forwardMessage += ' timestamp ' + this.numberToString(paginationTimestamp);
5365
+ }
5353
5366
  this.log(forwardMessage);
5354
5367
  }
5355
5368
  if (responseLength === 0) {
@@ -1384,9 +1384,11 @@ class bitfinex2 extends bitfinex2$1 {
1384
1384
  'symbol': market['id'],
1385
1385
  'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
1386
1386
  'sort': 1,
1387
- 'start': since,
1388
1387
  'limit': limit,
1389
1388
  };
1389
+ if (since !== undefined) {
1390
+ request['start'] = since;
1391
+ }
1390
1392
  [request, params] = this.handleUntilOption('end', request, params);
1391
1393
  const response = await this.publicGetCandlesTradeTimeframeSymbolHist(this.extend(request, params));
1392
1394
  //
@@ -2959,7 +2961,7 @@ class bitfinex2 extends bitfinex2$1 {
2959
2961
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2960
2962
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2961
2963
  */
2962
- return this.fetchFundingRates([symbol], params);
2964
+ return await this.fetchFundingRates([symbol], params);
2963
2965
  }
2964
2966
  async fetchFundingRates(symbols = undefined, params = {}) {
2965
2967
  /**
@@ -2241,7 +2241,8 @@ class gate extends gate$1 {
2241
2241
  const [request, requestParams] = this.prepareRequest(market, type, query);
2242
2242
  request['type'] = 'fund'; // 'dnw' 'pnl' 'fee' 'refr' 'fund' 'point_dnw' 'point_fee' 'point_refr'
2243
2243
  if (since !== undefined) {
2244
- request['from'] = since / 1000;
2244
+ // from should be integer
2245
+ request['from'] = this.parseToInt(since / 1000);
2245
2246
  }
2246
2247
  if (limit !== undefined) {
2247
2248
  request['limit'] = limit;
@@ -882,13 +882,16 @@ class hyperliquid extends hyperliquid$1 {
882
882
  }
883
883
  orderReq.push(orderObj);
884
884
  }
885
+ const vaultAddress = this.safeString(params, 'vaultAddress');
885
886
  const orderAction = {
886
887
  'type': 'order',
887
888
  'orders': orderReq,
888
889
  'grouping': 'na',
889
- 'brokerCode': 1,
890
+ // 'brokerCode': 1, // cant
890
891
  };
891
- const vaultAddress = this.safeString(params, 'vaultAddress');
892
+ if (vaultAddress === undefined) {
893
+ orderAction['brokerCode'] = 1;
894
+ }
892
895
  const signature = this.signL1Action(orderAction, nonce, vaultAddress);
893
896
  const request = {
894
897
  'action': orderAction,
@@ -248,6 +248,9 @@ class krakenfutures extends krakenfutures$1 {
248
248
  },
249
249
  },
250
250
  },
251
+ 'fetchTrades': {
252
+ 'method': 'historyGetMarketSymbolExecutions', // historyGetMarketSymbolExecutions, publicGetHistory
253
+ },
251
254
  },
252
255
  'timeframes': {
253
256
  '1m': '1m',
@@ -697,6 +700,7 @@ class krakenfutures extends krakenfutures$1 {
697
700
  * @method
698
701
  * @name krakenfutures#fetchTrades
699
702
  * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-trade-history
703
+ * @see https://docs.futures.kraken.com/#http-api-history-market-history-get-public-execution-events
700
704
  * @description Fetch a history of filled trades that this account has made
701
705
  * @param {string} symbol Unified CCXT market symbol
702
706
  * @param {int} [since] Timestamp in ms of earliest trade. Not used by krakenfutures except in combination with params.until
@@ -704,6 +708,7 @@ class krakenfutures extends krakenfutures$1 {
704
708
  * @param {object} [params] Exchange specific params
705
709
  * @param {int} [params.until] Timestamp in ms of latest trade
706
710
  * @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)
711
+ * @param {string} [params.method] The method to use to fetch trades. Can be 'historyGetMarketSymbolExecutions' or 'publicGetHistory' default is 'historyGetMarketSymbolExecutions'
707
712
  * @returns An array of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
708
713
  */
709
714
  await this.loadMarkets();
@@ -713,38 +718,113 @@ class krakenfutures extends krakenfutures$1 {
713
718
  return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
714
719
  }
715
720
  const market = this.market(symbol);
716
- const request = {
721
+ let request = {
717
722
  'symbol': market['id'],
718
723
  };
719
- const until = this.safeInteger(params, 'until');
720
- if (until !== undefined) {
721
- request['lastTime'] = this.iso8601(until);
724
+ let method = undefined;
725
+ [method, params] = this.handleOptionAndParams(params, 'fetchTrades', 'method', 'historyGetMarketSymbolExecutions');
726
+ let rawTrades = undefined;
727
+ const isFullHistoryEndpoint = (method === 'historyGetMarketSymbolExecutions');
728
+ if (isFullHistoryEndpoint) {
729
+ [request, params] = this.handleUntilOption('before', request, params);
730
+ if (since !== undefined) {
731
+ request['since'] = since;
732
+ request['sort'] = 'asc';
733
+ }
734
+ if (limit !== undefined) {
735
+ request['count'] = limit;
736
+ }
737
+ const response = await this.historyGetMarketSymbolExecutions(this.extend(request, params));
738
+ //
739
+ // {
740
+ // "elements": [
741
+ // {
742
+ // "uid": "a5105030-f054-44cc-98ab-30d5cae96bef",
743
+ // "timestamp": "1710150778607",
744
+ // "event": {
745
+ // "Execution": {
746
+ // "execution": {
747
+ // "uid": "2d485b71-cd28-4a1e-9364-371a127550d2",
748
+ // "makerOrder": {
749
+ // "uid": "0a25f66b-1109-49ec-93a3-d17bf9e9137e",
750
+ // "tradeable": "PF_XBTUSD",
751
+ // "direction": "Buy",
752
+ // "quantity": "0.26500",
753
+ // "timestamp": "1710150778570",
754
+ // "limitPrice": "71907",
755
+ // "orderType": "Post",
756
+ // "reduceOnly": false,
757
+ // "lastUpdateTimestamp": "1710150778570"
758
+ // },
759
+ // "takerOrder": {
760
+ // "uid": "04de3ee0-9125-4960-bf8f-f63b577b6790",
761
+ // "tradeable": "PF_XBTUSD",
762
+ // "direction": "Sell",
763
+ // "quantity": "0.0002",
764
+ // "timestamp": "1710150778607",
765
+ // "limitPrice": "71187.00",
766
+ // "orderType": "Market",
767
+ // "reduceOnly": false,
768
+ // "lastUpdateTimestamp": "1710150778607"
769
+ // },
770
+ // "timestamp": "1710150778607",
771
+ // "quantity": "0.0002",
772
+ // "price": "71907",
773
+ // "markPrice": "71903.32715463147",
774
+ // "limitFilled": false,
775
+ // "usdValue": "14.38"
776
+ // },
777
+ // "takerReducedQuantity": ""
778
+ // }
779
+ // }
780
+ // },
781
+ // ... followed by older items
782
+ // ],
783
+ // "len": "1000",
784
+ // "continuationToken": "QTexMDE0OTe33NTcyXy8xNDIzAjc1NjY5MwI="
785
+ // }
786
+ //
787
+ const elements = this.safeList(response, 'elements', []);
788
+ // we need to reverse the list to fix chronology
789
+ rawTrades = [];
790
+ const length = elements.length;
791
+ for (let i = 0; i < length; i++) {
792
+ const index = length - 1 - i;
793
+ const element = elements[index];
794
+ const event = this.safeDict(element, 'event', {});
795
+ const executionContainer = this.safeDict(event, 'Execution', {});
796
+ const rawTrade = this.safeDict(executionContainer, 'execution', {});
797
+ rawTrades.push(rawTrade);
798
+ }
722
799
  }
723
- //
724
- // {
725
- // "result": "success",
726
- // "history": [
727
- // {
728
- // "time": "2022-03-18T04:55:37.692Z",
729
- // "trade_id": 100,
730
- // "price": 0.7921,
731
- // "size": 1068,
732
- // "side": "sell",
733
- // "type": "fill",
734
- // "uid": "6c5da0b0-f1a8-483f-921f-466eb0388265"
735
- // },
736
- // ...
737
- // ],
738
- // "serverTime": "2022-03-18T06:39:18.056Z"
739
- // }
740
- //
741
- const response = await this.publicGetHistory(this.extend(request, params));
742
- const history = this.safeValue(response, 'history');
743
- return this.parseTrades(history, market, since, limit);
800
+ else {
801
+ [request, params] = this.handleUntilOption('lastTime', request, params);
802
+ const response = await this.publicGetHistory(this.extend(request, params));
803
+ //
804
+ // {
805
+ // "result": "success",
806
+ // "history": [
807
+ // {
808
+ // "time": "2022-03-18T04:55:37.692Z",
809
+ // "trade_id": 100,
810
+ // "price": 0.7921,
811
+ // "size": 1068,
812
+ // "side": "sell",
813
+ // "type": "fill",
814
+ // "uid": "6c5da0b0-f1a8-483f-921f-466eb0388265"
815
+ // },
816
+ // ...
817
+ // ],
818
+ // "serverTime": "2022-03-18T06:39:18.056Z"
819
+ // }
820
+ //
821
+ rawTrades = this.safeList(response, 'history', []);
822
+ }
823
+ return this.parseTrades(rawTrades, market, since, limit);
744
824
  }
745
825
  parseTrade(trade, market = undefined) {
746
826
  //
747
- // fetchTrades (public)
827
+ // fetchTrades (recent trades)
748
828
  //
749
829
  // {
750
830
  // "time": "2019-02-14T09:25:33.920Z",
@@ -752,10 +832,24 @@ class krakenfutures extends krakenfutures$1 {
752
832
  // "price": 3574,
753
833
  // "size": 100,
754
834
  // "side": "buy",
755
- // "type": "fill" // fill, liquidation, assignment, termination
835
+ // "type": "fill" // fill, liquidation, assignment, termination
756
836
  // "uid": "11c3d82c-9e70-4fe9-8115-f643f1b162d4"
757
837
  // }
758
838
  //
839
+ // fetchTrades (executions history)
840
+ //
841
+ // {
842
+ // "timestamp": "1710152516830",
843
+ // "price": "71927.0",
844
+ // "quantity": "0.0695",
845
+ // "markPrice": "71936.38701675525",
846
+ // "limitFilled": true,
847
+ // "usdValue": "4998.93",
848
+ // "uid": "116ae634-253f-470b-bd20-fa9d429fb8b1",
849
+ // "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" },
850
+ // "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" }
851
+ // }
852
+ //
759
853
  // fetchMyTrades (private)
760
854
  //
761
855
  // {
@@ -794,9 +888,9 @@ class krakenfutures extends krakenfutures$1 {
794
888
  // "type": "EXECUTION"
795
889
  // }
796
890
  //
797
- const timestamp = this.parse8601(this.safeString2(trade, 'time', 'fillTime'));
891
+ let timestamp = this.parse8601(this.safeString2(trade, 'time', 'fillTime'));
798
892
  const price = this.safeString(trade, 'price');
799
- const amount = this.safeString2(trade, 'size', 'amount', '0.0');
893
+ const amount = this.safeStringN(trade, ['size', 'amount', 'quantity'], '0.0');
800
894
  let id = this.safeString2(trade, 'uid', 'fill_id');
801
895
  if (id === undefined) {
802
896
  id = this.safeString(trade, 'executionId');
@@ -845,6 +939,15 @@ class krakenfutures extends krakenfutures$1 {
845
939
  takerOrMaker = 'maker';
846
940
  }
847
941
  }
942
+ const isHistoricalExecution = ('takerOrder' in trade);
943
+ if (isHistoricalExecution) {
944
+ timestamp = this.safeInteger(trade, 'timestamp');
945
+ const taker = this.safeDict(trade, 'takerOrder', {});
946
+ if (taker !== undefined) {
947
+ side = this.safeStringLower(taker, 'direction');
948
+ takerOrMaker = 'taker';
949
+ }
950
+ }
848
951
  return this.safeTrade({
849
952
  'info': trade,
850
953
  'id': id,
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.65";
7
+ declare const version = "4.2.67";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.66';
41
+ const version = '4.2.68';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -795,7 +795,8 @@ export default class Exchange {
795
795
  setHeaders(headers: any): any;
796
796
  marketId(symbol: string): string;
797
797
  symbol(symbol: string): string;
798
- handleParamString(params: object, paramName: string, defaultValue?: any): [string, object];
798
+ handleParamString(params: object, paramName: string, defaultValue?: Str): [string, object];
799
+ handleParamInteger(params: object, paramName: string, defaultValue?: Int): [Int, object];
799
800
  resolvePath(path: any, params: any): any[];
800
801
  getListFromObjectValues(objects: any, key: IndexType): any[];
801
802
  getSymbolsForMarketType(marketType?: string, subType?: string, symbolWithActiveStatus?: boolean, symbolWithUnknownStatus?: boolean): any[];
@@ -3522,6 +3522,13 @@ export default class Exchange {
3522
3522
  }
3523
3523
  return [value, params];
3524
3524
  }
3525
+ handleParamInteger(params, paramName, defaultValue = undefined) {
3526
+ const value = this.safeInteger(params, paramName, defaultValue);
3527
+ if (value !== undefined) {
3528
+ params = this.omit(params, paramName);
3529
+ }
3530
+ return [value, params];
3531
+ }
3525
3532
  resolvePath(path, params) {
3526
3533
  return [
3527
3534
  this.implodeParams(path, params),
@@ -5317,7 +5324,10 @@ export default class Exchange {
5317
5324
  const response = await this[method](symbol, undefined, maxEntriesPerRequest, params);
5318
5325
  const responseLength = response.length;
5319
5326
  if (this.verbose) {
5320
- const backwardMessage = 'Dynamic pagination call ' + calls + ' method ' + method + ' response length ' + responseLength + ' timestamp ' + paginationTimestamp;
5327
+ let backwardMessage = 'Dynamic pagination call ' + this.numberToString(calls) + ' method ' + method + ' response length ' + this.numberToString(responseLength);
5328
+ if (paginationTimestamp !== undefined) {
5329
+ backwardMessage += ' timestamp ' + this.numberToString(paginationTimestamp);
5330
+ }
5321
5331
  this.log(backwardMessage);
5322
5332
  }
5323
5333
  if (responseLength === 0) {
@@ -5336,7 +5346,10 @@ export default class Exchange {
5336
5346
  const response = await this[method](symbol, paginationTimestamp, maxEntriesPerRequest, params);
5337
5347
  const responseLength = response.length;
5338
5348
  if (this.verbose) {
5339
- const forwardMessage = 'Dynamic pagination call ' + calls + ' method ' + method + ' response length ' + responseLength + ' timestamp ' + paginationTimestamp;
5349
+ let forwardMessage = 'Dynamic pagination call ' + this.numberToString(calls) + ' method ' + method + ' response length ' + this.numberToString(responseLength);
5350
+ if (paginationTimestamp !== undefined) {
5351
+ forwardMessage += ' timestamp ' + this.numberToString(paginationTimestamp);
5352
+ }
5340
5353
  this.log(forwardMessage);
5341
5354
  }
5342
5355
  if (responseLength === 0) {
@@ -11,8 +11,10 @@ export declare type SubType = 'linear' | 'inverse' | undefined;
11
11
  export interface Dictionary<T> {
12
12
  [key: string]: T;
13
13
  }
14
- export declare type Dict = Dictionary<any> | undefined;
14
+ export declare type Dict = Dictionary<any>;
15
+ export declare type NullableDict = Dict | undefined;
15
16
  export declare type List = Array<any> | undefined;
17
+ export declare type NullableList = List | undefined;
16
18
  /** Request parameters */
17
19
  export interface MinMax {
18
20
  min: Num;
@@ -1387,9 +1387,11 @@ export default class bitfinex2 extends Exchange {
1387
1387
  'symbol': market['id'],
1388
1388
  'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
1389
1389
  'sort': 1,
1390
- 'start': since,
1391
1390
  'limit': limit,
1392
1391
  };
1392
+ if (since !== undefined) {
1393
+ request['start'] = since;
1394
+ }
1393
1395
  [request, params] = this.handleUntilOption('end', request, params);
1394
1396
  const response = await this.publicGetCandlesTradeTimeframeSymbolHist(this.extend(request, params));
1395
1397
  //
@@ -2962,7 +2964,7 @@ export default class bitfinex2 extends Exchange {
2962
2964
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2963
2965
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2964
2966
  */
2965
- return this.fetchFundingRates([symbol], params);
2967
+ return await this.fetchFundingRates([symbol], params);
2966
2968
  }
2967
2969
  async fetchFundingRates(symbols = undefined, params = {}) {
2968
2970
  /**
package/js/src/gate.js CHANGED
@@ -2244,7 +2244,8 @@ export default class gate extends Exchange {
2244
2244
  const [request, requestParams] = this.prepareRequest(market, type, query);
2245
2245
  request['type'] = 'fund'; // 'dnw' 'pnl' 'fee' 'refr' 'fund' 'point_dnw' 'point_fee' 'point_refr'
2246
2246
  if (since !== undefined) {
2247
- request['from'] = since / 1000;
2247
+ // from should be integer
2248
+ request['from'] = this.parseToInt(since / 1000);
2248
2249
  }
2249
2250
  if (limit !== undefined) {
2250
2251
  request['limit'] = limit;
@@ -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,