ccxt 4.2.29 → 4.2.31

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.
Files changed (164) hide show
  1. package/README.md +5 -6
  2. package/dist/ccxt.browser.js +2196 -601
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +3 -1
  5. package/dist/cjs/src/ascendex.js +5 -5
  6. package/dist/cjs/src/base/Exchange.js +33 -25
  7. package/dist/cjs/src/base/errors.js +3 -3
  8. package/dist/cjs/src/base/functions/type.js +12 -0
  9. package/dist/cjs/src/bigone.js +2 -2
  10. package/dist/cjs/src/binance.js +897 -218
  11. package/dist/cjs/src/bingx.js +1 -1
  12. package/dist/cjs/src/bitfinex.js +1 -1
  13. package/dist/cjs/src/bitfinex2.js +457 -93
  14. package/dist/cjs/src/bitforex.js +3 -0
  15. package/dist/cjs/src/bitget.js +8 -4
  16. package/dist/cjs/src/bitmart.js +3 -3
  17. package/dist/cjs/src/bitmex.js +4 -4
  18. package/dist/cjs/src/bitrue.js +1 -1
  19. package/dist/cjs/src/bitso.js +1 -1
  20. package/dist/cjs/src/bitteam.js +2 -2
  21. package/dist/cjs/src/btcalpha.js +1 -1
  22. package/dist/cjs/src/bybit.js +3 -3
  23. package/dist/cjs/src/coinbase.js +22 -5
  24. package/dist/cjs/src/coincheck.js +1 -1
  25. package/dist/cjs/src/coinex.js +2 -2
  26. package/dist/cjs/src/coinlist.js +1 -1
  27. package/dist/cjs/src/coinmate.js +1 -1
  28. package/dist/cjs/src/coinmetro.js +2 -2
  29. package/dist/cjs/src/coinsph.js +1 -1
  30. package/dist/cjs/src/cryptocom.js +3 -3
  31. package/dist/cjs/src/deribit.js +1 -0
  32. package/dist/cjs/src/digifinex.js +6 -4
  33. package/dist/cjs/src/exmo.js +2 -2
  34. package/dist/cjs/src/gate.js +5 -5
  35. package/dist/cjs/src/gemini.js +3 -3
  36. package/dist/cjs/src/hitbtc.js +14 -20
  37. package/dist/cjs/src/hollaex.js +2 -2
  38. package/dist/cjs/src/htx.js +6 -6
  39. package/dist/cjs/src/huobijp.js +1 -1
  40. package/dist/cjs/src/kraken.js +3 -1
  41. package/dist/cjs/src/krakenfutures.js +4 -1
  42. package/dist/cjs/src/kucoin.js +17 -17
  43. package/dist/cjs/src/kucoinfutures.js +3 -3
  44. package/dist/cjs/src/lbank.js +28 -27
  45. package/dist/cjs/src/mexc.js +7 -7
  46. package/dist/cjs/src/novadax.js +1 -1
  47. package/dist/cjs/src/okcoin.js +2 -2
  48. package/dist/cjs/src/okx.js +23 -8
  49. package/dist/cjs/src/p2b.js +1 -0
  50. package/dist/cjs/src/phemex.js +3 -3
  51. package/dist/cjs/src/poloniexfutures.js +6 -3
  52. package/dist/cjs/src/pro/alpaca.js +1 -1
  53. package/dist/cjs/src/pro/binance.js +4 -4
  54. package/dist/cjs/src/pro/bitget.js +1 -1
  55. package/dist/cjs/src/pro/bitmart.js +1 -1
  56. package/dist/cjs/src/pro/bitmex.js +49 -6
  57. package/dist/cjs/src/pro/bitvavo.js +1 -1
  58. package/dist/cjs/src/pro/bybit.js +2 -2
  59. package/dist/cjs/src/pro/cex.js +2 -2
  60. package/dist/cjs/src/pro/independentreserve.js +1 -1
  61. package/dist/cjs/src/pro/okx.js +1 -1
  62. package/dist/cjs/src/pro/onetrading.js +2 -2
  63. package/dist/cjs/src/pro/p2b.js +432 -0
  64. package/dist/cjs/src/pro/probit.js +5 -5
  65. package/dist/cjs/src/pro/whitebit.js +1 -1
  66. package/dist/cjs/src/probit.js +1 -1
  67. package/dist/cjs/src/timex.js +2 -2
  68. package/dist/cjs/src/tokocrypto.js +3 -3
  69. package/dist/cjs/src/wavesexchange.js +2 -2
  70. package/dist/cjs/src/whitebit.js +3 -3
  71. package/dist/cjs/src/woo.js +3 -3
  72. package/dist/cjs/src/yobit.js +1 -1
  73. package/dist/cjs/src/zaif.js +1 -1
  74. package/dist/cjs/src/zonda.js +3 -3
  75. package/js/ccxt.d.ts +4 -1
  76. package/js/ccxt.js +3 -1
  77. package/js/src/abstract/bybit.d.ts +2 -2
  78. package/js/src/abstract/coinbase.d.ts +10 -0
  79. package/js/src/abstract/okx.d.ts +12 -1
  80. package/js/src/ascendex.js +5 -5
  81. package/js/src/base/Exchange.d.ts +2 -2
  82. package/js/src/base/Exchange.js +33 -25
  83. package/js/src/base/errorHierarchy.d.ts +7 -6
  84. package/js/src/base/errorHierarchy.js +7 -6
  85. package/js/src/base/errors.d.ts +3 -3
  86. package/js/src/base/errors.js +3 -3
  87. package/js/src/base/functions/type.js +12 -0
  88. package/js/src/bigone.js +2 -2
  89. package/js/src/binance.d.ts +1 -0
  90. package/js/src/binance.js +898 -219
  91. package/js/src/bingx.js +1 -1
  92. package/js/src/bitfinex.js +1 -1
  93. package/js/src/bitfinex2.d.ts +6 -1
  94. package/js/src/bitfinex2.js +457 -93
  95. package/js/src/bitforex.js +3 -0
  96. package/js/src/bitget.js +8 -4
  97. package/js/src/bitmart.js +3 -3
  98. package/js/src/bitmex.js +4 -4
  99. package/js/src/bitrue.js +1 -1
  100. package/js/src/bitso.d.ts +1 -1
  101. package/js/src/bitso.js +1 -1
  102. package/js/src/bitteam.js +2 -2
  103. package/js/src/btcalpha.js +1 -1
  104. package/js/src/bybit.js +3 -3
  105. package/js/src/coinbase.js +22 -5
  106. package/js/src/coincheck.js +1 -1
  107. package/js/src/coinex.js +2 -2
  108. package/js/src/coinlist.js +1 -1
  109. package/js/src/coinmate.js +1 -1
  110. package/js/src/coinmetro.d.ts +1 -1
  111. package/js/src/coinmetro.js +2 -2
  112. package/js/src/coinsph.js +1 -1
  113. package/js/src/cryptocom.js +3 -3
  114. package/js/src/deribit.js +1 -0
  115. package/js/src/digifinex.js +6 -4
  116. package/js/src/exmo.js +2 -2
  117. package/js/src/gate.js +5 -5
  118. package/js/src/gemini.d.ts +1 -1
  119. package/js/src/gemini.js +3 -3
  120. package/js/src/hitbtc.js +14 -20
  121. package/js/src/hollaex.js +2 -2
  122. package/js/src/htx.js +6 -6
  123. package/js/src/huobijp.js +1 -1
  124. package/js/src/kraken.js +3 -1
  125. package/js/src/krakenfutures.js +4 -1
  126. package/js/src/kucoin.js +17 -17
  127. package/js/src/kucoinfutures.js +3 -3
  128. package/js/src/lbank.d.ts +1 -1
  129. package/js/src/lbank.js +28 -27
  130. package/js/src/mexc.js +7 -7
  131. package/js/src/novadax.js +1 -1
  132. package/js/src/okcoin.js +2 -2
  133. package/js/src/okx.js +23 -8
  134. package/js/src/p2b.js +1 -0
  135. package/js/src/phemex.js +3 -3
  136. package/js/src/poloniexfutures.js +6 -3
  137. package/js/src/pro/alpaca.js +1 -1
  138. package/js/src/pro/binance.js +4 -4
  139. package/js/src/pro/bitget.js +1 -1
  140. package/js/src/pro/bitmart.js +1 -1
  141. package/js/src/pro/bitmex.d.ts +2 -1
  142. package/js/src/pro/bitmex.js +49 -6
  143. package/js/src/pro/bitvavo.js +1 -1
  144. package/js/src/pro/bybit.js +2 -2
  145. package/js/src/pro/cex.js +2 -2
  146. package/js/src/pro/independentreserve.js +1 -1
  147. package/js/src/pro/okx.js +1 -1
  148. package/js/src/pro/onetrading.js +2 -2
  149. package/js/src/pro/p2b.d.ts +23 -0
  150. package/js/src/pro/p2b.js +433 -0
  151. package/js/src/pro/probit.js +5 -5
  152. package/js/src/pro/whitebit.js +1 -1
  153. package/js/src/probit.js +1 -1
  154. package/js/src/timex.js +2 -2
  155. package/js/src/tokocrypto.js +3 -3
  156. package/js/src/wavesexchange.js +2 -2
  157. package/js/src/whitebit.js +3 -3
  158. package/js/src/woo.js +3 -3
  159. package/js/src/yobit.js +1 -1
  160. package/js/src/zaif.js +1 -1
  161. package/js/src/zonda.d.ts +1 -1
  162. package/js/src/zonda.js +3 -3
  163. package/package.json +1 -1
  164. package/skip-tests.json +3 -10
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 } 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.28";
7
+ declare const version = "4.2.30";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -157,6 +157,7 @@ import ndaxPro from './src/pro/ndax.js';
157
157
  import okcoinPro from './src/pro/okcoin.js';
