ccxt 4.2.5 → 4.2.7
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 +245 -45
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +7 -2
- package/dist/cjs/src/base/errors.js +8 -1
- package/dist/cjs/src/base/ws/Client.js +4 -0
- package/dist/cjs/src/bingx.js +9 -1
- package/dist/cjs/src/bitmex.js +89 -27
- package/dist/cjs/src/htx.js +66 -1
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/woo.js +60 -11
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitmex.d.ts +20 -0
- package/js/src/base/Exchange.d.ts +1 -1
- package/js/src/base/Exchange.js +8 -3
- package/js/src/base/errorHierarchy.d.ts +1 -0
- package/js/src/base/errorHierarchy.js +1 -0
- package/js/src/base/errors.d.ts +5 -1
- package/js/src/base/errors.js +8 -2
- package/js/src/base/ws/Client.js +5 -1
- package/js/src/bingx.js +9 -1
- package/js/src/bitmex.js +89 -27
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +66 -1
- package/js/src/phemex.js +1 -1
- package/js/src/woo.js +60 -11
- 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.2.
|
|
213
|
-
* unpkg: https://unpkg.com/ccxt@4.2.
|
|
212
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.7/dist/ccxt.browser.js
|
|
213
|
+
* unpkg: https://unpkg.com/ccxt@4.2.7/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.2.
|
|
218
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.7/dist/ccxt.browser.js"></script>
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -8220,10 +8220,15 @@ class Exchange {
|
|
|
8220
8220
|
const closedClients = [];
|
|
8221
8221
|
for (let i = 0; i < clients.length; i++) {
|
|
8222
8222
|
const client = clients[i];
|
|
8223
|
-
|
|
8223
|
+
client.error = new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeClosedByUser(this.id + ' closedByUser');
|
|
8224
8224
|
closedClients.push(client.close());
|
|
8225
8225
|
}
|
|
8226
|
-
|
|
8226
|
+
await Promise.all(closedClients);
|
|
8227
|
+
for (let i = 0; i < clients.length; i++) {
|
|
8228
|
+
const client = clients[i];
|
|
8229
|
+
delete this.clients[client.url];
|
|
8230
|
+
}
|
|
8231
|
+
return;
|
|
8227
8232
|
}
|
|
8228
8233
|
async loadOrderBook(client, messageHash, symbol, limit = undefined, params = {}) {
|
|
8229
8234
|
if (!(symbol in this.orderbooks)) {
|
|
@@ -12250,6 +12255,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12250
12255
|
/* harmony export */ ContractUnavailable: () => (/* binding */ ContractUnavailable),
|
|
12251
12256
|
/* harmony export */ DDoSProtection: () => (/* binding */ DDoSProtection),
|
|
12252
12257
|
/* harmony export */ DuplicateOrderId: () => (/* binding */ DuplicateOrderId),
|
|
12258
|
+
/* harmony export */ ExchangeClosedByUser: () => (/* binding */ ExchangeClosedByUser),
|
|
12253
12259
|
/* harmony export */ ExchangeError: () => (/* binding */ ExchangeError),
|
|
12254
12260
|
/* harmony export */ ExchangeNotAvailable: () => (/* binding */ ExchangeNotAvailable),
|
|
12255
12261
|
/* harmony export */ InsufficientFunds: () => (/* binding */ InsufficientFunds),
|
|
@@ -12318,6 +12324,12 @@ class ExchangeError extends Error {
|
|
|
12318
12324
|
this.name = 'ExchangeError';
|
|
12319
12325
|
}
|
|
12320
12326
|
}
|
|
12327
|
+
class ExchangeClosedByUser extends Error {
|
|
12328
|
+
constructor(message) {
|
|
12329
|
+
super(message);
|
|
12330
|
+
this.name = 'ExchangeClosedByUser';
|
|
12331
|
+
}
|
|
12332
|
+
}
|
|
12321
12333
|
class AuthenticationError extends ExchangeError {
|
|
12322
12334
|
constructor(message) {
|
|
12323
12335
|
super(message);
|
|
@@ -12524,7 +12536,7 @@ class RequestTimeout extends NetworkError {
|
|
|
12524
12536
|
// // Derived class hierarchy
|
|
12525
12537
|
// errorHierarchy
|
|
12526
12538
|
// )
|
|
12527
|
-
const errors = { 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, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
|
|
12539
|
+
const errors = { BaseError, ExchangeClosedByUser, 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, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
|
|
12528
12540
|
|
|
12529
12541
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (errors);
|
|
12530
12542
|
|
|
@@ -14515,6 +14527,9 @@ class Client {
|
|
|
14515
14527
|
// todo: exception types for server-side disconnects
|
|
14516
14528
|
this.reset(new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.NetworkError('connection closed by remote server, closing code ' + String(event.code)));
|
|
14517
14529
|
}
|
|
14530
|
+
if (this.error instanceof _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeClosedByUser) {
|
|
14531
|
+
this.reset(this.error);
|
|
14532
|
+
}
|
|
14518
14533
|
if (this.disconnected !== undefined) {
|
|
14519
14534
|
this.disconnected.resolve(true);
|
|
14520
14535
|
}
|
|
@@ -14535,6 +14550,7 @@ class Client {
|
|
|
14535
14550
|
const future = (0,_Future_js__WEBPACK_IMPORTED_MODULE_2__/* .Future */ .o)();
|
|
14536
14551
|
if (_base_functions_js__WEBPACK_IMPORTED_MODULE_5__/* .isNode */ .UG) {
|
|
14537
14552
|
/* eslint-disable no-inner-declarations */
|
|
14553
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
14538
14554
|
function onSendComplete(error) {
|
|
14539
14555
|
if (error) {
|
|
14540
14556
|
future.reject(error);
|
|
@@ -29295,6 +29311,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
29295
29311
|
* @param {string} id order id
|
|
29296
29312
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
29297
29313
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
29314
|
+
* @param {string} [params.clientOrderId] a unique id for the order
|
|
29298
29315
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
29299
29316
|
*/
|
|
29300
29317
|
if (symbol === undefined) {
|
|
@@ -29304,8 +29321,15 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
29304
29321
|
const market = this.market(symbol);
|
|
29305
29322
|
const request = {
|
|
29306
29323
|
'symbol': market['id'],
|
|
29307
|
-
'orderId': id,
|
|
29308
29324
|
};
|
|
29325
|
+
const clientOrderId = this.safeString2(params, 'clientOrderId', 'clientOrderID');
|
|
29326
|
+
params = this.omit(params, ['clientOrderId']);
|
|
29327
|
+
if (clientOrderId !== undefined) {
|
|
29328
|
+
request['clientOrderID'] = clientOrderId;
|
|
29329
|
+
}
|
|
29330
|
+
else {
|
|
29331
|
+
request['orderId'] = id;
|
|
29332
|
+
}
|
|
29309
29333
|
let response = undefined;
|
|
29310
29334
|
const [marketType, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
|
|
29311
29335
|
if (marketType === 'spot') {
|
|
@@ -54479,6 +54503,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
54479
54503
|
'chat/connected': 5,
|
|
54480
54504
|
'chat/pinned': 5,
|
|
54481
54505
|
'funding': 5,
|
|
54506
|
+
'guild': 5,
|
|
54482
54507
|
'instrument': 5,
|
|
54483
54508
|
'instrument/active': 5,
|
|
54484
54509
|
'instrument/activeAndIndices': 5,
|
|
@@ -54507,6 +54532,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
54507
54532
|
},
|
|
54508
54533
|
'private': {
|
|
54509
54534
|
'get': {
|
|
54535
|
+
'address': 5,
|
|
54510
54536
|
'apiKey': 5,
|
|
54511
54537
|
'execution': 5,
|
|
54512
54538
|
'execution/tradeHistory': 5,
|
|
@@ -54519,21 +54545,33 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
54519
54545
|
'user/affiliateStatus': 5,
|
|
54520
54546
|
'user/checkReferralCode': 5,
|
|
54521
54547
|
'user/commission': 5,
|
|
54548
|
+
'user/csa': 5,
|
|
54522
54549
|
'user/depositAddress': 5,
|
|
54523
54550
|
'user/executionHistory': 5,
|
|
54551
|
+
'user/getWalletTransferAccounts': 5,
|
|
54524
54552
|
'user/margin': 5,
|
|
54525
54553
|
'user/quoteFillRatio': 5,
|
|
54526
54554
|
'user/quoteValueRatio': 5,
|
|
54555
|
+
'user/staking': 5,
|
|
54556
|
+
'user/staking/instruments': 5,
|
|
54557
|
+
'user/staking/tiers': 5,
|
|
54527
54558
|
'user/tradingVolume': 5,
|
|
54559
|
+
'user/unstakingRequests': 5,
|
|
54528
54560
|
'user/wallet': 5,
|
|
54529
54561
|
'user/walletHistory': 5,
|
|
54530
54562
|
'user/walletSummary': 5,
|
|
54563
|
+
'userAffiliates': 5,
|
|
54531
54564
|
'userEvent': 5,
|
|
54532
54565
|
},
|
|
54533
54566
|
'post': {
|
|
54567
|
+
'address': 5,
|
|
54534
54568
|
'chat': 5,
|
|
54569
|
+
'guild': 5,
|
|
54570
|
+
'guild/archive': 5,
|
|
54535
54571
|
'guild/join': 5,
|
|
54572
|
+
'guild/kick': 5,
|
|
54536
54573
|
'guild/leave': 5,
|
|
54574
|
+
'guild/sharesTrades': 5,
|
|
54537
54575
|
'order': 1,
|
|
54538
54576
|
'order/cancelAllAfter': 5,
|
|
54539
54577
|
'order/closePosition': 5,
|
|
@@ -54541,6 +54579,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
54541
54579
|
'position/leverage': 1,
|
|
54542
54580
|
'position/riskLimit': 5,
|
|
54543
54581
|
'position/transferMargin': 1,
|
|
54582
|
+
'user/addSubaccount': 5,
|
|
54544
54583
|
'user/cancelWithdrawal': 5,
|
|
54545
54584
|
'user/communicationToken': 5,
|
|
54546
54585
|
'user/confirmEmail': 5,
|
|
@@ -54548,13 +54587,18 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
54548
54587
|
'user/logout': 5,
|
|
54549
54588
|
'user/preferences': 5,
|
|
54550
54589
|
'user/requestWithdrawal': 5,
|
|
54590
|
+
'user/unstakingRequests': 5,
|
|
54591
|
+
'user/updateSubaccount': 5,
|
|
54592
|
+
'user/walletTransfer': 5,
|
|
54551
54593
|
},
|
|
54552
54594
|
'put': {
|
|
54595
|
+
'guild': 5,
|
|
54553
54596
|
'order': 1,
|
|
54554
54597
|
},
|
|
54555
54598
|
'delete': {
|
|
54556
54599
|
'order': 1,
|
|
54557
54600
|
'order/all': 1,
|
|
54601
|
+
'user/unstakingRequests': 5,
|
|
54558
54602
|
},
|
|
54559
54603
|
},
|
|
54560
54604
|
},
|
|
@@ -55942,13 +55986,11 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
55942
55986
|
let fee = undefined;
|
|
55943
55987
|
const feeCostString = this.numberToString(this.convertFromRawCost(symbol, this.safeString(trade, 'execComm')));
|
|
55944
55988
|
if (feeCostString !== undefined) {
|
|
55945
|
-
const currencyId = this.
|
|
55946
|
-
const feeCurrencyCode = this.safeCurrencyCode(currencyId);
|
|
55947
|
-
const feeRateString = this.safeString(trade, 'commission');
|
|
55989
|
+
const currencyId = this.safeString2(trade, 'settlCurrency', 'currency');
|
|
55948
55990
|
fee = {
|
|
55949
|
-
'cost':
|
|
55950
|
-
'currency':
|
|
55951
|
-
'rate':
|
|
55991
|
+
'cost': feeCostString,
|
|
55992
|
+
'currency': this.safeCurrencyCode(currencyId),
|
|
55993
|
+
'rate': this.safeString(trade, 'commission'),
|
|
55952
55994
|
};
|
|
55953
55995
|
}
|
|
55954
55996
|
// Trade or Funding
|
|
@@ -56183,14 +56225,15 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
56183
56225
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
56184
56226
|
* @param {object} [params.triggerPrice] the price at which a trigger order is triggered at
|
|
56185
56227
|
* @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'above' or 'below'
|
|
56228
|
+
* @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
56186
56229
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
56187
56230
|
*/
|
|
56188
56231
|
await this.loadMarkets();
|
|
56189
56232
|
const market = this.market(symbol);
|
|
56190
|
-
|
|
56233
|
+
let orderType = this.capitalize(type);
|
|
56191
56234
|
const reduceOnly = this.safeValue(params, 'reduceOnly');
|
|
56192
56235
|
if (reduceOnly !== undefined) {
|
|
56193
|
-
if ((market['
|
|
56236
|
+
if ((!market['swap']) && (!market['future'])) {
|
|
56194
56237
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap and future markets only');
|
|
56195
56238
|
}
|
|
56196
56239
|
}
|
|
@@ -56203,44 +56246,54 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
56203
56246
|
'ordType': orderType,
|
|
56204
56247
|
'text': brokerId,
|
|
56205
56248
|
};
|
|
56206
|
-
const customTriggerType = (orderType === 'Stop') || (orderType === 'StopLimit') || (orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched');
|
|
56207
56249
|
// support for unified trigger format
|
|
56208
56250
|
const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPx', 'stopPrice']);
|
|
56209
|
-
|
|
56210
|
-
|
|
56251
|
+
let trailingAmount = this.safeString2(params, 'trailingAmount', 'pegOffsetValue');
|
|
56252
|
+
const isTriggerOrder = triggerPrice !== undefined;
|
|
56253
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
56254
|
+
if (isTriggerOrder || isTrailingAmountOrder) {
|
|
56211
56255
|
const triggerDirection = this.safeString(params, 'triggerDirection');
|
|
56212
|
-
params = this.omit(params, ['triggerPrice', 'stopPrice', 'stopPx', 'triggerDirection']);
|
|
56213
56256
|
const triggerAbove = (triggerDirection === 'above');
|
|
56214
|
-
|
|
56215
|
-
|
|
56257
|
+
if ((type === 'limit') || (type === 'market')) {
|
|
56258
|
+
this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
|
|
56259
|
+
}
|
|
56216
56260
|
if (type === 'limit') {
|
|
56217
|
-
request['price'] = parseFloat(this.priceToPrecision(symbol, price));
|
|
56218
56261
|
if (side === 'buy') {
|
|
56219
|
-
|
|
56262
|
+
orderType = triggerAbove ? 'StopLimit' : 'LimitIfTouched';
|
|
56220
56263
|
}
|
|
56221
56264
|
else {
|
|
56222
|
-
|
|
56265
|
+
orderType = triggerAbove ? 'LimitIfTouched' : 'StopLimit';
|
|
56223
56266
|
}
|
|
56224
56267
|
}
|
|
56225
56268
|
else if (type === 'market') {
|
|
56226
56269
|
if (side === 'buy') {
|
|
56227
|
-
|
|
56270
|
+
orderType = triggerAbove ? 'Stop' : 'MarketIfTouched';
|
|
56228
56271
|
}
|
|
56229
56272
|
else {
|
|
56230
|
-
|
|
56273
|
+
orderType = triggerAbove ? 'MarketIfTouched' : 'Stop';
|
|
56231
56274
|
}
|
|
56232
56275
|
}
|
|
56233
|
-
|
|
56234
|
-
|
|
56235
|
-
|
|
56236
|
-
|
|
56237
|
-
|
|
56276
|
+
if (isTrailingAmountOrder) {
|
|
56277
|
+
const isStopSellOrder = (side === 'sell') && ((orderType === 'Stop') || (orderType === 'StopLimit'));
|
|
56278
|
+
const isBuyIfTouchedOrder = (side === 'buy') && ((orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched'));
|
|
56279
|
+
if (isStopSellOrder || isBuyIfTouchedOrder) {
|
|
56280
|
+
trailingAmount = '-' + trailingAmount;
|
|
56281
|
+
}
|
|
56282
|
+
request['pegOffsetValue'] = this.parseToNumeric(trailingAmount);
|
|
56283
|
+
request['pegPriceType'] = 'TrailingStopPeg';
|
|
56284
|
+
}
|
|
56285
|
+
else {
|
|
56286
|
+
if (triggerPrice === undefined) {
|
|
56287
|
+
// if exchange specific trigger types were provided
|
|
56288
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder() requires a triggerPrice (stopPx|stopPrice) parameter for the ' + orderType + ' order type');
|
|
56289
|
+
}
|
|
56290
|
+
request['stopPx'] = this.parseToNumeric(this.priceToPrecision(symbol, triggerPrice));
|
|
56238
56291
|
}
|
|
56239
|
-
|
|
56240
|
-
|
|
56292
|
+
request['ordType'] = orderType;
|
|
56293
|
+
params = this.omit(params, ['triggerPrice', 'stopPrice', 'stopPx', 'triggerDirection', 'trailingAmount']);
|
|
56241
56294
|
}
|
|
56242
56295
|
if ((orderType === 'Limit') || (orderType === 'StopLimit') || (orderType === 'LimitIfTouched')) {
|
|
56243
|
-
request['price'] =
|
|
56296
|
+
request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
|
|
56244
56297
|
}
|
|
56245
56298
|
const clientOrderId = this.safeString2(params, 'clOrdID', 'clientOrderId');
|
|
56246
56299
|
if (clientOrderId !== undefined) {
|
|
@@ -56253,6 +56306,39 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
56253
56306
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
56254
56307
|
await this.loadMarkets();
|
|
56255
56308
|
const request = {};
|
|
56309
|
+
let trailingAmount = this.safeString2(params, 'trailingAmount', 'pegOffsetValue');
|
|
56310
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
56311
|
+
if (isTrailingAmountOrder) {
|
|
56312
|
+
const triggerDirection = this.safeString(params, 'triggerDirection');
|
|
56313
|
+
const triggerAbove = (triggerDirection === 'above');
|
|
56314
|
+
if ((type === 'limit') || (type === 'market')) {
|
|
56315
|
+
this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
|
|
56316
|
+
}
|
|
56317
|
+
let orderType = undefined;
|
|
56318
|
+
if (type === 'limit') {
|
|
56319
|
+
if (side === 'buy') {
|
|
56320
|
+
orderType = triggerAbove ? 'StopLimit' : 'LimitIfTouched';
|
|
56321
|
+
}
|
|
56322
|
+
else {
|
|
56323
|
+
orderType = triggerAbove ? 'LimitIfTouched' : 'StopLimit';
|
|
56324
|
+
}
|
|
56325
|
+
}
|
|
56326
|
+
else if (type === 'market') {
|
|
56327
|
+
if (side === 'buy') {
|
|
56328
|
+
orderType = triggerAbove ? 'Stop' : 'MarketIfTouched';
|
|
56329
|
+
}
|
|
56330
|
+
else {
|
|
56331
|
+
orderType = triggerAbove ? 'MarketIfTouched' : 'Stop';
|
|
56332
|
+
}
|
|
56333
|
+
}
|
|
56334
|
+
const isStopSellOrder = (side === 'sell') && ((orderType === 'Stop') || (orderType === 'StopLimit'));
|
|
56335
|
+
const isBuyIfTouchedOrder = (side === 'buy') && ((orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched'));
|
|
56336
|
+
if (isStopSellOrder || isBuyIfTouchedOrder) {
|
|
56337
|
+
trailingAmount = '-' + trailingAmount;
|
|
56338
|
+
}
|
|
56339
|
+
request['pegOffsetValue'] = this.parseToNumeric(trailingAmount);
|
|
56340
|
+
params = this.omit(params, ['triggerDirection', 'trailingAmount']);
|
|
56341
|
+
}
|
|
56256
56342
|
const origClOrdID = this.safeString2(params, 'origClOrdID', 'clientOrderId');
|
|
56257
56343
|
if (origClOrdID !== undefined) {
|
|
56258
56344
|
request['origClOrdID'] = origClOrdID;
|
|
@@ -138822,7 +138908,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
138822
138908
|
'repayIsolatedMargin': true,
|
|
138823
138909
|
'setLeverage': true,
|
|
138824
138910
|
'setMarginMode': false,
|
|
138825
|
-
'setPositionMode':
|
|
138911
|
+
'setPositionMode': true,
|
|
138826
138912
|
'signIn': undefined,
|
|
138827
138913
|
'transfer': true,
|
|
138828
138914
|
'withdraw': true,
|
|
@@ -147659,6 +147745,71 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
147659
147745
|
'datetime': this.iso8601(timestamp),
|
|
147660
147746
|
});
|
|
147661
147747
|
}
|
|
147748
|
+
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
147749
|
+
/**
|
|
147750
|
+
* @method
|
|
147751
|
+
* @name htx#setPositionMode
|
|
147752
|
+
* @description set hedged to true or false
|
|
147753
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
|
|
147754
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-position-mode
|
|
147755
|
+
* @param {bool} hedged set to true to for hedged mode, must be set separately for each market in isolated margin mode, only valid for linear markets
|
|
147756
|
+
* @param {string} [symbol] unified market symbol, required for isolated margin mode
|
|
147757
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
147758
|
+
* @param {string} [params.marginMode] "cross" (default) or "isolated"
|
|
147759
|
+
* @returns {object} response from the exchange
|
|
147760
|
+
*/
|
|
147761
|
+
await this.loadMarkets();
|
|
147762
|
+
const posMode = hedged ? 'dual_side' : 'single_side';
|
|
147763
|
+
let market = undefined;
|
|
147764
|
+
if (symbol !== undefined) {
|
|
147765
|
+
market = this.market(symbol);
|
|
147766
|
+
}
|
|
147767
|
+
let marginMode = undefined;
|
|
147768
|
+
[marginMode, params] = this.handleMarginModeAndParams('setPositionMode', params, 'cross');
|
|
147769
|
+
const request = {
|
|
147770
|
+
'position_mode': posMode,
|
|
147771
|
+
};
|
|
147772
|
+
let response = undefined;
|
|
147773
|
+
if ((market !== undefined) && (market['inverse'])) {
|
|
147774
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' setPositionMode can only be used for linear markets');
|
|
147775
|
+
}
|
|
147776
|
+
if (marginMode === 'isolated') {
|
|
147777
|
+
if (symbol === undefined) {
|
|
147778
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setPositionMode requires a symbol argument for isolated margin mode');
|
|
147779
|
+
}
|
|
147780
|
+
request['margin_account'] = market['id'];
|
|
147781
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapSwitchPositionMode(this.extend(request, params));
|
|
147782
|
+
//
|
|
147783
|
+
// {
|
|
147784
|
+
// "status": "ok",
|
|
147785
|
+
// "data": [
|
|
147786
|
+
// {
|
|
147787
|
+
// "margin_account": "BTC-USDT",
|
|
147788
|
+
// "position_mode": "single_side"
|
|
147789
|
+
// }
|
|
147790
|
+
// ],
|
|
147791
|
+
// "ts": 1566899973811
|
|
147792
|
+
// }
|
|
147793
|
+
//
|
|
147794
|
+
}
|
|
147795
|
+
else {
|
|
147796
|
+
request['margin_account'] = 'USDT';
|
|
147797
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossSwitchPositionMode(this.extend(request, params));
|
|
147798
|
+
//
|
|
147799
|
+
// {
|
|
147800
|
+
// "status": "ok",
|
|
147801
|
+
// "data": [
|
|
147802
|
+
// {
|
|
147803
|
+
// "margin_account": "USDT",
|
|
147804
|
+
// "position_mode": "single_side"
|
|
147805
|
+
// }
|
|
147806
|
+
// ],
|
|
147807
|
+
// "ts": 1566899973811
|
|
147808
|
+
// }
|
|
147809
|
+
//
|
|
147810
|
+
}
|
|
147811
|
+
return response;
|
|
147812
|
+
}
|
|
147662
147813
|
}
|
|
147663
147814
|
|
|
147664
147815
|
|
|
@@ -198461,7 +198612,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
198461
198612
|
},
|
|
198462
198613
|
},
|
|
198463
198614
|
'options': {
|
|
198464
|
-
'brokerId': '
|
|
198615
|
+
'brokerId': 'CCXT',
|
|
198465
198616
|
'x-phemex-request-expiry': 60,
|
|
198466
198617
|
'createOrderByQuoteRequiresPrice': true,
|
|
198467
198618
|
'networks': {
|
|
@@ -280303,9 +280454,9 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280303
280454
|
/**
|
|
280304
280455
|
* @method
|
|
280305
280456
|
* @name woo#createOrder
|
|
280457
|
+
* @description create a trade order
|
|
280306
280458
|
* @see https://docs.woo.org/#send-order
|
|
280307
280459
|
* @see https://docs.woo.org/#send-algo-order
|
|
280308
|
-
* @description create a trade order
|
|
280309
280460
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
280310
280461
|
* @param {string} type 'market' or 'limit'
|
|
280311
280462
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -280319,6 +280470,9 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280319
280470
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
280320
280471
|
* @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
|
|
280321
280472
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
280473
|
+
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
280474
|
+
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
280475
|
+
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
280322
280476
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
280323
280477
|
*/
|
|
280324
280478
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
|
|
@@ -280335,7 +280489,13 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280335
280489
|
const stopLoss = this.safeValue(params, 'stopLoss');
|
|
280336
280490
|
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
280337
280491
|
const algoType = this.safeString(params, 'algoType');
|
|
280338
|
-
const
|
|
280492
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
|
|
280493
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
|
|
280494
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
280495
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
280496
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
280497
|
+
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
|
|
280498
|
+
const isStop = isTrailing || stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
|
|
280339
280499
|
const isMarket = orderType === 'MARKET';
|
|
280340
280500
|
const timeInForce = this.safeStringLower(params, 'timeInForce');
|
|
280341
280501
|
const postOnly = this.isPostOnly(isMarket, undefined, params);
|
|
@@ -280400,7 +280560,21 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280400
280560
|
if (clientOrderId !== undefined) {
|
|
280401
280561
|
request[clientOrderIdKey] = clientOrderId;
|
|
280402
280562
|
}
|
|
280403
|
-
if (
|
|
280563
|
+
if (isTrailing) {
|
|
280564
|
+
if (trailingTriggerPrice === undefined) {
|
|
280565
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder() requires a trailingTriggerPrice parameter for trailing orders');
|
|
280566
|
+
}
|
|
280567
|
+
request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
280568
|
+
request['algoType'] = 'TRAILING_STOP';
|
|
280569
|
+
if (isTrailingAmountOrder) {
|
|
280570
|
+
request['callbackValue'] = trailingAmount;
|
|
280571
|
+
}
|
|
280572
|
+
else if (isTrailingPercentOrder) {
|
|
280573
|
+
const convertedTrailingPercent = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
|
|
280574
|
+
request['callbackRate'] = convertedTrailingPercent;
|
|
280575
|
+
}
|
|
280576
|
+
}
|
|
280577
|
+
else if (stopPrice !== undefined) {
|
|
280404
280578
|
if (algoType !== 'TRAILING_STOP') {
|
|
280405
280579
|
request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
|
|
280406
280580
|
request['algoType'] = 'STOP';
|
|
@@ -280439,7 +280613,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280439
280613
|
}
|
|
280440
280614
|
request['childOrders'] = [outterOrder];
|
|
280441
280615
|
}
|
|
280442
|
-
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit']);
|
|
280616
|
+
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingPercent', 'trailingAmount', 'trailingTriggerPrice']);
|
|
280443
280617
|
let response = undefined;
|
|
280444
280618
|
if (isStop) {
|
|
280445
280619
|
response = await this.v3PrivatePostAlgoOrder(this.extend(request, params));
|
|
@@ -280485,11 +280659,11 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280485
280659
|
/**
|
|
280486
280660
|
* @method
|
|
280487
280661
|
* @name woo#editOrder
|
|
280662
|
+
* @description edit a trade order
|
|
280488
280663
|
* @see https://docs.woo.org/#edit-order
|
|
280489
280664
|
* @see https://docs.woo.org/#edit-order-by-client_order_id
|
|
280490
280665
|
* @see https://docs.woo.org/#edit-algo-order
|
|
280491
280666
|
* @see https://docs.woo.org/#edit-algo-order-by-client_order_id
|
|
280492
|
-
* @description edit a trade order
|
|
280493
280667
|
* @param {string} id order id
|
|
280494
280668
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
280495
280669
|
* @param {string} type 'market' or 'limit'
|
|
@@ -280500,6 +280674,9 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280500
280674
|
* @param {float} [params.triggerPrice] The price a trigger order is triggered at
|
|
280501
280675
|
* @param {float} [params.stopLossPrice] price to trigger stop-loss orders
|
|
280502
280676
|
* @param {float} [params.takeProfitPrice] price to trigger take-profit orders
|
|
280677
|
+
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
280678
|
+
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
280679
|
+
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
280503
280680
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
280504
280681
|
*/
|
|
280505
280682
|
await this.loadMarkets();
|
|
@@ -280521,8 +280698,26 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280521
280698
|
if (stopPrice !== undefined) {
|
|
280522
280699
|
request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
|
|
280523
280700
|
}
|
|
280524
|
-
|
|
280525
|
-
const
|
|
280701
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
|
|
280702
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
|
|
280703
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
280704
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
280705
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
280706
|
+
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
|
|
280707
|
+
if (isTrailing) {
|
|
280708
|
+
if (trailingTriggerPrice !== undefined) {
|
|
280709
|
+
request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
280710
|
+
}
|
|
280711
|
+
if (isTrailingAmountOrder) {
|
|
280712
|
+
request['callbackValue'] = trailingAmount;
|
|
280713
|
+
}
|
|
280714
|
+
else if (isTrailingPercentOrder) {
|
|
280715
|
+
const convertedTrailingPercent = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(trailingPercent, '100');
|
|
280716
|
+
request['callbackRate'] = convertedTrailingPercent;
|
|
280717
|
+
}
|
|
280718
|
+
}
|
|
280719
|
+
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice', 'trailingTriggerPrice', 'trailingAmount', 'trailingPercent']);
|
|
280720
|
+
const isStop = isTrailing || (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
|
|
280526
280721
|
let response = undefined;
|
|
280527
280722
|
if (isByClientOrder) {
|
|
280528
280723
|
request['client_order_id'] = clientOrderIdExchangeSpecific;
|
|
@@ -280722,9 +280917,9 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280722
280917
|
/**
|
|
280723
280918
|
* @method
|
|
280724
280919
|
* @name woo#fetchOrders
|
|
280920
|
+
* @description fetches information on multiple orders made by the user
|
|
280725
280921
|
* @see https://docs.woo.org/#get-orders
|
|
280726
280922
|
* @see https://docs.woo.org/#get-algo-orders
|
|
280727
|
-
* @description fetches information on multiple orders made by the user
|
|
280728
280923
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
280729
280924
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
280730
280925
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -280732,19 +280927,21 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280732
280927
|
* @param {boolean} [params.stop] whether the order is a stop/algo order
|
|
280733
280928
|
* @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
|
|
280734
280929
|
* @param {string} [params.side] 'buy' or 'sell'
|
|
280930
|
+
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
|
280735
280931
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
280736
280932
|
*/
|
|
280737
280933
|
await this.loadMarkets();
|
|
280738
280934
|
const request = {};
|
|
280739
280935
|
let market = undefined;
|
|
280740
280936
|
const stop = this.safeValue(params, 'stop');
|
|
280741
|
-
|
|
280937
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
280938
|
+
params = this.omit(params, ['stop', 'trailing']);
|
|
280742
280939
|
if (symbol !== undefined) {
|
|
280743
280940
|
market = this.market(symbol);
|
|
280744
280941
|
request['symbol'] = market['id'];
|
|
280745
280942
|
}
|
|
280746
280943
|
if (since !== undefined) {
|
|
280747
|
-
if (stop) {
|
|
280944
|
+
if (stop || trailing) {
|
|
280748
280945
|
request['createdTimeStart'] = since;
|
|
280749
280946
|
}
|
|
280750
280947
|
else {
|
|
@@ -280754,8 +280951,11 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
280754
280951
|
if (stop) {
|
|
280755
280952
|
request['algoType'] = 'stop';
|
|
280756
280953
|
}
|
|
280954
|
+
else if (trailing) {
|
|
280955
|
+
request['algoType'] = 'TRAILING_STOP';
|
|
280956
|
+
}
|
|
280757
280957
|
let response = undefined;
|
|
280758
|
-
if (stop) {
|
|
280958
|
+
if (stop || trailing) {
|
|
280759
280959
|
response = await this.v3PrivateGetAlgoOrders(this.extend(request, params));
|
|
280760
280960
|
}
|
|
280761
280961
|
else {
|
|
@@ -291718,7 +291918,7 @@ SOFTWARE.
|
|
|
291718
291918
|
|
|
291719
291919
|
//-----------------------------------------------------------------------------
|
|
291720
291920
|
// this is updated by vss.js when building
|
|
291721
|
-
const version = '4.2.
|
|
291921
|
+
const version = '4.2.7';
|
|
291722
291922
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
291723
291923
|
//-----------------------------------------------------------------------------
|
|
291724
291924
|
|