ccxt 4.3.23 → 4.3.27

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 (49) hide show
  1. package/README.md +5 -5
  2. package/dist/cjs/ccxt.js +9 -6
  3. package/dist/cjs/src/base/Exchange.js +26 -27
  4. package/dist/cjs/src/base/functions/number.js +10 -5
  5. package/dist/cjs/src/bitrue.js +6 -1
  6. package/dist/cjs/src/coinbaseadvanced.js +17 -0
  7. package/dist/cjs/src/{coinbasepro.js → coinbaseexchange.js} +40 -40
  8. package/dist/cjs/src/coinex.js +81 -147
  9. package/dist/cjs/src/kraken.js +60 -7
  10. package/dist/cjs/src/kucoin.js +1 -0
  11. package/dist/cjs/src/phemex.js +18 -2
  12. package/dist/cjs/src/pro/binance.js +1 -1
  13. package/dist/cjs/src/pro/bitget.js +12 -3
  14. package/dist/cjs/src/pro/{coinbasepro.js → coinbaseexchange.js} +13 -13
  15. package/dist/cjs/src/pro/cryptocom.js +9 -7
  16. package/dist/cjs/src/pro/kraken.js +6 -4
  17. package/dist/cjs/src/pro/okx.js +1 -1
  18. package/js/ccxt.d.ts +11 -8
  19. package/js/ccxt.js +8 -6
  20. package/js/src/abstract/coinbaseadvanced.d.ts +97 -0
  21. package/js/src/abstract/coinbaseadvanced.js +11 -0
  22. package/js/src/base/Exchange.d.ts +4 -2
  23. package/js/src/base/Exchange.js +26 -27
  24. package/js/src/base/functions/number.js +10 -5
  25. package/js/src/bitrue.js +6 -1
  26. package/js/src/coinbaseadvanced.d.ts +4 -0
  27. package/js/src/coinbaseadvanced.js +18 -0
  28. package/js/src/{coinbasepro.d.ts → coinbaseexchange.d.ts} +3 -3
  29. package/js/src/{coinbasepro.js → coinbaseexchange.js} +39 -39
  30. package/js/src/coinex.d.ts +1 -1
  31. package/js/src/coinex.js +81 -147
  32. package/js/src/kraken.d.ts +3 -1
  33. package/js/src/kraken.js +60 -7
  34. package/js/src/kucoin.js +1 -0
  35. package/js/src/phemex.js +18 -2
  36. package/js/src/pro/binance.d.ts +1 -1
  37. package/js/src/pro/binance.js +1 -1
  38. package/js/src/pro/bitget.js +12 -3
  39. package/js/src/pro/{coinbasepro.d.ts → coinbaseexchange.d.ts} +2 -2
  40. package/js/src/pro/{coinbasepro.js → coinbaseexchange.js} +12 -12
  41. package/js/src/pro/cryptocom.js +9 -7
  42. package/js/src/pro/kraken.d.ts +1 -1
  43. package/js/src/pro/kraken.js +6 -4
  44. package/js/src/pro/okx.d.ts +1 -1
  45. package/js/src/pro/okx.js +1 -1
  46. package/package.json +1 -1
  47. /package/dist/cjs/src/abstract/{coinbasepro.js → coinbaseexchange.js} +0 -0
  48. /package/js/src/abstract/{coinbasepro.d.ts → coinbaseexchange.d.ts} +0 -0
  49. /package/js/src/abstract/{coinbasepro.js → coinbaseexchange.js} +0 -0
@@ -1,10 +1,10 @@
1
- import Exchange from './abstract/coinbasepro.js';
1
+ import Exchange from './abstract/coinbaseexchange.js';
2
2
  import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Strings, Market, Currency, Num, Account, Currencies, TradingFees, Dict } from './base/types.js';
3
3
  /**
4
- * @class coinbasepro
4
+ * @class coinbaseexchange
5
5
  * @augments Exchange
6
6
  */
