ccxt 4.1.19 → 4.1.20
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 -7
- package/dist/ccxt.browser.js +470 -177
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +1 -0
- package/dist/cjs/src/bitget.js +372 -125
- package/dist/cjs/src/bybit.js +2 -2
- package/dist/cjs/src/krakenfutures.js +1 -0
- package/dist/cjs/src/pro/kucoin.js +87 -44
- package/dist/cjs/src/pro/okx.js +6 -5
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +1 -0
- package/js/src/bitget.js +372 -125
- package/js/src/bybit.js +2 -2
- package/js/src/krakenfutures.js +1 -0
- package/js/src/pro/kucoin.js +87 -44
- package/js/src/pro/okx.js +6 -5
- package/package.json +1 -1
package/dist/ccxt.browser.js
CHANGED
|
@@ -6585,6 +6585,7 @@ class Exchange {
|
|
|
6585
6585
|
this.orderbooks = {};
|
|
6586
6586
|
this.tickers = {};
|
|
6587
6587
|
this.orders = undefined;
|
|
6588
|
+
this.triggerOrders = undefined;
|
|
6588
6589
|
this.transactions = {};
|
|
6589
6590
|
this.positions = {};
|
|
6590
6591
|
this.requiresWeb3 = false;
|
|
@@ -40891,42 +40892,61 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
40891
40892
|
// "symbol": "BTCUSDT_UMCBL"
|
|
40892
40893
|
// }
|
|
40893
40894
|
//
|
|
40894
|
-
//
|
|
40895
|
+
// spot: fetchMyTrades
|
|
40895
40896
|
//
|
|
40896
40897
|
// {
|
|
40897
|
-
// accountId:
|
|
40898
|
-
// symbol:
|
|
40899
|
-
// orderId:
|
|
40900
|
-
// fillId:
|
|
40901
|
-
// orderType:
|
|
40902
|
-
// side:
|
|
40903
|
-
// fillPrice:
|
|
40904
|
-
// fillQuantity:
|
|
40905
|
-
// fillTotalAmount:
|
|
40906
|
-
// feeCcy:
|
|
40907
|
-
// fees:
|
|
40908
|
-
//
|
|
40898
|
+
// "accountId": "7264631750",
|
|
40899
|
+
// "symbol": "BTCUSDT_SPBL",
|
|
40900
|
+
// "orderId": "1098394344925597696",
|
|
40901
|
+
// "fillId": "1098394344974925824",
|
|
40902
|
+
// "orderType": "market",
|
|
40903
|
+
// "side": "sell",
|
|
40904
|
+
// "fillPrice": "28467.68",
|
|
40905
|
+
// "fillQuantity": "0.0002",
|
|
40906
|
+
// "fillTotalAmount": "5.693536",
|
|
40907
|
+
// "feeCcy": "USDT",
|
|
40908
|
+
// "fees": "-0.005693536",
|
|
40909
|
+
// "takerMakerFlag": "taker",
|
|
40910
|
+
// "cTime": "1697603539699"
|
|
40909
40911
|
// }
|
|
40910
40912
|
//
|
|
40913
|
+
// swap and future: fetchMyTrades
|
|
40914
|
+
//
|
|
40911
40915
|
// {
|
|
40912
|
-
// tradeId:
|
|
40913
|
-
// symbol:
|
|
40914
|
-
// orderId:
|
|
40915
|
-
// price:
|
|
40916
|
-
// sizeQty:
|
|
40917
|
-
// fee:
|
|
40918
|
-
// side:
|
|
40919
|
-
// fillAmount:
|
|
40920
|
-
// profit:
|
|
40921
|
-
//
|
|
40916
|
+
// "tradeId": "1099351653724958721",
|
|
40917
|
+
// "symbol": "BTCUSDT_UMCBL",
|
|
40918
|
+
// "orderId": "1099351653682413569",
|
|
40919
|
+
// "price": "29531.3",
|
|
40920
|
+
// "sizeQty": "0.001",
|
|
40921
|
+
// "fee": "-0.01771878",
|
|
40922
|
+
// "side": "close_long",
|
|
40923
|
+
// "fillAmount": "29.5313",
|
|
40924
|
+
// "profit": "0.001",
|
|
40925
|
+
// "enterPointSource": "WEB",
|
|
40926
|
+
// "tradeSide": "close_long",
|
|
40927
|
+
// "holdMode": "double_hold",
|
|
40928
|
+
// "takerMakerFlag": "taker",
|
|
40929
|
+
// "cTime": "1697831779891"
|
|
40930
|
+
// }
|
|
40931
|
+
//
|
|
40932
|
+
// isolated and cross margin: fetchMyTrades
|
|
40933
|
+
//
|
|
40934
|
+
// {
|
|
40935
|
+
// "orderId": "1099353730455318528",
|
|
40936
|
+
// "fillId": "1099353730627092481",
|
|
40937
|
+
// "orderType": "market",
|
|
40938
|
+
// "side": "sell",
|
|
40939
|
+
// "fillPrice": "29543.7",
|
|
40940
|
+
// "fillQuantity": "0.0001",
|
|
40941
|
+
// "fillTotalAmount": "2.95437",
|
|
40942
|
+
// "feeCcy": "USDT",
|
|
40943
|
+
// "fees": "-0.00295437",
|
|
40944
|
+
// "ctime": "1697832275063"
|
|
40922
40945
|
// }
|
|
40923
40946
|
//
|
|
40924
40947
|
const marketId = this.safeString(trade, 'symbol');
|
|
40925
40948
|
const symbol = this.safeSymbol(marketId, market);
|
|
40926
|
-
|
|
40927
|
-
amount = this.safeString(trade, 'sizeQty', amount);
|
|
40928
|
-
let timestamp = this.safeInteger2(trade, 'fillTime', 'timestamp');
|
|
40929
|
-
timestamp = this.safeInteger(trade, 'cTime', timestamp);
|
|
40949
|
+
const timestamp = this.safeIntegerN(trade, ['fillTime', 'timestamp', 'ctime', 'cTime']);
|
|
40930
40950
|
let fee = undefined;
|
|
40931
40951
|
const feeAmount = this.safeString(trade, 'fees');
|
|
40932
40952
|
if (feeAmount !== undefined) {
|
|
@@ -40937,7 +40957,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
40937
40957
|
'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringNeg */ .O.stringNeg(feeAmount),
|
|
40938
40958
|
};
|
|
40939
40959
|
}
|
|
40940
|
-
const datetime = this.iso8601(timestamp);
|
|
40941
40960
|
return this.safeTrade({
|
|
40942
40961
|
'info': trade,
|
|
40943
40962
|
'id': this.safeString2(trade, 'tradeId', 'fillId'),
|
|
@@ -40945,13 +40964,13 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
40945
40964
|
'symbol': symbol,
|
|
40946
40965
|
'side': this.safeStringLower(trade, 'side'),
|
|
40947
40966
|
'type': this.safeString(trade, 'orderType'),
|
|
40948
|
-
'takerOrMaker':
|
|
40967
|
+
'takerOrMaker': this.safeString(trade, 'takerMakerFlag'),
|
|
40949
40968
|
'price': this.safeString2(trade, 'fillPrice', 'price'),
|
|
40950
|
-
'amount':
|
|
40969
|
+
'amount': this.safeStringN(trade, ['fillQuantity', 'size', 'sizeQty']),
|
|
40951
40970
|
'cost': undefined,
|
|
40952
|
-
'fee': fee,
|
|
40953
40971
|
'timestamp': timestamp,
|
|
40954
|
-
'datetime':
|
|
40972
|
+
'datetime': this.iso8601(timestamp),
|
|
40973
|
+
'fee': fee,
|
|
40955
40974
|
}, market);
|
|
40956
40975
|
}
|
|
40957
40976
|
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
@@ -41627,18 +41646,31 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41627
41646
|
// "data": "1098753830701928448"
|
|
41628
41647
|
// }
|
|
41629
41648
|
//
|
|
41649
|
+
// isolated and cross margin: fetchOpenOrders, fetchCanceledOrders, fetchClosedOrders
|
|
41650
|
+
//
|
|
41651
|
+
// {
|
|
41652
|
+
// "symbol": "BTCUSDT",
|
|
41653
|
+
// "orderType": "limit",
|
|
41654
|
+
// "source": "WEB",
|
|
41655
|
+
// "orderId": "1099108898629627904",
|
|
41656
|
+
// "clientOid": "f9b55416029e4cc2bbbe2f40ac368c38",
|
|
41657
|
+
// "loanType": "autoLoan",
|
|
41658
|
+
// "price": "25000",
|
|
41659
|
+
// "side": "buy",
|
|
41660
|
+
// "status": "new",
|
|
41661
|
+
// "baseQuantity": "0.0002",
|
|
41662
|
+
// "quoteAmount": "5",
|
|
41663
|
+
// "fillPrice": "0",
|
|
41664
|
+
// "fillQuantity": "0",
|
|
41665
|
+
// "fillTotalAmount": "0",
|
|
41666
|
+
// "ctime": "1697773902588"
|
|
41667
|
+
// }
|
|
41668
|
+
//
|
|
41630
41669
|
const marketId = this.safeString(order, 'symbol');
|
|
41631
41670
|
market = this.safeMarket(marketId, market);
|
|
41632
|
-
const
|
|
41633
|
-
const
|
|
41634
|
-
const
|
|
41635
|
-
const amount = this.safeString2(order, 'quantity', 'size');
|
|
41636
|
-
const filled = this.safeString2(order, 'fillQuantity', 'filledQty');
|
|
41637
|
-
const cost = this.safeString2(order, 'fillTotalAmount', 'filledAmount');
|
|
41638
|
-
const average = this.safeString2(order, 'fillPrice', 'priceAvg');
|
|
41639
|
-
const type = this.safeString(order, 'orderType');
|
|
41640
|
-
const timestamp = this.safeInteger(order, 'cTime');
|
|
41641
|
-
const lastUpdatetimestamp = this.safeInteger(order, 'uTime');
|
|
41671
|
+
const timestamp = this.safeInteger2(order, 'cTime', 'ctime');
|
|
41672
|
+
const updateTimestamp = this.safeInteger(order, 'uTime');
|
|
41673
|
+
const rawStatus = this.safeString2(order, 'status', 'state');
|
|
41642
41674
|
let side = this.safeString2(order, 'side', 'posSide');
|
|
41643
41675
|
if ((side === 'open_long') || (side === 'close_short')) {
|
|
41644
41676
|
side = 'buy';
|
|
@@ -41646,7 +41678,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41646
41678
|
else if ((side === 'close_long') || (side === 'open_short')) {
|
|
41647
41679
|
side = 'sell';
|
|
41648
41680
|
}
|
|
41649
|
-
const clientOrderId = this.safeString2(order, 'clientOrderId', 'clientOid');
|
|
41650
41681
|
let fee = undefined;
|
|
41651
41682
|
const feeCostString = this.safeString(order, 'fee');
|
|
41652
41683
|
if (feeCostString !== undefined) {
|
|
@@ -41666,31 +41697,28 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41666
41697
|
'currency': this.safeCurrencyCode(this.safeString(first, 'feeCoinCode')),
|
|
41667
41698
|
};
|
|
41668
41699
|
}
|
|
41669
|
-
const rawStatus = this.safeString2(order, 'status', 'state');
|
|
41670
|
-
const status = this.parseOrderStatus(rawStatus);
|
|
41671
|
-
const lastTradeTimestamp = this.safeInteger(order, 'uTime');
|
|
41672
41700
|
return this.safeOrder({
|
|
41673
41701
|
'info': order,
|
|
41674
|
-
'id':
|
|
41675
|
-
'clientOrderId': clientOrderId,
|
|
41702
|
+
'id': this.safeString2(order, 'orderId', 'data'),
|
|
41703
|
+
'clientOrderId': this.safeString2(order, 'clientOrderId', 'clientOid'),
|
|
41676
41704
|
'timestamp': timestamp,
|
|
41677
41705
|
'datetime': this.iso8601(timestamp),
|
|
41678
|
-
'lastTradeTimestamp':
|
|
41679
|
-
'lastUpdateTimestamp':
|
|
41680
|
-
'symbol': symbol,
|
|
41681
|
-
'type':
|
|
41706
|
+
'lastTradeTimestamp': updateTimestamp,
|
|
41707
|
+
'lastUpdateTimestamp': updateTimestamp,
|
|
41708
|
+
'symbol': market['symbol'],
|
|
41709
|
+
'type': this.safeString(order, 'orderType'),
|
|
41682
41710
|
'timeInForce': undefined,
|
|
41683
41711
|
'postOnly': undefined,
|
|
41684
41712
|
'side': side,
|
|
41685
|
-
'price': price,
|
|
41713
|
+
'price': this.safeString2(order, 'price', 'executePrice'),
|
|
41686
41714
|
'stopPrice': this.safeNumber(order, 'triggerPrice'),
|
|
41687
41715
|
'triggerPrice': this.safeNumber(order, 'triggerPrice'),
|
|
41688
|
-
'average':
|
|
41689
|
-
'cost':
|
|
41690
|
-
'amount':
|
|
41691
|
-
'filled':
|
|
41716
|
+
'average': this.safeString2(order, 'fillPrice', 'priceAvg'),
|
|
41717
|
+
'cost': this.safeString2(order, 'fillTotalAmount', 'filledAmount'),
|
|
41718
|
+
'amount': this.safeStringN(order, ['quantity', 'size', 'baseQuantity']),
|
|
41719
|
+
'filled': this.safeString2(order, 'fillQuantity', 'filledQty'),
|
|
41692
41720
|
'remaining': undefined,
|
|
41693
|
-
'status':
|
|
41721
|
+
'status': this.parseOrderStatus(rawStatus),
|
|
41694
41722
|
'fee': fee,
|
|
41695
41723
|
'trades': undefined,
|
|
41696
41724
|
}, market);
|
|
@@ -42429,9 +42457,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42429
42457
|
* @name bitget#fetchOpenOrders
|
|
42430
42458
|
* @description fetch all unfilled currently open orders
|
|
42431
42459
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-order-list
|
|
42460
|
+
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-current-plan-orders
|
|
42432
42461
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-all-open-order
|
|
42433
42462
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-plan-order-tpsl-list
|
|
42434
42463
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-open-order
|
|
42464
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-open-orders
|
|
42465
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-open-orders
|
|
42435
42466
|
* @param {string} symbol unified market symbol
|
|
42436
42467
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
42437
42468
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
@@ -42440,32 +42471,59 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42440
42471
|
*/
|
|
42441
42472
|
await this.loadMarkets();
|
|
42442
42473
|
const request = {};
|
|
42443
|
-
let marketType = undefined;
|
|
42444
|
-
let query = undefined;
|
|
42445
42474
|
let market = undefined;
|
|
42475
|
+
let marketType = undefined;
|
|
42476
|
+
let marginMode = undefined;
|
|
42477
|
+
let response = undefined;
|
|
42446
42478
|
if (symbol !== undefined) {
|
|
42447
42479
|
market = this.market(symbol);
|
|
42448
|
-
|
|
42480
|
+
const symbolRequest = (marginMode !== undefined) ? (market['info']['symbolName']) : (market['id']);
|
|
42481
|
+
request['symbol'] = symbolRequest;
|
|
42449
42482
|
}
|
|
42450
|
-
[marketType,
|
|
42451
|
-
|
|
42452
|
-
const stop = this.
|
|
42483
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
|
|
42484
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
|
|
42485
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
42486
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
42453
42487
|
if (stop) {
|
|
42454
42488
|
this.checkRequiredSymbol('fetchOpenOrders', symbol);
|
|
42455
|
-
query = this.omit(query, 'stop');
|
|
42456
42489
|
if (marketType === 'spot') {
|
|
42457
42490
|
if (limit !== undefined) {
|
|
42458
42491
|
request['pageSize'] = limit;
|
|
42459
42492
|
}
|
|
42460
|
-
response = await this.privateSpotPostPlanCurrentPlan(this.extend(request,
|
|
42493
|
+
response = await this.privateSpotPostPlanCurrentPlan(this.extend(request, params));
|
|
42461
42494
|
}
|
|
42462
42495
|
else {
|
|
42463
|
-
response = await this.privateMixGetPlanCurrentPlan(this.extend(request,
|
|
42496
|
+
response = await this.privateMixGetPlanCurrentPlan(this.extend(request, params));
|
|
42464
42497
|
}
|
|
42465
42498
|
}
|
|
42466
42499
|
else {
|
|
42467
42500
|
if (marketType === 'spot') {
|
|
42468
|
-
|
|
42501
|
+
if (marginMode !== undefined) {
|
|
42502
|
+
const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
|
|
42503
|
+
const endTime = this.safeIntegerN(params, ['endTime', 'until', 'till']);
|
|
42504
|
+
params = this.omit(params, ['until', 'till', 'clientOrderId']);
|
|
42505
|
+
if (clientOrderId !== undefined) {
|
|
42506
|
+
request['clientOid'] = clientOrderId;
|
|
42507
|
+
}
|
|
42508
|
+
if (endTime !== undefined) {
|
|
42509
|
+
request['endTime'] = endTime;
|
|
42510
|
+
}
|
|
42511
|
+
if (since !== undefined) {
|
|
42512
|
+
request['startTime'] = since;
|
|
42513
|
+
}
|
|
42514
|
+
if (limit !== undefined) {
|
|
42515
|
+
request['pageSize'] = limit;
|
|
42516
|
+
}
|
|
42517
|
+
if (marginMode === 'isolated') {
|
|
42518
|
+
response = await this.privateMarginGetIsolatedOrderOpenOrders(this.extend(request, params));
|
|
42519
|
+
}
|
|
42520
|
+
else if (marginMode === 'cross') {
|
|
42521
|
+
response = await this.privateMarginGetCrossOrderOpenOrders(this.extend(request, params));
|
|
42522
|
+
}
|
|
42523
|
+
}
|
|
42524
|
+
else {
|
|
42525
|
+
response = await this.privateSpotPostTradeOpenOrders(this.extend(request, params));
|
|
42526
|
+
}
|
|
42469
42527
|
}
|
|
42470
42528
|
else {
|
|
42471
42529
|
if (market === undefined) {
|
|
@@ -42477,10 +42535,11 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42477
42535
|
productType = 'S' + productType;
|
|
42478
42536
|
}
|
|
42479
42537
|
request['productType'] = productType;
|
|
42480
|
-
response = await this.privateMixGetOrderMarginCoinCurrent(this.extend(request,
|
|
42538
|
+
response = await this.privateMixGetOrderMarginCoinCurrent(this.extend(request, params));
|
|
42481
42539
|
}
|
|
42482
42540
|
else {
|
|
42483
|
-
|
|
42541
|
+
this.checkRequiredSymbol('fetchOpenOrders', symbol);
|
|
42542
|
+
response = await this.privateMixGetOrderCurrent(this.extend(request, params));
|
|
42484
42543
|
}
|
|
42485
42544
|
}
|
|
42486
42545
|
}
|
|
@@ -42587,10 +42646,45 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42587
42646
|
// }
|
|
42588
42647
|
// }
|
|
42589
42648
|
//
|
|
42649
|
+
// isolated and cross margin
|
|
42650
|
+
//
|
|
42651
|
+
// {
|
|
42652
|
+
// "code": "00000",
|
|
42653
|
+
// "msg": "success",
|
|
42654
|
+
// "requestTime": 1697773997250,
|
|
42655
|
+
// "data": {
|
|
42656
|
+
// "orderList": [
|
|
42657
|
+
// {
|
|
42658
|
+
// "symbol": "BTCUSDT",
|
|
42659
|
+
// "orderType": "limit",
|
|
42660
|
+
// "source": "WEB",
|
|
42661
|
+
// "orderId": "1099108898629627904",
|
|
42662
|
+
// "clientOid": "f9b55416029e4cc2bbbe2f40ac368c38",
|
|
42663
|
+
// "loanType": "autoLoan",
|
|
42664
|
+
// "price": "25000",
|
|
42665
|
+
// "side": "buy",
|
|
42666
|
+
// "status": "new",
|
|
42667
|
+
// "baseQuantity": "0.0002",
|
|
42668
|
+
// "quoteAmount": "5",
|
|
42669
|
+
// "fillPrice": "0",
|
|
42670
|
+
// "fillQuantity": "0",
|
|
42671
|
+
// "fillTotalAmount": "0",
|
|
42672
|
+
// "ctime": "1697773902588"
|
|
42673
|
+
// }
|
|
42674
|
+
// ],
|
|
42675
|
+
// "maxId": "1099108898629627904",
|
|
42676
|
+
// "minId": "1099108898629627904"
|
|
42677
|
+
// }
|
|
42678
|
+
// }
|
|
42679
|
+
//
|
|
42590
42680
|
if (typeof response === 'string') {
|
|
42591
42681
|
response = JSON.parse(response);
|
|
42592
42682
|
}
|
|
42593
42683
|
const data = this.safeValue(response, 'data', []);
|
|
42684
|
+
if (marginMode !== undefined) {
|
|
42685
|
+
const resultList = this.safeValue(data, 'orderList', []);
|
|
42686
|
+
return this.parseOrders(resultList, market, since, limit);
|
|
42687
|
+
}
|
|
42594
42688
|
if (!Array.isArray(data)) {
|
|
42595
42689
|
const result = this.safeValue(data, 'orderList', []);
|
|
42596
42690
|
return this.addPaginationCursorToResult(data, result);
|
|
@@ -42603,9 +42697,11 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42603
42697
|
* @name bitget#fetchClosedOrders
|
|
42604
42698
|
* @description fetches information on multiple closed orders made by the user
|
|
42605
42699
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-order-history
|
|
42700
|
+
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-history-plan-orders
|
|
42606
42701
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-orders
|
|
42607
42702
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-plan-orders-tpsl
|
|
42608
|
-
* @see https://bitgetlimited.github.io/apidoc/en/
|
|
42703
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-order-history
|
|
42704
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-order-history
|
|
42609
42705
|
* @param {string} symbol unified market symbol of the closed orders
|
|
42610
42706
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
42611
42707
|
* @param {int} [limit] the max number of closed orders to return
|
|
@@ -42641,9 +42737,11 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42641
42737
|
* @name bitget#fetchCanceledOrders
|
|
42642
42738
|
* @description fetches information on multiple canceled orders made by the user
|
|
42643
42739
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-order-history
|
|
42740
|
+
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-history-plan-orders
|
|
42644
42741
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-orders
|
|
42645
42742
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-plan-orders-tpsl
|
|
42646
|
-
* @see https://bitgetlimited.github.io/apidoc/en/
|
|
42743
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-order-history
|
|
42744
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-order-history
|
|
42647
42745
|
* @param {string} symbol unified market symbol of the canceled orders
|
|
42648
42746
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
42649
42747
|
* @param {int} [limit] the max number of canceled orders to return
|
|
@@ -42677,37 +42775,30 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42677
42775
|
await this.loadMarkets();
|
|
42678
42776
|
const market = this.market(symbol);
|
|
42679
42777
|
let marketType = undefined;
|
|
42778
|
+
let marginMode = undefined;
|
|
42779
|
+
let response = undefined;
|
|
42680
42780
|
[marketType, params] = this.handleMarketTypeAndParams('fetchCanceledAndClosedOrders', market, params);
|
|
42681
|
-
|
|
42682
|
-
|
|
42781
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchCanceledAndClosedOrders', params);
|
|
42782
|
+
const symbolRequest = (marginMode !== undefined) ? (market['info']['symbolName']) : (market['id']);
|
|
42683
42783
|
const request = {
|
|
42684
|
-
'symbol':
|
|
42784
|
+
'symbol': symbolRequest,
|
|
42685
42785
|
};
|
|
42686
|
-
|
|
42687
|
-
|
|
42688
|
-
}
|
|
42689
|
-
let method = this.getSupportedMapping(marketType, {
|
|
42690
|
-
'spot': 'privateSpotPostTradeHistory',
|
|
42691
|
-
'swap': 'privateMixGetOrderHistory',
|
|
42692
|
-
'future': 'privateMixGetOrderHistory',
|
|
42693
|
-
});
|
|
42786
|
+
const now = this.milliseconds();
|
|
42787
|
+
const endTime = this.safeIntegerN(params, ['endTime', 'until', 'till']);
|
|
42694
42788
|
const stop = this.safeValue(params, 'stop');
|
|
42695
|
-
|
|
42696
|
-
|
|
42697
|
-
method = 'privateSpotPostPlanHistoryPlan';
|
|
42698
|
-
}
|
|
42699
|
-
else {
|
|
42700
|
-
method = 'privateMixGetPlanHistoryPlan';
|
|
42701
|
-
}
|
|
42702
|
-
params = this.omit(params, 'stop');
|
|
42703
|
-
}
|
|
42704
|
-
if (marketType === 'swap' || stop) {
|
|
42789
|
+
params = this.omit(params, ['until', 'till', 'stop']);
|
|
42790
|
+
if (stop || (marketType === 'swap') || (marketType === 'future')) {
|
|
42705
42791
|
if (limit === undefined) {
|
|
42706
42792
|
limit = 100;
|
|
42707
42793
|
}
|
|
42708
42794
|
request['pageSize'] = limit;
|
|
42709
42795
|
if (since === undefined) {
|
|
42710
|
-
|
|
42796
|
+
if (marketType === 'spot') {
|
|
42797
|
+
since = now - 7776000000;
|
|
42798
|
+
}
|
|
42799
|
+
else {
|
|
42800
|
+
since = 0;
|
|
42801
|
+
}
|
|
42711
42802
|
}
|
|
42712
42803
|
request['startTime'] = since;
|
|
42713
42804
|
if (endTime === undefined) {
|
|
@@ -42717,15 +42808,52 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42717
42808
|
request['endTime'] = endTime;
|
|
42718
42809
|
}
|
|
42719
42810
|
}
|
|
42811
|
+
if (stop) {
|
|
42812
|
+
if (marketType === 'spot') {
|
|
42813
|
+
response = await this.privateSpotPostPlanHistoryPlan(this.extend(request, params));
|
|
42814
|
+
}
|
|
42815
|
+
else {
|
|
42816
|
+
response = await this.privateMixGetPlanHistoryPlan(this.extend(request, params));
|
|
42817
|
+
}
|
|
42818
|
+
}
|
|
42720
42819
|
else {
|
|
42721
|
-
if (
|
|
42722
|
-
|
|
42820
|
+
if ((marketType === 'swap') || (marketType === 'future')) {
|
|
42821
|
+
response = await this.privateMixGetOrderHistory(this.extend(request, params));
|
|
42723
42822
|
}
|
|
42724
|
-
|
|
42725
|
-
|
|
42823
|
+
else {
|
|
42824
|
+
if (marginMode !== undefined) {
|
|
42825
|
+
if (since === undefined) {
|
|
42826
|
+
since = now - 7776000000;
|
|
42827
|
+
}
|
|
42828
|
+
request['startTime'] = since;
|
|
42829
|
+
if (endTime !== undefined) {
|
|
42830
|
+
request['endTime'] = endTime;
|
|
42831
|
+
}
|
|
42832
|
+
if (limit !== undefined) {
|
|
42833
|
+
request['pageSize'] = limit;
|
|
42834
|
+
}
|
|
42835
|
+
if (marginMode === 'isolated') {
|
|
42836
|
+
response = await this.privateMarginGetIsolatedOrderHistory(this.extend(request, params));
|
|
42837
|
+
}
|
|
42838
|
+
else if (marginMode === 'cross') {
|
|
42839
|
+
response = await this.privateMarginGetCrossOrderHistory(this.extend(request, params));
|
|
42840
|
+
}
|
|
42841
|
+
}
|
|
42842
|
+
else {
|
|
42843
|
+
if (limit !== undefined) {
|
|
42844
|
+
request['limit'] = limit;
|
|
42845
|
+
}
|
|
42846
|
+
if (since !== undefined) {
|
|
42847
|
+
request['after'] = since;
|
|
42848
|
+
}
|
|
42849
|
+
if (endTime !== undefined) {
|
|
42850
|
+
params = this.omit(params, 'endTime');
|
|
42851
|
+
request['before'] = endTime;
|
|
42852
|
+
}
|
|
42853
|
+
response = await this.privateSpotPostTradeHistory(this.extend(request, params));
|
|
42854
|
+
}
|
|
42726
42855
|
}
|
|
42727
42856
|
}
|
|
42728
|
-
const response = await this[method](this.extend(request, params));
|
|
42729
42857
|
//
|
|
42730
42858
|
// spot
|
|
42731
42859
|
//
|
|
@@ -42842,6 +42970,37 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42842
42970
|
// "requestTime":1627354109502
|
|
42843
42971
|
// }
|
|
42844
42972
|
//
|
|
42973
|
+
// isolated and cross margin
|
|
42974
|
+
//
|
|
42975
|
+
// {
|
|
42976
|
+
// "code": "00000",
|
|
42977
|
+
// "msg": "success",
|
|
42978
|
+
// "requestTime": 1697779608818,
|
|
42979
|
+
// "data": {
|
|
42980
|
+
// "orderList": [
|
|
42981
|
+
// {
|
|
42982
|
+
// "symbol": "BTCUSDT",
|
|
42983
|
+
// "orderType": "limit",
|
|
42984
|
+
// "source": "API",
|
|
42985
|
+
// "orderId": "1098761451063619584",
|
|
42986
|
+
// "clientOid": "8d8ac3454ed345fca914c9cd55682121",
|
|
42987
|
+
// "loanType": "normal",
|
|
42988
|
+
// "price": "25000",
|
|
42989
|
+
// "side": "buy",
|
|
42990
|
+
// "status": "cancelled",
|
|
42991
|
+
// "baseQuantity": "0.0002",
|
|
42992
|
+
// "quoteAmount": "0",
|
|
42993
|
+
// "fillPrice": "0",
|
|
42994
|
+
// "fillQuantity": "0",
|
|
42995
|
+
// "fillTotalAmount": "0",
|
|
42996
|
+
// "ctime": "1697691064614"
|
|
42997
|
+
// },
|
|
42998
|
+
// ],
|
|
42999
|
+
// "maxId": "1098761451063619584",
|
|
43000
|
+
// "minId": "1098394690472521728"
|
|
43001
|
+
// }
|
|
43002
|
+
// }
|
|
43003
|
+
//
|
|
42845
43004
|
const data = this.safeValue(response, 'data');
|
|
42846
43005
|
if (data !== undefined) {
|
|
42847
43006
|
if ('orderList' in data) {
|
|
@@ -42980,12 +43139,14 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
42980
43139
|
* @description fetch all trades made by the user
|
|
42981
43140
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-transaction-details
|
|
42982
43141
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-order-fill-detail
|
|
43142
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-transaction-details
|
|
43143
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-order-fills
|
|
42983
43144
|
* @param {string} symbol unified market symbol
|
|
42984
43145
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
42985
43146
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
42986
43147
|
* @param {object} [params] extra parameters specific to the bitget api endpoint
|
|
42987
|
-
* @param {int} [params.until]
|
|
42988
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
43148
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
43149
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
42989
43150
|
* @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
|
|
42990
43151
|
*/
|
|
42991
43152
|
this.checkRequiredSymbol('fetchMyTrades', symbol);
|
|
@@ -43001,15 +43162,43 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
43001
43162
|
return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params, 500);
|
|
43002
43163
|
}
|
|
43003
43164
|
}
|
|
43165
|
+
let response = undefined;
|
|
43166
|
+
let marginMode = undefined;
|
|
43167
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
43168
|
+
const symbolRequest = (marginMode !== undefined) ? (market['info']['symbolName']) : (market['id']);
|
|
43004
43169
|
let request = {
|
|
43005
|
-
'symbol':
|
|
43170
|
+
'symbol': symbolRequest,
|
|
43006
43171
|
};
|
|
43007
|
-
if (limit !== undefined) {
|
|
43008
|
-
request['limit'] = limit;
|
|
43009
|
-
}
|
|
43010
|
-
let response = undefined;
|
|
43011
43172
|
if (market['spot']) {
|
|
43012
|
-
|
|
43173
|
+
if (marginMode !== undefined) {
|
|
43174
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
43175
|
+
if (since !== undefined) {
|
|
43176
|
+
request['startTime'] = since;
|
|
43177
|
+
}
|
|
43178
|
+
else {
|
|
43179
|
+
const now = this.milliseconds();
|
|
43180
|
+
request['startTime'] = now - 7776000000;
|
|
43181
|
+
}
|
|
43182
|
+
if (limit !== undefined) {
|
|
43183
|
+
request['pageSize'] = limit;
|
|
43184
|
+
}
|
|
43185
|
+
if (marginMode === 'isolated') {
|
|
43186
|
+
response = await this.privateMarginGetIsolatedOrderFills(this.extend(request, params));
|
|
43187
|
+
}
|
|
43188
|
+
else if (marginMode === 'cross') {
|
|
43189
|
+
response = await this.privateMarginGetCrossOrderFills(this.extend(request, params));
|
|
43190
|
+
}
|
|
43191
|
+
}
|
|
43192
|
+
else {
|
|
43193
|
+
[request, params] = this.handleUntilOption('before', request, params);
|
|
43194
|
+
if (since !== undefined) {
|
|
43195
|
+
request['after'] = since;
|
|
43196
|
+
}
|
|
43197
|
+
if (limit !== undefined) {
|
|
43198
|
+
request['limit'] = limit;
|
|
43199
|
+
}
|
|
43200
|
+
response = await this.privateSpotPostTradeFills(this.extend(request, params));
|
|
43201
|
+
}
|
|
43013
43202
|
}
|
|
43014
43203
|
else {
|
|
43015
43204
|
const orderId = this.safeString(params, 'orderId'); // when order id is not defined, startTime and endTime are required
|
|
@@ -43026,29 +43215,88 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
43026
43215
|
response = await this.privateMixGetOrderFills(this.extend(request, params));
|
|
43027
43216
|
}
|
|
43028
43217
|
//
|
|
43218
|
+
// spot
|
|
43219
|
+
//
|
|
43029
43220
|
// {
|
|
43030
|
-
//
|
|
43031
|
-
//
|
|
43032
|
-
//
|
|
43033
|
-
//
|
|
43034
|
-
//
|
|
43035
|
-
//
|
|
43036
|
-
//
|
|
43037
|
-
//
|
|
43038
|
-
//
|
|
43039
|
-
//
|
|
43040
|
-
//
|
|
43041
|
-
//
|
|
43042
|
-
//
|
|
43043
|
-
//
|
|
43044
|
-
//
|
|
43045
|
-
//
|
|
43046
|
-
//
|
|
43221
|
+
// "code": "00000",
|
|
43222
|
+
// "msg": "success",
|
|
43223
|
+
// "requestTime": 1697831543676,
|
|
43224
|
+
// "data": [
|
|
43225
|
+
// {
|
|
43226
|
+
// "accountId": "7264631750",
|
|
43227
|
+
// "symbol": "BTCUSDT_SPBL",
|
|
43228
|
+
// "orderId": "1098394344925597696",
|
|
43229
|
+
// "fillId": "1098394344974925824",
|
|
43230
|
+
// "orderType": "market",
|
|
43231
|
+
// "side": "sell",
|
|
43232
|
+
// "fillPrice": "28467.68",
|
|
43233
|
+
// "fillQuantity": "0.0002",
|
|
43234
|
+
// "fillTotalAmount": "5.693536",
|
|
43235
|
+
// "feeCcy": "USDT",
|
|
43236
|
+
// "fees": "-0.005693536",
|
|
43237
|
+
// "takerMakerFlag": "taker",
|
|
43238
|
+
// "cTime": "1697603539699"
|
|
43239
|
+
// },
|
|
43240
|
+
// ]
|
|
43241
|
+
// }
|
|
43242
|
+
//
|
|
43243
|
+
// swap and future
|
|
43244
|
+
//
|
|
43245
|
+
// {
|
|
43246
|
+
// "code": "00000",
|
|
43247
|
+
// "msg": "success",
|
|
43248
|
+
// "requestTime": 1697831790948,
|
|
43249
|
+
// "data": [
|
|
43250
|
+
// {
|
|
43251
|
+
// "tradeId": "1099351653724958721",
|
|
43252
|
+
// "symbol": "BTCUSDT_UMCBL",
|
|
43253
|
+
// "orderId": "1099351653682413569",
|
|
43254
|
+
// "price": "29531.3",
|
|
43255
|
+
// "sizeQty": "0.001",
|
|
43256
|
+
// "fee": "-0.01771878",
|
|
43257
|
+
// "side": "close_long",
|
|
43258
|
+
// "fillAmount": "29.5313",
|
|
43259
|
+
// "profit": "0.001",
|
|
43260
|
+
// "enterPointSource": "WEB",
|
|
43261
|
+
// "tradeSide": "close_long",
|
|
43262
|
+
// "holdMode": "double_hold",
|
|
43263
|
+
// "takerMakerFlag": "taker",
|
|
43264
|
+
// "cTime": "1697831779891"
|
|
43265
|
+
// },
|
|
43266
|
+
// ]
|
|
43267
|
+
// }
|
|
43268
|
+
//
|
|
43269
|
+
// isolated and cross margin
|
|
43270
|
+
//
|
|
43271
|
+
// {
|
|
43272
|
+
// "code": "00000",
|
|
43273
|
+
// "msg": "success",
|
|
43274
|
+
// "requestTime": 1697832285469,
|
|
43275
|
+
// "data": {
|
|
43276
|
+
// "fills": [
|
|
43277
|
+
// {
|
|
43278
|
+
// "orderId": "1099353730455318528",
|
|
43279
|
+
// "fillId": "1099353730627092481",
|
|
43280
|
+
// "orderType": "market",
|
|
43281
|
+
// "side": "sell",
|
|
43282
|
+
// "fillPrice": "29543.7",
|
|
43283
|
+
// "fillQuantity": "0.0001",
|
|
43284
|
+
// "fillTotalAmount": "2.95437",
|
|
43285
|
+
// "feeCcy": "USDT",
|
|
43286
|
+
// "fees": "-0.00295437",
|
|
43287
|
+
// "ctime": "1697832275063"
|
|
43288
|
+
// },
|
|
43289
|
+
// ],
|
|
43290
|
+
// "minId": "1099353591699161118",
|
|
43291
|
+
// "maxId": "1099353730627092481"
|
|
43047
43292
|
// }
|
|
43048
|
-
// ]
|
|
43049
43293
|
// }
|
|
43050
43294
|
//
|
|
43051
43295
|
const data = this.safeValue(response, 'data');
|
|
43296
|
+
if (marginMode !== undefined) {
|
|
43297
|
+
const fills = this.safeValue(data, 'fills', []);
|
|
43298
|
+
return this.parseTrades(fills, market, since, limit);
|
|
43299
|
+
}
|
|
43052
43300
|
return this.parseTrades(data, market, since, limit);
|
|
43053
43301
|
}
|
|
43054
43302
|
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -75543,7 +75791,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
75543
75791
|
const feeToken = this.safeString(trade, 'feeTokenId');
|
|
75544
75792
|
const feeCurrency = this.safeCurrencyCode(feeToken);
|
|
75545
75793
|
fee = {
|
|
75546
|
-
'cost':
|
|
75794
|
+
'cost': feeCost,
|
|
75547
75795
|
'currency': feeCurrency,
|
|
75548
75796
|
};
|
|
75549
75797
|
}
|
|
@@ -75709,7 +75957,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
75709
75957
|
feeCurrencyCode = market['inverse'] ? market['base'] : market['settle'];
|
|
75710
75958
|
}
|
|
75711
75959
|
fee = {
|
|
75712
|
-
'cost':
|
|
75960
|
+
'cost': feeCostString,
|
|
75713
75961
|
'currency': feeCurrencyCode,
|
|
75714
75962
|
};
|
|
75715
75963
|
}
|
|
@@ -147303,6 +147551,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
147303
147551
|
'type': this.parseOrderType(type),
|
|
147304
147552
|
'timeInForce': timeInForce,
|
|
147305
147553
|
'postOnly': type === 'post',
|
|
147554
|
+
'reduceOnly': this.safeValue(details, 'reduceOnly'),
|
|
147306
147555
|
'side': this.safeString(details, 'side'),
|
|
147307
147556
|
'price': price,
|
|
147308
147557
|
'stopPrice': this.safeString(details, 'triggerPrice'),
|
|
@@ -230000,13 +230249,16 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
230000
230249
|
* @description watches information on multiple orders made by the user
|
|
230001
230250
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
230002
230251
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
230003
|
-
* @param {int} [limit] the maximum number of
|
|
230252
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
230004
230253
|
* @param {object} [params] extra parameters specific to the kucoin api endpoint
|
|
230254
|
+
* @param {boolean} [params.stop] trigger orders are watched if true
|
|
230005
230255
|
* @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
230006
230256
|
*/
|
|
230007
230257
|
await this.loadMarkets();
|
|
230258
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
230259
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
230008
230260
|
const url = await this.negotiate(true);
|
|
230009
|
-
const topic = '/spotMarket/tradeOrders';
|
|
230261
|
+
const topic = stop ? '/spotMarket/advancedOrders' : '/spotMarket/tradeOrders';
|
|
230010
230262
|
const request = {
|
|
230011
230263
|
'privateChannel': true,
|
|
230012
230264
|
};
|
|
@@ -230029,59 +230281,79 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
230029
230281
|
'match': 'open',
|
|
230030
230282
|
'update': 'open',
|
|
230031
230283
|
'canceled': 'canceled',
|
|
230284
|
+
'cancel': 'canceled',
|
|
230285
|
+
'TRIGGERED': 'triggered',
|
|
230032
230286
|
};
|
|
230033
230287
|
return this.safeString(statuses, status, status);
|
|
230034
230288
|
}
|
|
230035
230289
|
parseWsOrder(order, market = undefined) {
|
|
230036
230290
|
//
|
|
230037
|
-
//
|
|
230038
|
-
//
|
|
230039
|
-
//
|
|
230040
|
-
//
|
|
230041
|
-
//
|
|
230042
|
-
//
|
|
230043
|
-
//
|
|
230044
|
-
//
|
|
230045
|
-
//
|
|
230046
|
-
//
|
|
230047
|
-
//
|
|
230048
|
-
//
|
|
230049
|
-
//
|
|
230050
|
-
//
|
|
230051
|
-
//
|
|
230291
|
+
// /spotMarket/tradeOrders
|
|
230292
|
+
//
|
|
230293
|
+
// {
|
|
230294
|
+
// 'symbol': 'XCAD-USDT',
|
|
230295
|
+
// 'orderType': 'limit',
|
|
230296
|
+
// 'side': 'buy',
|
|
230297
|
+
// 'orderId': '6249167327218b000135e749',
|
|
230298
|
+
// 'type': 'canceled',
|
|
230299
|
+
// 'orderTime': 1648957043065280224,
|
|
230300
|
+
// 'size': '100.452',
|
|
230301
|
+
// 'filledSize': '0',
|
|
230302
|
+
// 'price': '2.9635',
|
|
230303
|
+
// 'clientOid': 'buy-XCAD-USDT-1648957043010159',
|
|
230304
|
+
// 'remainSize': '0',
|
|
230305
|
+
// 'status': 'done',
|
|
230306
|
+
// 'ts': 1648957054031001037
|
|
230307
|
+
// }
|
|
230308
|
+
//
|
|
230309
|
+
// /spotMarket/advancedOrders
|
|
230310
|
+
//
|
|
230311
|
+
// {
|
|
230312
|
+
// "createdAt": 1589789942337,
|
|
230313
|
+
// "orderId": "5ec244f6a8a75e0009958237",
|
|
230314
|
+
// "orderPrice": "0.00062",
|
|
230315
|
+
// "orderType": "stop",
|
|
230316
|
+
// "side": "sell",
|
|
230317
|
+
// "size": "1",
|
|
230318
|
+
// "stop": "entry",
|
|
230319
|
+
// "stopPrice": "0.00062",
|
|
230320
|
+
// "symbol": "KCS-BTC",
|
|
230321
|
+
// "tradeType": "TRADE",
|
|
230322
|
+
// "triggerSuccess": true,
|
|
230323
|
+
// "ts": 1589790121382281286,
|
|
230324
|
+
// "type": "triggered"
|
|
230325
|
+
// }
|
|
230052
230326
|
//
|
|
230053
|
-
const id = this.safeString(order, 'orderId');
|
|
230054
|
-
const clientOrderId = this.safeString(order, 'clientOid');
|
|
230055
|
-
const orderType = this.safeStringLower(order, 'orderType');
|
|
230056
|
-
const price = this.safeString(order, 'price');
|
|
230057
|
-
const filled = this.safeString(order, 'filledSize');
|
|
230058
|
-
const amount = this.safeString(order, 'size');
|
|
230059
230327
|
const rawType = this.safeString(order, 'type');
|
|
230060
|
-
|
|
230061
|
-
const timestamp = this.
|
|
230328
|
+
let status = this.parseWsOrderStatus(rawType);
|
|
230329
|
+
const timestamp = this.safeInteger2(order, 'orderTime', 'createdAt');
|
|
230062
230330
|
const marketId = this.safeString(order, 'symbol');
|
|
230063
230331
|
market = this.safeMarket(marketId, market);
|
|
230064
|
-
const
|
|
230065
|
-
const
|
|
230332
|
+
const triggerPrice = this.safeString(order, 'stopPrice');
|
|
230333
|
+
const triggerSuccess = this.safeValue(order, 'triggerSuccess');
|
|
230334
|
+
const triggerFail = (triggerSuccess !== true) && (triggerSuccess !== undefined); // TODO: updated to triggerSuccess === False once transpiler transpiles it correctly
|
|
230335
|
+
if ((status === 'triggered') && triggerFail) {
|
|
230336
|
+
status = 'canceled';
|
|
230337
|
+
}
|
|
230066
230338
|
return this.safeOrder({
|
|
230067
230339
|
'info': order,
|
|
230068
|
-
'symbol': symbol,
|
|
230069
|
-
'id':
|
|
230070
|
-
'clientOrderId':
|
|
230340
|
+
'symbol': market['symbol'],
|
|
230341
|
+
'id': this.safeString(order, 'orderId'),
|
|
230342
|
+
'clientOrderId': this.safeString(order, 'clientOid'),
|
|
230071
230343
|
'timestamp': timestamp,
|
|
230072
230344
|
'datetime': this.iso8601(timestamp),
|
|
230073
230345
|
'lastTradeTimestamp': undefined,
|
|
230074
|
-
'type': orderType,
|
|
230346
|
+
'type': this.safeStringLower(order, 'orderType'),
|
|
230075
230347
|
'timeInForce': undefined,
|
|
230076
230348
|
'postOnly': undefined,
|
|
230077
|
-
'side': side,
|
|
230078
|
-
'price': price,
|
|
230079
|
-
'stopPrice':
|
|
230080
|
-
'triggerPrice':
|
|
230081
|
-
'amount':
|
|
230349
|
+
'side': this.safeStringLower(order, 'side'),
|
|
230350
|
+
'price': this.safeString2(order, 'price', 'orderPrice'),
|
|
230351
|
+
'stopPrice': triggerPrice,
|
|
230352
|
+
'triggerPrice': triggerPrice,
|
|
230353
|
+
'amount': this.safeString(order, 'size'),
|
|
230082
230354
|
'cost': undefined,
|
|
230083
230355
|
'average': undefined,
|
|
230084
|
-
'filled':
|
|
230356
|
+
'filled': this.safeString(order, 'filledSize'),
|
|
230085
230357
|
'remaining': undefined,
|
|
230086
230358
|
'status': status,
|
|
230087
230359
|
'fee': undefined,
|
|
@@ -230089,32 +230361,51 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
230089
230361
|
}, market);
|
|
230090
230362
|
}
|
|
230091
230363
|
handleOrder(client, message) {
|
|
230364
|
+
//
|
|
230365
|
+
// Trigger Orders
|
|
230366
|
+
//
|
|
230367
|
+
// {
|
|
230368
|
+
// createdAt: 1692745706437,
|
|
230369
|
+
// error: 'Balance insufficient!', // not always there
|
|
230370
|
+
// orderId: 'vs86kp757vlda6ni003qs70v',
|
|
230371
|
+
// orderPrice: '0.26',
|
|
230372
|
+
// orderType: 'stop',
|
|
230373
|
+
// side: 'sell',
|
|
230374
|
+
// size: '5',
|
|
230375
|
+
// stop: 'loss',
|
|
230376
|
+
// stopPrice: '0.26',
|
|
230377
|
+
// symbol: 'ADA-USDT',
|
|
230378
|
+
// tradeType: 'TRADE',
|
|
230379
|
+
// triggerSuccess: false, // not always there
|
|
230380
|
+
// ts: '1692745706442929298',
|
|
230381
|
+
// type: 'open'
|
|
230382
|
+
// }
|
|
230383
|
+
//
|
|
230092
230384
|
const messageHash = 'orders';
|
|
230093
230385
|
const data = this.safeValue(message, 'data');
|
|
230094
230386
|
const parsed = this.parseWsOrder(data);
|
|
230095
230387
|
const symbol = this.safeString(parsed, 'symbol');
|
|
230096
230388
|
const orderId = this.safeString(parsed, 'id');
|
|
230389
|
+
const triggerPrice = this.safeValue(parsed, 'triggerPrice');
|
|
230390
|
+
const isTriggerOrder = (triggerPrice !== undefined);
|
|
230097
230391
|
if (this.orders === undefined) {
|
|
230098
230392
|
const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
|
|
230099
230393
|
this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCacheBySymbolById */ .hl(limit);
|
|
230394
|
+
this.triggerOrders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCacheBySymbolById */ .hl(limit);
|
|
230100
230395
|
}
|
|
230101
|
-
const cachedOrders = this.orders;
|
|
230396
|
+
const cachedOrders = isTriggerOrder ? this.triggerOrders : this.orders;
|
|
230102
230397
|
const orders = this.safeValue(cachedOrders.hashmap, symbol, {});
|
|
230103
230398
|
const order = this.safeValue(orders, orderId);
|
|
230104
230399
|
if (order !== undefined) {
|
|
230105
230400
|
// todo add others to calculate average etc
|
|
230106
|
-
const stopPrice = this.safeValue(order, 'stopPrice');
|
|
230107
|
-
if (stopPrice !== undefined) {
|
|
230108
|
-
parsed['stopPrice'] = stopPrice;
|
|
230109
|
-
}
|
|
230110
230401
|
if (order['status'] === 'closed') {
|
|
230111
230402
|
parsed['status'] = 'closed';
|
|
230112
230403
|
}
|
|
230113
230404
|
}
|
|
230114
230405
|
cachedOrders.append(parsed);
|
|
230115
|
-
client.resolve(
|
|
230406
|
+
client.resolve(cachedOrders, messageHash);
|
|
230116
230407
|
const symbolSpecificMessageHash = messageHash + ':' + symbol;
|
|
230117
|
-
client.resolve(
|
|
230408
|
+
client.resolve(cachedOrders, symbolSpecificMessageHash);
|
|
230118
230409
|
}
|
|
230119
230410
|
async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
230120
230411
|
/**
|
|
@@ -230311,6 +230602,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
230311
230602
|
'account.balance': this.handleBalance,
|
|
230312
230603
|
'/spot/tradeFills': this.handleMyTrade,
|
|
230313
230604
|
'orderChange': this.handleOrder,
|
|
230605
|
+
'stopOrder': this.handleOrder,
|
|
230314
230606
|
};
|
|
230315
230607
|
const method = this.safeValue(methods, subject);
|
|
230316
230608
|
if (method === undefined) {
|
|
@@ -234898,8 +235190,8 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
234898
235190
|
let type = undefined;
|
|
234899
235191
|
// By default, receive order updates from any instrument type
|
|
234900
235192
|
[type, params] = this.handleOptionAndParams(params, 'watchOrders', 'type', 'ANY');
|
|
234901
|
-
const isStop = this.
|
|
234902
|
-
params = this.omit(params, ['stop']);
|
|
235193
|
+
const isStop = this.safeValue2(params, 'stop', 'trigger', false);
|
|
235194
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
234903
235195
|
await this.loadMarkets();
|
|
234904
235196
|
await this.authenticate({ 'access': isStop ? 'business' : 'private' });
|
|
234905
235197
|
let market = undefined;
|
|
@@ -234986,8 +235278,9 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
234986
235278
|
const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
|
|
234987
235279
|
if (this.orders === undefined) {
|
|
234988
235280
|
this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
|
|
235281
|
+
this.triggerOrders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
|
|
234989
235282
|
}
|
|
234990
|
-
const stored = this.orders;
|
|
235283
|
+
const stored = (channel === 'orders-algo') ? this.triggerOrders : this.orders;
|
|
234991
235284
|
const marketIds = [];
|
|
234992
235285
|
const parsed = this.parseOrders(orders);
|
|
234993
235286
|
for (let i = 0; i < parsed.length; i++) {
|
|
@@ -234997,10 +235290,10 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
234997
235290
|
const market = this.market(symbol);
|
|
234998
235291
|
marketIds.push(market['id']);
|
|
234999
235292
|
}
|
|
235000
|
-
client.resolve(
|
|
235293
|
+
client.resolve(stored, channel);
|
|
235001
235294
|
for (let i = 0; i < marketIds.length; i++) {
|
|
235002
235295
|
const messageHash = channel + ':' + marketIds[i];
|
|
235003
|
-
client.resolve(
|
|
235296
|
+
client.resolve(stored, messageHash);
|
|
235004
235297
|
}
|
|
235005
235298
|
}
|
|
235006
235299
|
}
|
|
@@ -278187,7 +278480,7 @@ SOFTWARE.
|
|
|
278187
278480
|
|
|
278188
278481
|
//-----------------------------------------------------------------------------
|
|
278189
278482
|
// this is updated by vss.js when building
|
|
278190
|
-
const version = '4.1.
|
|
278483
|
+
const version = '4.1.20';
|
|
278191
278484
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
|
|
278192
278485
|
//-----------------------------------------------------------------------------
|
|
278193
278486
|
|