ccxt 4.3.13 → 4.3.15

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 (61) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +3 -3
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/base/Exchange.js +14 -6
  5. package/dist/cjs/src/base/errors.js +8 -1
  6. package/dist/cjs/src/base/functions/misc.js +2 -2
  7. package/dist/cjs/src/base/ws/Client.js +2 -1
  8. package/dist/cjs/src/binance.js +106 -5
  9. package/dist/cjs/src/bingx.js +1 -0
  10. package/dist/cjs/src/bybit.js +105 -105
  11. package/dist/cjs/src/coinbase.js +103 -0
  12. package/dist/cjs/src/coinex.js +435 -423
  13. package/dist/cjs/src/cryptocom.js +2 -1
  14. package/dist/cjs/src/hitbtc.js +1 -0
  15. package/dist/cjs/src/luno.js +2 -0
  16. package/dist/cjs/src/okx.js +1 -1
  17. package/dist/cjs/src/phemex.js +1 -1
  18. package/dist/cjs/src/pro/hitbtc.js +1 -1
  19. package/dist/cjs/src/pro/independentreserve.js +3 -3
  20. package/dist/cjs/src/pro/poloniex.js +3 -3
  21. package/dist/cjs/src/pro/woo.js +147 -9
  22. package/js/ccxt.d.ts +3 -3
  23. package/js/ccxt.js +3 -3
  24. package/js/src/abstract/luno.d.ts +2 -0
  25. package/js/src/alpaca.d.ts +1 -1
  26. package/js/src/base/Exchange.d.ts +5 -5
  27. package/js/src/base/Exchange.js +14 -6
  28. package/js/src/base/errorHierarchy.d.ts +1 -0
  29. package/js/src/base/errorHierarchy.js +1 -0
  30. package/js/src/base/errors.d.ts +5 -1
  31. package/js/src/base/errors.js +8 -2
  32. package/js/src/base/functions/generic.d.ts +1 -1
  33. package/js/src/base/functions/misc.d.ts +5 -4
  34. package/js/src/base/functions/misc.js +2 -2
  35. package/js/src/base/functions/number.d.ts +5 -5
  36. package/js/src/base/functions/rsa.d.ts +2 -1
  37. package/js/src/base/functions/totp.d.ts +1 -1
  38. package/js/src/base/ws/Client.d.ts +8 -7
  39. package/js/src/base/ws/Client.js +2 -1
  40. package/js/src/binance.d.ts +14 -1
  41. package/js/src/binance.js +107 -6
  42. package/js/src/bingx.d.ts +1 -1
  43. package/js/src/bingx.js +1 -0
  44. package/js/src/bybit.js +105 -105
  45. package/js/src/coinbase.d.ts +5 -1
  46. package/js/src/coinbase.js +103 -0
  47. package/js/src/coinex.js +435 -423
  48. package/js/src/cryptocom.js +2 -1
  49. package/js/src/hitbtc.js +1 -0
  50. package/js/src/luno.js +2 -0
  51. package/js/src/okx.js +1 -1
  52. package/js/src/phemex.js +1 -1
  53. package/js/src/pro/hitbtc.js +1 -1
  54. package/js/src/pro/independentreserve.js +3 -3
  55. package/js/src/pro/poloniex.js +3 -3
  56. package/js/src/pro/woo.d.ts +2 -0
  57. package/js/src/pro/woo.js +147 -9
  58. package/js/src/upbit.d.ts +1 -1
  59. package/js/src/woo.d.ts +1 -1
  60. package/js/src/zonda.d.ts +1 -1
  61. package/package.json +1 -1