7
- export default class coinbasepro extends Exchange {
7
+ export default class coinbaseexchange extends Exchange {
8
8
  describe(): any;
9
9
  fetchCurrencies(params?: {}): Promise<Currencies>;
10
10
  fetchMarkets(params?: {}): Promise<Market[]>;
@@ -5,21 +5,21 @@
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
7
  // ----------------------------------------------------------------------------
8
- import Exchange from './abstract/coinbasepro.js';
8
+ import Exchange from './abstract/coinbaseexchange.js';
9
9
  import { InsufficientFunds, ArgumentsRequired, ExchangeError, InvalidOrder, InvalidAddress, AuthenticationError, OrderNotFound, OnMaintenance, PermissionDenied, RateLimitExceeded } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { TICK_SIZE } from './base/functions/number.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
13
  // ----------------------------------------------------------------------------
14
14
  /**
15
- * @class coinbasepro
15
+ * @class coinbaseexchange
16
16
  * @augments Exchange
17
17
  */
18
- export default class coinbasepro extends Exchange {
18
+ export default class coinbaseexchange extends Exchange {
19
19
  describe() {
20
20
  return this.deepExtend(super.describe(), {
21
- 'id': 'coinbasepro',
22
- 'name': 'Coinbase Pro(Deprecated)',
21
+ 'id': 'coinbaseexchange',
22
+ 'name': 'Coinbase Exchange',
23
23
  'countries': ['US'],
24
24
  'rateLimit': 100,
25
25
  'userAgent': this.userAgents['chrome'],
@@ -81,19 +81,19 @@ export default class coinbasepro extends Exchange {
81
81
  '6h': 21600,
82
82
  '1d': 86400,
83
83
  },
84
- 'hostname': 'pro.coinbase.com',
84
+ 'hostname': 'exchange.coinbase.com',
85
85
  'urls': {
86
86
  'test': {
87
- 'public': 'https://api-public.sandbox.pro.coinbase.com',
88
- 'private': 'https://api-public.sandbox.pro.coinbase.com',
87
+ 'public': 'https://api-public.sandbox.exchange.coinbase.com',
88
+ 'private': 'https://api-public.sandbox.exchange.coinbase.com',
89
89
  },
90
- 'logo': 'https://user-images.githubusercontent.com/1294454/41764625-63b7ffde-760a-11e8-996d-a6328fa9347a.jpg',
90
+ 'logo': 'https://github.com/ccxt/ccxt/assets/43336371/34a65553-88aa-4a38-a714-064bd228b97e',
91
91
  'api': {
92
92
  'public': 'https://api.{hostname}',
93
93
  'private': 'https://api.{hostname}',
94
94
  },
95
- 'www': 'https://pro.coinbase.com/',
96
- 'doc': 'https://docs.pro.coinbase.com',
95
+ 'www': 'https://coinbase.com/',
96
+ 'doc': 'https://docs.cloud.coinbase.com/exchange/docs/',
97
97
  'fees': [
98
98
  'https://docs.pro.coinbase.com/#fees',
99
99
  'https://support.pro.coinbase.com/customer/en/portal/articles/2945310-fees',
@@ -240,7 +240,7 @@ export default class coinbasepro extends Exchange {
240
240
  async fetchCurrencies(params = {}) {
241
241
  /**
242
242
  * @method
243
- * @name coinbasepro#fetchCurrencies
243
+ * @name coinbaseexchange#fetchCurrencies
244
244
  * @description fetches all available currencies on an exchange
245
245
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getcurrencies
246
246
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -311,8 +311,8 @@ export default class coinbasepro extends Exchange {
311
311
  async fetchMarkets(params = {}) {
312
312
  /**
313
313
  * @method
314
- * @name coinbasepro#fetchMarkets
315
- * @description retrieves data on all markets for coinbasepro
314
+ * @name coinbaseexchange#fetchMarkets
315
+ * @description retrieves data on all markets for coinbaseexchange
316
316
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproducts
317
317
  * @param {object} [params] extra parameters specific to the exchange API endpoint
318
318
  * @returns {object[]} an array of objects representing market data
@@ -432,7 +432,7 @@ export default class coinbasepro extends Exchange {
432
432
  async fetchAccounts(params = {}) {
433
433
  /**
434
434
  * @method
435
- * @name coinbasepro#fetchAccounts
435
+ * @name coinbaseexchange#fetchAccounts
436
436
  * @description fetch all the accounts associated with a profile
437
437
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounts
438
438
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -498,7 +498,7 @@ export default class coinbasepro extends Exchange {
498
498
  async fetchBalance(params = {}) {
499
499
  /**
500
500
  * @method
501
- * @name coinbasepro#fetchBalance
501
+ * @name coinbaseexchange#fetchBalance
502
502
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
503
503
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounts
504
504
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -511,7 +511,7 @@ export default class coinbasepro extends Exchange {
511
511
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
512
512
  /**
513
513
  * @method
514
- * @name coinbasepro#fetchOrderBook
514
+ * @name coinbaseexchange#fetchOrderBook
515
515
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductbook
516
516
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
517
517
  * @param {string} symbol unified symbol of the market to fetch the order book for
@@ -631,7 +631,7 @@ export default class coinbasepro extends Exchange {
631
631
  async fetchTickers(symbols = undefined, params = {}) {
632
632
  /**
633
633
  * @method
634
- * @name coinbasepro#fetchTickers
634
+ * @name coinbaseexchange#fetchTickers
635
635
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
636
636
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproduct
637
637
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
@@ -678,7 +678,7 @@ export default class coinbasepro extends Exchange {
678
678
  async fetchTicker(symbol, params = {}) {
679
679
  /**
680
680
  * @method
681
- * @name coinbasepro#fetchTicker
681
+ * @name coinbaseexchange#fetchTicker
682
682
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductticker
683
683
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
684
684
  * @param {string} symbol unified symbol of the market to fetch the ticker for
@@ -792,7 +792,7 @@ export default class coinbasepro extends Exchange {
792
792
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
793
793
  /**
794
794
  * @method
795
- * @name coinbasepro#fetchMyTrades
795
+ * @name coinbaseexchange#fetchMyTrades
796
796
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfills
797
797
  * @description fetch all trades made by the user
798
798
  * @param {string} symbol unified market symbol
@@ -833,7 +833,7 @@ export default class coinbasepro extends Exchange {
833
833
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
834
834
  /**
835
835
  * @method
836
- * @name coinbasepro#fetchTrades
836
+ * @name coinbaseexchange#fetchTrades
837
837
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproducttrades
838
838
  * @description get the list of most recent trades for a particular symbol
839
839
  * @param {string} symbol unified symbol of the market to fetch trades for
@@ -867,7 +867,7 @@ export default class coinbasepro extends Exchange {
867
867
  async fetchTradingFees(params = {}) {
868
868
  /**
869
869
  * @method
870
- * @name coinbasepro#fetchTradingFees
870
+ * @name coinbaseexchange#fetchTradingFees
871
871
  * @description fetch the trading fees for multiple markets
872
872
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfees
873
873
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -921,7 +921,7 @@ export default class coinbasepro extends Exchange {
921
921
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
922
922
  /**
923
923
  * @method
924
- * @name coinbasepro#fetchOHLCV
924
+ * @name coinbaseexchange#fetchOHLCV
925
925
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles
926
926
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
927
927
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
@@ -987,7 +987,7 @@ export default class coinbasepro extends Exchange {
987
987
  async fetchTime(params = {}) {
988
988
  /**
989
989
  * @method
990
- * @name coinbasepro#fetchTime
990
+ * @name coinbaseexchange#fetchTime
991
991
  * @description fetches the current integer timestamp in milliseconds from the exchange server
992
992
  * @param {object} [params] extra parameters specific to the exchange API endpoint
993
993
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
@@ -1090,10 +1090,10 @@ export default class coinbasepro extends Exchange {
1090
1090
  async fetchOrder(id, symbol = undefined, params = {}) {
1091
1091
  /**
1092
1092
  * @method
1093
- * @name coinbasepro#fetchOrder
1093
+ * @name coinbaseexchange#fetchOrder
1094
1094
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorder
1095
1095
  * @description fetches information on an order made by the user
1096
- * @param {string} symbol not used by coinbasepro fetchOrder
1096
+ * @param {string} symbol not used by coinbaseexchange fetchOrder
1097
1097
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1098
1098
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1099
1099
  */
@@ -1116,7 +1116,7 @@ export default class coinbasepro extends Exchange {
1116
1116
  async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1117
1117
  /**
1118
1118
  * @method
1119
- * @name coinbasepro#fetchOrderTrades
1119
+ * @name coinbaseexchange#fetchOrderTrades
1120
1120
  * @description fetch all the trades made from a single order
1121
1121
  * @param {string} id order id
1122
1122
  * @param {string} symbol unified market symbol
@@ -1139,7 +1139,7 @@ export default class coinbasepro extends Exchange {
1139
1139
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1140
1140
  /**
1141
1141
  * @method
1142
- * @name coinbasepro#fetchOrders
1142
+ * @name coinbaseexchange#fetchOrders
1143
1143
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorders
1144
1144
  * @description fetches information on multiple orders made by the user
1145
1145
  * @param {string} symbol unified market symbol of the market orders were made in
@@ -1157,7 +1157,7 @@ export default class coinbasepro extends Exchange {
1157
1157
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1158
1158
  /**
1159
1159
  * @method
1160
- * @name coinbasepro#fetchOpenOrders
1160
+ * @name coinbaseexchange#fetchOpenOrders
1161
1161
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorders
1162
1162
  * @description fetch all unfilled currently open orders
1163
1163
  * @param {string} symbol unified market symbol
@@ -1197,7 +1197,7 @@ export default class coinbasepro extends Exchange {
1197
1197
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1198
1198
  /**
1199
1199
  * @method
1200
- * @name coinbasepro#fetchClosedOrders
1200
+ * @name coinbaseexchange#fetchClosedOrders
1201
1201
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorders
1202
1202
  * @description fetches information on multiple closed orders made by the user
1203
1203
  * @param {string} symbol unified market symbol of the market orders were made in
@@ -1215,7 +1215,7 @@ export default class coinbasepro extends Exchange {
1215
1215
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1216
1216
  /**
1217
1217
  * @method
1218
- * @name coinbasepro#createOrder
1218
+ * @name coinbaseexchange#createOrder
1219
1219
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postorders
1220
1220
  * @description create a trade order
1221
1221
  * @param {string} symbol unified symbol of the market to create an order in
@@ -1311,7 +1311,7 @@ export default class coinbasepro extends Exchange {
1311
1311
  async cancelOrder(id, symbol = undefined, params = {}) {
1312
1312
  /**
1313
1313
  * @method
1314
- * @name coinbasepro#cancelOrder
1314
+ * @name coinbaseexchange#cancelOrder
1315
1315
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_deleteorder
1316
1316
  * @description cancels an open order
1317
1317
  * @param {string} id order id
@@ -1344,7 +1344,7 @@ export default class coinbasepro extends Exchange {
1344
1344
  async cancelAllOrders(symbol = undefined, params = {}) {
1345
1345
  /**
1346
1346
  * @method
1347
- * @name coinbasepro#cancelAllOrders
1347
+ * @name coinbaseexchange#cancelAllOrders
1348
1348
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_deleteorders
1349
1349
  * @description cancel all open orders
1350
1350
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
@@ -1366,7 +1366,7 @@ export default class coinbasepro extends Exchange {
1366
1366
  async withdraw(code, amount, address, tag = undefined, params = {}) {
1367
1367
  /**
1368
1368
  * @method
1369
- * @name coinbasepro#withdraw
1369
+ * @name coinbaseexchange#withdraw
1370
1370
  * @description make a withdrawal
1371
1371
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawpaymentmethod
1372
1372
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawcoinbaseaccount
@@ -1492,7 +1492,7 @@ export default class coinbasepro extends Exchange {
1492
1492
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1493
1493
  /**
1494
1494
  * @method
1495
- * @name coinbasepro#fetchLedger
1495
+ * @name coinbaseexchange#fetchLedger
1496
1496
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccountledger
1497
1497
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1498
1498
  * @param {string} code unified currency code, default is undefined
@@ -1543,7 +1543,7 @@ export default class coinbasepro extends Exchange {
1543
1543
  async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1544
1544
  /**
1545
1545
  * @method
1546
- * @name coinbasepro#fetchDepositsWithdrawals
1546
+ * @name coinbaseexchange#fetchDepositsWithdrawals
1547
1547
  * @description fetch history of deposits and withdrawals
1548
1548
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
1549
1549
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers
@@ -1651,7 +1651,7 @@ export default class coinbasepro extends Exchange {
1651
1651
  async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1652
1652
  /**
1653
1653
  * @method
1654
- * @name coinbasepro#fetchDeposits
1654
+ * @name coinbaseexchange#fetchDeposits
1655
1655
  * @description fetch all deposits made to an account
1656
1656
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
1657
1657
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers
@@ -1666,7 +1666,7 @@ export default class coinbasepro extends Exchange {
1666
1666
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1667
1667
  /**
1668
1668
  * @method
1669
- * @name coinbasepro#fetchWithdrawals
1669
+ * @name coinbaseexchange#fetchWithdrawals
1670
1670
  * @description fetch all withdrawals made from an account
1671
1671
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
1672
1672
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers
@@ -1778,7 +1778,7 @@ export default class coinbasepro extends Exchange {
1778
1778
  async createDepositAddress(code, params = {}) {
1779
1779
  /**
1780
1780
  * @method
1781
- * @name coinbasepro#createDepositAddress
1781
+ * @name coinbaseexchange#createDepositAddress
1782
1782
  * @description create a currency deposit address
1783
1783
  * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postcoinbaseaccountaddresses
1784
1784
  * @param {string} code unified currency code of the currency for the deposit address
@@ -121,7 +121,7 @@ export default class coinex extends Exchange {
121
121
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
122
122
  parseTransaction(transaction: any, currency?: Currency): Transaction;
123
123
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
124
- parseTransferStatus(status: Str): Str;
124
+ parseTransferStatus(status: any): string;
125
125
  parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
126
126
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntries>;
127
127
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
package/js/src/coinex.js CHANGED
@@ -447,8 +447,15 @@ export default class coinex extends Exchange {
447
447
  'fetchDepositAddress': {
448
448
  'fillResponseFromRequest': true,
449
449
  },
450
+ 'accountsByType': {
451
+ 'spot': 'SPOT',
452
+ 'margin': 'MARGIN',
453
+ 'swap': 'FUTURES',
454
+ },
450
455
  'accountsById': {
451
- 'spot': '0',
456
+ 'SPOT': 'spot',
457
+ 'MARGIN': 'margin',
458
+ 'FUTURES': 'swap',
452
459
  },
453
460
  'networks': {
454
461
  'BEP20': 'BSC',
@@ -3654,7 +3661,11 @@ export default class coinex extends Exchange {
3654
3661
  * @param {string} [params.marginMode] 'cross' or 'isolated' for fetching spot margin orders
3655
3662
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3656
3663
  */
3657
- return await this.fetchOrdersByStatus('pending', symbol, since, limit, params);
3664
+ const openOrders = await this.fetchOrdersByStatus('pending', symbol, since, limit, params);
3665
+ for (let i = 0; i < openOrders.length; i++) {
3666
+ openOrders[i]['status'] = 'open';
3667
+ }
3668
+ return openOrders;
3658
3669
  }
3659
3670
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3660
3671
  /**
@@ -4886,43 +4897,45 @@ export default class coinex extends Exchange {
4886
4897
  * @method
4887
4898
  * @name coinex#transfer
4888
4899
  * @description transfer currency internally between wallets on the same account
4889
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account014_balance_contract_transfer
4890
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account013_margin_transfer
4900
+ * @see https://docs.coinex.com/api/v2/assets/transfer/http/transfer
4891
4901
  * @param {string} code unified currency code
4892
4902
  * @param {float} amount amount to transfer
4893
4903
  * @param {string} fromAccount account to transfer from
4894
4904
  * @param {string} toAccount account to transfer to
4895
4905
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4906
+ * @param {string} [params.symbol] unified ccxt symbol, required when either the fromAccount or toAccount is margin
4896
4907
  * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
4897
4908
  */
4898
4909
  await this.loadMarkets();
4899
4910
  const currency = this.currency(code);
4900
4911
  const amountToPrecision = this.currencyToPrecision(code, amount);
4912
+ const accountsByType = this.safeDict(this.options, 'accountsById', {});
4913
+ const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
4914
+ const toId = this.safeString(accountsByType, toAccount, toAccount);
4901
4915
  const request = {
4916
+ 'ccy': currency['id'],
4902
4917
  'amount': amountToPrecision,
4903
- 'coin_type': currency['id'],
4918
+ 'from_account_type': fromId,
4919
+ 'to_account_type': toId,
4904
4920
  };
4905
- let response = undefined;
4906
- if ((fromAccount === 'spot') && (toAccount === 'swap')) {
4907
- request['transfer_side'] = 'in'; // 'in' spot to swap, 'out' swap to spot
4908
- response = await this.v1PrivatePostContractBalanceTransfer(this.extend(request, params));
4921
+ if ((fromAccount === 'margin') || (toAccount === 'margin')) {
4922
+ const symbol = this.safeString(params, 'symbol');
4923
+ if (symbol === undefined) {
4924
+ throw new ArgumentsRequired(this.id + ' transfer() the symbol parameter must be defined for a margin account');
4925
+ }
4926
+ params = this.omit(params, 'symbol');
4927
+ request['market'] = this.marketId(symbol);
4909
4928
  }
4910
- else if ((fromAccount === 'swap') && (toAccount === 'spot')) {
4911
- request['transfer_side'] = 'out'; // 'in' spot to swap, 'out' swap to spot
4912
- response = await this.v1PrivatePostContractBalanceTransfer(this.extend(request, params));
4913
- }
4914
- else {
4915
- const accountsById = this.safeValue(this.options, 'accountsById', {});
4916
- const fromId = this.safeString(accountsById, fromAccount, fromAccount);
4917
- const toId = this.safeString(accountsById, toAccount, toAccount);
4918
- // fromAccount and toAccount must be integers for margin transfers
4919
- // spot is 0, use fetchBalance() to find the margin account id
4920
- request['from_account'] = parseInt(fromId);
4921
- request['to_account'] = parseInt(toId);
4922
- response = await this.v1PrivatePostMarginTransfer(this.extend(request, params));
4929
+ if ((fromAccount !== 'spot') && (toAccount !== 'spot')) {
4930
+ throw new BadRequest(this.id + ' transfer() can only be between spot and swap, or spot and margin, either the fromAccount or toAccount must be spot');
4923
4931
  }
4932
+ const response = await this.v2PrivatePostAssetsTransfer(this.extend(request, params));
4924
4933
  //
4925
- // {"code": 0, "data": null, "message": "Success"}
4934
+ // {
4935
+ // "code": 0,
4936
+ // "data": {},
4937
+ // "message": "OK"
4938
+ // }
4926
4939
  //
4927
4940
  return this.extend(this.parseTransfer(response, currency), {
4928
4941
  'amount': this.parseNumber(amountToPrecision),
@@ -4934,67 +4947,26 @@ export default class coinex extends Exchange {
4934
4947
  const statuses = {
4935
4948
  '0': 'ok',
4936
4949
  'SUCCESS': 'ok',
4950
+ 'OK': 'ok',
4951
+ 'finished': 'ok',
4952
+ 'FINISHED': 'ok',
4937
4953
  };
4938
4954
  return this.safeString(statuses, status, status);
4939
4955
  }
4940
4956
  parseTransfer(transfer, currency = undefined) {
4941
- //
4942
- // fetchTransfers Swap
4943
- //
4944
- // {
4945
- // "amount": "10",
4946
- // "asset": "USDT",
4947
- // "transfer_type": "transfer_out", // from swap to spot
4948
- // "created_at": 1651633422
4949
- // },
4950
- //
4951
- // fetchTransfers Margin
4952
- //
4953
- // {
4954
- // "id": 7580062,
4955
- // "updated_at": 1653684379,
4956
- // "user_id": 3620173,
4957
- // "from_account_id": 0,
4958
- // "to_account_id": 1,
4959
- // "asset": "BTC",
4960
- // "amount": "0.00160829",
4961
- // "balance": "0.00160829",
4962
- // "transfer_type": "IN",
4963
- // "status": "SUCCESS",
4964
- // "created_at": 1653684379
4965
- // },
4966
- //
4967
- const timestamp = this.safeTimestamp(transfer, 'created_at');
4968
- const transferType = this.safeString(transfer, 'transfer_type');
4969
- let fromAccount = undefined;
4970
- let toAccount = undefined;
4971
- if (transferType === 'transfer_out') {
4972
- fromAccount = 'swap';
4973
- toAccount = 'spot';
4974
- }
4975
- else if (transferType === 'transfer_in') {
4976
- fromAccount = 'spot';
4977
- toAccount = 'swap';
4978
- }
4979
- else if (transferType === 'IN') {
4980
- fromAccount = 'spot';
4981
- toAccount = 'margin';
4982
- }
4983
- else if (transferType === 'OUT') {
4984
- fromAccount = 'margin';
4985
- toAccount = 'spot';
4986
- }
4987
- const currencyId = this.safeString(transfer, 'asset');
4988
- const currencyCode = this.safeCurrencyCode(currencyId, currency);
4957
+ const timestamp = this.safeInteger(transfer, 'created_at');
4958
+ const currencyId = this.safeString(transfer, 'ccy');
4959
+ const fromId = this.safeString(transfer, 'from_account_type');
4960
+ const toId = this.safeString(transfer, 'to_account_type');
4961
+ const accountsById = this.safeValue(this.options, 'accountsById', {});
4989
4962
  return {
4990
- 'info': transfer,
4991
- 'id': this.safeString(transfer, 'id'),
4963
+ 'id': undefined,
4992
4964
  'timestamp': timestamp,
4993
4965
  'datetime': this.iso8601(timestamp),
4994
- 'currency': currencyCode,
4966
+ 'currency': this.safeCurrencyCode(currencyId, currency),
4995
4967
  'amount': this.safeNumber(transfer, 'amount'),
4996
- 'fromAccount': fromAccount,
4997
- 'toAccount': toAccount,
4968
+ 'fromAccount': this.safeString(accountsById, fromId, fromId),
4969
+ 'toAccount': this.safeString(accountsById, toId, toId),
4998
4970
  'status': this.parseTransferStatus(this.safeString2(transfer, 'code', 'status')),
4999
4971
  };
5000
4972
  }
@@ -5003,31 +4975,29 @@ export default class coinex extends Exchange {
5003
4975
  * @method
5004
4976
  * @name coinex#fetchTransfers
5005
4977
  * @description fetch a history of internal transfers made on an account
5006
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account025_margin_transfer_history
5007
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account024_contract_transfer_history
4978
+ * @see https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
5008
4979
  * @param {string} code unified currency code of the currency transferred
5009
4980
  * @param {int} [since] the earliest time in ms to fetch transfers for
5010
- * @param {int} [limit] the maximum number of transfers structures to retrieve
4981
+ * @param {int} [limit] the maximum number of transfer structures to retrieve
5011
4982
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4983
+ * @param {string} [params.marginMode] 'cross' or 'isolated' for fetching transfers to and from your margin account
5012
4984
  * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
5013
4985
  */
5014
4986
  await this.loadMarkets();
5015
- let currency = undefined;
5016
- const request = {
5017
- 'page': 1,
5018
- // 'limit': limit,
5019
- // 'asset': 'USDT',
5020
- // 'start_time': since,
5021
- // 'end_time': 1515806440,
5022
- // 'transfer_type': 'transfer_in', // transfer_in: from Spot to Swap Account, transfer_out: from Swap to Spot Account
4987
+ if (code === undefined) {
4988
+ throw new ArgumentsRequired(this.id + ' fetchTransfers() requires a code argument');
4989
+ }
4990
+ const currency = this.currency(code);
4991
+ let request = {
4992
+ 'ccy': currency['id'],
5023
4993
  };
5024
- const page = this.safeInteger(params, 'page');
5025
- if (page !== undefined) {
5026
- request['page'] = page;
4994
+ let marginMode = undefined;
4995
+ [marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
4996
+ if (marginMode !== undefined) {
4997
+ request['transfer_type'] = 'MARGIN';
5027
4998
  }
5028
- if (code !== undefined) {
5029
- currency = this.currency(code);
5030
- request['asset'] = currency['id'];
4999
+ else {
5000
+ request['transfer_type'] = 'FUTURES';
5031
5001
  }
5032
5002
  if (since !== undefined) {
5033
5003
  request['start_time'] = since;
@@ -5035,66 +5005,30 @@ export default class coinex extends Exchange {
5035
5005
  if (limit !== undefined) {
5036
5006
  request['limit'] = limit;
5037
5007
  }
5038
- else {
5039
- request['limit'] = 100;
5040
- }
5041
- params = this.omit(params, 'page');
5042
- let marginMode = undefined;
5043
- [marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
5044
- let response = undefined;
5045
- if (marginMode !== undefined) {
5046
- response = await this.v1PrivateGetMarginTransferHistory(this.extend(request, params));
5047
- }
5048
- else {
5049
- response = await this.v1PrivateGetContractTransferHistory(this.extend(request, params));
5050
- }
5051
- //
5052
- // Swap
5008
+ [request, params] = this.handleUntilOption('end_time', request, params);
5009
+ const response = await this.v2PrivateGetAssetsTransferHistory(this.extend(request, params));
5053
5010
  //
5054
5011
  // {
5055
- // "code": 0,
5056
- // "data": {
5057
- // "records": [
5058
- // {
5059
- // "amount": "10",
5060
- // "asset": "USDT",
5061
- // "transfer_type": "transfer_out",
5062
- // "created_at": 1651633422
5063
- // },
5064
- // ],
5065
- // "total": 5
5012
+ // "data": [
5013
+ // {
5014
+ // "created_at": 1715848480646,
5015
+ // "from_account_type": "SPOT",
5016
+ // "to_account_type": "FUTURES",
5017
+ // "ccy": "USDT",
5018
+ // "amount": "10",
5019
+ // "status": "finished"
5020
+ // },
5021
+ // ],
5022
+ // "pagination": {
5023
+ // "total": 8,
5024
+ // "has_next": false
5066
5025
  // },
5067
- // "message": "Success"
5068
- // }
5069
- //
5070
- // Margin
5071
- //
5072
- // {
5073
5026
  // "code": 0,
5074
- // "data": {
5075
- // "records": [
5076
- // {
5077
- // "id": 7580062,
5078
- // "updated_at": 1653684379,
5079
- // "user_id": 3620173,
5080
- // "from_account_id": 0,
5081
- // "to_account_id": 1,
5082
- // "asset": "BTC",
5083
- // "amount": "0.00160829",
5084
- // "balance": "0.00160829",
5085
- // "transfer_type": "IN",
5086
- // "status": "SUCCESS",
5087
- // "created_at": 1653684379
5088
- // }
5089
- // ],
5090
- // "total": 1
5091
- // },
5092
- // "message": "Success"
5027
+ // "message": "OK"
5093
5028
  // }
5094
5029
  //
5095
- const data = this.safeValue(response, 'data', {});
5096
- const transfers = this.safeList(data, 'records', []);
5097
- return this.parseTransfers(transfers, currency, since, limit);
5030
+ const data = this.safeList(response, 'data', []);
5031
+ return this.parseTransfers(data, currency, since, limit);
5098
5032
  }
5099
5033
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
5100
5034
  /**
@@ -56,13 +56,15 @@ export default class kraken extends Exchange {
56
56
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
57
57
  parseBalance(response: any): Balances;
58
58
  fetchBalance(params?: {}): Promise<Balances>;
59
+ createMarketOrderWithCost(symbol: string, side: OrderSide, cost: number, params?: {}): Promise<Order>;
60
+ createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
59
61
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
60
62
  findMarketByAltnameOrId(id: any): any;
61
63
  getDelistedMarketById(id: any): any;
62
64
  parseOrderStatus(status: any): string;
63
65
  parseOrderType(status: any): string;
64
66
  parseOrder(order: any, market?: Market): Order;
65
- orderRequest(method: any, symbol: any, type: any, request: any, price?: any, params?: {}): any[];
67
+ orderRequest(method: string, symbol: string, type: string, request: Dict, amount: Num, price?: Num, params?: {}): Dict[];
66
68
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
67
69
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
68
70
  fetchOrderTrades(id: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;