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