@@ -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 } 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 } from './base/types.js';
3
3
  /**
4
4
  * @class coinbase
5
5
  * @augments Exchange
@@ -104,6 +104,10 @@ export default class coinbase extends Exchange {
104
104
  };
105
105
  deposit(code: string, amount: number, id: string, params?: {}): Promise<Transaction>;
106
106
  fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
107
+ fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
108
+ createConvertTrade(id: string, fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
109
+ fetchConvertTrade(id: string, code?: Str, params?: {}): Promise<Conversion>;
110
+ parseConversion(conversion: any, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
107
111
  closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
108
112
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
109
113
  fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
@@ -47,6 +47,7 @@ export default class coinbase extends Exchange {
47
47
  'cancelOrders': true,
48
48
  'closeAllPositions': false,
49
49
  'closePosition': true,
50
+ 'createConvertTrade': true,
50
51
  'createDepositAddress': true,
51
52
  'createLimitBuyOrder': true,
52
53
  'createLimitSellOrder': true,
@@ -70,6 +71,9 @@ export default class coinbase extends Exchange {
70
71
  'fetchBorrowRateHistory': false,
71
72
  'fetchCanceledOrders': true,
72
73
  'fetchClosedOrders': true,
74
+ 'fetchConvertQuote': true,
75
+ 'fetchConvertTrade': true,
76
+ 'fetchConvertTradeHistory': false,
73
77
  'fetchCrossBorrowRate': false,
74
78
  'fetchCrossBorrowRates': false,
75
79
  'fetchCurrencies': true,
@@ -4133,6 +4137,105 @@ export default class coinbase extends Exchange {
4133
4137
  const data = this.safeDict(response, 'data', {});
4134
4138
  return this.parseTransaction(data);
4135
4139
  }
4140
+ async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
4141
+ /**
4142
+ * @method
4143
+ * @name coinbase#fetchConvertQuote
4144
+ * @description fetch a quote for converting from one currency to another
4145
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_createconvertquote
4146
+ * @param {string} fromCode the currency that you want to sell and convert from
4147
+ * @param {string} toCode the currency that you want to buy and convert into
4148
+ * @param {float} [amount] how much you want to trade in units of the from currency
4149
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4150
+ * @param {object} [params.trade_incentive_metadata] an object to fill in user incentive data
4151
+ * @param {string} [params.trade_incentive_metadata.user_incentive_id] the id of the incentive
4152
+ * @param {string} [params.trade_incentive_metadata.code_val] the code value of the incentive
4153
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
4154
+ */
4155
+ await this.loadMarkets();
4156
+ const request = {
4157
+ 'from_account': fromCode,
4158
+ 'to_account': toCode,
4159
+ 'amount': this.numberToString(amount),
4160
+ };
4161
+ const response = await this.v3PrivatePostBrokerageConvertQuote(this.extend(request, params));
4162
+ const data = this.safeDict(response, 'trade', {});
4163
+ return this.parseConversion(data);
4164
+ }
4165
+ async createConvertTrade(id, fromCode, toCode, amount = undefined, params = {}) {
4166
+ /**
4167
+ * @method
4168
+ * @name coinbase#createConvertTrade
4169
+ * @description convert from one currency to another
4170
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_commitconverttrade
4171
+ * @param {string} id the id of the trade that you want to make
4172
+ * @param {string} fromCode the currency that you want to sell and convert from
4173
+ * @param {string} toCode the currency that you want to buy and convert into
4174
+ * @param {float} [amount] how much you want to trade in units of the from currency
4175
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4176
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
4177
+ */
4178
+ await this.loadMarkets();
4179
+ const request = {
4180
+ 'trade_id': id,
4181
+ 'from_account': fromCode,
4182
+ 'to_account': toCode,
4183
+ };
4184
+ const response = await this.v3PrivatePostBrokerageConvertTradeTradeId(this.extend(request, params));
4185
+ const data = this.safeDict(response, 'trade', {});
4186
+ return this.parseConversion(data);
4187
+ }
4188
+ async fetchConvertTrade(id, code = undefined, params = {}) {
4189
+ /**
4190
+ * @method
4191
+ * @name coinbase#fetchConvertTrade
4192
+ * @description fetch the data for a conversion trade
4193
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getconverttrade
4194
+ * @param {string} id the id of the trade that you want to commit
4195
+ * @param {string} code the unified currency code that was converted from
4196
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4197
+ * @param {strng} params.toCode the unified currency code that was converted into
4198
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
4199
+ */
4200
+ await this.loadMarkets();
4201
+ if (code === undefined) {
4202
+ throw new ArgumentsRequired(this.id + ' fetchConvertTrade() requires a code argument');
4203
+ }
4204
+ const toCode = this.safeString(params, 'toCode');
4205
+ if (toCode === undefined) {
4206
+ throw new ArgumentsRequired(this.id + ' fetchConvertTrade() requires a toCode parameter');
4207
+ }
4208
+ params = this.omit(params, 'toCode');
4209
+ const request = {
4210
+ 'trade_id': id,
4211
+ 'from_account': code,
4212
+ 'to_account': toCode,
4213
+ };
4214
+ const response = await this.v3PrivateGetBrokerageConvertTradeTradeId(this.extend(request, params));
4215
+ const data = this.safeDict(response, 'trade', {});
4216
+ return this.parseConversion(data);
4217
+ }
4218
+ parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
4219
+ const fromCoin = this.safeString(conversion, 'source_currency');
4220
+ const fromCode = this.safeCurrencyCode(fromCoin, fromCurrency);
4221
+ const to = this.safeString(conversion, 'target_currency');
4222
+ const toCode = this.safeCurrencyCode(to, toCurrency);
4223
+ const fromAmountStructure = this.safeDict(conversion, 'user_entered_amount');
4224
+ const feeStructure = this.safeDict(conversion, 'total_fee');
4225
+ const feeAmountStructure = this.safeDict(feeStructure, 'amount');
4226
+ return {
4227
+ 'info': conversion,
4228
+ 'timestamp': undefined,
4229
+ 'datetime': undefined,
4230
+ 'id': this.safeString(conversion, 'id'),
4231
+ 'fromCurrency': fromCode,
4232
+ 'fromAmount': this.safeNumber(fromAmountStructure, 'value'),
4233
+ 'toCurrency': toCode,
4234
+ 'toAmount': undefined,
4235
+ 'price': undefined,
4236
+ 'fee': this.safeNumber(feeAmountStructure, 'value'),
4237
+ };
4238
+ }
4136
4239
  async closePosition(symbol, side = undefined, params = {}) {
4137
4240
  /**
4138
4241
  * @method