158
158
  import okxPro from './src/pro/okx.js';
159
159
  import onetradingPro from './src/pro/onetrading.js';
160
+ import p2bPro from './src/pro/p2b.js';
160
161
  import phemexPro from './src/pro/phemex.js';
161
162
  import poloniexPro from './src/pro/poloniex.js';
162
163
  import poloniexfuturesPro from './src/pro/poloniexfutures.js';
@@ -320,6 +321,7 @@ declare const pro: {
320
321
  okcoin: typeof okcoinPro;
321
322
  okx: typeof okxPro;
322
323
  onetrading: typeof onetradingPro;
324
+ p2b: typeof p2bPro;
323
325
  phemex: typeof phemexPro;
324
326
  poloniex: typeof poloniexPro;
325
327
  poloniexfutures: typeof poloniexfuturesPro;
@@ -387,6 +389,7 @@ declare const ccxt: {
387
389
  okcoin: typeof okcoinPro;
388
390
  okx: typeof okxPro;
389
391
  onetrading: typeof onetradingPro;
392
+ p2b: typeof p2bPro;
390
393
  phemex: typeof phemexPro;
391
394
  poloniex: typeof poloniexPro;
392
395
  poloniexfutures: typeof poloniexfuturesPro;
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.29';
41
+ const version = '4.2.31';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -194,6 +194,7 @@ import ndaxPro from './src/pro/ndax.js';
194
194
  import okcoinPro from './src/pro/okcoin.js';
195
195
  import okxPro from './src/pro/okx.js';
196
196
  import onetradingPro from './src/pro/onetrading.js';
197
+ import p2bPro from './src/pro/p2b.js';
197
198
  import phemexPro from './src/pro/phemex.js';
198
199
  import poloniexPro from './src/pro/poloniex.js';
199
200
  import poloniexfuturesPro from './src/pro/poloniexfutures.js';
@@ -357,6 +358,7 @@ const pro = {
357
358
  'okcoin': okcoinPro,
358
359
  'okx': okxPro,
359
360
  'onetrading': onetradingPro,
361
+ 'p2b': p2bPro,
360
362
  'phemex': phemexPro,
361
363
  'poloniex': poloniexPro,
362
364
  'poloniexfutures': poloniexfuturesPro,
@@ -122,8 +122,6 @@ interface Exchange {
122
122
  privateGetV5PreUpgradeAssetSettlementRecord(params?: {}): Promise<implicitReturnType>;
123
123
  privateGetV5AccountWalletBalance(params?: {}): Promise<implicitReturnType>;
124
124
  privateGetV5AccountBorrowHistory(params?: {}): Promise<implicitReturnType>;
125
- privateGetV5AccountSetCollateralSwitch(params?: {}): Promise<implicitReturnType>;
126
- privateGetV5AccountSetCollateralSwitchBatch(params?: {}): Promise<implicitReturnType>;
127
125
  privateGetV5AccountCollateralInfo(params?: {}): Promise<implicitReturnType>;
128
126
  privateGetV5AssetCoinGreeks(params?: {}): Promise<implicitReturnType>;
129
127
  privateGetV5AccountFeeRate(params?: {}): Promise<implicitReturnType>;
@@ -290,6 +288,8 @@ interface Exchange {
290
288
  privatePostV5LendingPurchase(params?: {}): Promise<implicitReturnType>;
291
289
  privatePostV5LendingRedeem(params?: {}): Promise<implicitReturnType>;
292
290
  privatePostV5LendingRedeemCancel(params?: {}): Promise<implicitReturnType>;
291
+ privatePostV5AccountSetCollateralSwitch(params?: {}): Promise<implicitReturnType>;
292
+ privatePostV5AccountSetCollateralSwitchBatch(params?: {}): Promise<implicitReturnType>;
293
293
  }
294
294
  declare abstract class Exchange extends _Exchange {
295
295
  }
@@ -61,6 +61,13 @@ interface Exchange {
61
61
  v3PrivateGetBrokerageBestBidAsk(params?: {}): Promise<implicitReturnType>;
62
62
  v3PrivateGetBrokerageConvertTradeTradeId(params?: {}): Promise<implicitReturnType>;
63
63
  v3PrivateGetBrokerageTime(params?: {}): Promise<implicitReturnType>;
64
+ v3PrivateGetBrokerageCfmBalanceSummary(params?: {}): Promise<implicitReturnType>;
65
+ v3PrivateGetBrokerageCfmPositions(params?: {}): Promise<implicitReturnType>;
66
+ v3PrivateGetBrokerageCfmPositionsProductId(params?: {}): Promise<implicitReturnType>;
67
+ v3PrivateGetBrokerageCfmSweeps(params?: {}): Promise<implicitReturnType>;
68
+ v3PrivateGetBrokerageIntxPortfolioPortfolioUuid(params?: {}): Promise<implicitReturnType>;
69
+ v3PrivateGetBrokerageIntxPositionsPortfolioUuid(params?: {}): Promise<implicitReturnType>;
70
+ v3PrivateGetBrokerageIntxPositionsPortfolioUuidSymbol(params?: {}): Promise<implicitReturnType>;
64
71
  v3PrivatePostBrokerageOrders(params?: {}): Promise<implicitReturnType>;
65
72
  v3PrivatePostBrokerageOrdersBatchCancel(params?: {}): Promise<implicitReturnType>;
66
73
  v3PrivatePostBrokerageOrdersEdit(params?: {}): Promise<implicitReturnType>;
@@ -69,8 +76,11 @@ interface Exchange {
69
76
  v3PrivatePostBrokeragePortfoliosMoveFunds(params?: {}): Promise<implicitReturnType>;
70
77
  v3PrivatePostBrokerageConvertQuote(params?: {}): Promise<implicitReturnType>;
71
78
  v3PrivatePostBrokerageConvertTradeTradeId(params?: {}): Promise<implicitReturnType>;
79
+ v3PrivatePostBrokerageCfmSweepsSchedule(params?: {}): Promise<implicitReturnType>;
80
+ v3PrivatePostBrokerageIntxAllocate(params?: {}): Promise<implicitReturnType>;
72
81
  v3PrivatePutBrokeragePortfoliosPortfolioUuid(params?: {}): Promise<implicitReturnType>;
73
82
  v3PrivateDeleteBrokeragePortfoliosPortfolioUuid(params?: {}): Promise<implicitReturnType>;
83
+ v3PrivateDeleteBrokerageCfmSweeps(params?: {}): Promise<implicitReturnType>;
74
84
  }
75
85
  declare abstract class Exchange extends _Exchange {
76
86
  }
@@ -154,9 +154,11 @@ interface Exchange {
154
154
  privateGetTradingBotGridSubOrders(params?: {}): Promise<implicitReturnType>;
155
155
  privateGetTradingBotGridPositions(params?: {}): Promise<implicitReturnType>;
156
156
  privateGetTradingBotGridAiParam(params?: {}): Promise<implicitReturnType>;
157
- privateGetTradingBotPublicRsiBackTesting(params?: {}): Promise<implicitReturnType>;
157
+ privateGetTradingBotSignalSignals(params?: {}): Promise<implicitReturnType>;
158
158
  privateGetTradingBotSignalOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
159
+ privateGetTradingBotSignalOrdersAlgoHistory(params?: {}): Promise<implicitReturnType>;
159
160
  privateGetTradingBotSignalPositions(params?: {}): Promise<implicitReturnType>;
161
+ privateGetTradingBotSignalPositionsHistory(params?: {}): Promise<implicitReturnType>;
160
162
  privateGetTradingBotSignalSubOrders(params?: {}): Promise<implicitReturnType>;
161
163
  privateGetTradingBotSignalEventHistory(params?: {}): Promise<implicitReturnType>;
162
164
  privateGetTradingBotRecurringOrdersAlgoPending(params?: {}): Promise<implicitReturnType>;
@@ -262,6 +264,15 @@ interface Exchange {
262
264
  privatePostTradingBotGridComputeMarginBalance(params?: {}): Promise<implicitReturnType>;
263
265
  privatePostTradingBotGridMarginBalance(params?: {}): Promise<implicitReturnType>;
264
266
  privatePostTradingBotGridMinInvestment(params?: {}): Promise<implicitReturnType>;
267
+ privatePostTradingBotSignalCreateSignal(params?: {}): Promise<implicitReturnType>;
268
+ privatePostTradingBotSignalOrderAlgo(params?: {}): Promise<implicitReturnType>;
269
+ privatePostTradingBotSignalStopOrderAlgo(params?: {}): Promise<implicitReturnType>;
270
+ privatePostTradingBotSignalMarginBalance(params?: {}): Promise<implicitReturnType>;
271
+ privatePostTradingBotSignalAmendTPSL(params?: {}): Promise<implicitReturnType>;
272
+ privatePostTradingBotSignalSetInstruments(params?: {}): Promise<implicitReturnType>;
273
+ privatePostTradingBotSignalClosePosition(params?: {}): Promise<implicitReturnType>;
274
+ privatePostTradingBotSignalSubOrder(params?: {}): Promise<implicitReturnType>;
275
+ privatePostTradingBotSignalCancelSubOrder(params?: {}): Promise<implicitReturnType>;
265
276
  privatePostTradingBotRecurringOrderAlgo(params?: {}): Promise<implicitReturnType>;
266
277
  privatePostTradingBotRecurringAmendOrderAlgo(params?: {}): Promise<implicitReturnType>;
267
278
  privatePostTradingBotRecurringStopOrderAlgo(params?: {}): Promise<implicitReturnType>;
@@ -622,7 +622,7 @@ export default class ascendex extends Exchange {
622
622
  symbol = base + '/' + quote + ':' + settle;
623
623
  }
624
624
  const fee = this.safeNumber(market, 'commissionReserveRate');
625
- const marginTradable = this.safeValue(market, 'marginTradable', false);
625
+ const marginTradable = this.safeBool(market, 'marginTradable', false);
626
626
  result.push({
627
627
  'id': id,
628
628
  'symbol': symbol,
@@ -817,7 +817,7 @@ export default class ascendex extends Exchange {
817
817
  let marginMode = undefined;
818
818
  [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
819
819
  [marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
820
- const isMargin = this.safeValue(params, 'margin', false);
820
+ const isMargin = this.safeBool(params, 'margin', false);
821
821
  const isCross = marginMode === 'cross';
822
822
  marketType = (isMargin || isCross) ? 'margin' : marketType;
823
823
  params = this.omit(params, 'margin');
@@ -1177,7 +1177,7 @@ export default class ascendex extends Exchange {
1177
1177
  const timestamp = this.safeInteger(trade, 'ts');
1178
1178
  const priceString = this.safeString2(trade, 'price', 'p');
1179
1179
  const amountString = this.safeString(trade, 'q');
1180
- const buyerIsMaker = this.safeValue(trade, 'bm', false);
1180
+ const buyerIsMaker = this.safeBool(trade, 'bm', false);
1181
1181
  const side = buyerIsMaker ? 'sell' : 'buy';
1182
1182
  market = this.safeMarket(undefined, market);
1183
1183
  return this.safeTrade({
@@ -1521,7 +1521,7 @@ export default class ascendex extends Exchange {
1521
1521
  const isLimitOrder = ((type === 'limit') || (type === 'stop_limit'));
1522
1522
  const timeInForce = this.safeString(params, 'timeInForce');
1523
1523
  const postOnly = this.isPostOnly(isMarketOrder, false, params);
1524
- const reduceOnly = this.safeValue(params, 'reduceOnly', false);
1524
+ const reduceOnly = this.safeBool(params, 'reduceOnly', false);
1525
1525
  const stopPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
1526
1526
  if (isLimitOrder) {
1527
1527
  request['orderPrice'] = this.priceToPrecision(symbol, price);
@@ -3164,7 +3164,7 @@ export default class ascendex extends Exchange {
3164
3164
  // { "code": "0" }
3165
3165
  //
3166
3166
  const transferOptions = this.safeValue(this.options, 'transfer', {});
3167
- const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
3167
+ const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
3168
3168
  const transfer = this.parseTransfer(response, currency);
3169
3169
  if (fillResponseFromRequest) {
3170
3170
  transfer['fromAccount'] = fromAccount;
@@ -588,7 +588,7 @@ export default class Exchange {
588
588
  checkWsProxySettings(): any[];
589
589
  checkConflictingProxies(proxyAgentSet: any, proxyUrlSet: any): void;
590
590
  findMessageHashes(client: any, element: string): string[];
591
- filterByLimit(array: object[], limit?: Int, key?: IndexType): any;
591
+ filterByLimit(array: object[], limit?: Int, key?: IndexType, fromStart?: boolean): any;
592
592
  filterBySinceLimit(array: object[], since?: Int, limit?: Int, key?: IndexType, tail?: boolean): any;
593
593
  filterByValueSinceLimit(array: object[], field: IndexType, value?: any, since?: Int, limit?: Int, key?: string, tail?: boolean): any;
594
594
  setSandboxMode(enabled: any): void;
@@ -668,7 +668,7 @@ export default class Exchange {
668
668
  after: number;
669
669
  status: string;
670
670
  fee: any;
671
- info: any;
671
+ info: Dictionary<any>;
672
672
  };
673
673
  safeCurrencyStructure(currency: object): any;
674
674
  safeMarketStructure(market?: any): MarketInterface;
@@ -1677,7 +1677,7 @@ export default class Exchange {
1677
1677
  }
1678
1678
  return result;
1679
1679
  }
1680
- filterByLimit(array, limit = undefined, key = 'timestamp') {
1680
+ filterByLimit(array, limit = undefined, key = 'timestamp', fromStart = false) {
1681
1681
  if (this.valueIsDefined(limit)) {
1682
1682
  const arrayLength = array.length;
1683
1683
  if (arrayLength > 0) {
@@ -1689,7 +1689,12 @@ export default class Exchange {
1689
1689
  ascending = first <= last; // true if array is sorted in ascending order based on 'timestamp'
1690
1690
  }
1691
1691
  }
1692
- array = ascending ? this.arraySlice(array, -limit) : this.arraySlice(array, 0, limit);
1692
+ if (fromStart) {
1693
+ array = ascending ? this.arraySlice(array, 0, limit) : this.arraySlice(array, -limit);
1694
+ }
1695
+ else {
1696
+ array = ascending ? this.arraySlice(array, -limit) : this.arraySlice(array, 0, limit);
1697
+ }
1693
1698
  }
1694
1699
  }
1695
1700
  return array;
@@ -1711,7 +1716,10 @@ export default class Exchange {
1711
1716
  if (tail && limit !== undefined) {
1712
1717
  return this.arraySlice(result, -limit);
1713
1718
  }
1714
- return this.filterByLimit(result, limit, key);
1719
+ // if the user provided a 'since' argument
1720
+ // we want to limit the result starting from the 'since'
1721
+ const shouldFilterFromStart = !tail && sinceIsDefined;
1722
+ return this.filterByLimit(result, limit, key, shouldFilterFromStart);
1715
1723
  }
1716
1724
  filterByValueSinceLimit(array, field, value = undefined, since = undefined, limit = undefined, key = 'timestamp', tail = false) {
1717
1725
  const valueIsDefined = this.valueIsDefined(value);
@@ -1736,7 +1744,7 @@ export default class Exchange {
1736
1744
  if (tail && limit !== undefined) {
1737
1745
  return this.arraySlice(result, -limit);
1738
1746
  }
1739
- return this.filterByLimit(result, limit, key);
1747
+ return this.filterByLimit(result, limit, key, sinceIsDefined);
1740
1748
  }
1741
1749
  setSandboxMode(enabled) {
1742
1750
  if (enabled) {
@@ -1980,7 +1988,7 @@ export default class Exchange {
1980
1988
  fee['cost'] = this.safeNumber(fee, 'cost');
1981
1989
  }
1982
1990
  const timestamp = this.safeInteger(entry, 'timestamp');
1983
- const info = this.safeValue(entry, 'info', {});
1991
+ const info = this.safeDict(entry, 'info', {});
1984
1992
  return {
1985
1993
  'id': this.safeString(entry, 'id'),
1986
1994
  'timestamp': timestamp,
@@ -2152,7 +2160,7 @@ export default class Exchange {
2152
2160
  for (let i = 0; i < values.length; i++) {
2153
2161
  const market = values[i];
2154
2162
  const defaultCurrencyPrecision = (this.precisionMode === DECIMAL_PLACES) ? 8 : this.parseNumber('1e-8');
2155
- const marketPrecision = this.safeValue(market, 'precision', {});
2163
+ const marketPrecision = this.safeDict(market, 'precision', {});
2156
2164
  if ('base' in market) {
2157
2165
  const currency = this.safeCurrencyStructure({
2158
2166
  'id': this.safeString2(market, 'baseId', 'base'),
@@ -2182,7 +2190,7 @@ export default class Exchange {
2182
2190
  const resultingCurrencies = [];
2183
2191
  for (let i = 0; i < codes.length; i++) {
2184
2192
  const code = codes[i];
2185
- const groupedCurrenciesCode = this.safeValue(groupedCurrencies, code, []);
2193
+ const groupedCurrenciesCode = this.safeList(groupedCurrencies, code, []);
2186
2194
  let highestPrecisionCurrency = this.safeValue(groupedCurrenciesCode, 0);
2187
2195
  for (let j = 1; j < groupedCurrenciesCode.length; j++) {
2188
2196
  const currentCurrency = groupedCurrenciesCode[j];
@@ -2265,7 +2273,7 @@ export default class Exchange {
2265
2273
  const parseSymbol = symbol === undefined;
2266
2274
  const parseSide = side === undefined;
2267
2275
  const shouldParseFees = parseFee || parseFees;
2268
- const fees = this.safeValue(order, 'fees', []);
2276
+ const fees = this.safeList(order, 'fees', []);
2269
2277
  let trades = [];
2270
2278
  if (parseFilled || parseCost || shouldParseFees) {
2271
2279
  const rawTrades = this.safeValue(order, 'trades', trades);
@@ -2399,7 +2407,7 @@ export default class Exchange {
2399
2407
  }
2400
2408
  }
2401
2409
  // ensure that the average field is calculated correctly
2402
- const inverse = this.safeValue(market, 'inverse', false);
2410
+ const inverse = this.safeBool(market, 'inverse', false);
2403
2411
  const contractSize = this.numberToString(this.safeValue(market, 'contractSize', 1));
2404
2412
  // inverse
2405
2413
  // price = filled * contract size / cost
@@ -2453,12 +2461,12 @@ export default class Exchange {
2453
2461
  entry['amount'] = this.safeNumber(entry, 'amount');
2454
2462
  entry['price'] = this.safeNumber(entry, 'price');
2455
2463
  entry['cost'] = this.safeNumber(entry, 'cost');
2456
- const tradeFee = this.safeValue(entry, 'fee', {});
2464
+ const tradeFee = this.safeDict(entry, 'fee', {});
2457
2465
  tradeFee['cost'] = this.safeNumber(tradeFee, 'cost');
2458
2466
  if ('rate' in tradeFee) {
2459
2467
  tradeFee['rate'] = this.safeNumber(tradeFee, 'rate');
2460
2468
  }
2461
- const entryFees = this.safeValue(entry, 'fees', []);
2469
+ const entryFees = this.safeList(entry, 'fees', []);
2462
2470
  for (let j = 0; j < entryFees.length; j++) {
2463
2471
  entryFees[j]['cost'] = this.safeNumber(entryFees[j], 'cost');
2464
2472
  }
@@ -2633,7 +2641,7 @@ export default class Exchange {
2633
2641
  const contractSize = this.safeString(market, 'contractSize');
2634
2642
  let multiplyPrice = price;
2635
2643
  if (contractSize !== undefined) {
2636
- const inverse = this.safeValue(market, 'inverse', false);
2644
+ const inverse = this.safeBool(market, 'inverse', false);
2637
2645
  if (inverse) {
2638
2646
  multiplyPrice = Precise.stringDiv('1', price);
2639
2647
  }
@@ -2876,12 +2884,12 @@ export default class Exchange {
2876
2884
  }
2877
2885
  convertTradingViewToOHLCV(ohlcvs, timestamp = 't', open = 'o', high = 'h', low = 'l', close = 'c', volume = 'v', ms = false) {
2878
2886
  const result = [];
2879
- const timestamps = this.safeValue(ohlcvs, timestamp, []);
2880
- const opens = this.safeValue(ohlcvs, open, []);
2881
- const highs = this.safeValue(ohlcvs, high, []);
2882
- const lows = this.safeValue(ohlcvs, low, []);
2883
- const closes = this.safeValue(ohlcvs, close, []);
2884
- const volumes = this.safeValue(ohlcvs, volume, []);
2887
+ const timestamps = this.safeList(ohlcvs, timestamp, []);
2888
+ const opens = this.safeList(ohlcvs, open, []);
2889
+ const highs = this.safeList(ohlcvs, high, []);
2890
+ const lows = this.safeList(ohlcvs, low, []);
2891
+ const closes = this.safeList(ohlcvs, close, []);
2892
+ const volumes = this.safeList(ohlcvs, volume, []);
2885
2893
  for (let i = 0; i < timestamps.length; i++) {
2886
2894
  result.push([
2887
2895
  ms ? this.safeInteger(timestamps, i) : this.safeTimestamp(timestamps, i),
@@ -2916,10 +2924,10 @@ export default class Exchange {
2916
2924
  async fetchWebEndpoint(method, endpointMethod, returnAsJson, startRegex = undefined, endRegex = undefined) {
2917
2925
  let errorMessage = '';
2918
2926
  const options = this.safeValue(this.options, method, {});
2919
- const muteOnFailure = this.safeValue(options, 'webApiMuteFailure', true);
2927
+ const muteOnFailure = this.safeBool(options, 'webApiMuteFailure', true);
2920
2928
  try {
2921
2929
  // if it was not explicitly disabled, then don't fetch
2922
- if (this.safeValue(options, 'webApiEnable', true) !== true) {
2930
+ if (this.safeBool(options, 'webApiEnable', true) !== true) {
2923
2931
  return undefined;
2924
2932
  }
2925
2933
  const maxRetries = this.safeValue(options, 'webApiRetries', 10);
@@ -3130,7 +3138,7 @@ export default class Exchange {
3130
3138
  if (currencyCode !== undefined) {
3131
3139
  const defaultNetworkCodeReplacements = this.safeValue(this.options, 'defaultNetworkCodeReplacements', {});
3132
3140
  if (currencyCode in defaultNetworkCodeReplacements) {
3133
- const replacementObject = this.safeValue(defaultNetworkCodeReplacements, currencyCode, {});
3141
+ const replacementObject = this.safeDict(defaultNetworkCodeReplacements, currencyCode, {});
3134
3142
  networkCode = this.safeString(replacementObject, networkCode, networkCode);
3135
3143
  }
3136
3144
  }
@@ -3232,7 +3240,7 @@ export default class Exchange {
3232
3240
  const id = this.safeString(item, marketIdKey);
3233
3241
  const market = this.safeMarket(id, undefined, undefined, 'swap');
3234
3242
  const symbol = market['symbol'];
3235
- const contract = this.safeValue(market, 'contract', false);
3243
+ const contract = this.safeBool(market, 'contract', false);
3236
3244
  if (contract && ((symbols === undefined) || this.inArray(symbol, symbols))) {
3237
3245
  tiers[symbol] = this.parseMarketLeverageTiers(item, market);
3238
3246
  }
@@ -4403,8 +4411,8 @@ export default class Exchange {
4403
4411
  const currency = this.currencies[code];
4404
4412
  let precision = this.safeValue(currency, 'precision');
4405
4413
  if (networkCode !== undefined) {
4406
- const networks = this.safeValue(currency, 'networks', {});
4407
- const networkItem = this.safeValue(networks, networkCode, {});
4414
+ const networks = this.safeDict(currency, 'networks', {});
4415
+ const networkItem = this.safeDict(networks, networkCode, {});
4408
4416
  precision = this.safeValue(networkItem, 'precision', precision);
4409
4417
  }
4410
4418
  if (precision === undefined) {
@@ -4706,7 +4714,7 @@ export default class Exchange {
4706
4714
  * @returns {Array}
4707
4715
  */
4708
4716
  const timeInForce = this.safeStringUpper(params, 'timeInForce');
4709
- let postOnly = this.safeValue(params, 'postOnly', false);
4717
+ let postOnly = this.safeBool(params, 'postOnly', false);
4710
4718
  const ioc = timeInForce === 'IOC';
4711
4719
  const fok = timeInForce === 'FOK';
4712
4720
  const po = timeInForce === 'PO';
@@ -10,9 +10,11 @@ declare const errorHierarchy: {
10
10
  ArgumentsRequired: {};
11
11
  BadRequest: {
12
12
  BadSymbol: {};
13
- MarginModeAlreadySet: {};
14
- NoChange: {};
15
- OperationRejected: {};
13
+ };
14
+ OperationRejected: {
15
+ NoChange: {
16
+ MarginModeAlreadySet: {};
17
+ };
16
18
  };
17
19
  BadResponse: {
18
20
  NullResponse: {};
@@ -35,9 +37,8 @@ declare const errorHierarchy: {
35
37
  };
36
38
  OperationFailed: {
37
39
  NetworkError: {
38
- DDoSProtection: {
39
- RateLimitExceeded: {};
40
- };
40
+ DDoSProtection: {};
41
+ RateLimitExceeded: {};
41
42
  ExchangeNotAvailable: {
42
43
  OnMaintenance: {};
43
44
  };
@@ -16,9 +16,11 @@ const errorHierarchy = {
16
16
  'ArgumentsRequired': {},
17
17
  'BadRequest': {
18
18
  'BadSymbol': {},
19
- 'MarginModeAlreadySet': {},
20
- 'NoChange': {},
21
- 'OperationRejected': {},
19
+ },
20
+ 'OperationRejected': {
21
+ 'NoChange': {
22
+ 'MarginModeAlreadySet': {},
23
+ },
22
24
  },
23
25
  'BadResponse': {
24
26
  'NullResponse': {},
@@ -41,9 +43,8 @@ const errorHierarchy = {
41
43
  },
42
44
  'OperationFailed': {
43
45
  'NetworkError': {
44
- 'DDoSProtection': {
45
- 'RateLimitExceeded': {},
46
- },
46
+ 'DDoSProtection': {},
47
+ 'RateLimitExceeded': {},
47
48
  'ExchangeNotAvailable': {
48
49
  'OnMaintenance': {},
49
50
  },
@@ -25,13 +25,13 @@ declare class ArgumentsRequired extends ExchangeError {
25
25
  declare class BadRequest extends ExchangeError {
26
26
  constructor(message: any);
27
27
  }
28
- declare class OperationRejected extends BadRequest {
28
+ declare class OperationRejected extends ExchangeError {
29
29
  constructor(message: any);
30
30
  }
31
31
  declare class BadSymbol extends BadRequest {
32
32
  constructor(message: any);
33
33
  }
34
- declare class NoChange extends BadRequest {
34
+ declare class NoChange extends OperationRejected {
35
35
  constructor(message: any);
36
36
  }
37
37
  declare class MarginModeAlreadySet extends NoChange {
@@ -91,7 +91,7 @@ declare class NetworkError extends OperationFailed {
91
91
  declare class DDoSProtection extends NetworkError {
92
92
  constructor(message: any);
93
93
  }
94
- declare class RateLimitExceeded extends DDoSProtection {
94
+ declare class RateLimitExceeded extends NetworkError {
95
95
  constructor(message: any);
96
96
  }
97
97
  declare class ExchangeNotAvailable extends NetworkError {
@@ -90,7 +90,7 @@ class BadRequest extends ExchangeError {
90
90
  this.name = 'BadRequest';
91
91
  }
92
92
  }
93
- class OperationRejected extends BadRequest {
93
+ class OperationRejected extends ExchangeError {
94
94
  constructor(message) {
95
95
  super(message);
96
96
  this.name = 'OperationRejected';
@@ -102,7 +102,7 @@ class BadSymbol extends BadRequest {
102
102
  this.name = 'BadSymbol';
103
103
  }
104
104
  }
105
- class NoChange extends BadRequest {
105
+ class NoChange extends OperationRejected {
106
106
  constructor(message) {
107
107
  super(message);
108
108
  this.name = 'NoChange';
@@ -223,7 +223,7 @@ class DDoSProtection extends NetworkError {
223
223
  this.name = 'DDoSProtection';
224
224
  }
225
225
  }
226
- class RateLimitExceeded extends DDoSProtection {
226
+ class RateLimitExceeded extends NetworkError {
227
227
  constructor(message) {
228
228
  super(message);
229
229
  this.name = 'RateLimitExceeded';
@@ -98,6 +98,9 @@ const safeFloatN = (o, k, $default) => {
98
98
  return isNumber(n) ? n : $default;
99
99
  };
100
100
  const safeIntegerN = (o, k, $default) => {
101
+ if (o === undefined) {
102
+ return $default;
103
+ }
101
104
  const n = asInteger(getValueFromKeysInArray(o, k));
102
105
  return isNumber(n) ? n : $default;
103
106
  };
@@ -110,14 +113,23 @@ const safeTimestampN = (o, k, $default) => {
110
113
  return isNumber(n) ? parseInt(n * 1000) : $default;
111
114
  };
112
115
  const safeValueN = (o, k, $default) => {
116
+ if (o === undefined) {
117
+ return $default;
118
+ }
113
119
  const x = getValueFromKeysInArray(o, k);
114
120
  return hasProps(x) ? x : $default;
115
121
  };
116
122
  const safeStringN = (o, k, $default) => {
123
+ if (o === undefined) {
124
+ return $default;
125
+ }
117
126
  const x = getValueFromKeysInArray(o, k);
118
127
  return isStringCoercible(x) ? String(x) : $default;
119
128
  };
120
129
  const safeStringLowerN = (o, k, $default) => {
130
+ if (o === undefined) {
131
+ return $default;
132
+ }
121
133
  const x = getValueFromKeysInArray(o, k);
122
134
  return isStringCoercible(x) ? String(x).toLowerCase() : $default;
123
135
  };
package/js/src/bigone.js CHANGED
@@ -1472,7 +1472,7 @@ export default class bigone extends Exchange {
1472
1472
  const requestSide = isBuy ? 'BID' : 'ASK';
1473
1473
  let uppercaseType = type.toUpperCase();
1474
1474
  const isLimit = uppercaseType === 'LIMIT';
1475
- const exchangeSpecificParam = this.safeValue(params, 'post_only', false);
1475
+ const exchangeSpecificParam = this.safeBool(params, 'post_only', false);
1476
1476
  let postOnly = undefined;
1477
1477
  [postOnly, params] = this.handlePostOnly((uppercaseType === 'MARKET'), exchangeSpecificParam, params);
1478
1478
  const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'stop_price']);
@@ -2104,7 +2104,7 @@ export default class bigone extends Exchange {
2104
2104
  //
2105
2105
  const transfer = this.parseTransfer(response, currency);
2106
2106
  const transferOptions = this.safeValue(this.options, 'transfer', {});
2107
- const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
2107
+ const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
2108
2108
  if (fillResponseFromRequest) {
2109
2109
  transfer['fromAccount'] = fromAccount;
2110
2110
  transfer['toAccount'] = toAccount;
@@ -307,6 +307,7 @@ export default class binance extends Exchange {
307
307
  body: any;
308
308
  headers: any;
309
309
  };
310
+ getExceptionsByUrl(url: any, exactOrBroad: any): any;
310
311
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
311
312
  calculateRateLimiterCost(api: any, method: any, path: any, params: any, config?: {}): any;
312
313
  request(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any, config?: {}, context?: {}): Promise<any>;