ccxt 4.1.83 → 4.1.84
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/README.md +3 -3
- package/dist/ccxt.browser.js +95 -23
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/bybit.js +3 -3
- package/dist/cjs/src/coinsph.js +19 -9
- package/dist/cjs/src/htx.js +37 -4
- package/dist/cjs/src/huobijp.js +34 -5
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/binance.js +1 -1
- package/js/src/bybit.js +3 -3
- package/js/src/coinsph.js +19 -9
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +37 -4
- package/js/src/huobijp.d.ts +1 -0
- package/js/src/huobijp.js +35 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
209
209
|
|
|
210
210
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
211
211
|
|
|
212
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.
|
|
213
|
-
* unpkg: https://unpkg.com/ccxt@4.1.
|
|
212
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.84/dist/ccxt.browser.js
|
|
213
|
+
* unpkg: https://unpkg.com/ccxt@4.1.84/dist/ccxt.browser.js
|
|
214
214
|
|
|
215
215
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
|
216
216
|
|
|
217
217
|
```HTML
|
|
218
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.
|
|
218
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.84/dist/ccxt.browser.js"></script>
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -25587,7 +25587,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25587
25587
|
extendedParams = this.omit(extendedParams, ['orderidlist', 'origclientorderidlist']);
|
|
25588
25588
|
query = this.rawencode(extendedParams);
|
|
25589
25589
|
const orderidlistLength = orderidlist.length;
|
|
25590
|
-
const origclientorderidlistLength =
|
|
25590
|
+
const origclientorderidlistLength = origclientorderidlist.length;
|
|
25591
25591
|
if (orderidlistLength > 0) {
|
|
25592
25592
|
query = query + '&' + 'orderidlist=[' + orderidlist.join(',') + ']';
|
|
25593
25593
|
}
|
|
@@ -81908,9 +81908,11 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
81908
81908
|
else if (symbolsLength === 1) {
|
|
81909
81909
|
symbol = symbols[0];
|
|
81910
81910
|
}
|
|
81911
|
+
symbols = this.marketSymbols(symbols);
|
|
81911
81912
|
}
|
|
81912
81913
|
else if (symbols !== undefined) {
|
|
81913
81914
|
symbol = symbols;
|
|
81915
|
+
symbols = [this.symbol(symbol)];
|
|
81914
81916
|
}
|
|
81915
81917
|
await this.loadMarkets();
|
|
81916
81918
|
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
@@ -81920,14 +81922,12 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
81920
81922
|
let isUsdcSettled = false;
|
|
81921
81923
|
if (symbol !== undefined) {
|
|
81922
81924
|
market = this.market(symbol);
|
|
81925
|
+
symbol = market['symbol'];
|
|
81923
81926
|
request['symbol'] = market['id'];
|
|
81924
81927
|
isUsdcSettled = market['settle'] === 'USDC';
|
|
81925
81928
|
}
|
|
81926
81929
|
let type = undefined;
|
|
81927
81930
|
[type, params] = this.getBybitType('fetchPositions', market, params);
|
|
81928
|
-
if (type === 'spot') {
|
|
81929
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' fetchPositions() not support spot market');
|
|
81930
|
-
}
|
|
81931
81931
|
if (type === 'linear' || type === 'inverse') {
|
|
81932
81932
|
const baseCoin = this.safeString(params, 'baseCoin');
|
|
81933
81933
|
if (type === 'linear') {
|
|
@@ -101222,6 +101222,9 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
101222
101222
|
'closeAllPositions': false,
|
|
101223
101223
|
'closePosition': false,
|
|
101224
101224
|
'createDepositAddress': false,
|
|
101225
|
+
'createMarketBuyOrderWithCost': true,
|
|
101226
|
+
'createMarketOrderWithCost': false,
|
|
101227
|
+
'createMarketSellOrderWithCost': false,
|
|
101225
101228
|
'createOrder': true,
|
|
101226
101229
|
'createPostOnlyOrder': false,
|
|
101227
101230
|
'createReduceOnlyOrder': false,
|
|
@@ -102249,12 +102252,14 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
102249
102252
|
* @method
|
|
102250
102253
|
* @name coinsph#createOrder
|
|
102251
102254
|
* @description create a trade order
|
|
102255
|
+
* @see https://coins-docs.github.io/rest-api/#new-order--trade
|
|
102252
102256
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
102253
102257
|
* @param {string} type 'market', 'limit', 'stop_loss', 'take_profit', 'stop_loss_limit', 'take_profit_limit' or 'limit_maker'
|
|
102254
102258
|
* @param {string} side 'buy' or 'sell'
|
|
102255
102259
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
102256
102260
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
102257
102261
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
102262
|
+
* @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount for market buy orders
|
|
102258
102263
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
102259
102264
|
*/
|
|
102260
102265
|
// todo: add test order low priority
|
|
@@ -102290,24 +102295,29 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
102290
102295
|
request['quantity'] = this.amountToPrecision(symbol, amount);
|
|
102291
102296
|
}
|
|
102292
102297
|
else if (orderSide === 'BUY') {
|
|
102293
|
-
|
|
102294
|
-
|
|
102295
|
-
|
|
102296
|
-
|
|
102298
|
+
let quoteAmount = undefined;
|
|
102299
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
102300
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
102301
|
+
const cost = this.safeNumber2(params, 'cost', 'quoteOrderQty');
|
|
102302
|
+
params = this.omit(params, 'cost');
|
|
102303
|
+
if (cost !== undefined) {
|
|
102304
|
+
quoteAmount = this.costToPrecision(symbol, cost);
|
|
102297
102305
|
}
|
|
102298
102306
|
else if (createMarketBuyOrderRequiresPrice) {
|
|
102299
102307
|
if (price === undefined) {
|
|
102300
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id +
|
|
102308
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.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');
|
|
102301
102309
|
}
|
|
102302
102310
|
else {
|
|
102303
102311
|
const amountString = this.numberToString(amount);
|
|
102304
102312
|
const priceString = this.numberToString(price);
|
|
102305
|
-
const
|
|
102306
|
-
|
|
102313
|
+
const costRequest = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString);
|
|
102314
|
+
quoteAmount = this.costToPrecision(symbol, costRequest);
|
|
102307
102315
|
}
|
|
102308
102316
|
}
|
|
102309
|
-
|
|
102310
|
-
|
|
102317
|
+
else {
|
|
102318
|
+
quoteAmount = this.costToPrecision(symbol, amount);
|
|
102319
|
+
}
|
|
102320
|
+
request['quoteOrderQty'] = quoteAmount;
|
|
102311
102321
|
}
|
|
102312
102322
|
}
|
|
102313
102323
|
if (orderType === 'STOP_LOSS' || orderType === 'STOP_LOSS_LIMIT' || orderType === 'TAKE_PROFIT' || orderType === 'TAKE_PROFIT_LIMIT') {
|
|
@@ -136645,6 +136655,9 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
136645
136655
|
'cancelOrder': true,
|
|
136646
136656
|
'cancelOrders': true,
|
|
136647
136657
|
'createDepositAddress': undefined,
|
|
136658
|
+
'createMarketBuyOrderWithCost': true,
|
|
136659
|
+
'createMarketOrderWithCost': false,
|
|
136660
|
+
'createMarketSellOrderWithCost': false,
|
|
136648
136661
|
'createOrder': true,
|
|
136649
136662
|
'createOrders': true,
|
|
136650
136663
|
'createReduceOnlyOrder': false,
|
|
@@ -141447,6 +141460,25 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
141447
141460
|
'trades': trades,
|
|
141448
141461
|
}, market);
|
|
141449
141462
|
}
|
|
141463
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
141464
|
+
/**
|
|
141465
|
+
* @method
|
|
141466
|
+
* @name htx#createMarketBuyOrderWithCost
|
|
141467
|
+
* @description create a market buy order by providing the symbol and cost
|
|
141468
|
+
* @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec4ee16-7773-11ed-9966-0242ac110003
|
|
141469
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
141470
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
141471
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
141472
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
141473
|
+
*/
|
|
141474
|
+
await this.loadMarkets();
|
|
141475
|
+
const market = this.market(symbol);
|
|
141476
|
+
if (!market['spot']) {
|
|
141477
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
141478
|
+
}
|
|
141479
|
+
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
141480
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
141481
|
+
}
|
|
141450
141482
|
async createSpotOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
141451
141483
|
/**
|
|
141452
141484
|
* @method
|
|
@@ -141460,6 +141492,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
141460
141492
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
141461
141493
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
141462
141494
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
141495
|
+
* @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount for market buy orders
|
|
141463
141496
|
* @returns {object} request to be sent to the exchange
|
|
141464
141497
|
*/
|
|
141465
141498
|
await this.loadMarkets();
|
|
@@ -141534,9 +141567,17 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
141534
141567
|
request['source'] = 'c2c-margin-api';
|
|
141535
141568
|
}
|
|
141536
141569
|
if ((orderType === 'market') && (side === 'buy')) {
|
|
141537
|
-
|
|
141570
|
+
let quoteAmount = undefined;
|
|
141571
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
141572
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
141573
|
+
const cost = this.safeNumber(params, 'cost');
|
|
141574
|
+
params = this.omit(params, 'cost');
|
|
141575
|
+
if (cost !== undefined) {
|
|
141576
|
+
quoteAmount = this.amountToPrecision(symbol, cost);
|
|
141577
|
+
}
|
|
141578
|
+
else if (createMarketBuyOrderRequiresPrice) {
|
|
141538
141579
|
if (price === undefined) {
|
|
141539
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id +
|
|
141580
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.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');
|
|
141540
141581
|
}
|
|
141541
141582
|
else {
|
|
141542
141583
|
// despite that cost = amount * price is in quote currency and should have quote precision
|
|
@@ -141547,12 +141588,13 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
141547
141588
|
// we use amountToPrecision here because the exchange requires cost in base precision
|
|
141548
141589
|
const amountString = this.numberToString(amount);
|
|
141549
141590
|
const priceString = this.numberToString(price);
|
|
141550
|
-
|
|
141591
|
+
quoteAmount = this.amountToPrecision(symbol, _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString));
|
|
141551
141592
|
}
|
|
141552
141593
|
}
|
|
141553
141594
|
else {
|
|
141554
|
-
|
|
141595
|
+
quoteAmount = this.amountToPrecision(symbol, amount);
|
|
141555
141596
|
}
|
|
141597
|
+
request['amount'] = quoteAmount;
|
|
141556
141598
|
}
|
|
141557
141599
|
else {
|
|
141558
141600
|
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
@@ -141684,6 +141726,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
141684
141726
|
* @param {bool} [params.postOnly] *contract only* true or false
|
|
141685
141727
|
* @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
|
|
141686
141728
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
141729
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
141687
141730
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
141688
141731
|
*/
|
|
141689
141732
|
await this.loadMarkets();
|
|
@@ -145403,6 +145446,9 @@ class huobijp extends _abstract_huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
145403
145446
|
'cancelAllOrders': true,
|
|
145404
145447
|
'cancelOrder': true,
|
|
145405
145448
|
'cancelOrders': true,
|
|
145449
|
+
'createMarketBuyOrderWithCost': true,
|
|
145450
|
+
'createMarketOrderWithCost': false,
|
|
145451
|
+
'createMarketSellOrderWithCost': false,
|
|
145406
145452
|
'createOrder': true,
|
|
145407
145453
|
'createStopLimitOrder': false,
|
|
145408
145454
|
'createStopMarketOrder': false,
|
|
@@ -146727,6 +146773,24 @@ class huobijp extends _abstract_huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
146727
146773
|
'trades': undefined,
|
|
146728
146774
|
}, market);
|
|
146729
146775
|
}
|
|
146776
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
146777
|
+
/**
|
|
146778
|
+
* @method
|
|
146779
|
+
* @name huobijp#createMarketBuyOrderWithCost
|
|
146780
|
+
* @description create a market buy order by providing the symbol and cost
|
|
146781
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
146782
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
146783
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
146784
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
146785
|
+
*/
|
|
146786
|
+
await this.loadMarkets();
|
|
146787
|
+
const market = this.market(symbol);
|
|
146788
|
+
if (!market['spot']) {
|
|
146789
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
146790
|
+
}
|
|
146791
|
+
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
146792
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
146793
|
+
}
|
|
146730
146794
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
146731
146795
|
/**
|
|
146732
146796
|
* @method
|
|
@@ -146759,9 +146823,17 @@ class huobijp extends _abstract_huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
146759
146823
|
}
|
|
146760
146824
|
params = this.omit(params, ['clientOrderId', 'client-order-id']);
|
|
146761
146825
|
if ((type === 'market') && (side === 'buy')) {
|
|
146762
|
-
|
|
146826
|
+
let quoteAmount = undefined;
|
|
146827
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
146828
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
146829
|
+
const cost = this.safeNumber(params, 'cost');
|
|
146830
|
+
params = this.omit(params, 'cost');
|
|
146831
|
+
if (cost !== undefined) {
|
|
146832
|
+
quoteAmount = this.amountToPrecision(symbol, cost);
|
|
146833
|
+
}
|
|
146834
|
+
else if (createMarketBuyOrderRequiresPrice) {
|
|
146763
146835
|
if (price === undefined) {
|
|
146764
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id +
|
|
146836
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.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');
|
|
146765
146837
|
}
|
|
146766
146838
|
else {
|
|
146767
146839
|
// despite that cost = amount * price is in quote currency and should have quote precision
|
|
@@ -146772,13 +146844,13 @@ class huobijp extends _abstract_huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
146772
146844
|
// we use amountToPrecision here because the exchange requires cost in base precision
|
|
146773
146845
|
const amountString = this.numberToString(amount);
|
|
146774
146846
|
const priceString = this.numberToString(price);
|
|
146775
|
-
|
|
146776
|
-
request['amount'] = this.costToPrecision(symbol, baseAmount);
|
|
146847
|
+
quoteAmount = this.amountToPrecision(symbol, _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString));
|
|
146777
146848
|
}
|
|
146778
146849
|
}
|
|
146779
146850
|
else {
|
|
146780
|
-
|
|
146851
|
+
quoteAmount = this.amountToPrecision(symbol, amount);
|
|
146781
146852
|
}
|
|
146853
|
+
request['amount'] = quoteAmount;
|
|
146782
146854
|
}
|
|
146783
146855
|
else {
|
|
146784
146856
|
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
@@ -288967,7 +289039,7 @@ SOFTWARE.
|
|
|
288967
289039
|
|
|
288968
289040
|
//-----------------------------------------------------------------------------
|
|
288969
289041
|
// this is updated by vss.js when building
|
|
288970
|
-
const version = '4.1.
|
|
289042
|
+
const version = '4.1.84';
|
|
288971
289043
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
288972
289044
|
//-----------------------------------------------------------------------------
|
|
288973
289045
|
|