ccxt 4.1.76 → 4.1.77

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/dist/cjs/ccxt.js CHANGED
@@ -172,7 +172,7 @@ var woo$1 = require('./src/pro/woo.js');
172
172
 
173
173
  //-----------------------------------------------------------------------------
174
174
  // this is updated by vss.js when building
175
- const version = '4.1.76';
175
+ const version = '4.1.77';
176
176
  Exchange["default"].ccxtVersion = version;
177
177
  const exchanges = {
178
178
  'ace': ace,
@@ -29,6 +29,8 @@ class bingx extends bingx$1 {
29
29
  'cancelAllOrders': true,
30
30
  'cancelOrder': true,
31
31
  'cancelOrders': true,
32
+ 'closeAllPosition': true,
33
+ 'closePosition': false,
32
34
  'createMarketBuyOrderWithCost': true,
33
35
  'createMarketOrderWithCost': true,
34
36
  'createMarketSellOrderWithCost': true,
@@ -388,6 +388,12 @@ class bitmex extends bitmex$1 {
388
388
  return this.parseNumber(finalAmount);
389
389
  }
390
390
  convertToRealAmount(code, amount) {
391
+ if (code === undefined) {
392
+ return amount;
393
+ }
394
+ else if (amount === undefined) {
395
+ return undefined;
396
+ }
391
397
  const currency = this.currency(code);
392
398
  const precision = this.safeString(currency, 'precision');
393
399
  return Precise["default"].stringMul(amount, precision);
@@ -32,6 +32,9 @@ class bitrue extends bitrue$1 {
32
32
  'option': false,
33
33
  'cancelAllOrders': true,
34
34
  'cancelOrder': true,
35
+ 'createMarketBuyOrderWithCost': true,
36
+ 'createMarketOrderWithCost': false,
37
+ 'createMarketSellOrderWithCost': false,
35
38
  'createOrder': true,
36
39
  'createStopLimitOrder': true,
37
40
  'createStopMarketOrder': true,
@@ -1886,6 +1889,26 @@ class bitrue extends bitrue$1 {
1886
1889
  'trades': fills,
1887
1890
  }, market);
1888
1891
  }
1892
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1893
+ /**
1894
+ * @method
1895
+ * @name bitrue#createMarketBuyOrderWithCost
1896
+ * @description create a market buy order by providing the symbol and cost
1897
+ * @see https://www.bitrue.com/api-docs#new-order-trade-hmac-sha256
1898
+ * @see https://www.bitrue.com/api_docs_includes_file/delivery.html#new-order-trade-hmac-sha256
1899
+ * @param {string} symbol unified symbol of the market to create an order in
1900
+ * @param {float} cost how much you want to trade in units of the quote currency
1901
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1902
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1903
+ */
1904
+ await this.loadMarkets();
1905
+ const market = this.market(symbol);
1906
+ if (!market['swap']) {
1907
+ throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports swap orders only');
1908
+ }
1909
+ params['createMarketBuyOrderRequiresPrice'] = false;
1910
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
1911
+ }
1889
1912
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1890
1913
  /**
1891
1914
  * @method
@@ -1909,6 +1932,7 @@ class bitrue extends bitrue$1 {
1909
1932
  * EXCHANGE SPECIFIC PARAMETERS
1910
1933
  * @param {decimal} [params.icebergQty]
1911
1934
  * @param {long} [params.recvWindow]
1935
+ * @param {float} [params.cost] *swap market buy only* the quote quantity that can be used as an alternative for the amount
1912
1936
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1913
1937
  */
1914
1938
  await this.loadMarkets();
@@ -1945,7 +1969,9 @@ class bitrue extends bitrue$1 {
1945
1969
  request['type'] = 'IOC';
1946
1970
  }
1947
1971
  request['contractName'] = market['id'];
1948
- if (isMarket && (side === 'buy') && (this.options['createMarketBuyOrderRequiresPrice'])) {
1972
+ let createMarketBuyOrderRequiresPrice = true;
1973
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
1974
+ if (isMarket && (side === 'buy') && createMarketBuyOrderRequiresPrice) {
1949
1975
  const cost = this.safeString(params, 'cost');
1950
1976
  params = this.omit(params, 'cost');
1951
1977
  if (price === undefined && cost === undefined) {
@@ -1039,6 +1039,7 @@ class bitstamp extends bitstamp$1 {
1039
1039
  * @method
1040
1040
  * @name bitstamp#fetchOHLCV
1041
1041
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1042
+ * @see https://www.bitstamp.net/api/#tag/Market-info/operation/GetOHLCData
1042
1043
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1043
1044
  * @param {string} timeframe the length of time each candle represents
1044
1045
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1061,7 +1062,7 @@ class bitstamp extends bitstamp$1 {
1061
1062
  limit = 1000;
1062
1063
  const start = this.parseToInt(since / 1000);
1063
1064
  request['start'] = start;
1064
- request['end'] = this.sum(start, limit * duration);
1065
+ request['end'] = this.sum(start, duration * (limit - 1));
1065
1066
  request['limit'] = limit;
1066
1067
  }
1067
1068
  }
@@ -1069,7 +1070,7 @@ class bitstamp extends bitstamp$1 {
1069
1070
  if (since !== undefined) {
1070
1071
  const start = this.parseToInt(since / 1000);
1071
1072
  request['start'] = start;
1072
- request['end'] = this.sum(start, limit * duration);
1073
+ request['end'] = this.sum(start, duration * (limit - 1));
1073
1074
  }
1074
1075
  request['limit'] = Math.min(limit, 1000); // min 1, max 1000
1075
1076
  }
@@ -41,7 +41,10 @@ class coinbase extends coinbase$1 {
41
41
  'createLimitBuyOrder': true,
42
42
  'createLimitSellOrder': true,
43
43
  'createMarketBuyOrder': true,
44
+ 'createMarketBuyOrderWithCost': true,
45
+ 'createMarketOrderWithCost': false,
44
46
  'createMarketSellOrder': true,
47
+ 'createMarketSellOrderWithCost': false,
45
48
  'createOrder': true,
46
49
  'createPostOnlyOrder': true,
47
50
  'createReduceOnlyOrder': false,
@@ -2080,6 +2083,25 @@ class coinbase extends coinbase$1 {
2080
2083
  }
2081
2084
  return request;
2082
2085
  }
2086
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
2087
+ /**
2088
+ * @method
2089
+ * @name coinbase#createMarketBuyOrderWithCost
2090
+ * @description create a market buy order by providing the symbol and cost
2091
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_postorder
2092
+ * @param {string} symbol unified symbol of the market to create an order in
2093
+ * @param {float} cost how much you want to trade in units of the quote currency
2094
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2095
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2096
+ */
2097
+ await this.loadMarkets();
2098
+ const market = this.market(symbol);
2099
+ if (!market['spot']) {
2100
+ throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
2101
+ }
2102
+ params['createMarketBuyOrderRequiresPrice'] = false;
2103
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
2104
+ }
2083
2105
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2084
2106
  /**
2085
2107
  * @method
@@ -2100,6 +2122,7 @@ class coinbase extends coinbase$1 {
2100
2122
  * @param {string} [params.timeInForce] 'GTC', 'IOC', 'GTD' or 'PO'
2101
2123
  * @param {string} [params.stop_direction] 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
2102
2124
  * @param {string} [params.end_time] '2023-05-25T17:01:05.092Z' for 'GTD' orders
2125
+ * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
2103
2126
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2104
2127
  */
2105
2128
  await this.loadMarkets();
@@ -2202,21 +2225,27 @@ class coinbase extends coinbase$1 {
2202
2225
  throw new errors.NotSupported(this.id + ' createOrder() only stop limit orders are supported');
2203
2226
  }
2204
2227
  if (side === 'buy') {
2205
- const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
2206
2228
  let total = undefined;
2207
- if (createMarketBuyOrderRequiresPrice) {
2229
+ let createMarketBuyOrderRequiresPrice = true;
2230
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
2231
+ const cost = this.safeNumber(params, 'cost');
2232
+ params = this.omit(params, 'cost');
2233
+ if (cost !== undefined) {
2234
+ total = this.costToPrecision(symbol, cost);
2235
+ }
2236
+ else if (createMarketBuyOrderRequiresPrice) {
2208
2237
  if (price === undefined) {
2209
- throw new errors.InvalidOrder(this.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
2238
+ throw new errors.InvalidOrder(this.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
2210
2239
  }
2211
2240
  else {
2212
2241
  const amountString = this.numberToString(amount);
2213
2242
  const priceString = this.numberToString(price);
2214
- const cost = this.parseNumber(Precise["default"].stringMul(amountString, priceString));
2215
- total = this.priceToPrecision(symbol, cost);
2243
+ const costRequest = Precise["default"].stringMul(amountString, priceString);
2244
+ total = this.costToPrecision(symbol, costRequest);
2216
2245
  }
2217
2246
  }
2218
2247
  else {
2219
- total = this.priceToPrecision(symbol, amount);
2248
+ total = this.costToPrecision(symbol, amount);
2220
2249
  }
2221
2250
  request['order_configuration'] = {
2222
2251
  'market_market_ioc': {
@@ -542,6 +542,7 @@ class gate extends gate$1 {
542
542
  '15m': '15m',
543
543
  '30m': '30m',
544
544
  '1h': '1h',
545
+ '2h': '2h',
545
546
  '4h': '4h',
546
547
  '8h': '8h',
547
548
  '1d': '1d',
@@ -19,7 +19,7 @@ class okx extends okx$1 {
19
19
  'name': 'OKX',
20
20
  'countries': ['CN', 'US'],
21
21
  'version': 'v5',
22
- 'rateLimit': 100,
22
+ 'rateLimit': 100 * 1.03,
23
23
  'pro': true,
24
24
  'certified': true,
25
25
  'has': {
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.75";
7
+ declare const version = "4.1.76";
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, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.76';
41
+ const version = '4.1.77';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
package/js/src/bingx.js CHANGED
@@ -32,6 +32,8 @@ export default class bingx extends Exchange {
32
32
  'cancelAllOrders': true,
33
33
  'cancelOrder': true,
34
34
  'cancelOrders': true,
35
+ 'closeAllPosition': true,
36
+ 'closePosition': false,
35
37
  'createMarketBuyOrderWithCost': true,
36
38
  'createMarketOrderWithCost': true,
37
39
  'createMarketSellOrderWithCost': true,
@@ -8,7 +8,7 @@ export default class bitmex extends Exchange {
8
8
  describe(): any;
9
9
  fetchCurrencies(params?: {}): Promise<{}>;
10
10
  convertFromRealAmount(code: any, amount: any): number;
11
- convertToRealAmount(code: string, amount: string): string;
11
+ convertToRealAmount(code: Str, amount: Str): string;
12
12
  amountToPrecision(symbol: any, amount: any): any;
13
13
  convertFromRawQuantity(symbol: any, rawQuantity: any, currencySide?: string): number;
14
14
  convertFromRawCost(symbol: any, rawQuantity: any): number;
package/js/src/bitmex.js CHANGED
@@ -391,6 +391,12 @@ export default class bitmex extends Exchange {
391
391
  return this.parseNumber(finalAmount);
392
392
  }
393
393
  convertToRealAmount(code, amount) {
394
+ if (code === undefined) {
395
+ return amount;
396
+ }
397
+ else if (amount === undefined) {
398
+ return undefined;
399
+ }
394
400
  const currency = this.currency(code);
395
401
  const precision = this.safeString(currency, 'precision');
396
402
  return Precise.stringMul(amount, precision);
@@ -33,6 +33,7 @@ export default class bitrue extends Exchange {
33
33
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
34
34
  parseOrderStatus(status: any): string;
35
35
  parseOrder(order: any, market?: Market): Order;
36
+ createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
36
37
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
37
38
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
38
39
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/bitrue.js CHANGED
@@ -35,6 +35,9 @@ export default class bitrue extends Exchange {
35
35
  'option': false,
36
36
  'cancelAllOrders': true,
37
37
  'cancelOrder': true,
38
+ 'createMarketBuyOrderWithCost': true,
39
+ 'createMarketOrderWithCost': false,
40
+ 'createMarketSellOrderWithCost': false,
38
41
  'createOrder': true,
39
42
  'createStopLimitOrder': true,
40
43
  'createStopMarketOrder': true,
@@ -1889,6 +1892,26 @@ export default class bitrue extends Exchange {
1889
1892
  'trades': fills,
1890
1893
  }, market);
1891
1894
  }
1895
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
1896
+ /**
1897
+ * @method
1898
+ * @name bitrue#createMarketBuyOrderWithCost
1899
+ * @description create a market buy order by providing the symbol and cost
1900
+ * @see https://www.bitrue.com/api-docs#new-order-trade-hmac-sha256
1901
+ * @see https://www.bitrue.com/api_docs_includes_file/delivery.html#new-order-trade-hmac-sha256
1902
+ * @param {string} symbol unified symbol of the market to create an order in
1903
+ * @param {float} cost how much you want to trade in units of the quote currency
1904
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1905
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1906
+ */
1907
+ await this.loadMarkets();
1908
+ const market = this.market(symbol);
1909
+ if (!market['swap']) {
1910
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports swap orders only');
1911
+ }
1912
+ params['createMarketBuyOrderRequiresPrice'] = false;
1913
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
1914
+ }
1892
1915
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1893
1916
  /**
1894
1917
  * @method
@@ -1912,6 +1935,7 @@ export default class bitrue extends Exchange {
1912
1935
  * EXCHANGE SPECIFIC PARAMETERS
1913
1936
  * @param {decimal} [params.icebergQty]
1914
1937
  * @param {long} [params.recvWindow]
1938
+ * @param {float} [params.cost] *swap market buy only* the quote quantity that can be used as an alternative for the amount
1915
1939
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1916
1940
  */
1917
1941
  await this.loadMarkets();
@@ -1948,7 +1972,9 @@ export default class bitrue extends Exchange {
1948
1972
  request['type'] = 'IOC';
1949
1973
  }
1950
1974
  request['contractName'] = market['id'];
1951
- if (isMarket && (side === 'buy') && (this.options['createMarketBuyOrderRequiresPrice'])) {
1975
+ let createMarketBuyOrderRequiresPrice = true;
1976
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
1977
+ if (isMarket && (side === 'buy') && createMarketBuyOrderRequiresPrice) {
1952
1978
  const cost = this.safeString(params, 'cost');
1953
1979
  params = this.omit(params, 'cost');
1954
1980
  if (price === undefined && cost === undefined) {
@@ -1042,6 +1042,7 @@ export default class bitstamp extends Exchange {
1042
1042
  * @method
1043
1043
  * @name bitstamp#fetchOHLCV
1044
1044
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1045
+ * @see https://www.bitstamp.net/api/#tag/Market-info/operation/GetOHLCData
1045
1046
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1046
1047
  * @param {string} timeframe the length of time each candle represents
1047
1048
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1064,7 +1065,7 @@ export default class bitstamp extends Exchange {
1064
1065
  limit = 1000;
1065
1066
  const start = this.parseToInt(since / 1000);
1066
1067
  request['start'] = start;
1067
- request['end'] = this.sum(start, limit * duration);
1068
+ request['end'] = this.sum(start, duration * (limit - 1));
1068
1069
  request['limit'] = limit;
1069
1070
  }
1070
1071
  }
@@ -1072,7 +1073,7 @@ export default class bitstamp extends Exchange {
1072
1073
  if (since !== undefined) {
1073
1074
  const start = this.parseToInt(since / 1000);
1074
1075
  request['start'] = start;
1075
- request['end'] = this.sum(start, limit * duration);
1076
+ request['end'] = this.sum(start, duration * (limit - 1));
1076
1077
  }
1077
1078
  request['limit'] = Math.min(limit, 1000); // min 1, max 1000
1078
1079
  }
@@ -93,6 +93,7 @@ export default class coinbase extends Exchange {
93
93
  prepareAccountRequestWithCurrencyCode(code?: Str, limit?: Int, params?: {}): Promise<{
94
94
  account_id: string;
95
95
  }>;
96
+ createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
96
97
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
97
98
  parseOrder(order: any, market?: Market): Order;
98
99
  parseOrderStatus(status: any): string;
@@ -44,7 +44,10 @@ export default class coinbase extends Exchange {
44
44
  'createLimitBuyOrder': true,
45
45
  'createLimitSellOrder': true,
46
46
  'createMarketBuyOrder': true,
47
+ 'createMarketBuyOrderWithCost': true,
48
+ 'createMarketOrderWithCost': false,
47
49
  'createMarketSellOrder': true,
50
+ 'createMarketSellOrderWithCost': false,
48
51
  'createOrder': true,
49
52
  'createPostOnlyOrder': true,
50
53
  'createReduceOnlyOrder': false,
@@ -2083,6 +2086,25 @@ export default class coinbase extends Exchange {
2083
2086
  }
2084
2087
  return request;
2085
2088
  }
2089
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
2090
+ /**
2091
+ * @method
2092
+ * @name coinbase#createMarketBuyOrderWithCost
2093
+ * @description create a market buy order by providing the symbol and cost
2094
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_postorder
2095
+ * @param {string} symbol unified symbol of the market to create an order in
2096
+ * @param {float} cost how much you want to trade in units of the quote currency
2097
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2098
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2099
+ */
2100
+ await this.loadMarkets();
2101
+ const market = this.market(symbol);
2102
+ if (!market['spot']) {
2103
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
2104
+ }
2105
+ params['createMarketBuyOrderRequiresPrice'] = false;
2106
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
2107
+ }
2086
2108
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
2087
2109
  /**
2088
2110
  * @method
@@ -2103,6 +2125,7 @@ export default class coinbase extends Exchange {
2103
2125
  * @param {string} [params.timeInForce] 'GTC', 'IOC', 'GTD' or 'PO'
2104
2126
  * @param {string} [params.stop_direction] 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
2105
2127
  * @param {string} [params.end_time] '2023-05-25T17:01:05.092Z' for 'GTD' orders
2128
+ * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
2106
2129
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2107
2130
  */
2108
2131
  await this.loadMarkets();
@@ -2205,21 +2228,27 @@ export default class coinbase extends Exchange {
2205
2228
  throw new NotSupported(this.id + ' createOrder() only stop limit orders are supported');
2206
2229
  }
2207
2230
  if (side === 'buy') {
2208
- const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
2209
2231
  let total = undefined;
2210
- if (createMarketBuyOrderRequiresPrice) {
2232
+ let createMarketBuyOrderRequiresPrice = true;
2233
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
2234
+ const cost = this.safeNumber(params, 'cost');
2235
+ params = this.omit(params, 'cost');
2236
+ if (cost !== undefined) {
2237
+ total = this.costToPrecision(symbol, cost);
2238
+ }
2239
+ else if (createMarketBuyOrderRequiresPrice) {
2211
2240
  if (price === undefined) {
2212
- throw new InvalidOrder(this.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
2241
+ throw new InvalidOrder(this.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
2213
2242
  }
2214
2243
  else {
2215
2244
  const amountString = this.numberToString(amount);
2216
2245
  const priceString = this.numberToString(price);
2217
- const cost = this.parseNumber(Precise.stringMul(amountString, priceString));
2218
- total = this.priceToPrecision(symbol, cost);
2246
+ const costRequest = Precise.stringMul(amountString, priceString);
2247
+ total = this.costToPrecision(symbol, costRequest);
2219
2248
  }
2220
2249
  }
2221
2250
  else {
2222
- total = this.priceToPrecision(symbol, amount);
2251
+ total = this.costToPrecision(symbol, amount);
2223
2252
  }
2224
2253
  request['order_configuration'] = {
2225
2254
  'market_market_ioc': {
package/js/src/gate.js CHANGED
@@ -545,6 +545,7 @@ export default class gate extends Exchange {
545
545
  '15m': '15m',
546
546
  '30m': '30m',
547
547
  '1h': '1h',
548
+ '2h': '2h',
548
549
  '4h': '4h',
549
550
  '8h': '8h',
550
551
  '1d': '1d',
package/js/src/okx.js CHANGED
@@ -22,7 +22,7 @@ export default class okx extends Exchange {
22
22
  'name': 'OKX',
23
23
  'countries': ['CN', 'US'],
24
24
  'version': 'v5',
25
- 'rateLimit': 100,
25
+ 'rateLimit': 100 * 1.03,
26
26
  'pro': true,
27
27
  'certified': true,
28
28
  'has': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.76",
3
+ "version": "4.1.77",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",