ccxt 4.3.34 → 4.3.36

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 (59) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/alpaca.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +11 -0
  6. package/dist/cjs/src/bingx.js +2 -2
  7. package/dist/cjs/src/bit2c.js +2 -1
  8. package/dist/cjs/src/bitget.js +11 -4
  9. package/dist/cjs/src/bitmart.js +2 -9
  10. package/dist/cjs/src/coinbase.js +63 -2
  11. package/dist/cjs/src/coinex.js +26 -19
  12. package/dist/cjs/src/kraken.js +3 -1
  13. package/dist/cjs/src/paymium.js +4 -1
  14. package/dist/cjs/src/pro/binance.js +4 -4
  15. package/dist/cjs/src/pro/bingx.js +10 -4
  16. package/dist/cjs/src/pro/bitfinex2.js +5 -5
  17. package/dist/cjs/src/pro/bitget.js +31 -1
  18. package/dist/cjs/src/pro/bitmart.js +9 -5
  19. package/dist/cjs/src/pro/bybit.js +6 -6
  20. package/dist/cjs/src/pro/htx.js +5 -6
  21. package/dist/cjs/src/pro/okx.js +4 -5
  22. package/dist/cjs/src/pro/woo.js +4 -4
  23. package/dist/cjs/src/whitebit.js +24 -3
  24. package/dist/cjs/src/zaif.js +30 -2
  25. package/dist/cjs/src/zonda.js +6 -0
  26. package/js/ccxt.d.ts +1 -1
  27. package/js/ccxt.js +1 -1
  28. package/js/src/abstract/bitbay.d.ts +6 -0
  29. package/js/src/abstract/zonda.d.ts +6 -0
  30. package/js/src/alpaca.d.ts +1 -1
  31. package/js/src/alpaca.js +1 -1
  32. package/js/src/base/Exchange.d.ts +1 -0
  33. package/js/src/base/Exchange.js +11 -0
  34. package/js/src/bingx.js +2 -2
  35. package/js/src/bit2c.d.ts +1 -1
  36. package/js/src/bit2c.js +2 -1
  37. package/js/src/bitget.js +11 -4
  38. package/js/src/bitmart.js +2 -9
  39. package/js/src/coinbase.d.ts +2 -1
  40. package/js/src/coinbase.js +63 -2
  41. package/js/src/coinex.js +26 -19
  42. package/js/src/kraken.js +3 -1
  43. package/js/src/paymium.d.ts +1 -1
  44. package/js/src/paymium.js +4 -1
  45. package/js/src/pro/binance.js +4 -4
  46. package/js/src/pro/bingx.js +10 -4
  47. package/js/src/pro/bitfinex2.js +5 -5
  48. package/js/src/pro/bitget.js +31 -1
  49. package/js/src/pro/bitmart.js +10 -6
  50. package/js/src/pro/bybit.js +6 -6
  51. package/js/src/pro/htx.js +5 -6
  52. package/js/src/pro/okx.js +4 -5
  53. package/js/src/pro/woo.js +4 -4
  54. package/js/src/whitebit.d.ts +2 -2
  55. package/js/src/whitebit.js +24 -3
  56. package/js/src/zaif.d.ts +1 -1
  57. package/js/src/zaif.js +30 -2
  58. package/js/src/zonda.js +6 -0
  59. package/package.json +1 -1
@@ -1419,7 +1419,27 @@ class whitebit extends whitebit$1 {
1419
1419
  'market': market['id'],
1420
1420
  'orderId': parseInt(id),
1421
1421
  };
1422
- return await this.v4PrivatePostOrderCancel(this.extend(request, params));
1422
+ const response = await this.v4PrivatePostOrderCancel(this.extend(request, params));
1423
+ //
1424
+ // {
1425
+ // "orderId": 4180284841, // order id
1426
+ // "clientOrderId": "customId11", // custom order identifier; "clientOrderId": "" - if not specified.
1427
+ // "market": "BTC_USDT", // deal market
1428
+ // "side": "buy", // order side
1429
+ // "type": "stop market", // order type
1430
+ // "timestamp": 1595792396.165973, // current timestamp
1431
+ // "dealMoney": "0", // if order finished - amount in money currency that is finished
1432
+ // "dealStock": "0", // if order finished - amount in stock currency that is finished
1433
+ // "amount": "0.001", // amount
1434
+ // "takerFee": "0.001", // maker fee ratio. If the number less than 0.0001 - it will be rounded to zero
1435
+ // "makerFee": "0.001", // maker fee ratio. If the number less than 0.0001 - it will be rounded to zero
1436
+ // "left": "0.001", // if order not finished - rest of the amount that must be finished
1437
+ // "dealFee": "0", // fee in money that you pay if order is finished
1438
+ // "price": "40000", // price if price isset
1439
+ // "activation_price": "40000" // activation price if activation price is set
1440
+ // }
1441
+ //
1442
+ return this.parseOrder(response);
1423
1443
  }
