ccxt 4.1.72 → 4.1.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/src/bybit.js CHANGED
@@ -38,6 +38,8 @@ export default class bybit extends Exchange {
38
38
  'borrowCrossMargin': true,
39
39
  'cancelAllOrders': true,
40
40
  'cancelOrder': true,
41
+ 'createMarketBuyOrderWithCost': true,
42
+ 'createMarketSellOrderWithCost': false,
41
43
  'createOrder': true,
42
44
  'createOrders': true,
43
45
  'createPostOnlyOrder': true,
@@ -3449,6 +3451,25 @@ export default class bybit extends Exchange {
3449
3451
  }
3450
3452
  return this.safeValue(result, 0);
3451
3453
  }
3454
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
3455
+ /**
3456
+ * @method
3457
+ * @name bybit#createMarketBuyOrderWithCost
3458
+ * @see https://bybit-exchange.github.io/docs/v5/order/create-order
3459
+ * @description create a market buy order by providing the symbol and cost
3460
+ * @param {string} symbol unified symbol of the market to create an order in
3461
+ * @param {float} cost how much you want to trade in units of the quote currency
3462
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3463
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3464
+ */
3465
+ await this.loadMarkets();
3466
+ const market = this.market(symbol);
3467
+ if (!market['spot']) {
3468
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
3469
+ }
3470
+ params['createMarketBuyOrderRequiresPrice'] = false;
3471
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
3472
+ }
3452
3473
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
3453
3474
  /**
3454
3475
  * @method
@@ -3549,18 +3570,20 @@ export default class bybit extends Exchange {
3549
3570
  }
3550
3571
  if (market['spot'] && (type === 'market') && (side === 'buy')) {
3551
3572
  // for market buy it requires the amount of quote currency to spend
3552
- if (this.options['createMarketBuyOrderRequiresPrice']) {
3553
- const cost = this.safeNumber(params, 'cost');
3554
- params = this.omit(params, 'cost');
3555
- if (price === undefined && cost === undefined) {
3556
- throw new InvalidOrder(this.id + ' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false to supply the cost in the amount argument (the exchange-specific behaviour)');
3573
+ let createMarketBuyOrderRequiresPrice = true;
3574
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
3575
+ const cost = this.safeNumber(params, 'cost');
3576
+ params = this.omit(params, 'cost');
3577
+ if (createMarketBuyOrderRequiresPrice) {
3578
+ if ((price === undefined) && (cost === undefined)) {
3579
+ throw new InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
3557
3580
  }
3558
3581
  else {
3559
3582
  const amountString = this.numberToString(amount);
3560
3583
  const priceString = this.numberToString(price);
3561
3584
  const quoteAmount = Precise.stringMul(amountString, priceString);
3562
- amount = (cost !== undefined) ? cost : this.parseNumber(quoteAmount);
3563
- request['qty'] = this.costToPrecision(symbol, amount);
3585
+ const costRequest = (cost !== undefined) ? cost : quoteAmount;
3586
+ request['qty'] = this.costToPrecision(symbol, costRequest);
3564
3587
  }
3565
3588
  }
3566
3589
  else {
package/js/src/cex.d.ts CHANGED
@@ -22,6 +22,7 @@ export default class cex extends Exchange {
22
22
  fetchTradingFees(params?: {}): Promise<{}>;
23
23
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
24
24
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
25
+ cancelAllOrders(symbol?: string, params?: {}): Promise<any>;
25
26
  parseOrder(order: any, market?: Market): Order;
26
27
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
27
28
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/cex.js CHANGED
@@ -31,6 +31,7 @@ export default class cex extends Exchange {
31
31
  'future': false,
32
32
  'option': false,
33
33
  'addMargin': false,
34
+ 'cancelAllOrders': true,
34
35
  'cancelOrder': true,
35
36
  'cancelOrders': false,
36
37
  'createDepositAddress': false,
@@ -466,6 +467,7 @@ export default class cex extends Exchange {
466
467
  /**
467
468
  * @method
468
469
  * @name cex#fetchBalance
470
+ * @see https://docs.cex.io/#account-balance
469
471
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
470
472
  * @param {object} [params] extra parameters specific to the exchange API endpoint
471
473
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
@@ -478,6 +480,7 @@ export default class cex extends Exchange {
478
480
  /**
479
481
  * @method
480
482
  * @name cex#fetchOrderBook
483
+ * @see https://docs.cex.io/#orderbook
481
484
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
482
485
  * @param {string} symbol unified symbol of the market to fetch the order book for
483
486
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -520,6 +523,7 @@ export default class cex extends Exchange {
520
523
  /**
521
524
  * @method
522
525
  * @name cex#fetchOHLCV
526
+ * @see https://docs.cex.io/#historical-ohlcv-chart
523
527
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
524
528
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
525
529
  * @param {string} timeframe the length of time each candle represents
@@ -625,6 +629,7 @@ export default class cex extends Exchange {
625
629
  /**
626
630
  * @method
627
631
  * @name cex#fetchTicker
632
+ * @see https://docs.cex.io/#ticker
628
633
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
629
634
  * @param {string} symbol unified symbol of the market to fetch the ticker for
630
635
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -677,6 +682,7 @@ export default class cex extends Exchange {
677
682
  /**
678
683
  * @method
679
684
  * @name cex#fetchTrades
685
+ * @see https://docs.cex.io/#trade-history
680
686
  * @description get the list of most recent trades for a particular symbol
681
687
  * @param {string} symbol unified symbol of the market to fetch trades for
682
688
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -696,6 +702,7 @@ export default class cex extends Exchange {
696
702
  /**
697
703
  * @method
698
704
  * @name cex#fetchTradingFees
705
+ * @see https://docs.cex.io/#get-my-fee
699
706
  * @description fetch the trading fees for multiple markets
700
707
  * @param {object} [params] extra parameters specific to the exchange API endpoint
701
708
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
@@ -737,6 +744,7 @@ export default class cex extends Exchange {
737
744
  /**
738
745
  * @method
739
746
  * @name cex#createOrder
747
+ * @see https://docs.cex.io/#place-order
740
748
  * @description create a trade order
741
749
  * @see https://cex.io/rest-api#place-order
742
750
  * @param {string} symbol unified symbol of the market to create an order in
@@ -820,6 +828,7 @@ export default class cex extends Exchange {
820
828
  /**
821
829
  * @method
822
830
  * @name cex#cancelOrder
831
+ * @see https://docs.cex.io/#cancel-order
823
832
  * @description cancels an open order
824
833
  * @param {string} id order id
825
834
  * @param {string} symbol not used by cex cancelOrder ()
@@ -834,6 +843,36 @@ export default class cex extends Exchange {
834
843
  // 'true'
835
844
  return this.extend(this.parseOrder({}), { 'info': response, 'type': undefined, 'id': id, 'status': 'canceled' });
836
845
  }
846
+ async cancelAllOrders(symbol = undefined, params = {}) {
847
+ /**
848
+ * @method
849
+ * @name cex#cancelAllOrders
850
+ * @see https://docs.cex.io/#cancel-all-orders-for-given-pair
851
+ * @description cancel all open orders in a market
852
+ * @param {string} symbol unified market symbol of the market to cancel orders in
853
+ * @param {object} [params] extra parameters specific to the cex api endpoint
854
+ * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
855
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
856
+ */
857
+ if (symbol === undefined) {
858
+ throw new ArgumentsRequired(this.id + ' cancelAllOrders requires a symbol.');
859
+ }
860
+ await this.loadMarkets();
861
+ const market = this.market(symbol);
862
+ const request = {
863
+ 'pair': market['id'],
864
+ };
865
+ const orders = await this.privatePostCancelOrdersPair(this.extend(request, params));
866
+ //
867
+ // {
868
+ // "e":"cancel_orders",
869
+ // "ok":"ok",
870
+ // "data":[
871
+ // ]
872
+ // }
873
+ //
874
+ return orders;
875
+ }
837
876
  parseOrder(order, market = undefined) {
838
877
  // Depending on the call, 'time' can be a unix int, unix string or ISO string
839
878
  // Yes, really
@@ -847,9 +886,9 @@ export default class cex extends Exchange {
847
886
  timestamp = parseInt(timestamp);
848
887
  }
849
888
  let symbol = undefined;
850
- if (market === undefined) {
851
- const baseId = this.safeString(order, 'symbol1');
852
- const quoteId = this.safeString(order, 'symbol2');
889
+ const baseId = this.safeString(order, 'symbol1');
890
+ const quoteId = this.safeString(order, 'symbol2');
891
+ if (market === undefined && baseId !== undefined && quoteId !== undefined) {
853
892
  const base = this.safeCurrencyCode(baseId);
854
893
  const quote = this.safeCurrencyCode(quoteId);
855
894
  if ((base !== undefined) && (quote !== undefined)) {
@@ -1104,6 +1143,7 @@ export default class cex extends Exchange {
1104
1143
  /**
1105
1144
  * @method
1106
1145
  * @name cex#fetchOpenOrders
1146
+ * @see https://docs.cex.io/#open-orders
1107
1147
  * @description fetch all unfilled currently open orders
1108
1148
  * @param {string} symbol unified market symbol
1109
1149
  * @param {int} [since] the earliest time in ms to fetch open orders for
@@ -1130,6 +1170,7 @@ export default class cex extends Exchange {
1130
1170
  /**
1131
1171
  * @method
1132
1172
  * @name cex#fetchClosedOrders
1173
+ * @see https://docs.cex.io/#archived-orders
1133
1174
  * @description fetches information on multiple closed orders made by the user
1134
1175
  * @param {string} symbol unified market symbol of the market orders were made in
1135
1176
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -1151,6 +1192,7 @@ export default class cex extends Exchange {
1151
1192
  /**
1152
1193
  * @method
1153
1194
  * @name cex#fetchOrder
1195
+ * @see https://docs.cex.io/?python#get-order-details
1154
1196
  * @description fetches information on an order made by the user
1155
1197
  * @param {string} symbol not used by cex fetchOrder
1156
1198
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1268,6 +1310,7 @@ export default class cex extends Exchange {
1268
1310
  /**
1269
1311
  * @method
1270
1312
  * @name cex#fetchOrders
1313
+ * @see https://docs.cex.io/#archived-orders
1271
1314
  * @description fetches information on multiple orders made by the user
1272
1315
  * @param {string} symbol unified market symbol of the market orders were made in
1273
1316
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -1490,6 +1533,20 @@ export default class cex extends Exchange {
1490
1533
  return this.safeString(this.options['order']['status'], status, status);
1491
1534
  }
1492
1535
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1536
+ /**
1537
+ * @method
1538
+ * @name cex#editOrderWs
1539
+ * @description edit a trade order
1540
+ * @see https://docs.cex.io/#cancel-replace-order
1541
+ * @param {string} id order id
1542
+ * @param {string} symbol unified symbol of the market to create an order in
1543
+ * @param {string} type 'market' or 'limit'
1544
+ * @param {string} side 'buy' or 'sell'
1545
+ * @param {float} amount how much of the currency you want to trade in units of the base currency
1546
+ * @param {float|undefined} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1547
+ * @param {object} [params] extra parameters specific to the cex api endpoint
1548
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
1549
+ */
1493
1550
  if (amount === undefined) {
1494
1551
  throw new ArgumentsRequired(this.id + ' editOrder() requires a amount argument');
1495
1552
  }
@@ -1513,6 +1570,7 @@ export default class cex extends Exchange {
1513
1570
  /**
1514
1571
  * @method
1515
1572
  * @name cex#fetchDepositAddress
1573
+ * @see https://docs.cex.io/#get-crypto-address
1516
1574
  * @description fetch the deposit address for a currency associated with this account
1517
1575
  * @param {string} code unified currency code
1518
1576
  * @param {object} [params] extra parameters specific to the exchange API endpoint
package/js/src/coinex.js CHANGED
@@ -47,8 +47,8 @@ export default class coinex extends Exchange {
47
47
  'cancelOrder': true,
48
48
  'cancelOrders': true,
49
49
  'createDepositAddress': true,
50
- 'createOrder': true,
51
50
  'createMarketBuyOrderWithCost': true,
51
+ 'createOrder': true,
52
52
  'createOrders': true,
53
53
  'createReduceOnlyOrder': true,
54
54
  'editOrder': true,
package/js/src/exmo.d.ts CHANGED
@@ -42,7 +42,7 @@ export default class exmo extends Exchange {
42
42
  total: any;
43
43
  status: string;
44
44
  }>;
45
- fetchTradingFees(params?: {}): Promise<any>;
45
+ fetchTradingFees(params?: {}): Promise<{}>;
46
46
  fetchPrivateTradingFees(params?: {}): Promise<{}>;
47
47
  fetchPublicTradingFees(params?: {}): Promise<{}>;
48
48
  parseFixedFloatValue(input: any): number;
package/js/src/exmo.js CHANGED
@@ -240,14 +240,13 @@ export default class exmo extends Exchange {
240
240
  'position_id': market['id'],
241
241
  'quantity': amount,
242
242
  };
243
- let method = undefined;
243
+ let response = undefined;
244
244
  if (type === 'add') {
245
- method = 'privatePostMarginUserPositionMarginAdd';
245
+ response = await this.privatePostMarginUserPositionMarginAdd(this.extend(request, params));
246
246
  }
247
247
  else if (type === 'reduce') {
248
- method = 'privatePostMarginUserPositionMarginReduce';
248
+ response = await this.privatePostMarginUserPositionMarginRemove(this.extend(request, params));
249
249
  }
250
- const response = await this[method](this.extend(request, params));
251
250
  //
252
251
  // {}
253
252
  //
@@ -306,13 +305,16 @@ export default class exmo extends Exchange {
306
305
  * @param {object} [params] extra parameters specific to the exchange API endpoint
307
306
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
308
307
  */
309
- let method = this.safeString(params, 'method');
308
+ const options = this.safeValue(this.options, 'fetchTradingFees', {});
309
+ const defaultMethod = this.safeString(options, 'method', 'fetchPrivateTradingFees');
310
+ const method = this.safeString(params, 'method', defaultMethod);
310
311
  params = this.omit(params, 'method');
311
- if (method === undefined) {
312
- const options = this.safeValue(this.options, 'fetchTradingFees', {});
313
- method = this.safeString(options, 'method', 'fetchPrivateTradingFees');
312
+ if (method === 'fetchPrivateTradingFees') {
313
+ return await this.fetchPrivateTradingFees(params);
314
+ }
315
+ else {
316
+ return await this.fetchPublicTradingFees(params);
314
317
  }
315
- return await this[method](params);
316
318
  }
317
319
  async fetchPrivateTradingFees(params = {}) {
318
320
  await this.loadMarkets();
@@ -1425,7 +1427,6 @@ export default class exmo extends Exchange {
1425
1427
  // 'client_id': 123, // optional, must be a positive integer
1426
1428
  // 'comment': '', // up to 50 latin symbols, whitespaces, underscores
1427
1429
  };
1428
- let method = isSpot ? 'privatePostOrderCreate' : 'privatePostMarginUserOrderCreate';
1429
1430
  let clientOrderId = this.safeValue2(params, 'client_id', 'clientOrderId');
1430
1431
  if (clientOrderId !== undefined) {
1431
1432
  clientOrderId = this.safeInteger2(params, 'client_id', 'clientOrderId');
@@ -1441,32 +1442,22 @@ export default class exmo extends Exchange {
1441
1442
  throw new ArgumentsRequired(this.id + ' createOrder requires an extra param params["leverage"] for margin orders');
1442
1443
  }
1443
1444
  params = this.omit(params, ['stopPrice', 'stop_price', 'triggerPrice', 'timeInForce', 'client_id', 'clientOrderId']);
1444
- if (triggerPrice !== undefined) {
1445
- if (isSpot) {
1445
+ if (price !== undefined) {
1446
+ request['price'] = this.priceToPrecision(market['symbol'], price);
1447
+ }
1448
+ let response = undefined;
1449
+ if (isSpot) {
1450
+ if (triggerPrice !== undefined) {
1446
1451
  if (type === 'limit') {
1447
1452
  throw new BadRequest(this.id + ' createOrder () cannot create stop limit orders for spot, only stop market');
1448
1453
  }
1449
1454
  else {
1450
- method = 'privatePostStopMarketOrderCreate';
1451
1455
  request['type'] = side;
1452
1456
  request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
1453
1457
  }
1458
+ response = await this.privatePostStopMarketOrderCreate(this.extend(request, params));
1454
1459
  }
1455
1460
  else {
1456
- request['stop_price'] = this.priceToPrecision(symbol, triggerPrice);
1457
- if (type === 'limit') {
1458
- request['type'] = 'stop_limit_' + side;
1459
- }
1460
- else if (type === 'market') {
1461
- request['type'] = 'stop_' + side;
1462
- }
1463
- else {
1464
- request['type'] = type;
1465
- }
1466
- }
1467
- }
1468
- else {
1469
- if (isSpot) {
1470
1461
  const execType = this.safeString(params, 'exec_type');
1471
1462
  let isPostOnly = undefined;
1472
1463
  [isPostOnly, params] = this.handlePostOnly(type === 'market', execType === 'post_only', params);
@@ -1484,6 +1475,21 @@ export default class exmo extends Exchange {
1484
1475
  else if (timeInForce !== undefined) {
1485
1476
  request['exec_type'] = timeInForce;
1486
1477
  }
1478
+ response = await this.privatePostOrderCreate(this.extend(request, params));
1479
+ }
1480
+ }
1481
+ else {
1482
+ if (triggerPrice !== undefined) {
1483
+ request['stop_price'] = this.priceToPrecision(symbol, triggerPrice);
1484
+ if (type === 'limit') {
1485
+ request['type'] = 'stop_limit_' + side;
1486
+ }
1487
+ else if (type === 'market') {
1488
+ request['type'] = 'stop_' + side;
1489
+ }
1490
+ else {
1491
+ request['type'] = type;
1492
+ }
1487
1493
  }
1488
1494
  else {
1489
1495
  if (type === 'limit' || type === 'market') {
@@ -1493,11 +1499,8 @@ export default class exmo extends Exchange {
1493
1499
  request['type'] = type;
1494
1500
  }
1495
1501
  }
1502
+ response = await this.privatePostMarginUserOrderCreate(this.extend(request, params));
1496
1503
  }
1497
- if (price !== undefined) {
1498
- request['price'] = this.priceToPrecision(market['symbol'], price);
1499
- }
1500
- const response = await this[method](this.extend(request, params));
1501
1504
  return this.parseOrder(response, market);
1502
1505
  }
1503
1506
  async cancelOrder(id, symbol = undefined, params = {}) {
package/js/src/kraken.js CHANGED
@@ -196,6 +196,8 @@ export default class kraken extends Exchange {
196
196
  'Withdraw': 3,
197
197
  'WithdrawCancel': 3,
198
198
  'WithdrawInfo': 3,
199
+ 'WithdrawMethods': 3,
200
+ 'WithdrawAddresses': 3,
199
201
  'WithdrawStatus': 3,
200
202
  'WalletTransfer': 3,
201
203
  // sub accounts
@@ -18,7 +18,12 @@ export default class latoken extends Exchange {
18
18
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
19
19
  parseTrade(trade: any, market?: Market): Trade;
20
20
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
21
- fetchTradingFee(symbol: string, params?: {}): Promise<any>;
21
+ fetchTradingFee(symbol: string, params?: {}): Promise<{
22
+ info: any;
23
+ symbol: string;
24
+ maker: number;
25
+ taker: number;
26
+ }>;
22
27
  fetchPublicTradingFee(symbol: string, params?: {}): Promise<{
23
28
  info: any;
24
29
  symbol: string;
package/js/src/latoken.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/latoken.js';
9
- import { ExchangeError, AuthenticationError, InvalidNonce, BadRequest, ExchangeNotAvailable, PermissionDenied, AccountSuspended, RateLimitExceeded, InsufficientFunds, BadSymbol, InvalidOrder, ArgumentsRequired } from './base/errors.js';
9
+ import { ExchangeError, AuthenticationError, InvalidNonce, BadRequest, ExchangeNotAvailable, PermissionDenied, AccountSuspended, RateLimitExceeded, InsufficientFunds, BadSymbol, InvalidOrder, ArgumentsRequired, NotSupported } from './base/errors.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  import { sha512 } from './static_dependencies/noble-hashes/sha512.js';
12
12
  // ---------------------------------------------------------------------------
@@ -829,13 +829,19 @@ export default class latoken extends Exchange {
829
829
  * @param {object} [params] extra parameters specific to the exchange API endpoint
830
830
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
831
831
  */
832
- let method = this.safeString(params, 'method');
832
+ const options = this.safeValue(this.options, 'fetchTradingFee', {});
833
+ const defaultMethod = this.safeString(options, 'method', 'fetchPrivateTradingFee');
834
+ const method = this.safeString(params, 'method', defaultMethod);
833
835
  params = this.omit(params, 'method');
834
- if (method === undefined) {
835
- const options = this.safeValue(this.options, 'fetchTradingFee', {});
836
- method = this.safeString(options, 'method', 'fetchPrivateTradingFee');
836
+ if (method === 'fetchPrivateTradingFee') {
837
+ return await this.fetchPrivateTradingFee(symbol, params);
838
+ }
839
+ else if (method === 'fetchPublicTradingFee') {
840
+ return await this.fetchPublicTradingFee(symbol, params);
841
+ }
842
+ else {
843
+ throw new NotSupported(this.id + ' not support this method');
837
844
  }
838
- return await this[method](symbol, params);
839
845
  }
840
846
  async fetchPublicTradingFee(symbol, params = {}) {
841
847
  await this.loadMarkets();
@@ -901,18 +907,20 @@ export default class latoken extends Exchange {
901
907
  // 'from': this.milliseconds (),
902
908
  // 'limit': limit, // default '100'
903
909
  };
904
- let method = 'privateGetAuthTrade';
905
910
  let market = undefined;
911
+ if (limit !== undefined) {
912
+ request['limit'] = limit; // default 100
913
+ }
914
+ let response = undefined;
906
915
  if (symbol !== undefined) {
907
916
  market = this.market(symbol);
908
917
  request['currency'] = market['baseId'];
909
918
  request['quote'] = market['quoteId'];
910
- method = 'privateGetAuthTradePairCurrencyQuote';
919
+ response = await this.privateGetAuthTradePairCurrencyQuote(this.extend(request, params));
911
920
  }
912
- if (limit !== undefined) {
913
- request['limit'] = limit; // default 100
921
+ else {
922
+ response = await this.privateGetAuthTrade(this.extend(request, params));
914
923
  }
915
- const response = await this[method](this.extend(request, params));
916
924
  //
917
925
  // [
918
926
  // {
@@ -1578,22 +1586,21 @@ export default class latoken extends Exchange {
1578
1586
  */
1579
1587
  await this.loadMarkets();
1580
1588
  const currency = this.currency(code);
1581
- let method = undefined;
1589
+ const request = {
1590
+ 'currency': currency['id'],
1591
+ 'recipient': toAccount,
1592
+ 'value': this.currencyToPrecision(code, amount),
1593
+ };
1594
+ let response = undefined;
1582
1595
  if (toAccount.indexOf('@') >= 0) {
1583
- method = 'privatePostAuthTransferEmail';
1596
+ response = await this.privatePostAuthTransferEmail(this.extend(request, params));
1584
1597
  }
1585
1598
  else if (toAccount.length === 36) {
1586
- method = 'privatePostAuthTransferId';
1599
+ response = await this.privatePostAuthTransferId(this.extend(request, params));
1587
1600
  }
1588
1601
  else {
1589
- method = 'privatePostAuthTransferPhone';
1602
+ response = await this.privatePostAuthTransferPhone(this.extend(request, params));
1590
1603
  }
1591
- const request = {
1592
- 'currency': currency['id'],
1593
- 'recipient': toAccount,
1594
- 'value': this.currencyToPrecision(code, amount),
1595
- };
1596
- const response = await this[method](this.extend(request, params));
1597
1604
  //
1598
1605
  // {
1599
1606
  // "id": "e6fc4ace-7750-44e4-b7e9-6af038ac7107",
package/js/src/okx.d.ts CHANGED
@@ -52,6 +52,8 @@ export default class okx extends Exchange {
52
52
  taker: number;
53
53
  }>;
54
54
  fetchBalance(params?: {}): Promise<Balances>;
55
+ createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
56
+ createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
55
57
  createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
56
58
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
57
59
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
package/js/src/okx.js CHANGED
@@ -38,6 +38,8 @@ export default class okx extends Exchange {
38
38
  'cancelOrder': true,
39
39
  'cancelOrders': true,
40
40
  'createDepositAddress': false,
41
+ 'createMarketBuyOrderWithCost': true,
42
+ 'createMarketSellOrderWithCost': true,
41
43
  'createOrder': true,
42
44
  'createOrders': true,
43
45
  'createPostOnlyOrder': true,
@@ -2492,6 +2494,46 @@ export default class okx extends Exchange {
2492
2494
  //
2493
2495
  return this.parseBalanceByType(marketType, response);
2494
2496
  }
2497
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
2498
+ /**
2499
+ * @method
2500
+ * @name okx#createMarketBuyOrderWithCost
2501
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
2502
+ * @description create a market buy order by providing the symbol and cost
2503
+ * @param {string} symbol unified symbol of the market to create an order in
2504
+ * @param {float} cost how much you want to trade in units of the quote currency
2505
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2506
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2507
+ */
2508
+ await this.loadMarkets();
2509
+ const market = this.market(symbol);
2510
+ if (!market['spot']) {
2511
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot markets only');
2512
+ }
2513
+ params['createMarketBuyOrderRequiresPrice'] = false;
2514
+ params['tgtCcy'] = 'quote_ccy';
2515
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
2516
+ }
2517
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
2518
+ /**
2519
+ * @method
2520
+ * @name okx#createMarketSellOrderWithCost
2521
+ * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
2522
+ * @description create a market buy order by providing the symbol and cost
2523
+ * @param {string} symbol unified symbol of the market to create an order in
2524
+ * @param {float} cost how much you want to trade in units of the quote currency
2525
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2526
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2527
+ */
2528
+ await this.loadMarkets();
2529
+ const market = this.market(symbol);
2530
+ if (!market['spot']) {
2531
+ throw new NotSupported(this.id + ' createMarketSellOrderWithCost() supports spot markets only');
2532
+ }
2533
+ params['createMarketBuyOrderRequiresPrice'] = false;
2534
+ params['tgtCcy'] = 'quote_ccy';
2535
+ return await this.createOrder(symbol, 'market', 'sell', cost, undefined, params);
2536
+ }
2495
2537
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
2496
2538
  const market = this.market(symbol);
2497
2539
  const request = {
@@ -2585,8 +2627,10 @@ export default class okx extends Exchange {
2585
2627
  // see documentation: https://www.okx.com/docs-v5/en/#rest-api-trade-place-order
2586
2628
  if (tgtCcy === 'quote_ccy') {
2587
2629
  // quote_ccy: sz refers to units of quote currency
2630
+ let createMarketBuyOrderRequiresPrice = true;
2631
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
2588
2632
  let notional = this.safeNumber2(params, 'cost', 'sz');
2589
- const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
2633
+ params = this.omit(params, ['cost', 'sz']);
2590
2634
  if (createMarketBuyOrderRequiresPrice) {
2591
2635
  if (price !== undefined) {
2592
2636
  if (notional === undefined) {
@@ -2604,7 +2648,6 @@ export default class okx extends Exchange {
2604
2648
  notional = (notional === undefined) ? amount : notional;
2605
2649
  }
2606
2650
  request['sz'] = this.costToPrecision(symbol, notional);
2607
- params = this.omit(params, ['cost', 'sz']);
2608
2651
  }
2609
2652
  }
2610
2653
  if (marketIOC && contract) {
@@ -1,5 +1,5 @@
1
1
  import cexRest from '../cex.js';
2
- import { Int, Str, Strings } from '../base/types.js';
2
+ import { Int, OrderSide, OrderType, Strings, Str } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class cex extends cexRest {
5
5
  describe(): any;
@@ -12,9 +12,11 @@ export default class cex extends cexRest {
12
12
  handleTrade(client: Client, message: any): void;
13
13
  watchTicker(symbol: string, params?: {}): Promise<any>;
14
14
  watchTickers(symbols?: Strings, params?: {}): any;
15
+ fetchTickerWs(symbol: string, params?: {}): Promise<any>;
15
16
  handleTicker(client: Client, message: any): void;
16
17
  parseWsTicker(ticker: any, market?: any): import("../base/types.js").Ticker;
17
- watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
18
+ fetchBalanceWs(params?: {}): Promise<any>;
19
+ watchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
18
20
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
19
21
  handleTransaction(client: Client, message: any): void;
20
22
  handleMyTrades(client: Client, message: any): void;
@@ -35,6 +37,13 @@ export default class cex extends cexRest {
35
37
  handleOHLCV24(client: Client, message: any): any;
36
38
  handleOHLCV1m(client: Client, message: any): void;
37
39
  handleOHLCV(client: Client, message: any): void;
40
+ fetchOrderWs(id: string, symbol?: string, params?: {}): Promise<import("../base/types.js").Order>;
41
+ fetchOpenOrdersWs(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("../base/types.js").Order[]>;
42
+ createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<import("../base/types.js").Order>;
43
+ editOrderWs(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<import("../base/types.js").Order>;
44
+ cancelOrderWs(id: string, symbol?: string, params?: {}): Promise<import("../base/types.js").Order>;
45
+ cancelOrdersWs(ids: any, symbol?: string, params?: {}): Promise<import("../base/types.js").Order[]>;
46
+ resolveData(client: Client, message: any): void;
38
47
  handleConnected(client: Client, message: any): any;
39
48
  handleErrorMessage(client: Client, message: any): void;
40
49
  handleMessage(client: Client, message: any): any;