ccxt 4.0.109 → 4.0.111
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 +225 -78
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +2 -1
- package/dist/cjs/src/bitget.js +1 -0
- package/dist/cjs/src/bitmart.js +124 -47
- package/dist/cjs/src/bybit.js +53 -7
- package/dist/cjs/src/phemex.js +45 -23
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bybit.d.ts +2 -0
- package/js/src/binance.js +2 -1
- package/js/src/bitget.js +1 -0
- package/js/src/bitmart.js +124 -47
- package/js/src/bybit.js +53 -7
- package/js/src/phemex.js +45 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -214,13 +214,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
214
214
|
|
|
215
215
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
216
216
|
|
|
217
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.
|
|
218
|
-
* unpkg: https://unpkg.com/ccxt@4.0.
|
|
217
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.111/dist/ccxt.browser.js
|
|
218
|
+
* unpkg: https://unpkg.com/ccxt@4.0.111/dist/ccxt.browser.js
|
|
219
219
|
|
|
220
220
|
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.
|
|
221
221
|
|
|
222
222
|
```HTML
|
|
223
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.
|
|
223
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.111/dist/ccxt.browser.js"></script>
|
|
224
224
|
```
|
|
225
225
|
|
|
226
226
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -15742,7 +15742,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
15742
15742
|
'fetchFundingRateHistory': true,
|
|
15743
15743
|
'fetchFundingRates': true,
|
|
15744
15744
|
'fetchIndexOHLCV': true,
|
|
15745
|
-
'fetchL3OrderBook':
|
|
15745
|
+
'fetchL3OrderBook': false,
|
|
15746
15746
|
'fetchLastPrices': true,
|
|
15747
15747
|
'fetchLedger': true,
|
|
15748
15748
|
'fetchLeverage': false,
|
|
@@ -15781,6 +15781,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
15781
15781
|
'fetchTransfers': true,
|
|
15782
15782
|
'fetchUnderlyingAssets': false,
|
|
15783
15783
|
'fetchVolatilityHistory': false,
|
|
15784
|
+
'fetchWithdrawAddresses': false,
|
|
15784
15785
|
'fetchWithdrawal': false,
|
|
15785
15786
|
'fetchWithdrawals': true,
|
|
15786
15787
|
'fetchWithdrawalWhitelist': false,
|
|
@@ -38471,6 +38472,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
38471
38472
|
'40712': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InsufficientFunds,
|
|
38472
38473
|
'40713': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
|
|
38473
38474
|
'40714': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
|
|
38475
|
+
'40768': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.OrderNotFound,
|
|
38474
38476
|
'41114': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.OnMaintenance,
|
|
38475
38477
|
'43011': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
|
|
38476
38478
|
'43025': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
|
|
@@ -45156,7 +45158,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
45156
45158
|
// "type": "buy"
|
|
45157
45159
|
// }
|
|
45158
45160
|
//
|
|
45159
|
-
//
|
|
45161
|
+
// spot: fetchMyTrades
|
|
45160
45162
|
//
|
|
45161
45163
|
// {
|
|
45162
45164
|
// "tradeId":"182342999769370687",
|
|
@@ -45175,28 +45177,42 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
45175
45177
|
// "createTime":1695658457836,
|
|
45176
45178
|
// }
|
|
45177
45179
|
//
|
|
45178
|
-
|
|
45179
|
-
|
|
45180
|
-
|
|
45181
|
-
|
|
45180
|
+
// swap: fetchMyTrades
|
|
45181
|
+
//
|
|
45182
|
+
// {
|
|
45183
|
+
// "order_id": "230930336848609",
|
|
45184
|
+
// "trade_id": "6212604014",
|
|
45185
|
+
// "symbol": "BTCUSDT",
|
|
45186
|
+
// "side": 3,
|
|
45187
|
+
// "price": "26910.4",
|
|
45188
|
+
// "vol": "1",
|
|
45189
|
+
// "exec_type": "Taker",
|
|
45190
|
+
// "profit": false,
|
|
45191
|
+
// "create_time": 1695961596692,
|
|
45192
|
+
// "realised_profit": "-0.0003",
|
|
45193
|
+
// "paid_fees": "0.01614624"
|
|
45194
|
+
// }
|
|
45195
|
+
//
|
|
45196
|
+
const timestamp = this.safeIntegerN(trade, ['order_time', 'createTime', 'create_time']);
|
|
45182
45197
|
const isPublicTrade = ('order_time' in trade);
|
|
45183
|
-
const price = this.safeString(trade, 'price');
|
|
45184
45198
|
let amount = undefined;
|
|
45185
45199
|
let cost = undefined;
|
|
45186
45200
|
let type = undefined;
|
|
45201
|
+
let side = undefined;
|
|
45187
45202
|
if (isPublicTrade) {
|
|
45188
45203
|
amount = this.safeString(trade, 'count');
|
|
45189
45204
|
cost = this.safeString(trade, 'amount');
|
|
45205
|
+
side = this.safeString(trade, 'type');
|
|
45190
45206
|
}
|
|
45191
45207
|
else {
|
|
45192
|
-
amount = this.
|
|
45208
|
+
amount = this.safeString2(trade, 'size', 'vol');
|
|
45193
45209
|
cost = this.safeString(trade, 'notional');
|
|
45194
45210
|
type = this.safeString(trade, 'type');
|
|
45211
|
+
side = this.parseOrderSide(this.safeString(trade, 'side'));
|
|
45195
45212
|
}
|
|
45196
|
-
const orderId = this.safeString(trade, 'orderId');
|
|
45197
45213
|
const marketId = this.safeString(trade, 'symbol');
|
|
45198
|
-
market = this.safeMarket(marketId, market
|
|
45199
|
-
const feeCostString = this.
|
|
45214
|
+
market = this.safeMarket(marketId, market);
|
|
45215
|
+
const feeCostString = this.safeString2(trade, 'fee', 'paid_fees');
|
|
45200
45216
|
let fee = undefined;
|
|
45201
45217
|
if (feeCostString !== undefined) {
|
|
45202
45218
|
const feeCurrencyId = this.safeString(trade, 'feeCoinName');
|
|
@@ -45211,17 +45227,17 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
45211
45227
|
}
|
|
45212
45228
|
return this.safeTrade({
|
|
45213
45229
|
'info': trade,
|
|
45214
|
-
'id':
|
|
45215
|
-
'order': orderId,
|
|
45230
|
+
'id': this.safeString2(trade, 'tradeId', 'trade_id'),
|
|
45231
|
+
'order': this.safeString2(trade, 'orderId', 'order_id'),
|
|
45216
45232
|
'timestamp': timestamp,
|
|
45217
45233
|
'datetime': this.iso8601(timestamp),
|
|
45218
45234
|
'symbol': market['symbol'],
|
|
45219
45235
|
'type': type,
|
|
45220
45236
|
'side': side,
|
|
45221
|
-
'price': price,
|
|
45237
|
+
'price': this.safeString(trade, 'price'),
|
|
45222
45238
|
'amount': amount,
|
|
45223
45239
|
'cost': cost,
|
|
45224
|
-
'takerOrMaker':
|
|
45240
|
+
'takerOrMaker': this.safeStringLower2(trade, 'tradeRole', 'exec_type'),
|
|
45225
45241
|
'fee': fee,
|
|
45226
45242
|
}, market);
|
|
45227
45243
|
}
|
|
@@ -45424,6 +45440,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
45424
45440
|
* @method
|
|
45425
45441
|
* @name bitmart#fetchMyTrades
|
|
45426
45442
|
* @see https://developer-pro.bitmart.com/en/spot/#account-trade-list-v4-signed
|
|
45443
|
+
* @see https://developer-pro.bitmart.com/en/futures/#get-order-trade-keyed
|
|
45427
45444
|
* @description fetch all trades made by the user
|
|
45428
45445
|
* @param {string} symbol unified market symbol
|
|
45429
45446
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
@@ -45438,32 +45455,46 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
45438
45455
|
const request = {};
|
|
45439
45456
|
if (symbol !== undefined) {
|
|
45440
45457
|
market = this.market(symbol);
|
|
45458
|
+
request['symbol'] = market['id'];
|
|
45441
45459
|
}
|
|
45442
45460
|
let type = undefined;
|
|
45461
|
+
let response = undefined;
|
|
45443
45462
|
[type, params] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
|
|
45444
|
-
|
|
45445
|
-
|
|
45446
|
-
|
|
45447
|
-
|
|
45448
|
-
|
|
45449
|
-
|
|
45450
|
-
|
|
45451
|
-
|
|
45452
|
-
|
|
45453
|
-
|
|
45454
|
-
|
|
45455
|
-
|
|
45463
|
+
const until = this.safeIntegerN(params, ['until', 'endTime', 'end_time']);
|
|
45464
|
+
params = this.omit(params, ['until']);
|
|
45465
|
+
if (type === 'spot') {
|
|
45466
|
+
let marginMode = undefined;
|
|
45467
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
45468
|
+
if (marginMode === 'isolated') {
|
|
45469
|
+
request['orderMode'] = 'iso_margin';
|
|
45470
|
+
}
|
|
45471
|
+
const options = this.safeValue(this.options, 'fetchMyTrades', {});
|
|
45472
|
+
const defaultLimit = this.safeInteger(options, 'limit', 200);
|
|
45473
|
+
if (limit === undefined) {
|
|
45474
|
+
limit = defaultLimit;
|
|
45475
|
+
}
|
|
45476
|
+
request['limit'] = limit;
|
|
45477
|
+
if (since !== undefined) {
|
|
45478
|
+
request['startTime'] = since;
|
|
45479
|
+
}
|
|
45480
|
+
if (until !== undefined) {
|
|
45481
|
+
request['endTime'] = until;
|
|
45482
|
+
}
|
|
45483
|
+
response = await this.privatePostSpotV4QueryTrades(this.extend(request, params));
|
|
45456
45484
|
}
|
|
45457
|
-
|
|
45458
|
-
|
|
45459
|
-
|
|
45485
|
+
else if (type === 'swap') {
|
|
45486
|
+
this.checkRequiredSymbol('fetchMyTrades', symbol);
|
|
45487
|
+
if (since !== undefined) {
|
|
45488
|
+
request['start_time'] = since;
|
|
45489
|
+
}
|
|
45490
|
+
if (until !== undefined) {
|
|
45491
|
+
request['end_time'] = until;
|
|
45492
|
+
}
|
|
45493
|
+
response = await this.privateGetContractPrivateTrades(this.extend(request, params));
|
|
45460
45494
|
}
|
|
45461
|
-
|
|
45462
|
-
|
|
45463
|
-
params = this.omit(params, ['endTime']);
|
|
45464
|
-
request['endTime'] = until;
|
|
45495
|
+
else {
|
|
45496
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchMyTrades() does not support ' + type + ' orders, only spot and swap orders are accepted');
|
|
45465
45497
|
}
|
|
45466
|
-
const response = await this.privatePostSpotV4QueryTrades(this.extend(request, params));
|
|
45467
45498
|
//
|
|
45468
45499
|
// spot
|
|
45469
45500
|
//
|
|
@@ -45492,7 +45523,30 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
45492
45523
|
// "trace":"fbaee9e0e2f5442fba5b3262fc86b0ac.65.16956593456523085"
|
|
45493
45524
|
// }
|
|
45494
45525
|
//
|
|
45495
|
-
|
|
45526
|
+
// swap
|
|
45527
|
+
//
|
|
45528
|
+
// {
|
|
45529
|
+
// "code": 1000,
|
|
45530
|
+
// "message": "Ok",
|
|
45531
|
+
// "data": [
|
|
45532
|
+
// {
|
|
45533
|
+
// "order_id": "230930336848609",
|
|
45534
|
+
// "trade_id": "6212604014",
|
|
45535
|
+
// "symbol": "BTCUSDT",
|
|
45536
|
+
// "side": 3,
|
|
45537
|
+
// "price": "26910.4",
|
|
45538
|
+
// "vol": "1",
|
|
45539
|
+
// "exec_type": "Taker",
|
|
45540
|
+
// "profit": false,
|
|
45541
|
+
// "create_time": 1695961596692,
|
|
45542
|
+
// "realised_profit": "-0.0003",
|
|
45543
|
+
// "paid_fees": "0.01614624"
|
|
45544
|
+
// },
|
|
45545
|
+
// ],
|
|
45546
|
+
// "trace": "4cad855074634097ac6ba5257c47305d.62.16959616054873723"
|
|
45547
|
+
// }
|
|
45548
|
+
//
|
|
45549
|
+
const data = this.safeValue(response, 'data', []);
|
|
45496
45550
|
return this.parseTrades(data, market, since, limit);
|
|
45497
45551
|
}
|
|
45498
45552
|
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -45861,10 +45915,10 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
45861
45915
|
}
|
|
45862
45916
|
parseOrderSide(side) {
|
|
45863
45917
|
const sides = {
|
|
45864
|
-
'1': '
|
|
45865
|
-
'2': '
|
|
45866
|
-
'3': '
|
|
45867
|
-
'4': '
|
|
45918
|
+
'1': 'buy',
|
|
45919
|
+
'2': 'buy',
|
|
45920
|
+
'3': 'sell',
|
|
45921
|
+
'4': 'sell',
|
|
45868
45922
|
};
|
|
45869
45923
|
return this.safeString(sides, side, side);
|
|
45870
45924
|
}
|
|
@@ -46003,25 +46057,47 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
46003
46057
|
/**
|
|
46004
46058
|
* @method
|
|
46005
46059
|
* @name bitmart#cancelOrder
|
|
46060
|
+
* @see https://developer-pro.bitmart.com/en/futures/#cancel-order-signed
|
|
46061
|
+
* @see https://developer-pro.bitmart.com/en/spot/#cancel-order-v3-signed
|
|
46062
|
+
* @see https://developer-pro.bitmart.com/en/futures/#cancel-plan-order-signed
|
|
46006
46063
|
* @description cancels an open order
|
|
46007
46064
|
* @param {string} id order id
|
|
46008
46065
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
46009
46066
|
* @param {object} [params] extra parameters specific to the bitmart api endpoint
|
|
46067
|
+
* @param {string} [params.clientOrderId] *spot only* the client order id of the order to cancel
|
|
46068
|
+
* @param {boolean} [params.stop] *swap only* whether the order is a stop order
|
|
46010
46069
|
* @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
46011
46070
|
*/
|
|
46012
|
-
|
|
46013
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
46014
|
-
}
|
|
46071
|
+
this.checkRequiredSymbol('cancelOrder', symbol);
|
|
46015
46072
|
await this.loadMarkets();
|
|
46016
46073
|
const market = this.market(symbol);
|
|
46017
|
-
if (!market['spot']) {
|
|
46018
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelOrder() does not support ' + market['type'] + ' orders, only spot orders are accepted');
|
|
46019
|
-
}
|
|
46020
46074
|
const request = {
|
|
46021
|
-
'order_id': id.toString(),
|
|
46022
46075
|
'symbol': market['id'],
|
|
46023
46076
|
};
|
|
46024
|
-
const
|
|
46077
|
+
const clientOrderId = this.safeString2(params, 'clientOrderId', 'client_order_id');
|
|
46078
|
+
if (clientOrderId !== undefined) {
|
|
46079
|
+
request['client_order_id'] = clientOrderId;
|
|
46080
|
+
}
|
|
46081
|
+
else {
|
|
46082
|
+
request['order_id'] = id.toString();
|
|
46083
|
+
}
|
|
46084
|
+
params = this.omit(params, ['clientOrderId']);
|
|
46085
|
+
let response = undefined;
|
|
46086
|
+
if (market['spot']) {
|
|
46087
|
+
response = await this.privatePostSpotV3CancelOrder(this.extend(request, params));
|
|
46088
|
+
}
|
|
46089
|
+
else {
|
|
46090
|
+
const stop = this.safeValue(params, 'stop');
|
|
46091
|
+
params = this.omit(params, ['stop']);
|
|
46092
|
+
if (!stop) {
|
|
46093
|
+
response = await this.privatePostContractPrivateCancelOrder(this.extend(request, params));
|
|
46094
|
+
}
|
|
46095
|
+
else {
|
|
46096
|
+
response = await this.privatePostContractPrivateCancelPlanOrder(this.extend(request, params));
|
|
46097
|
+
}
|
|
46098
|
+
}
|
|
46099
|
+
// swap
|
|
46100
|
+
// {"code":1000,"message":"Ok","trace":"7f9c94e10f9d4513bc08a7bfc2a5559a.55.16959817848001851"}
|
|
46025
46101
|
//
|
|
46026
46102
|
// spot
|
|
46027
46103
|
//
|
|
@@ -46043,6 +46119,9 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
46043
46119
|
// "data": true
|
|
46044
46120
|
// }
|
|
46045
46121
|
//
|
|
46122
|
+
if (market['swap']) {
|
|
46123
|
+
return response;
|
|
46124
|
+
}
|
|
46046
46125
|
const data = this.safeValue(response, 'data');
|
|
46047
46126
|
if (data === true) {
|
|
46048
46127
|
return this.parseOrder(id, market);
|
|
@@ -70784,6 +70863,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
70784
70863
|
'v5/market/insurance': 2.5,
|
|
70785
70864
|
'v5/market/risk-limit': 2.5,
|
|
70786
70865
|
'v5/market/delivery-price': 2.5,
|
|
70866
|
+
'v5/market/account-ratio': 2.5,
|
|
70787
70867
|
// spot leverage token
|
|
70788
70868
|
'v5/spot-lever-token/info': 2.5,
|
|
70789
70869
|
'v5/spot-lever-token/reference': 2.5,
|
|
@@ -71185,6 +71265,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
71185
71265
|
// c2c lending
|
|
71186
71266
|
'v5/lending/purchase': 2.5,
|
|
71187
71267
|
'v5/lending/redeem': 2.5,
|
|
71268
|
+
'v5/lending/redeem-cancel': 2.5,
|
|
71188
71269
|
},
|
|
71189
71270
|
'delete': {
|
|
71190
71271
|
// spot
|
|
@@ -71238,10 +71319,11 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
71238
71319
|
'10027': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.PermissionDenied,
|
|
71239
71320
|
'10028': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.PermissionDenied,
|
|
71240
71321
|
'10029': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.PermissionDenied,
|
|
71322
|
+
'12137': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
|
|
71241
71323
|
'12201': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
|
|
71242
71324
|
'12141': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
|
|
71243
71325
|
'100028': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.PermissionDenied,
|
|
71244
|
-
'110001': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.
|
|
71326
|
+
'110001': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.OrderNotFound,
|
|
71245
71327
|
'110003': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
|
|
71246
71328
|
'110004': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InsufficientFunds,
|
|
71247
71329
|
'110005': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
|
|
@@ -74064,11 +74146,38 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
74064
74146
|
if ((clientOrderId !== undefined) && (clientOrderId.length < 1)) {
|
|
74065
74147
|
clientOrderId = undefined;
|
|
74066
74148
|
}
|
|
74149
|
+
const avgPrice = this.omitZero(this.safeString(order, 'avgPrice'));
|
|
74067
74150
|
const rawTimeInForce = this.safeString(order, 'timeInForce');
|
|
74068
74151
|
const timeInForce = this.parseTimeInForce(rawTimeInForce);
|
|
74069
74152
|
const stopPrice = this.omitZero(this.safeString(order, 'triggerPrice'));
|
|
74070
|
-
const
|
|
74071
|
-
|
|
74153
|
+
const reduceOnly = this.safeValue(order, 'reduceOnly');
|
|
74154
|
+
let takeProfitPrice = this.omitZero(this.safeString(order, 'takeProfit'));
|
|
74155
|
+
let stopLossPrice = this.omitZero(this.safeString(order, 'stopLoss'));
|
|
74156
|
+
const triggerDirection = this.safeString(order, 'triggerDirection');
|
|
74157
|
+
const isAscending = (triggerDirection === '1');
|
|
74158
|
+
const isStopOrderType2 = (stopPrice !== undefined) && reduceOnly;
|
|
74159
|
+
if ((stopLossPrice === undefined) && isStopOrderType2) {
|
|
74160
|
+
// check if order is stop order type 2 - stopLossPrice
|
|
74161
|
+
if (isAscending && (side === 'buy')) {
|
|
74162
|
+
// stopLoss order against short position
|
|
74163
|
+
stopLossPrice = stopPrice;
|
|
74164
|
+
}
|
|
74165
|
+
if (!isAscending && (side === 'sell')) {
|
|
74166
|
+
// stopLoss order against a long position
|
|
74167
|
+
stopLossPrice = stopPrice;
|
|
74168
|
+
}
|
|
74169
|
+
}
|
|
74170
|
+
if ((takeProfitPrice === undefined) && isStopOrderType2) {
|
|
74171
|
+
// check if order is stop order type 2 - takeProfitPrice
|
|
74172
|
+
if (isAscending && (side === 'sell')) {
|
|
74173
|
+
// takeprofit order against a long position
|
|
74174
|
+
takeProfitPrice = stopPrice;
|
|
74175
|
+
}
|
|
74176
|
+
if (!isAscending && (side === 'buy')) {
|
|
74177
|
+
// takeprofit order against a short position
|
|
74178
|
+
takeProfitPrice = stopPrice;
|
|
74179
|
+
}
|
|
74180
|
+
}
|
|
74072
74181
|
return this.safeOrder({
|
|
74073
74182
|
'info': order,
|
|
74074
74183
|
'id': id,
|
|
@@ -74090,7 +74199,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
74090
74199
|
'stopLossPrice': stopLossPrice,
|
|
74091
74200
|
'amount': amount,
|
|
74092
74201
|
'cost': cost,
|
|
74093
|
-
'average':
|
|
74202
|
+
'average': avgPrice,
|
|
74094
74203
|
'filled': filled,
|
|
74095
74204
|
'remaining': remaining,
|
|
74096
74205
|
'status': status,
|
|
@@ -74142,6 +74251,14 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
74142
74251
|
* @param {boolean} [params.isLeverage] *unified spot only* false then spot trading true then margin trading
|
|
74143
74252
|
* @param {string} [params.tpslMode] *contract only* 'full' or 'partial'
|
|
74144
74253
|
* @param {string} [params.mmp] *option only* market maker protection
|
|
74254
|
+
* @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'up' or 'down'
|
|
74255
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
74256
|
+
* @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
|
|
74257
|
+
* @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
|
|
74258
|
+
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
|
|
74259
|
+
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
74260
|
+
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
|
|
74261
|
+
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
74145
74262
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
74146
74263
|
*/
|
|
74147
74264
|
await this.loadMarkets();
|
|
@@ -74247,13 +74364,21 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
74247
74364
|
const isStopLoss = stopLoss !== undefined;
|
|
74248
74365
|
const isTakeProfit = takeProfit !== undefined;
|
|
74249
74366
|
const isBuy = side === 'buy';
|
|
74250
|
-
const
|
|
74367
|
+
const setTriggerDirection = (stopLossTriggerPrice || triggerPrice) ? !isBuy : isBuy;
|
|
74368
|
+
const defaultTriggerDirection = setTriggerDirection ? 2 : 1;
|
|
74369
|
+
const triggerDirection = this.safeString(params, 'triggerDirection');
|
|
74370
|
+
params = this.omit(params, 'triggerDirection');
|
|
74371
|
+
let selectedDirection = defaultTriggerDirection;
|
|
74372
|
+
if (triggerDirection !== undefined) {
|
|
74373
|
+
const isAsending = ((triggerDirection === 'up') || (triggerDirection === '1'));
|
|
74374
|
+
selectedDirection = isAsending ? 1 : 2;
|
|
74375
|
+
}
|
|
74251
74376
|
if (triggerPrice !== undefined) {
|
|
74252
|
-
request['triggerDirection'] =
|
|
74377
|
+
request['triggerDirection'] = selectedDirection;
|
|
74253
74378
|
request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
74254
74379
|
}
|
|
74255
74380
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
74256
|
-
request['triggerDirection'] =
|
|
74381
|
+
request['triggerDirection'] = selectedDirection;
|
|
74257
74382
|
triggerPrice = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
|
|
74258
74383
|
request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
74259
74384
|
request['reduceOnly'] = true;
|
|
@@ -183573,9 +183698,10 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
183573
183698
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#query-kline
|
|
183574
183699
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
183575
183700
|
* @param {string} timeframe the length of time each candle represents
|
|
183576
|
-
* @param {int} [since] *emulated not supported by the exchange* timestamp in ms of the earliest candle to fetch
|
|
183701
|
+
* @param {int} [since] *only used for USDT settled contracts, otherwise is emulated and not supported by the exchange* timestamp in ms of the earliest candle to fetch
|
|
183577
183702
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
183578
183703
|
* @param {object} [params] extra parameters specific to the phemex api endpoint
|
|
183704
|
+
* @param {int} [params.until] *USDT settled/ linear swaps only* end time in ms
|
|
183579
183705
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
183580
183706
|
*/
|
|
183581
183707
|
await this.loadMarkets();
|
|
@@ -183585,34 +183711,55 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
183585
183711
|
'symbol': market['id'],
|
|
183586
183712
|
'resolution': this.safeString(this.timeframes, timeframe, timeframe),
|
|
183587
183713
|
};
|
|
183588
|
-
const
|
|
183589
|
-
|
|
183590
|
-
|
|
183591
|
-
|
|
183592
|
-
|
|
183593
|
-
|
|
183594
|
-
// phemex also provides kline query with from/to, however, this interface is NOT recommended and does not work properly.
|
|
183595
|
-
// we do not send since param to the exchange, instead we calculate appropriate limit param
|
|
183596
|
-
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
183597
|
-
const timeDelta = this.milliseconds() - since;
|
|
183598
|
-
limit = this.parseToInt(timeDelta / duration); // setting limit to the number of candles after since
|
|
183714
|
+
const until = this.safeInteger2(params, 'until', 'to');
|
|
183715
|
+
params = this.omit(params, ['until']);
|
|
183716
|
+
const usesSpecialFromToEndpoint = ((market['linear'] || market['settle'] === 'USDT')) && ((since !== undefined) || (until !== undefined));
|
|
183717
|
+
let maxLimit = 1000;
|
|
183718
|
+
if (usesSpecialFromToEndpoint) {
|
|
183719
|
+
maxLimit = 2000;
|
|
183599
183720
|
}
|
|
183600
|
-
if (limit
|
|
183721
|
+
if (limit === undefined) {
|
|
183601
183722
|
limit = maxLimit;
|
|
183602
183723
|
}
|
|
183603
|
-
|
|
183604
|
-
for (let i = 0; i < possibleLimitValues.length; i++) {
|
|
183605
|
-
if (limit <= possibleLimitValues[i]) {
|
|
183606
|
-
limit = possibleLimitValues[i];
|
|
183607
|
-
}
|
|
183608
|
-
}
|
|
183609
|
-
}
|
|
183610
|
-
request['limit'] = limit;
|
|
183724
|
+
request['limit'] = Math.min(limit, maxLimit);
|
|
183611
183725
|
let response = undefined;
|
|
183612
183726
|
if (market['linear'] || market['settle'] === 'USDT') {
|
|
183613
|
-
|
|
183727
|
+
if ((until !== undefined) || (since !== undefined)) {
|
|
183728
|
+
const candleDuration = this.parseTimeframe(timeframe);
|
|
183729
|
+
if (since !== undefined) {
|
|
183730
|
+
since = Math.round(since / 1000);
|
|
183731
|
+
request['from'] = since;
|
|
183732
|
+
}
|
|
183733
|
+
else {
|
|
183734
|
+
// when 'to' is defined since is mandatory
|
|
183735
|
+
since = (until / 100) - (maxLimit * candleDuration);
|
|
183736
|
+
}
|
|
183737
|
+
if (until !== undefined) {
|
|
183738
|
+
request['to'] = Math.round(until / 1000);
|
|
183739
|
+
}
|
|
183740
|
+
else {
|
|
183741
|
+
// when since is defined 'to' is mandatory
|
|
183742
|
+
let to = since + (maxLimit * candleDuration);
|
|
183743
|
+
const now = this.seconds();
|
|
183744
|
+
if (to > now) {
|
|
183745
|
+
to = now;
|
|
183746
|
+
}
|
|
183747
|
+
request['to'] = to;
|
|
183748
|
+
}
|
|
183749
|
+
response = await this.publicGetMdV2KlineList(this.extend(request, params));
|
|
183750
|
+
}
|
|
183751
|
+
else {
|
|
183752
|
+
response = await this.publicGetMdV2KlineLast(this.extend(request, params));
|
|
183753
|
+
}
|
|
183614
183754
|
}
|
|
183615
183755
|
else {
|
|
183756
|
+
if (since !== undefined) {
|
|
183757
|
+
// phemex also provides kline query with from/to, however, this interface is NOT recommended and does not work properly.
|
|
183758
|
+
// we do not send since param to the exchange, instead we calculate appropriate limit param
|
|
183759
|
+
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
183760
|
+
const timeDelta = this.milliseconds() - since;
|
|
183761
|
+
limit = this.parseToInt(timeDelta / duration); // setting limit to the number of candles after since
|
|
183762
|
+
}
|
|
183616
183763
|
response = await this.publicGetMdV2Kline(this.extend(request, params));
|
|
183617
183764
|
}
|
|
183618
183765
|
//
|
|
@@ -273297,7 +273444,7 @@ SOFTWARE.
|
|
|
273297
273444
|
|
|
273298
273445
|
//-----------------------------------------------------------------------------
|
|
273299
273446
|
// this is updated by vss.js when building
|
|
273300
|
-
const version = '4.0.
|
|
273447
|
+
const version = '4.0.111';
|
|
273301
273448
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
|
|
273302
273449
|
//-----------------------------------------------------------------------------
|
|
273303
273450
|
|