1424
1444
  async cancelAllOrders(symbol = undefined, params = {}) {
1425
1445
  /**
@@ -1464,7 +1484,7 @@ class whitebit extends whitebit$1 {
1464
1484
  //
1465
1485
  // []
1466
1486
  //
1467
- return response;
1487
+ return this.parseOrders(response, market);
1468
1488
  }
1469
1489
  async cancelAllOrdersAfter(timeout, params = {}) {
1470
1490
  /**
@@ -1698,7 +1718,7 @@ class whitebit extends whitebit$1 {
1698
1718
  }
1699
1719
  parseOrder(order, market = undefined) {
1700
1720
  //
1701
- // createOrder, fetchOpenOrders
1721
+ // createOrder, fetchOpenOrders, cancelOrder
1702
1722
  //
1703
1723
  // {
1704
1724
  // "orderId":105687928629,
@@ -1713,6 +1733,7 @@ class whitebit extends whitebit$1 {
1713
1733
  // "takerFee":"0.001",
1714
1734
  // "makerFee":"0",
1715
1735
  // "left":"100",
1736
+ // "price": "40000", // price if price isset
1716
1737
  // "dealFee":"0",
1717
1738
  // "activation_price":"0.065" // stop price (if stop limit or stop market)
1718
1739
  // }
@@ -476,7 +476,23 @@ class zaif extends zaif$1 {
476
476
  const request = {
477
477
  'order_id': id,
478
478
  };
479
- return await this.privatePostCancelOrder(this.extend(request, params));
479
+ const response = await this.privatePostCancelOrder(this.extend(request, params));
480
+ //
481
+ // {
482
+ // "success": 1,
483
+ // "return": {
484
+ // "order_id": 184,
485
+ // "funds": {
486
+ // "jpy": 15320,
487
+ // "btc": 1.392,
488
+ // "mona": 2600,
489
+ // "kaori": 0.1
490
+ // }
491
+ // }
492
+ // }
493
+ //
494
+ const data = this.safeDict(response, 'return');
495
+ return this.parseOrder(data);
480
496
  }
481
497
  parseOrder(order, market = undefined) {
482
498
  //
@@ -489,6 +505,18 @@ class zaif extends zaif$1 {
489
505
  // "comment" : "demo"
490
506
  // }
491
507
  //
508
+ // cancelOrder
509
+ //
510
+ // {
511
+ // "order_id": 184,
512
+ // "funds": {
513
+ // "jpy": 15320,
514
+ // "btc": 1.392,
515
+ // "mona": 2600,
516
+ // "kaori": 0.1
517
+ // }
518
+ // }
519
+ //
492
520
  let side = this.safeString(order, 'action');
493
521
  side = (side === 'bid') ? 'buy' : 'sell';
494
522
  const timestamp = this.safeTimestamp(order, 'timestamp');
@@ -496,7 +524,7 @@ class zaif extends zaif$1 {
496
524
  const symbol = this.safeSymbol(marketId, market, '_');
497
525
  const price = this.safeString(order, 'price');
498
526
  const amount = this.safeString(order, 'amount');
499
- const id = this.safeString(order, 'id');
527
+ const id = this.safeString2(order, 'id', 'order_id');
500
528
  return this.safeOrder({
501
529
  'id': id,
502
530
  'clientOrderId': undefined,
@@ -169,6 +169,10 @@ class zonda extends zonda$1 {
169
169
  'balances/BITBAY/balance',
170
170
  'fiat_cantor/rate/{baseId}/{quoteId}',
171
171
  'fiat_cantor/history',
172
+ 'client_payments/v2/customer/crypto/{currency}/channels/deposit',
173
+ 'client_payments/v2/customer/crypto/{currency}/channels/withdrawal',
174
+ 'client_payments/v2/customer/crypto/deposit/fee',
175
+ 'client_payments/v2/customer/crypto/withdrawal/fee',
172
176
  ],
173
177
  'post': [
174
178
  'trading/offer/{symbol}',
@@ -179,6 +183,8 @@ class zonda extends zonda$1 {
179
183
  'fiat_cantor/exchange',
180
184
  'api_payments/withdrawals/crypto',
181
185
  'api_payments/withdrawals/fiat',
186
+ 'client_payments/v2/customer/crypto/deposit',
187
+ 'client_payments/v2/customer/crypto/withdrawal',
182
188
  ],
183
189
  'delete': [
184
190
  'trading/offer/{symbol}/{id}/{side}/{price}',
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, MarketClosed, 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.3.33";
7
+ declare const version = "4.3.35";
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, MarketClosed, 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.3.34';
41
+ const version = '4.3.36';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -33,6 +33,10 @@ interface zonda {
33
33
  v1_01PrivateGetBalancesBITBAYBalance(params?: {}): Promise<implicitReturnType>;
34
34
  v1_01PrivateGetFiatCantorRateBaseIdQuoteId(params?: {}): Promise<implicitReturnType>;
35
35
  v1_01PrivateGetFiatCantorHistory(params?: {}): Promise<implicitReturnType>;
36
+ v1_01PrivateGetClientPaymentsV2CustomerCryptoCurrencyChannelsDeposit(params?: {}): Promise<implicitReturnType>;
37
+ v1_01PrivateGetClientPaymentsV2CustomerCryptoCurrencyChannelsWithdrawal(params?: {}): Promise<implicitReturnType>;
38
+ v1_01PrivateGetClientPaymentsV2CustomerCryptoDepositFee(params?: {}): Promise<implicitReturnType>;
39
+ v1_01PrivateGetClientPaymentsV2CustomerCryptoWithdrawalFee(params?: {}): Promise<implicitReturnType>;
36
40
  v1_01PrivatePostTradingOfferSymbol(params?: {}): Promise<implicitReturnType>;
37
41
  v1_01PrivatePostTradingStopOfferSymbol(params?: {}): Promise<implicitReturnType>;
38
42
  v1_01PrivatePostTradingConfigSymbol(params?: {}): Promise<implicitReturnType>;
@@ -41,6 +45,8 @@ interface zonda {
41
45
  v1_01PrivatePostFiatCantorExchange(params?: {}): Promise<implicitReturnType>;
42
46
  v1_01PrivatePostApiPaymentsWithdrawalsCrypto(params?: {}): Promise<implicitReturnType>;
43
47
  v1_01PrivatePostApiPaymentsWithdrawalsFiat(params?: {}): Promise<implicitReturnType>;
48
+ v1_01PrivatePostClientPaymentsV2CustomerCryptoDeposit(params?: {}): Promise<implicitReturnType>;
49
+ v1_01PrivatePostClientPaymentsV2CustomerCryptoWithdrawal(params?: {}): Promise<implicitReturnType>;
44
50
  v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(params?: {}): Promise<implicitReturnType>;
45
51
  v1_01PrivateDeleteTradingStopOfferSymbolIdSidePrice(params?: {}): Promise<implicitReturnType>;
46
52
  v1_01PrivatePutBalancesBITBAYBalanceId(params?: {}): Promise<implicitReturnType>;
@@ -33,6 +33,10 @@ interface Exchange {
33
33
  v1_01PrivateGetBalancesBITBAYBalance(params?: {}): Promise<implicitReturnType>;
34
34
  v1_01PrivateGetFiatCantorRateBaseIdQuoteId(params?: {}): Promise<implicitReturnType>;
35
35
  v1_01PrivateGetFiatCantorHistory(params?: {}): Promise<implicitReturnType>;
36
+ v1_01PrivateGetClientPaymentsV2CustomerCryptoCurrencyChannelsDeposit(params?: {}): Promise<implicitReturnType>;
37
+ v1_01PrivateGetClientPaymentsV2CustomerCryptoCurrencyChannelsWithdrawal(params?: {}): Promise<implicitReturnType>;
38
+ v1_01PrivateGetClientPaymentsV2CustomerCryptoDepositFee(params?: {}): Promise<implicitReturnType>;
39
+ v1_01PrivateGetClientPaymentsV2CustomerCryptoWithdrawalFee(params?: {}): Promise<implicitReturnType>;
36
40
  v1_01PrivatePostTradingOfferSymbol(params?: {}): Promise<implicitReturnType>;
37
41
  v1_01PrivatePostTradingStopOfferSymbol(params?: {}): Promise<implicitReturnType>;
38
42
  v1_01PrivatePostTradingConfigSymbol(params?: {}): Promise<implicitReturnType>;
@@ -41,6 +45,8 @@ interface Exchange {
41
45
  v1_01PrivatePostFiatCantorExchange(params?: {}): Promise<implicitReturnType>;
42
46
  v1_01PrivatePostApiPaymentsWithdrawalsCrypto(params?: {}): Promise<implicitReturnType>;
43
47
  v1_01PrivatePostApiPaymentsWithdrawalsFiat(params?: {}): Promise<implicitReturnType>;
48
+ v1_01PrivatePostClientPaymentsV2CustomerCryptoDeposit(params?: {}): Promise<implicitReturnType>;
49
+ v1_01PrivatePostClientPaymentsV2CustomerCryptoWithdrawal(params?: {}): Promise<implicitReturnType>;
44
50
  v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(params?: {}): Promise<implicitReturnType>;
45
51
  v1_01PrivateDeleteTradingStopOfferSymbolIdSidePrice(params?: {}): Promise<implicitReturnType>;
46
52
  v1_01PrivatePutBalancesBITBAYBalanceId(params?: {}): Promise<implicitReturnType>;
@@ -14,7 +14,7 @@ export default class alpaca extends Exchange {
14
14
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
15
15
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
16
16
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
17
- cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
17
+ cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
18
18
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
19
19
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
20
20
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/alpaca.js CHANGED
@@ -794,7 +794,7 @@ export default class alpaca extends Exchange {
794
794
  // "message": "order is not found."
795
795
  // }
796
796
  //
797
- return this.safeValue(response, 'message', {});
797
+ return this.parseOrder(response);
798
798
  }
799
799
  async cancelAllOrders(symbol = undefined, params = {}) {
800
800
  /**
@@ -807,6 +807,7 @@ export default class Exchange {
807
807
  };
808
808
  safeLiquidation(liquidation: object, market?: Market): Liquidation;
809
809
  safeTrade(trade: object, market?: Market): Trade;
810
+ findNearestCeiling(arr: number[], providedValue: number): number;
810
811
  invertFlatStringDictionary(dict: any): {};
811
812
  reduceFeesByCurrency(fees: any): any[];
812
813
  safeTicker(ticker: object, market?: Market): Ticker;
@@ -2949,6 +2949,17 @@ export default class Exchange {
2949
2949
  trade['cost'] = this.parseNumber(cost);
2950
2950
  return trade;
2951
2951
  }
2952
+ findNearestCeiling(arr, providedValue) {
2953
+ // i.e. findNearestCeiling ([ 10, 30, 50], 23) returns 30
2954
+ const length = arr.length;
2955
+ for (let i = 0; i < length; i++) {
2956
+ const current = arr[i];
2957
+ if (providedValue <= current) {
2958
+ return current;
2959
+ }
2960
+ }
2961
+ return arr[length - 1];
2962
+ }
2952
2963
  invertFlatStringDictionary(dict) {
2953
2964
  const reversed = {};
2954
2965
  const keys = Object.keys(dict);
package/js/src/bingx.js CHANGED
@@ -1039,7 +1039,7 @@ export default class bingx extends Exchange {
1039
1039
  time = undefined;
1040
1040
  }
1041
1041
  const cost = this.safeString(trade, 'quoteQty');
1042
- const type = (cost === undefined) ? 'spot' : 'swap';
1042
+ // const type = (cost === undefined) ? 'spot' : 'swap'; this is not reliable
1043
1043
  const currencyId = this.safeStringN(trade, ['currency', 'N', 'commissionAsset']);
1044
1044
  const currencyCode = this.safeCurrencyCode(currencyId);
1045
1045
  const m = this.safeBool(trade, 'm');
@@ -1076,7 +1076,7 @@ export default class bingx extends Exchange {
1076
1076
  'info': trade,
1077
1077
  'timestamp': time,
1078
1078
  'datetime': this.iso8601(time),
1079
- 'symbol': this.safeSymbol(marketId, market, '-', type),
1079
+ 'symbol': this.safeSymbol(marketId, market, '-'),
1080
1080
  'order': this.safeString2(trade, 'orderId', 'i'),
1081
1081
  'type': this.safeStringLower(trade, 'o'),
1082
1082
  'side': this.parseOrderSide(side),
package/js/src/bit2c.d.ts CHANGED
@@ -14,7 +14,7 @@ export default class bit2c extends Exchange {
14
14
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
15
15
  fetchTradingFees(params?: {}): Promise<TradingFees>;
16
16
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
17
- cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
17
+ cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
18
18
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
19
19
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
20
20
  parseOrder(order: Dict, market?: Market): Order;
package/js/src/bit2c.js CHANGED
@@ -467,7 +467,8 @@ export default class bit2c extends Exchange {
467
467
  const request = {
468
468
  'id': id,
469
469
  };
470
- return await this.privatePostOrderCancelOrder(this.extend(request, params));
470
+ const response = await this.privatePostOrderCancelOrder(this.extend(request, params));
471
+ return this.parseOrder(response);
471
472
  }
472
473
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
473
474
  /**
package/js/src/bitget.js CHANGED
@@ -1231,6 +1231,7 @@ export default class bitget extends Exchange {
1231
1231
  '40712': InsufficientFunds,
1232
1232
  '40713': ExchangeError,
1233
1233
  '40714': ExchangeError,
1234
+ '40762': InsufficientFunds,
1234
1235
  '40768': OrderNotFound,
1235
1236
  '41114': OnMaintenance,
1236
1237
  '43011': InvalidOrder,
@@ -4346,11 +4347,17 @@ export default class bitget extends Exchange {
4346
4347
  }
4347
4348
  const marginModeRequest = (marginMode === 'cross') ? 'crossed' : 'isolated';
4348
4349
  request['marginMode'] = marginModeRequest;
4349
- const oneWayMode = this.safeBool(params, 'oneWayMode', false);
4350
- params = this.omit(params, 'oneWayMode');
4350
+ let hedged = undefined;
4351
+ [hedged, params] = this.handleParamBool(params, 'hedged', false);
4352
+ // backward compatibility for `oneWayMode`
4353
+ let oneWayMode = undefined;
4354
+ [oneWayMode, params] = this.handleParamBool(params, 'oneWayMode');
4355
+ if (oneWayMode !== undefined) {
4356
+ hedged = !oneWayMode;
4357
+ }
4351
4358
  let requestSide = side;
4352
4359
  if (reduceOnly) {
4353
- if (oneWayMode) {
4360
+ if (!hedged) {
4354
4361
  request['reduceOnly'] = 'YES';
4355
4362
  }
4356
4363
  else {
@@ -4360,7 +4367,7 @@ export default class bitget extends Exchange {
4360
4367
  }
4361
4368
  }
4362
4369
  else {
4363
- if (!oneWayMode) {
4370
+ if (hedged) {
4364
4371
  request['tradeSide'] = 'Open';
4365
4372
  }
4366
4373
  }
package/js/src/bitmart.js CHANGED
@@ -1185,16 +1185,9 @@ export default class bitmart extends Exchange {
1185
1185
  market = this.safeMarket(marketId, market);
1186
1186
  const symbol = market['symbol'];
1187
1187
  const last = this.safeString2(ticker, 'close_24h', 'last_price');
1188
- let percentage = this.safeString(ticker, 'price_change_percent_24h');
1188
+ let percentage = Precise.stringAbs(this.safeString(ticker, 'price_change_percent_24h'));
1189
1189
  if (percentage === undefined) {
1190
- const percentageRaw = this.safeString(ticker, 'fluctuation');
1191
- if ((percentageRaw !== undefined) && (percentageRaw !== '0')) { // a few tickers show strictly '0' in fluctuation field
1192
- const direction = percentageRaw[0];
1193
- percentage = direction + Precise.stringMul(percentageRaw.replace(direction, ''), '100');
1194
- }
1195
- else if (percentageRaw === '0') {
1196
- percentage = '0';
1197
- }
1190
+ percentage = Precise.stringAbs(Precise.stringMul(this.safeString(ticker, 'fluctuation'), '100'));
1198
1191
  }
1199
1192
  let baseVolume = this.safeString(ticker, 'base_volume_24h');
1200
1193
  let quoteVolume = this.safeString(ticker, 'quote_volume_24h');
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/coinbase.js';
2
- import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface, Conversion, Dict, int } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface, Conversion, Dict, int, TradingFees } from './base/types.js';
3
3
  /**
4
4
  * @class coinbase
5
5
  * @augments Exchange
@@ -110,6 +110,7 @@ export default class coinbase extends Exchange {
110
110
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
111
111
  fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
112
112
  parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
113
+ fetchTradingFees(params?: {}): Promise<TradingFees>;
113
114
  createAuthToken(seconds: Int, method?: Str, url?: Str): string;
114
115
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
115
116
  url: string;
@@ -114,8 +114,8 @@ export default class coinbase extends Exchange {
114
114
  'fetchTickers': true,
115
115
  'fetchTime': true,
116
116
  'fetchTrades': true,
117
- 'fetchTradingFee': false,
118
- 'fetchTradingFees': false,
117
+ 'fetchTradingFee': 'emulated',
118
+ 'fetchTradingFees': true,
119
119
  'fetchWithdrawals': true,
120
120
  'reduceMargin': false,
121
121
  'setLeverage': false,
@@ -4540,6 +4540,67 @@ export default class coinbase extends Exchange {
4540
4540
  'takeProfitPrice': undefined,
4541
4541
  });
4542
4542
  }
4543
+ async fetchTradingFees(params = {}) {
4544
+ /**
4545
+ * @method
4546
+ * @name coinbase#fetchTradingFees
4547
+ * @see https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_gettransactionsummary/
4548
+ * @description fetch the trading fees for multiple markets
4549
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4550
+ * @param {string} [params.type] 'spot' or 'swap'
4551
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
4552
+ */
4553
+ await this.loadMarkets();
4554
+ let type = undefined;
4555
+ [type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
4556
+ const isSpot = (type === 'spot');
4557
+ const productType = isSpot ? 'SPOT' : 'FUTURE';
4558
+ const request = {
4559
+ 'product_type': productType,
4560
+ };
4561
+ const response = await this.v3PrivateGetBrokerageTransactionSummary(this.extend(request, params));
4562
+ //
4563
+ // {
4564
+ // total_volume: '0',
4565
+ // total_fees: '0',
4566
+ // fee_tier: {
4567
+ // pricing_tier: 'Advanced 1',
4568
+ // usd_from: '0',
4569
+ // usd_to: '1000',
4570
+ // taker_fee_rate: '0.008',
4571
+ // maker_fee_rate: '0.006',
4572
+ // aop_from: '',
4573
+ // aop_to: ''
4574
+ // },
4575
+ // margin_rate: null,
4576
+ // goods_and_services_tax: null,
4577
+ // advanced_trade_only_volume: '0',
4578
+ // advanced_trade_only_fees: '0',
4579
+ // coinbase_pro_volume: '0',
4580
+ // coinbase_pro_fees: '0',
4581
+ // total_balance: '',
4582
+ // has_promo_fee: false
4583
+ // }
4584
+ //
4585
+ const data = this.safeDict(response, 'fee_tier', {});
4586
+ const taker_fee = this.safeNumber(data, 'taker_fee_rate');
4587
+ const marker_fee = this.safeNumber(data, 'maker_fee_rate');
4588
+ const result = {};
4589
+ for (let i = 0; i < this.symbols.length; i++) {
4590
+ const symbol = this.symbols[i];
4591
+ const market = this.market(symbol);
4592
+ if ((isSpot && market['spot']) || (!isSpot && !market['spot'])) {
4593
+ result[symbol] = {
4594
+ 'info': response,
4595
+ 'symbol': symbol,
4596
+ 'maker': taker_fee,
4597
+ 'taker': marker_fee,
4598
+ 'percentage': true,
4599
+ };
4600
+ }
4601
+ }
4602
+ return result;
4603
+ }
4543
4604
  createAuthToken(seconds, method = undefined, url = undefined) {
4544
4605
  // it may not work for v2
4545
4606
  let uri = undefined;
package/js/src/coinex.js CHANGED
@@ -4646,7 +4646,7 @@ export default class coinex extends Exchange {
4646
4646
  * @method
4647
4647
  * @name coinex#withdraw
4648
4648
  * @description make a withdrawal
4649
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account015_submit_withdraw
4649
+ * @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
4650
4650
  * @param {string} code unified currency code
4651
4651
  * @param {float} amount the amount to withdraw
4652
4652
  * @param {string} address the address to withdraw to
@@ -4659,37 +4659,44 @@ export default class coinex extends Exchange {
4659
4659
  this.checkAddress(address);
4660
4660
  await this.loadMarkets();
4661
4661
  const currency = this.currency(code);
4662
- const networkCode = this.safeStringUpper(params, 'network');
4662
+ const networkCode = this.safeStringUpper2(params, 'network', 'chain');
4663
4663
  params = this.omit(params, 'network');
4664
4664
  if (tag) {
4665
4665
  address = address + ':' + tag;
4666
4666
  }
4667
4667
  const request = {
4668
- 'coin_type': currency['id'],
4669
- 'coin_address': address,
4670
- 'actual_amount': parseFloat(this.numberToString(amount)),
4671
- 'transfer_method': 'onchain', // onchain, local
4668
+ 'ccy': currency['id'],
4669
+ 'to_address': address,
4670
+ 'amount': this.numberToString(amount), // the actual amount without fees, https://www.coinex.com/fees
4672
4671
  };
4673
4672
  if (networkCode !== undefined) {
4674
- request['smart_contract_name'] = this.networkCodeToId(networkCode);
4673
+ request['chain'] = this.networkCodeToId(networkCode); // required for on-chain, not required for inter-user transfer
4675
4674
  }
4676
- const response = await this.v1PrivatePostBalanceCoinWithdraw(this.extend(request, params));
4675
+ const response = await this.v2PrivatePostAssetsWithdraw(this.extend(request, params));
4677
4676
  //
4678
4677
  // {
4679
4678
  // "code": 0,
4680
4679
  // "data": {
4681
- // "actual_amount": "1.00000000",
4682
- // "amount": "1.00000000",
4683
- // "coin_address": "1KAv3pazbTk2JnQ5xTo6fpKK7p1it2RzD4",
4684
- // "coin_type": "BCH",
4685
- // "coin_withdraw_id": 206,
4680
+ // "withdraw_id": 31193755,
4681
+ // "created_at": 1716874165038,
4682
+ // "withdraw_method": "ON_CHAIN",
4683
+ // "ccy": "USDT",
4684
+ // "amount": "17.3",
4685
+ // "actual_amount": "15",
4686
+ // "chain": "TRC20",
4687
+ // "tx_fee": "2.3",
4688
+ // "fee_asset": "USDT",
4689
+ // "fee_amount": "2.3",
4690
+ // "to_address": "TY5vq3MT6b5cQVAHWHtpGyPg1ERcQgi3UN",
4691
+ // "memo": "",
4692
+ // "tx_id": "",
4686
4693
  // "confirmations": 0,
4687
- // "create_time": 1524228297,
4688
- // "status": "audit",
4689
- // "tx_fee": "0",
4690
- // "tx_id": ""
4694
+ // "explorer_address_url": "https://tronscan.org/#/address/TY5vq3MT6b5cQVAHWHtpGyPg1ERcQgi3UN",
4695
+ // "explorer_tx_url": "https://tronscan.org/#/transaction/",
4696
+ // "remark": "",
4697
+ // "status": "audit_required"
4691
4698
  // },
4692
- // "message": "Ok"
4699
+ // "message": "OK"
4693
4700
  // }
4694
4701
  //
4695
4702
  const transaction = this.safeDict(response, 'data', {});
@@ -4800,7 +4807,7 @@ export default class coinex extends Exchange {
4800
4807
  // "remark": ""
4801
4808
  // }
4802
4809
  //
4803
- // fetchWithdrawals
4810
+ // fetchWithdrawals and withdraw
4804
4811
  //
4805
4812
  // {
4806
4813
  // "withdraw_id": 259364,
package/js/src/kraken.js CHANGED
@@ -989,7 +989,9 @@ export default class kraken extends Exchange {
989
989
  request['interval'] = timeframe;
990
990
  }
991
991
  if (since !== undefined) {
992
- request['since'] = this.numberToString(this.parseToInt(since / 1000)); // expected to be in seconds
992
+ const scaledSince = this.parseToInt(since / 1000);
993
+ const timeFrameInSeconds = parsedTimeframe * 60;
994
+ request['since'] = this.numberToString(scaledSince - timeFrameInSeconds); // expected to be in seconds
993
995
  }
994
996
  const response = await this.publicGetOHLC(this.extend(request, params));
995
997
  //
@@ -36,7 +36,7 @@ export default class paymium extends Exchange {
36
36
  network: any;
37
37
  };
38
38
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<import("./base/types.js").Order>;
39
- cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
39
+ cancelOrder(id: string, symbol?: Str, params?: {}): Promise<import("./base/types.js").Order>;
40
40
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
41
41
  parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
42
42
  parseTransferStatus(status: Str): Str;
package/js/src/paymium.js CHANGED
@@ -429,7 +429,10 @@ export default class paymium extends Exchange {
429
429
  const request = {
430
430
  'uuid': id,
431
431
  };
432
- return await this.privateDeleteUserOrdersUuidCancel(this.extend(request, params));
432
+ const response = await this.privateDeleteUserOrdersUuidCancel(this.extend(request, params));
433
+ return this.safeOrder({
434
+ 'info': response,
435
+ });
433
436
  }
434
437
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
435
438
  /**
@@ -726,11 +726,11 @@ export default class binance extends binanceRest {
726
726
  // todo: this is a synch blocking call - make it async
727
727
  // default 100, max 1000, valid limits 5, 10, 20, 50, 100, 500, 1000
728
728
  const snapshot = await this.fetchRestOrderBookSafe(symbol, limit, params);
729
- const orderbook = this.safeValue(this.orderbooks, symbol);
730
- if (orderbook === undefined) {
729
+ if (this.safeValue(this.orderbooks, symbol) === undefined) {
731
730
  // if the orderbook is dropped before the snapshot is received
732
731
  return;
733
732
  }
733
+ const orderbook = this.orderbooks[symbol];
734
734
  orderbook.reset(snapshot);
735
735
  // unroll the accumulated deltas
736
736
  const messages = orderbook.cache;
@@ -816,8 +816,7 @@ export default class binance extends binanceRest {
816
816
  const symbol = market['symbol'];
817
817
  const name = 'depth';
818
818
  const messageHash = market['lowercaseId'] + '@' + name;
819
- const orderbook = this.safeValue(this.orderbooks, symbol);
820
- if (orderbook === undefined) {
819
+ if (!(symbol in this.orderbooks)) {
821
820
  //
822
821
  // https://github.com/ccxt/ccxt/issues/6672
823
822
  //
@@ -828,6 +827,7 @@ export default class binance extends binanceRest {
828
827
  //
829
828
  return;
830
829
  }
830
+ const orderbook = this.orderbooks[symbol];
831
831
  const nonce = this.safeInteger(orderbook, 'nonce');
832
832
  if (nonce === undefined) {
833
833
  // 2. Buffer the events you receive from the stream.
@@ -991,14 +991,17 @@ export default class bingx extends bingxRest {
991
991
  // }
992
992
  //
993
993
  const isSpot = ('dataType' in message);
994
- const result = this.safeValue2(message, 'data', 'o', {});
994
+ const result = this.safeDict2(message, 'data', 'o', {});
995
995
  let cachedTrades = this.myTrades;
996
996
  if (cachedTrades === undefined) {
997
997
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
998
998
  cachedTrades = new ArrayCacheBySymbolById(limit);
999
999
  this.myTrades = cachedTrades;
1000
1000
  }
1001
- const parsed = this.parseTrade(result);
1001
+ const type = isSpot ? 'spot' : 'swap';
1002
+ const marketId = this.safeString(result, 's');
1003
+ const market = this.safeMarket(marketId, undefined, '-', type);
1004
+ const parsed = this.parseTrade(result, market);
1002
1005
  const symbol = parsed['symbol'];
1003
1006
  const spotHash = 'spot:mytrades';
1004
1007
  const swapHash = 'swap:mytrades';
@@ -1044,10 +1047,13 @@ export default class bingx extends bingxRest {
1044
1047
  // }
1045
1048
  // }
1046
1049
  //
1047
- const a = this.safeValue(message, 'a', {});
1048
- const data = this.safeValue(a, 'B', []);
1050
+ const a = this.safeDict(message, 'a', {});
1051
+ const data = this.safeList(a, 'B', []);
1049
1052
  const timestamp = this.safeInteger2(message, 'T', 'E');
1050
1053
  const type = ('P' in a) ? 'swap' : 'spot';
1054
+ if (!(type in this.balance)) {
1055
+ this.balance[type] = {};
1056
+ }
1051
1057
  this.balance[type]['info'] = data;
1052
1058
  this.balance[type]['timestamp'] = timestamp;
1053
1059
  this.balance[type]['datetime'] = this.iso8601(timestamp);