ccxt 4.2.96 → 4.2.98

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
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
182
182
 
183
183
  //-----------------------------------------------------------------------------
184
184
  // this is updated by vss.js when building
185
- const version = '4.2.96';
185
+ const version = '4.2.98';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -4062,11 +4062,26 @@ class Exchange {
4062
4062
  const [result, empty] = this.handleOptionAndParams({}, methodName, optionName, defaultValue);
4063
4063
  return result;
4064
4064
  }
4065
- handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
4065
+ handleMarketTypeAndParams(methodName, market = undefined, params = {}, defaultValue = undefined) {
4066
+ /**
4067
+ * @ignore
4068
+ * @method
4069
+ * @name exchange#handleMarketTypeAndParams
4070
+ * @param methodName the method calling handleMarketTypeAndParams
4071
+ * @param {Market} market
4072
+ * @param {object} params
4073
+ * @param {string} [params.type] type assigned by user
4074
+ * @param {string} [params.defaultType] same as params.type
4075
+ * @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
4076
+ * @returns {[string, object]} the market type and params with type and defaultType omitted
4077
+ */
4066
4078
  const defaultType = this.safeString2(this.options, 'defaultType', 'type', 'spot');
4079
+ if (defaultValue === undefined) { // defaultValue takes precendence over exchange wide defaultType
4080
+ defaultValue = defaultType;
4081
+ }
4067
4082
  const methodOptions = this.safeDict(this.options, methodName);
4068
- let methodType = defaultType;
4069
- if (methodOptions !== undefined) {
4083
+ let methodType = defaultValue;
4084
+ if (methodOptions !== undefined) { // user defined methodType takes precedence over defaultValue
4070
4085
  if (typeof methodOptions === 'string') {
4071
4086
  methodType = methodOptions;
4072
4087
  }
@@ -5796,7 +5796,7 @@ class binance extends binance$1 {
5796
5796
  response = await this.dapiPrivatePostOrder(request);
5797
5797
  }
5798
5798
  }
5799
- else if (marketType === 'margin' || marginMode !== undefined) {
5799
+ else if (marketType === 'margin' || marginMode !== undefined || isPortfolioMargin) {
5800
5800
  if (isPortfolioMargin) {
5801
5801
  response = await this.papiPostMarginOrder(request);
5802
5802
  }
@@ -5898,15 +5898,6 @@ class binance extends binance$1 {
5898
5898
  uppercaseType = market['contract'] ? 'TAKE_PROFIT' : 'TAKE_PROFIT_LIMIT';
5899
5899
  }
5900
5900
  }
5901
- if ((marketType === 'spot') || (marketType === 'margin')) {
5902
- request['newOrderRespType'] = this.safeString(this.options['newOrderRespType'], type, 'RESULT'); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
5903
- }
5904
- else {
5905
- // swap, futures and options
5906
- if (!isPortfolioMargin) {
5907
- request['newOrderRespType'] = 'RESULT'; // "ACK", "RESULT", default "ACK"
5908
- }
5909
- }
5910
5901
  if (market['option']) {
5911
5902
  if (type === 'market') {
5912
5903
  throw new errors.InvalidOrder(this.id + ' ' + type + ' is not a valid order type for the ' + symbol + ' market');
@@ -5946,6 +5937,14 @@ class binance extends binance$1 {
5946
5937
  }
5947
5938
  }
5948
5939
  }
5940
+ // handle newOrderRespType response type
5941
+ if (((marketType === 'spot') || (marketType === 'margin')) && !isPortfolioMargin) {
5942
+ request['newOrderRespType'] = this.safeString(this.options['newOrderRespType'], type, 'FULL'); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
5943
+ }
5944
+ else {
5945
+ // swap, futures and options
5946
+ request['newOrderRespType'] = 'RESULT'; // "ACK", "RESULT", default "ACK"
5947
+ }
5949
5948
  const typeRequest = isPortfolioMarginConditional ? 'strategyType' : 'type';
5950
5949
  request[typeRequest] = uppercaseType;
5951
5950
  // additional required fields depending on the order type
@@ -6599,7 +6598,7 @@ class binance extends binance$1 {
6599
6598
  response = await this.dapiPrivateGetOpenOrders(this.extend(request, params));
6600
6599
  }
6601
6600
  }
6602
- else if (type === 'margin' || marginMode !== undefined) {
6601
+ else if (type === 'margin' || marginMode !== undefined || isPortfolioMargin) {
6603
6602
  if (isPortfolioMargin) {
6604
6603
  response = await this.papiGetMarginOpenOrders(this.extend(request, params));
6605
6604
  }
@@ -7100,7 +7099,7 @@ class binance extends binance$1 {
7100
7099
  response = await this.dapiPrivateDeleteAllOpenOrders(this.extend(request, params));
7101
7100
  }
7102
7101
  }
7103
- else if ((type === 'margin') || (marginMode !== undefined)) {
7102
+ else if ((type === 'margin') || (marginMode !== undefined) || isPortfolioMargin) {
7104
7103
  if (isPortfolioMargin) {
7105
7104
  response = await this.papiDeleteMarginAllOpenOrders(this.extend(request, params));
7106
7105
  }
@@ -1180,12 +1180,18 @@ class coinbase extends coinbase$1 {
1180
1180
  this.v3PrivateGetBrokerageProducts(params),
1181
1181
  this.v3PrivateGetBrokerageTransactionSummary(params),
1182
1182
  ];
1183
- const unresolvedContractPromises = [
1184
- this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE' })),
1185
- this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1186
- this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE' })),
1187
- this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1188
- ];
1183
+ let unresolvedContractPromises = [];
1184
+ try {
1185
+ unresolvedContractPromises = [
1186
+ this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE' })),
1187
+ this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1188
+ this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE' })),
1189
+ this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1190
+ ];
1191
+ }
1192
+ catch (e) {
1193
+ unresolvedContractPromises = []; // the sync version of ccxt won't have the promise.all line so the request is made here
1194
+ }
1189
1195
  const promises = await Promise.all(spotUnresolvedPromises);
1190
1196
  let contractPromises = undefined;
1191
1197
  try {
@@ -1212,13 +1212,18 @@ class deribit extends deribit$1 {
1212
1212
  * @name deribit#fetchTickers
1213
1213
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1214
1214
  * @see https://docs.deribit.com/#public-get_book_summary_by_currency
1215
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1215
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1216
1216
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1217
+ * @param {string} [params.code] *required* the currency code to fetch the tickers for, eg. 'BTC', 'ETH'
1217
1218
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1218
1219
  */
1219
1220
  await this.loadMarkets();
1220
1221
  symbols = this.marketSymbols(symbols);
1221
- const code = this.codeFromOptions('fetchTickers', params);
1222
+ const code = this.safeString2(params, 'code', 'currency');
1223
+ params = this.omit(params, ['code']);
1224
+ if (code === undefined) {
1225
+ throw new errors.ArgumentsRequired(this.id + ' fetchTickers requires a currency/code (eg: BTC/ETH/USDT) parameter to fetch tickers for');
1226
+ }
1222
1227
  const currency = this.currency(code);
1223
1228
  const request = {
1224
1229
  'currency': currency['id'],
@@ -1254,7 +1259,7 @@ class deribit extends deribit$1 {
1254
1259
  // "testnet": false
1255
1260
  // }
1256
1261
  //
1257
- const result = this.safeValue(response, 'result', []);
1262
+ const result = this.safeList(response, 'result', []);
1258
1263
  const tickers = {};
1259
1264
  for (let i = 0; i < result.length; i++) {
1260
1265
  const ticker = this.parseTicker(result[i]);
@@ -1107,14 +1107,14 @@ class okx extends okx$1 {
1107
1107
  },
1108
1108
  });
1109
1109
  }
1110
- handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
1110
+ handleMarketTypeAndParams(methodName, market = undefined, params = {}, defaultValue = undefined) {
1111
1111
  const instType = this.safeString(params, 'instType');
1112
1112
  params = this.omit(params, 'instType');
1113
1113
  const type = this.safeString(params, 'type');
1114
1114
  if ((type === undefined) && (instType !== undefined)) {
1115
1115
  params['type'] = instType;
1116
1116
  }
1117
- return super.handleMarketTypeAndParams(methodName, market, params);
1117
+ return super.handleMarketTypeAndParams(methodName, market, params, defaultValue);
1118
1118
  }
1119
1119
  convertToInstrumentType(type) {
1120
1120
  const exchangeTypes = this.safeDict(this.options, 'exchangeType', {});
@@ -372,7 +372,10 @@ class poloniexfutures extends poloniexfutures$1 {
372
372
  //
373
373
  const marketId = this.safeString(ticker, 'symbol');
374
374
  const symbol = this.safeSymbol(marketId, market);
375
- const timestamp = this.safeIntegerProduct(ticker, 'ts', 0.000001);
375
+ const timestampString = this.safeString(ticker, 'ts');
376
+ // check timestamp bcz bug: https://app.travis-ci.com/github/ccxt/ccxt/builds/269959181#L4011
377
+ const multiplier = (timestampString.length === 18) ? 0.00001 : 0.000001;
378
+ const timestamp = this.safeIntegerProduct(ticker, 'ts', multiplier);
376
379
  const last = this.safeString2(ticker, 'price', 'lastPrice');
377
380
  const percentage = Precise["default"].stringMul(this.safeString(ticker, 'priceChgPct'), '100');
378
381
  return this.safeTicker({
@@ -422,8 +422,11 @@ class binance extends binance$1 {
422
422
  }
423
423
  }
424
424
  else {
425
- // todo: client.reject from handleOrderBookMessage properly
426
- throw new errors.ExchangeError(this.id + ' handleOrderBook received an out-of-order nonce');
425
+ const checksum = this.safeBool(this.options, 'checksum', true);
426
+ if (checksum) {
427
+ // todo: client.reject from handleOrderBookMessage properly
428
+ throw new errors.InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
429
+ }
427
430
  }
428
431
  }
429
432
  }
@@ -440,8 +443,11 @@ class binance extends binance$1 {
440
443
  }
441
444
  }
442
445
  else {
443
- // todo: client.reject from handleOrderBookMessage properly
444
- throw new errors.ExchangeError(this.id + ' handleOrderBook received an out-of-order nonce');
446
+ const checksum = this.safeBool(this.options, 'checksum', true);
447
+ if (checksum) {
448
+ // todo: client.reject from handleOrderBookMessage properly
449
+ throw new errors.InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
450
+ }
445
451
  }
446
452
  }
447
453
  }
@@ -851,7 +851,11 @@ class poloniexfutures extends poloniexfutures$1 {
851
851
  const sequence = this.safeInteger(delta, 'sequence');
852
852
  const nonce = this.safeInteger(orderbook, 'nonce');
853
853
  if (nonce !== sequence - 1) {
854
- throw new errors.ExchangeError(this.id + ' watchOrderBook received an out-of-order nonce');
854
+ const checksum = this.safeBool(this.options, 'checksum', true);
855
+ if (checksum) {
856
+ // todo: client.reject from handleOrderBookMessage properly
857
+ throw new errors.InvalidNonce(this.id + ' watchOrderBook received an out-of-order nonce');
858
+ }
855
859
  }
856
860
  const change = this.safeString(delta, 'change');
857
861
  const splitChange = change.split(',');
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, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.2.95";
7
+ declare const version = "4.2.97";
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, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.96';
41
+ const version = '4.2.98';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -860,7 +860,7 @@ export default class Exchange {
860
860
  handleOptionAndParams(params: object, methodName: string, optionName: string, defaultValue?: any): any[];
861
861
  handleOptionAndParams2(params: object, methodName: string, methodName2: string, optionName: string, defaultValue?: any): any[];
862
862
  handleOption(methodName: string, optionName: string, defaultValue?: any): any;
863
- handleMarketTypeAndParams(methodName: string, market?: Market, params?: {}): any;
863
+ handleMarketTypeAndParams(methodName: string, market?: Market, params?: {}, defaultValue?: any): any;
864
864
  handleSubTypeAndParams(methodName: string, market?: any, params?: {}, defaultValue?: any): any[];
865
865
  handleMarginModeAndParams(methodName: string, params?: {}, defaultValue?: any): any[];
866
866
  throwExactlyMatchedException(exact: any, string: any, message: any): void;
@@ -4049,11 +4049,26 @@ export default class Exchange {
4049
4049
  const [result, empty] = this.handleOptionAndParams({}, methodName, optionName, defaultValue);
4050
4050
  return result;
4051
4051
  }
4052
- handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
4052
+ handleMarketTypeAndParams(methodName, market = undefined, params = {}, defaultValue = undefined) {
4053
+ /**
4054
+ * @ignore
4055
+ * @method
4056
+ * @name exchange#handleMarketTypeAndParams
4057
+ * @param methodName the method calling handleMarketTypeAndParams
4058
+ * @param {Market} market
4059
+ * @param {object} params
4060
+ * @param {string} [params.type] type assigned by user
4061
+ * @param {string} [params.defaultType] same as params.type
4062
+ * @param {string} [defaultValue] assigned programatically in the method calling handleMarketTypeAndParams
4063
+ * @returns {[string, object]} the market type and params with type and defaultType omitted
4064
+ */
4053
4065
  const defaultType = this.safeString2(this.options, 'defaultType', 'type', 'spot');
4066
+ if (defaultValue === undefined) { // defaultValue takes precendence over exchange wide defaultType
4067
+ defaultValue = defaultType;
4068
+ }
4054
4069
  const methodOptions = this.safeDict(this.options, methodName);
4055
- let methodType = defaultType;
4056
- if (methodOptions !== undefined) {
4070
+ let methodType = defaultValue;
4071
+ if (methodOptions !== undefined) { // user defined methodType takes precedence over defaultValue
4057
4072
  if (typeof methodOptions === 'string') {
4058
4073
  methodType = methodOptions;
4059
4074
  }
package/js/src/binance.js CHANGED
@@ -5799,7 +5799,7 @@ export default class binance extends Exchange {
5799
5799
  response = await this.dapiPrivatePostOrder(request);
5800
5800
  }
5801
5801
  }
5802
- else if (marketType === 'margin' || marginMode !== undefined) {
5802
+ else if (marketType === 'margin' || marginMode !== undefined || isPortfolioMargin) {
5803
5803
  if (isPortfolioMargin) {
5804
5804
  response = await this.papiPostMarginOrder(request);
5805
5805
  }
@@ -5901,15 +5901,6 @@ export default class binance extends Exchange {
5901
5901
  uppercaseType = market['contract'] ? 'TAKE_PROFIT' : 'TAKE_PROFIT_LIMIT';
5902
5902
  }
5903
5903
  }
5904
- if ((marketType === 'spot') || (marketType === 'margin')) {
5905
- request['newOrderRespType'] = this.safeString(this.options['newOrderRespType'], type, 'RESULT'); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
5906
- }
5907
- else {
5908
- // swap, futures and options
5909
- if (!isPortfolioMargin) {
5910
- request['newOrderRespType'] = 'RESULT'; // "ACK", "RESULT", default "ACK"
5911
- }
5912
- }
5913
5904
  if (market['option']) {
5914
5905
  if (type === 'market') {
5915
5906
  throw new InvalidOrder(this.id + ' ' + type + ' is not a valid order type for the ' + symbol + ' market');
@@ -5949,6 +5940,14 @@ export default class binance extends Exchange {
5949
5940
  }
5950
5941
  }
5951
5942
  }
5943
+ // handle newOrderRespType response type
5944
+ if (((marketType === 'spot') || (marketType === 'margin')) && !isPortfolioMargin) {
5945
+ request['newOrderRespType'] = this.safeString(this.options['newOrderRespType'], type, 'FULL'); // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
5946
+ }
5947
+ else {
5948
+ // swap, futures and options
5949
+ request['newOrderRespType'] = 'RESULT'; // "ACK", "RESULT", default "ACK"
5950
+ }
5952
5951
  const typeRequest = isPortfolioMarginConditional ? 'strategyType' : 'type';
5953
5952
  request[typeRequest] = uppercaseType;
5954
5953
  // additional required fields depending on the order type
@@ -6602,7 +6601,7 @@ export default class binance extends Exchange {
6602
6601
  response = await this.dapiPrivateGetOpenOrders(this.extend(request, params));
6603
6602
  }
6604
6603
  }
6605
- else if (type === 'margin' || marginMode !== undefined) {
6604
+ else if (type === 'margin' || marginMode !== undefined || isPortfolioMargin) {
6606
6605
  if (isPortfolioMargin) {
6607
6606
  response = await this.papiGetMarginOpenOrders(this.extend(request, params));
6608
6607
  }
@@ -7103,7 +7102,7 @@ export default class binance extends Exchange {
7103
7102
  response = await this.dapiPrivateDeleteAllOpenOrders(this.extend(request, params));
7104
7103
  }
7105
7104
  }
7106
- else if ((type === 'margin') || (marginMode !== undefined)) {
7105
+ else if ((type === 'margin') || (marginMode !== undefined) || isPortfolioMargin) {
7107
7106
  if (isPortfolioMargin) {
7108
7107
  response = await this.papiDeleteMarginAllOpenOrders(this.extend(request, params));
7109
7108
  }
@@ -1183,12 +1183,18 @@ export default class coinbase extends Exchange {
1183
1183
  this.v3PrivateGetBrokerageProducts(params),
1184
1184
  this.v3PrivateGetBrokerageTransactionSummary(params),
1185
1185
  ];
1186
- const unresolvedContractPromises = [
1187
- this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE' })),
1188
- this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1189
- this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE' })),
1190
- this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1191
- ];
1186
+ let unresolvedContractPromises = [];
1187
+ try {
1188
+ unresolvedContractPromises = [
1189
+ this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE' })),
1190
+ this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1191
+ this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE' })),
1192
+ this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1193
+ ];
1194
+ }
1195
+ catch (e) {
1196
+ unresolvedContractPromises = []; // the sync version of ccxt won't have the promise.all line so the request is made here
1197
+ }
1192
1198
  const promises = await Promise.all(spotUnresolvedPromises);
1193
1199
  let contractPromises = undefined;
1194
1200
  try {
package/js/src/deribit.js CHANGED
@@ -1215,13 +1215,18 @@ export default class deribit extends Exchange {
1215
1215
  * @name deribit#fetchTickers
1216
1216
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1217
1217
  * @see https://docs.deribit.com/#public-get_book_summary_by_currency
1218
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1218
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1219
1219
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1220
+ * @param {string} [params.code] *required* the currency code to fetch the tickers for, eg. 'BTC', 'ETH'
1220
1221
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1221
1222
  */
1222
1223
  await this.loadMarkets();
1223
1224
  symbols = this.marketSymbols(symbols);
1224
- const code = this.codeFromOptions('fetchTickers', params);
1225
+ const code = this.safeString2(params, 'code', 'currency');
1226
+ params = this.omit(params, ['code']);
1227
+ if (code === undefined) {
1228
+ throw new ArgumentsRequired(this.id + ' fetchTickers requires a currency/code (eg: BTC/ETH/USDT) parameter to fetch tickers for');
1229
+ }
1225
1230
  const currency = this.currency(code);
1226
1231
  const request = {
1227
1232
  'currency': currency['id'],
@@ -1257,7 +1262,7 @@ export default class deribit extends Exchange {
1257
1262
  // "testnet": false
1258
1263
  // }
1259
1264
  //
1260
- const result = this.safeValue(response, 'result', []);
1265
+ const result = this.safeList(response, 'result', []);
1261
1266
  const tickers = {};
1262
1267
  for (let i = 0; i < result.length; i++) {
1263
1268
  const ticker = this.parseTicker(result[i]);
package/js/src/okx.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, Fun
6
6
  */
7
7
  export default class okx extends Exchange {
8
8
  describe(): any;
9
- handleMarketTypeAndParams(methodName: any, market?: any, params?: {}): any;
9
+ handleMarketTypeAndParams(methodName: string, market?: Market, params?: {}, defaultValue?: any): any;
10
10
  convertToInstrumentType(type: any): string;
11
11
  createExpiredOptionMarket(symbol: string): MarketInterface;
12
12
  safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
package/js/src/okx.js CHANGED
@@ -1110,14 +1110,14 @@ export default class okx extends Exchange {
1110
1110
  },
1111
1111
  });
1112
1112
  }
1113
- handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
1113
+ handleMarketTypeAndParams(methodName, market = undefined, params = {}, defaultValue = undefined) {
1114
1114
  const instType = this.safeString(params, 'instType');
1115
1115
  params = this.omit(params, 'instType');
1116
1116
  const type = this.safeString(params, 'type');
1117
1117
  if ((type === undefined) && (instType !== undefined)) {
1118
1118
  params['type'] = instType;
1119
1119
  }
1120
- return super.handleMarketTypeAndParams(methodName, market, params);
1120
+ return super.handleMarketTypeAndParams(methodName, market, params, defaultValue);
1121
1121
  }
1122
1122
  convertToInstrumentType(type) {
1123
1123
  const exchangeTypes = this.safeDict(this.options, 'exchangeType', {});
@@ -375,7 +375,10 @@ export default class poloniexfutures extends Exchange {
375
375
  //
376
376
  const marketId = this.safeString(ticker, 'symbol');
377
377
  const symbol = this.safeSymbol(marketId, market);
378
- const timestamp = this.safeIntegerProduct(ticker, 'ts', 0.000001);
378
+ const timestampString = this.safeString(ticker, 'ts');
379
+ // check timestamp bcz bug: https://app.travis-ci.com/github/ccxt/ccxt/builds/269959181#L4011
380
+ const multiplier = (timestampString.length === 18) ? 0.00001 : 0.000001;
381
+ const timestamp = this.safeIntegerProduct(ticker, 'ts', multiplier);
379
382
  const last = this.safeString2(ticker, 'price', 'lastPrice');
380
383
  const percentage = Precise.stringMul(this.safeString(ticker, 'priceChgPct'), '100');
381
384
  return this.safeTicker({
@@ -7,7 +7,7 @@
7
7
  // ----------------------------------------------------------------------------
8
8
  import binanceRest from '../binance.js';
9
9
  import { Precise } from '../base/Precise.js';
10
- import { ExchangeError, ArgumentsRequired, BadRequest, NotSupported } from '../base/errors.js';
10
+ import { InvalidNonce, ArgumentsRequired, BadRequest, NotSupported } from '../base/errors.js';
11
11
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
12
12
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
13
13
  import { rsa } from '../base/functions/rsa.js';
@@ -425,8 +425,11 @@ export default class binance extends binanceRest {
425
425
  }
426
426
  }
427
427
  else {
428
- // todo: client.reject from handleOrderBookMessage properly
429
- throw new ExchangeError(this.id + ' handleOrderBook received an out-of-order nonce');
428
+ const checksum = this.safeBool(this.options, 'checksum', true);
429
+ if (checksum) {
430
+ // todo: client.reject from handleOrderBookMessage properly
431
+ throw new InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
432
+ }
430
433
  }
431
434
  }
432
435
  }
@@ -443,8 +446,11 @@ export default class binance extends binanceRest {
443
446
  }
444
447
  }
445
448
  else {
446
- // todo: client.reject from handleOrderBookMessage properly
447
- throw new ExchangeError(this.id + ' handleOrderBook received an out-of-order nonce');
449
+ const checksum = this.safeBool(this.options, 'checksum', true);
450
+ if (checksum) {
451
+ // todo: client.reject from handleOrderBookMessage properly
452
+ throw new InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
453
+ }
448
454
  }
449
455
  }
450
456
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import poloniexfuturesRest from '../poloniexfutures.js';
9
- import { AuthenticationError, BadRequest, ExchangeError } from '../base/errors.js';
9
+ import { AuthenticationError, BadRequest, InvalidNonce } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
11
11
  // ---------------------------------------------------------------------------
12
12
  export default class poloniexfutures extends poloniexfuturesRest {
@@ -854,7 +854,11 @@ export default class poloniexfutures extends poloniexfuturesRest {
854
854
  const sequence = this.safeInteger(delta, 'sequence');
855
855
  const nonce = this.safeInteger(orderbook, 'nonce');
856
856
  if (nonce !== sequence - 1) {
857
- throw new ExchangeError(this.id + ' watchOrderBook received an out-of-order nonce');
857
+ const checksum = this.safeBool(this.options, 'checksum', true);
858
+ if (checksum) {
859
+ // todo: client.reject from handleOrderBookMessage properly
860
+ throw new InvalidNonce(this.id + ' watchOrderBook received an out-of-order nonce');
861
+ }
858
862
  }
859
863
  const change = this.safeString(delta, 'change');
860
864
  const splitChange = change.split(',');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.96",
3
+ "version": "4.2.98",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",