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/cjs/src/bitget.js
CHANGED
|
@@ -2208,42 +2208,61 @@ class bitget extends bitget$1 {
|
|
|
2208
2208
|
// "symbol": "BTCUSDT_UMCBL"
|
|
2209
2209
|
// }
|
|
2210
2210
|
//
|
|
2211
|
-
//
|
|
2211
|
+
// spot: fetchMyTrades
|
|
2212
2212
|
//
|
|
2213
2213
|
// {
|
|
2214
|
-
// accountId:
|
|
2215
|
-
// symbol:
|
|
2216
|
-
// orderId:
|
|
2217
|
-
// fillId:
|
|
2218
|
-
// orderType:
|
|
2219
|
-
// side:
|
|
2220
|
-
// fillPrice:
|
|
2221
|
-
// fillQuantity:
|
|
2222
|
-
// fillTotalAmount:
|
|
2223
|
-
// feeCcy:
|
|
2224
|
-
// fees:
|
|
2225
|
-
//
|
|
2214
|
+
// "accountId": "7264631750",
|
|
2215
|
+
// "symbol": "BTCUSDT_SPBL",
|
|
2216
|
+
// "orderId": "1098394344925597696",
|
|
2217
|
+
// "fillId": "1098394344974925824",
|
|
2218
|
+
// "orderType": "market",
|
|
2219
|
+
// "side": "sell",
|
|
2220
|
+
// "fillPrice": "28467.68",
|
|
2221
|
+
// "fillQuantity": "0.0002",
|
|
2222
|
+
// "fillTotalAmount": "5.693536",
|
|
2223
|
+
// "feeCcy": "USDT",
|
|
2224
|
+
// "fees": "-0.005693536",
|
|
2225
|
+
// "takerMakerFlag": "taker",
|
|
2226
|
+
// "cTime": "1697603539699"
|
|
2226
2227
|
// }
|
|
2227
2228
|
//
|
|
2229
|
+
// swap and future: fetchMyTrades
|
|
2230
|
+
//
|
|
2228
2231
|
// {
|
|
2229
|
-
// tradeId:
|
|
2230
|
-
// symbol:
|
|
2231
|
-
// orderId:
|
|
2232
|
-
// price:
|
|
2233
|
-
// sizeQty:
|
|
2234
|
-
// fee:
|
|
2235
|
-
// side:
|
|
2236
|
-
// fillAmount:
|
|
2237
|
-
// profit:
|
|
2238
|
-
//
|
|
2232
|
+
// "tradeId": "1099351653724958721",
|
|
2233
|
+
// "symbol": "BTCUSDT_UMCBL",
|
|
2234
|
+
// "orderId": "1099351653682413569",
|
|
2235
|
+
// "price": "29531.3",
|
|
2236
|
+
// "sizeQty": "0.001",
|
|
2237
|
+
// "fee": "-0.01771878",
|
|
2238
|
+
// "side": "close_long",
|
|
2239
|
+
// "fillAmount": "29.5313",
|
|
2240
|
+
// "profit": "0.001",
|
|
2241
|
+
// "enterPointSource": "WEB",
|
|
2242
|
+
// "tradeSide": "close_long",
|
|
2243
|
+
// "holdMode": "double_hold",
|
|
2244
|
+
// "takerMakerFlag": "taker",
|
|
2245
|
+
// "cTime": "1697831779891"
|
|
2246
|
+
// }
|
|
2247
|
+
//
|
|
2248
|
+
// isolated and cross margin: fetchMyTrades
|
|
2249
|
+
//
|
|
2250
|
+
// {
|
|
2251
|
+
// "orderId": "1099353730455318528",
|
|
2252
|
+
// "fillId": "1099353730627092481",
|
|
2253
|
+
// "orderType": "market",
|
|
2254
|
+
// "side": "sell",
|
|
2255
|
+
// "fillPrice": "29543.7",
|
|
2256
|
+
// "fillQuantity": "0.0001",
|
|
2257
|
+
// "fillTotalAmount": "2.95437",
|
|
2258
|
+
// "feeCcy": "USDT",
|
|
2259
|
+
// "fees": "-0.00295437",
|
|
2260
|
+
// "ctime": "1697832275063"
|
|
2239
2261
|
// }
|
|
2240
2262
|
//
|
|
2241
2263
|
const marketId = this.safeString(trade, 'symbol');
|
|
2242
2264
|
const symbol = this.safeSymbol(marketId, market);
|
|
2243
|
-
|
|
2244
|
-
amount = this.safeString(trade, 'sizeQty', amount);
|
|
2245
|
-
let timestamp = this.safeInteger2(trade, 'fillTime', 'timestamp');
|
|
2246
|
-
timestamp = this.safeInteger(trade, 'cTime', timestamp);
|
|
2265
|
+
const timestamp = this.safeIntegerN(trade, ['fillTime', 'timestamp', 'ctime', 'cTime']);
|
|
2247
2266
|
let fee = undefined;
|
|
2248
2267
|
const feeAmount = this.safeString(trade, 'fees');
|
|
2249
2268
|
if (feeAmount !== undefined) {
|
|
@@ -2254,7 +2273,6 @@ class bitget extends bitget$1 {
|
|
|
2254
2273
|
'cost': Precise["default"].stringNeg(feeAmount),
|
|
2255
2274
|
};
|
|
2256
2275
|
}
|
|
2257
|
-
const datetime = this.iso8601(timestamp);
|
|
2258
2276
|
return this.safeTrade({
|
|
2259
2277
|
'info': trade,
|
|
2260
2278
|
'id': this.safeString2(trade, 'tradeId', 'fillId'),
|
|
@@ -2262,13 +2280,13 @@ class bitget extends bitget$1 {
|
|
|
2262
2280
|
'symbol': symbol,
|
|
2263
2281
|
'side': this.safeStringLower(trade, 'side'),
|
|
2264
2282
|
'type': this.safeString(trade, 'orderType'),
|
|
2265
|
-
'takerOrMaker':
|
|
2283
|
+
'takerOrMaker': this.safeString(trade, 'takerMakerFlag'),
|
|
2266
2284
|
'price': this.safeString2(trade, 'fillPrice', 'price'),
|
|
2267
|
-
'amount':
|
|
2285
|
+
'amount': this.safeStringN(trade, ['fillQuantity', 'size', 'sizeQty']),
|
|
2268
2286
|
'cost': undefined,
|
|
2269
|
-
'fee': fee,
|
|
2270
2287
|
'timestamp': timestamp,
|
|
2271
|
-
'datetime':
|
|
2288
|
+
'datetime': this.iso8601(timestamp),
|
|
2289
|
+
'fee': fee,
|
|
2272
2290
|
}, market);
|
|
2273
2291
|
}
|
|
2274
2292
|
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2944,18 +2962,31 @@ class bitget extends bitget$1 {
|
|
|
2944
2962
|
// "data": "1098753830701928448"
|
|
2945
2963
|
// }
|
|
2946
2964
|
//
|
|
2965
|
+
// isolated and cross margin: fetchOpenOrders, fetchCanceledOrders, fetchClosedOrders
|
|
2966
|
+
//
|
|
2967
|
+
// {
|
|
2968
|
+
// "symbol": "BTCUSDT",
|
|
2969
|
+
// "orderType": "limit",
|
|
2970
|
+
// "source": "WEB",
|
|
2971
|
+
// "orderId": "1099108898629627904",
|
|
2972
|
+
// "clientOid": "f9b55416029e4cc2bbbe2f40ac368c38",
|
|
2973
|
+
// "loanType": "autoLoan",
|
|
2974
|
+
// "price": "25000",
|
|
2975
|
+
// "side": "buy",
|
|
2976
|
+
// "status": "new",
|
|
2977
|
+
// "baseQuantity": "0.0002",
|
|
2978
|
+
// "quoteAmount": "5",
|
|
2979
|
+
// "fillPrice": "0",
|
|
2980
|
+
// "fillQuantity": "0",
|
|
2981
|
+
// "fillTotalAmount": "0",
|
|
2982
|
+
// "ctime": "1697773902588"
|
|
2983
|
+
// }
|
|
2984
|
+
//
|
|
2947
2985
|
const marketId = this.safeString(order, 'symbol');
|
|
2948
2986
|
market = this.safeMarket(marketId, market);
|
|
2949
|
-
const
|
|
2950
|
-
const
|
|
2951
|
-
const
|
|
2952
|
-
const amount = this.safeString2(order, 'quantity', 'size');
|
|
2953
|
-
const filled = this.safeString2(order, 'fillQuantity', 'filledQty');
|
|
2954
|
-
const cost = this.safeString2(order, 'fillTotalAmount', 'filledAmount');
|
|
2955
|
-
const average = this.safeString2(order, 'fillPrice', 'priceAvg');
|
|
2956
|
-
const type = this.safeString(order, 'orderType');
|
|
2957
|
-
const timestamp = this.safeInteger(order, 'cTime');
|
|
2958
|
-
const lastUpdatetimestamp = this.safeInteger(order, 'uTime');
|
|
2987
|
+
const timestamp = this.safeInteger2(order, 'cTime', 'ctime');
|
|
2988
|
+
const updateTimestamp = this.safeInteger(order, 'uTime');
|
|
2989
|
+
const rawStatus = this.safeString2(order, 'status', 'state');
|
|
2959
2990
|
let side = this.safeString2(order, 'side', 'posSide');
|
|
2960
2991
|
if ((side === 'open_long') || (side === 'close_short')) {
|
|
2961
2992
|
side = 'buy';
|
|
@@ -2963,7 +2994,6 @@ class bitget extends bitget$1 {
|
|
|
2963
2994
|
else if ((side === 'close_long') || (side === 'open_short')) {
|
|
2964
2995
|
side = 'sell';
|
|
2965
2996
|
}
|
|
2966
|
-
const clientOrderId = this.safeString2(order, 'clientOrderId', 'clientOid');
|
|
2967
2997
|
let fee = undefined;
|
|
2968
2998
|
const feeCostString = this.safeString(order, 'fee');
|
|
2969
2999
|
if (feeCostString !== undefined) {
|
|
@@ -2983,31 +3013,28 @@ class bitget extends bitget$1 {
|
|
|
2983
3013
|
'currency': this.safeCurrencyCode(this.safeString(first, 'feeCoinCode')),
|
|
2984
3014
|
};
|
|
2985
3015
|
}
|
|
2986
|
-
const rawStatus = this.safeString2(order, 'status', 'state');
|
|
2987
|
-
const status = this.parseOrderStatus(rawStatus);
|
|
2988
|
-
const lastTradeTimestamp = this.safeInteger(order, 'uTime');
|
|
2989
3016
|
return this.safeOrder({
|
|
2990
3017
|
'info': order,
|
|
2991
|
-
'id':
|
|
2992
|
-
'clientOrderId': clientOrderId,
|
|
3018
|
+
'id': this.safeString2(order, 'orderId', 'data'),
|
|
3019
|
+
'clientOrderId': this.safeString2(order, 'clientOrderId', 'clientOid'),
|
|
2993
3020
|
'timestamp': timestamp,
|
|
2994
3021
|
'datetime': this.iso8601(timestamp),
|
|
2995
|
-
'lastTradeTimestamp':
|
|
2996
|
-
'lastUpdateTimestamp':
|
|
2997
|
-
'symbol': symbol,
|
|
2998
|
-
'type':
|
|
3022
|
+
'lastTradeTimestamp': updateTimestamp,
|
|
3023
|
+
'lastUpdateTimestamp': updateTimestamp,
|
|
3024
|
+
'symbol': market['symbol'],
|
|
3025
|
+
'type': this.safeString(order, 'orderType'),
|
|
2999
3026
|
'timeInForce': undefined,
|
|
3000
3027
|
'postOnly': undefined,
|
|
3001
3028
|
'side': side,
|
|
3002
|
-
'price': price,
|
|
3029
|
+
'price': this.safeString2(order, 'price', 'executePrice'),
|
|
3003
3030
|
'stopPrice': this.safeNumber(order, 'triggerPrice'),
|
|
3004
3031
|
'triggerPrice': this.safeNumber(order, 'triggerPrice'),
|
|
3005
|
-
'average':
|
|
3006
|
-
'cost':
|
|
3007
|
-
'amount':
|
|
3008
|
-
'filled':
|
|
3032
|
+
'average': this.safeString2(order, 'fillPrice', 'priceAvg'),
|
|
3033
|
+
'cost': this.safeString2(order, 'fillTotalAmount', 'filledAmount'),
|
|
3034
|
+
'amount': this.safeStringN(order, ['quantity', 'size', 'baseQuantity']),
|
|
3035
|
+
'filled': this.safeString2(order, 'fillQuantity', 'filledQty'),
|
|
3009
3036
|
'remaining': undefined,
|
|
3010
|
-
'status':
|
|
3037
|
+
'status': this.parseOrderStatus(rawStatus),
|
|
3011
3038
|
'fee': fee,
|
|
3012
3039
|
'trades': undefined,
|
|
3013
3040
|
}, market);
|
|
@@ -3746,9 +3773,12 @@ class bitget extends bitget$1 {
|
|
|
3746
3773
|
* @name bitget#fetchOpenOrders
|
|
3747
3774
|
* @description fetch all unfilled currently open orders
|
|
3748
3775
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-order-list
|
|
3776
|
+
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-current-plan-orders
|
|
3749
3777
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-all-open-order
|
|
3750
3778
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-plan-order-tpsl-list
|
|
3751
3779
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-open-order
|
|
3780
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-open-orders
|
|
3781
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-open-orders
|
|
3752
3782
|
* @param {string} symbol unified market symbol
|
|
3753
3783
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
3754
3784
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
@@ -3757,32 +3787,59 @@ class bitget extends bitget$1 {
|
|
|
3757
3787
|
*/
|
|
3758
3788
|
await this.loadMarkets();
|
|
3759
3789
|
const request = {};
|
|
3760
|
-
let marketType = undefined;
|
|
3761
|
-
let query = undefined;
|
|
3762
3790
|
let market = undefined;
|
|
3791
|
+
let marketType = undefined;
|
|
3792
|
+
let marginMode = undefined;
|
|
3793
|
+
let response = undefined;
|
|
3763
3794
|
if (symbol !== undefined) {
|
|
3764
3795
|
market = this.market(symbol);
|
|
3765
|
-
|
|
3796
|
+
const symbolRequest = (marginMode !== undefined) ? (market['info']['symbolName']) : (market['id']);
|
|
3797
|
+
request['symbol'] = symbolRequest;
|
|
3766
3798
|
}
|
|
3767
|
-
[marketType,
|
|
3768
|
-
|
|
3769
|
-
const stop = this.
|
|
3799
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
|
|
3800
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
|
|
3801
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
3802
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
3770
3803
|
if (stop) {
|
|
3771
3804
|
this.checkRequiredSymbol('fetchOpenOrders', symbol);
|
|
3772
|
-
query = this.omit(query, 'stop');
|
|
3773
3805
|
if (marketType === 'spot') {
|
|
3774
3806
|
if (limit !== undefined) {
|
|
3775
3807
|
request['pageSize'] = limit;
|
|
3776
3808
|
}
|
|
3777
|
-
response = await this.privateSpotPostPlanCurrentPlan(this.extend(request,
|
|
3809
|
+
response = await this.privateSpotPostPlanCurrentPlan(this.extend(request, params));
|
|
3778
3810
|
}
|
|
3779
3811
|
else {
|
|
3780
|
-
response = await this.privateMixGetPlanCurrentPlan(this.extend(request,
|
|
3812
|
+
response = await this.privateMixGetPlanCurrentPlan(this.extend(request, params));
|
|
3781
3813
|
}
|
|
3782
3814
|
}
|
|
3783
3815
|
else {
|
|
3784
3816
|
if (marketType === 'spot') {
|
|
3785
|
-
|
|
3817
|
+
if (marginMode !== undefined) {
|
|
3818
|
+
const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
|
|
3819
|
+
const endTime = this.safeIntegerN(params, ['endTime', 'until', 'till']);
|
|
3820
|
+
params = this.omit(params, ['until', 'till', 'clientOrderId']);
|
|
3821
|
+
if (clientOrderId !== undefined) {
|
|
3822
|
+
request['clientOid'] = clientOrderId;
|
|
3823
|
+
}
|
|
3824
|
+
if (endTime !== undefined) {
|
|
3825
|
+
request['endTime'] = endTime;
|
|
3826
|
+
}
|
|
3827
|
+
if (since !== undefined) {
|
|
3828
|
+
request['startTime'] = since;
|
|
3829
|
+
}
|
|
3830
|
+
if (limit !== undefined) {
|
|
3831
|
+
request['pageSize'] = limit;
|
|
3832
|
+
}
|
|
3833
|
+
if (marginMode === 'isolated') {
|
|
3834
|
+
response = await this.privateMarginGetIsolatedOrderOpenOrders(this.extend(request, params));
|
|
3835
|
+
}
|
|
3836
|
+
else if (marginMode === 'cross') {
|
|
3837
|
+
response = await this.privateMarginGetCrossOrderOpenOrders(this.extend(request, params));
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
else {
|
|
3841
|
+
response = await this.privateSpotPostTradeOpenOrders(this.extend(request, params));
|
|
3842
|
+
}
|
|
3786
3843
|
}
|
|
3787
3844
|
else {
|
|
3788
3845
|
if (market === undefined) {
|
|
@@ -3794,10 +3851,11 @@ class bitget extends bitget$1 {
|
|
|
3794
3851
|
productType = 'S' + productType;
|
|
3795
3852
|
}
|
|
3796
3853
|
request['productType'] = productType;
|
|
3797
|
-
response = await this.privateMixGetOrderMarginCoinCurrent(this.extend(request,
|
|
3854
|
+
response = await this.privateMixGetOrderMarginCoinCurrent(this.extend(request, params));
|
|
3798
3855
|
}
|
|
3799
3856
|
else {
|
|
3800
|
-
|
|
3857
|
+
this.checkRequiredSymbol('fetchOpenOrders', symbol);
|
|
3858
|
+
response = await this.privateMixGetOrderCurrent(this.extend(request, params));
|
|
3801
3859
|
}
|
|
3802
3860
|
}
|
|
3803
3861
|
}
|
|
@@ -3904,10 +3962,45 @@ class bitget extends bitget$1 {
|
|
|
3904
3962
|
// }
|
|
3905
3963
|
// }
|
|
3906
3964
|
//
|
|
3965
|
+
// isolated and cross margin
|
|
3966
|
+
//
|
|
3967
|
+
// {
|
|
3968
|
+
// "code": "00000",
|
|
3969
|
+
// "msg": "success",
|
|
3970
|
+
// "requestTime": 1697773997250,
|
|
3971
|
+
// "data": {
|
|
3972
|
+
// "orderList": [
|
|
3973
|
+
// {
|
|
3974
|
+
// "symbol": "BTCUSDT",
|
|
3975
|
+
// "orderType": "limit",
|
|
3976
|
+
// "source": "WEB",
|
|
3977
|
+
// "orderId": "1099108898629627904",
|
|
3978
|
+
// "clientOid": "f9b55416029e4cc2bbbe2f40ac368c38",
|
|
3979
|
+
// "loanType": "autoLoan",
|
|
3980
|
+
// "price": "25000",
|
|
3981
|
+
// "side": "buy",
|
|
3982
|
+
// "status": "new",
|
|
3983
|
+
// "baseQuantity": "0.0002",
|
|
3984
|
+
// "quoteAmount": "5",
|
|
3985
|
+
// "fillPrice": "0",
|
|
3986
|
+
// "fillQuantity": "0",
|
|
3987
|
+
// "fillTotalAmount": "0",
|
|
3988
|
+
// "ctime": "1697773902588"
|
|
3989
|
+
// }
|
|
3990
|
+
// ],
|
|
3991
|
+
// "maxId": "1099108898629627904",
|
|
3992
|
+
// "minId": "1099108898629627904"
|
|
3993
|
+
// }
|
|
3994
|
+
// }
|
|
3995
|
+
//
|
|
3907
3996
|
if (typeof response === 'string') {
|
|
3908
3997
|
response = JSON.parse(response);
|
|
3909
3998
|
}
|
|
3910
3999
|
const data = this.safeValue(response, 'data', []);
|
|
4000
|
+
if (marginMode !== undefined) {
|
|
4001
|
+
const resultList = this.safeValue(data, 'orderList', []);
|
|
4002
|
+
return this.parseOrders(resultList, market, since, limit);
|
|
4003
|
+
}
|
|
3911
4004
|
if (!Array.isArray(data)) {
|
|
3912
4005
|
const result = this.safeValue(data, 'orderList', []);
|
|
3913
4006
|
return this.addPaginationCursorToResult(data, result);
|
|
@@ -3920,9 +4013,11 @@ class bitget extends bitget$1 {
|
|
|
3920
4013
|
* @name bitget#fetchClosedOrders
|
|
3921
4014
|
* @description fetches information on multiple closed orders made by the user
|
|
3922
4015
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-order-history
|
|
4016
|
+
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-history-plan-orders
|
|
3923
4017
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-orders
|
|
3924
4018
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-plan-orders-tpsl
|
|
3925
|
-
* @see https://bitgetlimited.github.io/apidoc/en/
|
|
4019
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-order-history
|
|
4020
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-order-history
|
|
3926
4021
|
* @param {string} symbol unified market symbol of the closed orders
|
|
3927
4022
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
3928
4023
|
* @param {int} [limit] the max number of closed orders to return
|
|
@@ -3958,9 +4053,11 @@ class bitget extends bitget$1 {
|
|
|
3958
4053
|
* @name bitget#fetchCanceledOrders
|
|
3959
4054
|
* @description fetches information on multiple canceled orders made by the user
|
|
3960
4055
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-order-history
|
|
4056
|
+
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-history-plan-orders
|
|
3961
4057
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-orders
|
|
3962
4058
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-plan-orders-tpsl
|
|
3963
|
-
* @see https://bitgetlimited.github.io/apidoc/en/
|
|
4059
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-order-history
|
|
4060
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-order-history
|
|
3964
4061
|
* @param {string} symbol unified market symbol of the canceled orders
|
|
3965
4062
|
* @param {int} [since] timestamp in ms of the earliest order
|
|
3966
4063
|
* @param {int} [limit] the max number of canceled orders to return
|
|
@@ -3994,37 +4091,30 @@ class bitget extends bitget$1 {
|
|
|
3994
4091
|
await this.loadMarkets();
|
|
3995
4092
|
const market = this.market(symbol);
|
|
3996
4093
|
let marketType = undefined;
|
|
4094
|
+
let marginMode = undefined;
|
|
4095
|
+
let response = undefined;
|
|
3997
4096
|
[marketType, params] = this.handleMarketTypeAndParams('fetchCanceledAndClosedOrders', market, params);
|
|
3998
|
-
|
|
3999
|
-
|
|
4097
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchCanceledAndClosedOrders', params);
|
|
4098
|
+
const symbolRequest = (marginMode !== undefined) ? (market['info']['symbolName']) : (market['id']);
|
|
4000
4099
|
const request = {
|
|
4001
|
-
'symbol':
|
|
4100
|
+
'symbol': symbolRequest,
|
|
4002
4101
|
};
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
}
|
|
4006
|
-
let method = this.getSupportedMapping(marketType, {
|
|
4007
|
-
'spot': 'privateSpotPostTradeHistory',
|
|
4008
|
-
'swap': 'privateMixGetOrderHistory',
|
|
4009
|
-
'future': 'privateMixGetOrderHistory',
|
|
4010
|
-
});
|
|
4102
|
+
const now = this.milliseconds();
|
|
4103
|
+
const endTime = this.safeIntegerN(params, ['endTime', 'until', 'till']);
|
|
4011
4104
|
const stop = this.safeValue(params, 'stop');
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
method = 'privateSpotPostPlanHistoryPlan';
|
|
4015
|
-
}
|
|
4016
|
-
else {
|
|
4017
|
-
method = 'privateMixGetPlanHistoryPlan';
|
|
4018
|
-
}
|
|
4019
|
-
params = this.omit(params, 'stop');
|
|
4020
|
-
}
|
|
4021
|
-
if (marketType === 'swap' || stop) {
|
|
4105
|
+
params = this.omit(params, ['until', 'till', 'stop']);
|
|
4106
|
+
if (stop || (marketType === 'swap') || (marketType === 'future')) {
|
|
4022
4107
|
if (limit === undefined) {
|
|
4023
4108
|
limit = 100;
|
|
4024
4109
|
}
|
|
4025
4110
|
request['pageSize'] = limit;
|
|
4026
4111
|
if (since === undefined) {
|
|
4027
|
-
|
|
4112
|
+
if (marketType === 'spot') {
|
|
4113
|
+
since = now - 7776000000;
|
|
4114
|
+
}
|
|
4115
|
+
else {
|
|
4116
|
+
since = 0;
|
|
4117
|
+
}
|
|
4028
4118
|
}
|
|
4029
4119
|
request['startTime'] = since;
|
|
4030
4120
|
if (endTime === undefined) {
|
|
@@ -4034,15 +4124,52 @@ class bitget extends bitget$1 {
|
|
|
4034
4124
|
request['endTime'] = endTime;
|
|
4035
4125
|
}
|
|
4036
4126
|
}
|
|
4127
|
+
if (stop) {
|
|
4128
|
+
if (marketType === 'spot') {
|
|
4129
|
+
response = await this.privateSpotPostPlanHistoryPlan(this.extend(request, params));
|
|
4130
|
+
}
|
|
4131
|
+
else {
|
|
4132
|
+
response = await this.privateMixGetPlanHistoryPlan(this.extend(request, params));
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4037
4135
|
else {
|
|
4038
|
-
if (
|
|
4039
|
-
|
|
4136
|
+
if ((marketType === 'swap') || (marketType === 'future')) {
|
|
4137
|
+
response = await this.privateMixGetOrderHistory(this.extend(request, params));
|
|
4040
4138
|
}
|
|
4041
|
-
|
|
4042
|
-
|
|
4139
|
+
else {
|
|
4140
|
+
if (marginMode !== undefined) {
|
|
4141
|
+
if (since === undefined) {
|
|
4142
|
+
since = now - 7776000000;
|
|
4143
|
+
}
|
|
4144
|
+
request['startTime'] = since;
|
|
4145
|
+
if (endTime !== undefined) {
|
|
4146
|
+
request['endTime'] = endTime;
|
|
4147
|
+
}
|
|
4148
|
+
if (limit !== undefined) {
|
|
4149
|
+
request['pageSize'] = limit;
|
|
4150
|
+
}
|
|
4151
|
+
if (marginMode === 'isolated') {
|
|
4152
|
+
response = await this.privateMarginGetIsolatedOrderHistory(this.extend(request, params));
|
|
4153
|
+
}
|
|
4154
|
+
else if (marginMode === 'cross') {
|
|
4155
|
+
response = await this.privateMarginGetCrossOrderHistory(this.extend(request, params));
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
else {
|
|
4159
|
+
if (limit !== undefined) {
|
|
4160
|
+
request['limit'] = limit;
|
|
4161
|
+
}
|
|
4162
|
+
if (since !== undefined) {
|
|
4163
|
+
request['after'] = since;
|
|
4164
|
+
}
|
|
4165
|
+
if (endTime !== undefined) {
|
|
4166
|
+
params = this.omit(params, 'endTime');
|
|
4167
|
+
request['before'] = endTime;
|
|
4168
|
+
}
|
|
4169
|
+
response = await this.privateSpotPostTradeHistory(this.extend(request, params));
|
|
4170
|
+
}
|
|
4043
4171
|
}
|
|
4044
4172
|
}
|
|
4045
|
-
const response = await this[method](this.extend(request, params));
|
|
4046
4173
|
//
|
|
4047
4174
|
// spot
|
|
4048
4175
|
//
|
|
@@ -4159,6 +4286,37 @@ class bitget extends bitget$1 {
|
|
|
4159
4286
|
// "requestTime":1627354109502
|
|
4160
4287
|
// }
|
|
4161
4288
|
//
|
|
4289
|
+
// isolated and cross margin
|
|
4290
|
+
//
|
|
4291
|
+
// {
|
|
4292
|
+
// "code": "00000",
|
|
4293
|
+
// "msg": "success",
|
|
4294
|
+
// "requestTime": 1697779608818,
|
|
4295
|
+
// "data": {
|
|
4296
|
+
// "orderList": [
|
|
4297
|
+
// {
|
|
4298
|
+
// "symbol": "BTCUSDT",
|
|
4299
|
+
// "orderType": "limit",
|
|
4300
|
+
// "source": "API",
|
|
4301
|
+
// "orderId": "1098761451063619584",
|
|
4302
|
+
// "clientOid": "8d8ac3454ed345fca914c9cd55682121",
|
|
4303
|
+
// "loanType": "normal",
|
|
4304
|
+
// "price": "25000",
|
|
4305
|
+
// "side": "buy",
|
|
4306
|
+
// "status": "cancelled",
|
|
4307
|
+
// "baseQuantity": "0.0002",
|
|
4308
|
+
// "quoteAmount": "0",
|
|
4309
|
+
// "fillPrice": "0",
|
|
4310
|
+
// "fillQuantity": "0",
|
|
4311
|
+
// "fillTotalAmount": "0",
|
|
4312
|
+
// "ctime": "1697691064614"
|
|
4313
|
+
// },
|
|
4314
|
+
// ],
|
|
4315
|
+
// "maxId": "1098761451063619584",
|
|
4316
|
+
// "minId": "1098394690472521728"
|
|
4317
|
+
// }
|
|
4318
|
+
// }
|
|
4319
|
+
//
|
|
4162
4320
|
const data = this.safeValue(response, 'data');
|
|
4163
4321
|
if (data !== undefined) {
|
|
4164
4322
|
if ('orderList' in data) {
|
|
@@ -4297,12 +4455,14 @@ class bitget extends bitget$1 {
|
|
|
4297
4455
|
* @description fetch all trades made by the user
|
|
4298
4456
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#get-transaction-details
|
|
4299
4457
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-order-fill-detail
|
|
4458
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-transaction-details
|
|
4459
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-order-fills
|
|
4300
4460
|
* @param {string} symbol unified market symbol
|
|
4301
4461
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
4302
4462
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
4303
4463
|
* @param {object} [params] extra parameters specific to the bitget api endpoint
|
|
4304
|
-
* @param {int} [params.until]
|
|
4305
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
4464
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
4465
|
+
* @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)
|
|
4306
4466
|
* @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
|
|
4307
4467
|
*/
|
|
4308
4468
|
this.checkRequiredSymbol('fetchMyTrades', symbol);
|
|
@@ -4318,15 +4478,43 @@ class bitget extends bitget$1 {
|
|
|
4318
4478
|
return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params, 500);
|
|
4319
4479
|
}
|
|
4320
4480
|
}
|
|
4481
|
+
let response = undefined;
|
|
4482
|
+
let marginMode = undefined;
|
|
4483
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
4484
|
+
const symbolRequest = (marginMode !== undefined) ? (market['info']['symbolName']) : (market['id']);
|
|
4321
4485
|
let request = {
|
|
4322
|
-
'symbol':
|
|
4486
|
+
'symbol': symbolRequest,
|
|
4323
4487
|
};
|
|
4324
|
-
if (limit !== undefined) {
|
|
4325
|
-
request['limit'] = limit;
|
|
4326
|
-
}
|
|
4327
|
-
let response = undefined;
|
|
4328
4488
|
if (market['spot']) {
|
|
4329
|
-
|
|
4489
|
+
if (marginMode !== undefined) {
|
|
4490
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
4491
|
+
if (since !== undefined) {
|
|
4492
|
+
request['startTime'] = since;
|
|
4493
|
+
}
|
|
4494
|
+
else {
|
|
4495
|
+
const now = this.milliseconds();
|
|
4496
|
+
request['startTime'] = now - 7776000000;
|
|
4497
|
+
}
|
|
4498
|
+
if (limit !== undefined) {
|
|
4499
|
+
request['pageSize'] = limit;
|
|
4500
|
+
}
|
|
4501
|
+
if (marginMode === 'isolated') {
|
|
4502
|
+
response = await this.privateMarginGetIsolatedOrderFills(this.extend(request, params));
|
|
4503
|
+
}
|
|
4504
|
+
else if (marginMode === 'cross') {
|
|
4505
|
+
response = await this.privateMarginGetCrossOrderFills(this.extend(request, params));
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
else {
|
|
4509
|
+
[request, params] = this.handleUntilOption('before', request, params);
|
|
4510
|
+
if (since !== undefined) {
|
|
4511
|
+
request['after'] = since;
|
|
4512
|
+
}
|
|
4513
|
+
if (limit !== undefined) {
|
|
4514
|
+
request['limit'] = limit;
|
|
4515
|
+
}
|
|
4516
|
+
response = await this.privateSpotPostTradeFills(this.extend(request, params));
|
|
4517
|
+
}
|
|
4330
4518
|
}
|
|
4331
4519
|
else {
|
|
4332
4520
|
const orderId = this.safeString(params, 'orderId'); // when order id is not defined, startTime and endTime are required
|
|
@@ -4343,29 +4531,88 @@ class bitget extends bitget$1 {
|
|
|
4343
4531
|
response = await this.privateMixGetOrderFills(this.extend(request, params));
|
|
4344
4532
|
}
|
|
4345
4533
|
//
|
|
4534
|
+
// spot
|
|
4535
|
+
//
|
|
4346
4536
|
// {
|
|
4347
|
-
//
|
|
4348
|
-
//
|
|
4349
|
-
//
|
|
4350
|
-
//
|
|
4351
|
-
//
|
|
4352
|
-
//
|
|
4353
|
-
//
|
|
4354
|
-
//
|
|
4355
|
-
//
|
|
4356
|
-
//
|
|
4357
|
-
//
|
|
4358
|
-
//
|
|
4359
|
-
//
|
|
4360
|
-
//
|
|
4361
|
-
//
|
|
4362
|
-
//
|
|
4363
|
-
//
|
|
4537
|
+
// "code": "00000",
|
|
4538
|
+
// "msg": "success",
|
|
4539
|
+
// "requestTime": 1697831543676,
|
|
4540
|
+
// "data": [
|
|
4541
|
+
// {
|
|
4542
|
+
// "accountId": "7264631750",
|
|
4543
|
+
// "symbol": "BTCUSDT_SPBL",
|
|
4544
|
+
// "orderId": "1098394344925597696",
|
|
4545
|
+
// "fillId": "1098394344974925824",
|
|
4546
|
+
// "orderType": "market",
|
|
4547
|
+
// "side": "sell",
|
|
4548
|
+
// "fillPrice": "28467.68",
|
|
4549
|
+
// "fillQuantity": "0.0002",
|
|
4550
|
+
// "fillTotalAmount": "5.693536",
|
|
4551
|
+
// "feeCcy": "USDT",
|
|
4552
|
+
// "fees": "-0.005693536",
|
|
4553
|
+
// "takerMakerFlag": "taker",
|
|
4554
|
+
// "cTime": "1697603539699"
|
|
4555
|
+
// },
|
|
4556
|
+
// ]
|
|
4557
|
+
// }
|
|
4558
|
+
//
|
|
4559
|
+
// swap and future
|
|
4560
|
+
//
|
|
4561
|
+
// {
|
|
4562
|
+
// "code": "00000",
|
|
4563
|
+
// "msg": "success",
|
|
4564
|
+
// "requestTime": 1697831790948,
|
|
4565
|
+
// "data": [
|
|
4566
|
+
// {
|
|
4567
|
+
// "tradeId": "1099351653724958721",
|
|
4568
|
+
// "symbol": "BTCUSDT_UMCBL",
|
|
4569
|
+
// "orderId": "1099351653682413569",
|
|
4570
|
+
// "price": "29531.3",
|
|
4571
|
+
// "sizeQty": "0.001",
|
|
4572
|
+
// "fee": "-0.01771878",
|
|
4573
|
+
// "side": "close_long",
|
|
4574
|
+
// "fillAmount": "29.5313",
|
|
4575
|
+
// "profit": "0.001",
|
|
4576
|
+
// "enterPointSource": "WEB",
|
|
4577
|
+
// "tradeSide": "close_long",
|
|
4578
|
+
// "holdMode": "double_hold",
|
|
4579
|
+
// "takerMakerFlag": "taker",
|
|
4580
|
+
// "cTime": "1697831779891"
|
|
4581
|
+
// },
|
|
4582
|
+
// ]
|
|
4583
|
+
// }
|
|
4584
|
+
//
|
|
4585
|
+
// isolated and cross margin
|
|
4586
|
+
//
|
|
4587
|
+
// {
|
|
4588
|
+
// "code": "00000",
|
|
4589
|
+
// "msg": "success",
|
|
4590
|
+
// "requestTime": 1697832285469,
|
|
4591
|
+
// "data": {
|
|
4592
|
+
// "fills": [
|
|
4593
|
+
// {
|
|
4594
|
+
// "orderId": "1099353730455318528",
|
|
4595
|
+
// "fillId": "1099353730627092481",
|
|
4596
|
+
// "orderType": "market",
|
|
4597
|
+
// "side": "sell",
|
|
4598
|
+
// "fillPrice": "29543.7",
|
|
4599
|
+
// "fillQuantity": "0.0001",
|
|
4600
|
+
// "fillTotalAmount": "2.95437",
|
|
4601
|
+
// "feeCcy": "USDT",
|
|
4602
|
+
// "fees": "-0.00295437",
|
|
4603
|
+
// "ctime": "1697832275063"
|
|
4604
|
+
// },
|
|
4605
|
+
// ],
|
|
4606
|
+
// "minId": "1099353591699161118",
|
|
4607
|
+
// "maxId": "1099353730627092481"
|
|
4364
4608
|
// }
|
|
4365
|
-
// ]
|
|
4366
4609
|
// }
|
|
4367
4610
|
//
|
|
4368
4611
|
const data = this.safeValue(response, 'data');
|
|
4612
|
+
if (marginMode !== undefined) {
|
|
4613
|
+
const fills = this.safeValue(data, 'fills', []);
|
|
4614
|
+
return this.parseTrades(fills, market, since, limit);
|
|
4615
|
+
}
|
|
4369
4616
|
return this.parseTrades(data, market, since, limit);
|
|
4370
4617
|
}
|
|
4371
4618
|
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|