ccxt 4.2.43 → 4.2.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.js +1489 -463
- package/dist/ccxt.browser.min.js +6 -6
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +54 -0
- package/dist/cjs/src/binance.js +627 -51
- package/dist/cjs/src/bingx.js +46 -6
- package/dist/cjs/src/bitstamp.js +1 -1
- package/dist/cjs/src/blofin.js +2 -1
- package/dist/cjs/src/bybit.js +96 -43
- package/dist/cjs/src/coinbase.js +221 -41
- package/dist/cjs/src/deribit.js +1 -1
- package/dist/cjs/src/krakenfutures.js +3 -2
- package/dist/cjs/src/kucoin.js +9 -5
- package/dist/cjs/src/mexc.js +348 -266
- package/dist/cjs/src/pro/gate.js +76 -42
- package/dist/cjs/src/pro/hitbtc.js +1 -0
- package/dist/cjs/src/probit.js +3 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/coinbase.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +54 -0
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +627 -51
- package/js/src/bingx.d.ts +2 -1
- package/js/src/bingx.js +46 -6
- package/js/src/bitstamp.js +1 -1
- package/js/src/blofin.js +2 -1
- package/js/src/bybit.d.ts +4 -1
- package/js/src/bybit.js +96 -43
- package/js/src/coinbase.d.ts +10 -4
- package/js/src/coinbase.js +221 -41
- package/js/src/coinbasepro.d.ts +1 -1
- package/js/src/deribit.js +1 -1
- package/js/src/krakenfutures.js +3 -2
- package/js/src/kucoin.js +9 -5
- package/js/src/mexc.d.ts +4 -5
- package/js/src/mexc.js +348 -266
- package/js/src/pro/gate.d.ts +4 -0
- package/js/src/pro/gate.js +76 -42
- package/js/src/pro/hitbtc.js +1 -0
- package/js/src/probit.js +3 -3
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/package.json +1 -1
- package/skip-tests.json +2 -0
package/dist/cjs/src/binance.js
CHANGED
|
@@ -99,7 +99,7 @@ class binance extends binance$1 {
|
|
|
99
99
|
'fetchOHLCV': true,
|
|
100
100
|
'fetchOpenInterest': true,
|
|
101
101
|
'fetchOpenInterestHistory': true,
|
|
102
|
-
'fetchOpenOrder':
|
|
102
|
+
'fetchOpenOrder': true,
|
|
103
103
|
'fetchOpenOrders': true,
|
|
104
104
|
'fetchOrder': true,
|
|
105
105
|
'fetchOrderBook': true,
|
|
@@ -2652,9 +2652,11 @@ class binance extends binance$1 {
|
|
|
2652
2652
|
const networkList = this.safeList(entry, 'networkList', []);
|
|
2653
2653
|
const fees = {};
|
|
2654
2654
|
let fee = undefined;
|
|
2655
|
+
const networks = {};
|
|
2655
2656
|
for (let j = 0; j < networkList.length; j++) {
|
|
2656
2657
|
const networkItem = networkList[j];
|
|
2657
2658
|
const network = this.safeString(networkItem, 'network');
|
|
2659
|
+
const networkCode = this.networkIdToCode(network);
|
|
2658
2660
|
// const name = this.safeString (networkItem, 'name');
|
|
2659
2661
|
const withdrawFee = this.safeNumber(networkItem, 'withdrawFee');
|
|
2660
2662
|
const depositEnable = this.safeBool(networkItem, 'depositEnable');
|
|
@@ -2672,6 +2674,26 @@ class binance extends binance$1 {
|
|
|
2672
2674
|
if (!Precise["default"].stringEq(precisionTick, '0')) {
|
|
2673
2675
|
minPrecision = (minPrecision === undefined) ? precisionTick : Precise["default"].stringMin(minPrecision, precisionTick);
|
|
2674
2676
|
}
|
|
2677
|
+
networks[networkCode] = {
|
|
2678
|
+
'info': networkItem,
|
|
2679
|
+
'id': network,
|
|
2680
|
+
'network': networkCode,
|
|
2681
|
+
'active': depositEnable && withdrawEnable,
|
|
2682
|
+
'deposit': depositEnable,
|
|
2683
|
+
'withdraw': withdrawEnable,
|
|
2684
|
+
'fee': this.parseNumber(fee),
|
|
2685
|
+
'precision': minPrecision,
|
|
2686
|
+
'limits': {
|
|
2687
|
+
'withdraw': {
|
|
2688
|
+
'min': this.safeNumber(networkItem, 'withdrawMin'),
|
|
2689
|
+
'max': this.safeNumber(networkItem, 'withdrawMax'),
|
|
2690
|
+
},
|
|
2691
|
+
'deposit': {
|
|
2692
|
+
'min': undefined,
|
|
2693
|
+
'max': undefined,
|
|
2694
|
+
},
|
|
2695
|
+
},
|
|
2696
|
+
};
|
|
2675
2697
|
}
|
|
2676
2698
|
const trading = this.safeBool(entry, 'trading');
|
|
2677
2699
|
const active = (isWithdrawEnabled && isDepositEnabled && trading);
|
|
@@ -2688,7 +2710,7 @@ class binance extends binance$1 {
|
|
|
2688
2710
|
'active': active,
|
|
2689
2711
|
'deposit': isDepositEnabled,
|
|
2690
2712
|
'withdraw': isWithdrawEnabled,
|
|
2691
|
-
'networks':
|
|
2713
|
+
'networks': networks,
|
|
2692
2714
|
'fee': fee,
|
|
2693
2715
|
'fees': fees,
|
|
2694
2716
|
'limits': this.limits,
|
|
@@ -5101,7 +5123,7 @@ class binance extends binance$1 {
|
|
|
5101
5123
|
// "msg": "Quantity greater than max quantity."
|
|
5102
5124
|
// }
|
|
5103
5125
|
//
|
|
5104
|
-
// createOrder, fetchOpenOrders, fetchOrder, cancelOrder: portfolio margin linear swap and future
|
|
5126
|
+
// createOrder, fetchOpenOrders, fetchOrder, cancelOrder, fetchOrders: portfolio margin linear swap and future
|
|
5105
5127
|
//
|
|
5106
5128
|
// {
|
|
5107
5129
|
// "symbol": "BTCUSDT",
|
|
@@ -5124,7 +5146,7 @@ class binance extends binance$1 {
|
|
|
5124
5146
|
// "status": "NEW"
|
|
5125
5147
|
// }
|
|
5126
5148
|
//
|
|
5127
|
-
// createOrder, fetchOpenOrders, fetchOrder, cancelOrder: portfolio margin inverse swap and future
|
|
5149
|
+
// createOrder, fetchOpenOrders, fetchOrder, cancelOrder, fetchOrders: portfolio margin inverse swap and future
|
|
5128
5150
|
//
|
|
5129
5151
|
// {
|
|
5130
5152
|
// "symbol": "ETHUSD_PERP",
|
|
@@ -5146,7 +5168,7 @@ class binance extends binance$1 {
|
|
|
5146
5168
|
// "status": "NEW"
|
|
5147
5169
|
// }
|
|
5148
5170
|
//
|
|
5149
|
-
// createOrder, fetchOpenOrders: portfolio margin linear swap and future conditional
|
|
5171
|
+
// createOrder, fetchOpenOrders, fetchOpenOrder: portfolio margin linear swap and future conditional
|
|
5150
5172
|
//
|
|
5151
5173
|
// {
|
|
5152
5174
|
// "newClientStrategyId": "x-xcKtGhcu27f109953d6e4dc0974006",
|
|
@@ -5209,7 +5231,7 @@ class binance extends binance$1 {
|
|
|
5209
5231
|
// "type": "LIMIT"
|
|
5210
5232
|
// }
|
|
5211
5233
|
//
|
|
5212
|
-
// fetchOpenOrders, fetchOrder: portfolio margin spot margin
|
|
5234
|
+
// fetchOpenOrders, fetchOrder, fetchOrders: portfolio margin spot margin
|
|
5213
5235
|
//
|
|
5214
5236
|
// {
|
|
5215
5237
|
// "symbol": "BTCUSDT",
|
|
@@ -5259,6 +5281,156 @@ class binance extends binance$1 {
|
|
|
5259
5281
|
// "selfTradePreventionMode": "NONE"
|
|
5260
5282
|
// }
|
|
5261
5283
|
//
|
|
5284
|
+
// fetchOrders: portfolio margin linear and inverse swap conditional
|
|
5285
|
+
//
|
|
5286
|
+
// {
|
|
5287
|
+
// "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
|
|
5288
|
+
// "strategyId": 3733211,
|
|
5289
|
+
// "strategyStatus": "CANCELLED",
|
|
5290
|
+
// "strategyType": "STOP",
|
|
5291
|
+
// "origQty": "0.010",
|
|
5292
|
+
// "price": "35000",
|
|
5293
|
+
// "orderId": 0,
|
|
5294
|
+
// "reduceOnly": false,
|
|
5295
|
+
// "side": "BUY",
|
|
5296
|
+
// "positionSide": "BOTH",
|
|
5297
|
+
// "stopPrice": "50000",
|
|
5298
|
+
// "symbol": "BTCUSDT",
|
|
5299
|
+
// "type": "LIMIT",
|
|
5300
|
+
// "bookTime": 1707270098774,
|
|
5301
|
+
// "updateTime": 1707270119261,
|
|
5302
|
+
// "timeInForce": "GTC",
|
|
5303
|
+
// "triggerTime": 0,
|
|
5304
|
+
// "workingType": "CONTRACT_PRICE",
|
|
5305
|
+
// "priceProtect": false,
|
|
5306
|
+
// "goodTillDate": 0,
|
|
5307
|
+
// "selfTradePreventionMode": "NONE"
|
|
5308
|
+
// }
|
|
5309
|
+
//
|
|
5310
|
+
// fetchOpenOrder: linear swap
|
|
5311
|
+
//
|
|
5312
|
+
// {
|
|
5313
|
+
// "orderId": 3697213934,
|
|
5314
|
+
// "symbol": "BTCUSDT",
|
|
5315
|
+
// "status": "NEW",
|
|
5316
|
+
// "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
|
|
5317
|
+
// "price": "33000.00",
|
|
5318
|
+
// "avgPrice": "0.00000",
|
|
5319
|
+
// "origQty": "0.010",
|
|
5320
|
+
// "executedQty": "0.000",
|
|
5321
|
+
// "cumQuote": "0.00000",
|
|
5322
|
+
// "timeInForce": "GTC",
|
|
5323
|
+
// "type": "LIMIT",
|
|
5324
|
+
// "reduceOnly": false,
|
|
5325
|
+
// "closePosition": false,
|
|
5326
|
+
// "side": "BUY",
|
|
5327
|
+
// "positionSide": "BOTH",
|
|
5328
|
+
// "stopPrice": "0.00",
|
|
5329
|
+
// "workingType": "CONTRACT_PRICE",
|
|
5330
|
+
// "priceProtect": false,
|
|
5331
|
+
// "origType": "LIMIT",
|
|
5332
|
+
// "priceMatch": "NONE",
|
|
5333
|
+
// "selfTradePreventionMode": "NONE",
|
|
5334
|
+
// "goodTillDate": 0,
|
|
5335
|
+
// "time": 1707892893502,
|
|
5336
|
+
// "updateTime": 1707892893515
|
|
5337
|
+
// }
|
|
5338
|
+
//
|
|
5339
|
+
// fetchOpenOrder: inverse swap
|
|
5340
|
+
//
|
|
5341
|
+
// {
|
|
5342
|
+
// "orderId": 597368542,
|
|
5343
|
+
// "symbol": "BTCUSD_PERP",
|
|
5344
|
+
// "pair": "BTCUSD",
|
|
5345
|
+
// "status": "NEW",
|
|
5346
|
+
// "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
|
|
5347
|
+
// "price": "35000",
|
|
5348
|
+
// "avgPrice": "0",
|
|
5349
|
+
// "origQty": "1",
|
|
5350
|
+
// "executedQty": "0",
|
|
5351
|
+
// "cumBase": "0",
|
|
5352
|
+
// "timeInForce": "GTC",
|
|
5353
|
+
// "type": "LIMIT",
|
|
5354
|
+
// "reduceOnly": false,
|
|
5355
|
+
// "closePosition": false,
|
|
5356
|
+
// "side": "BUY",
|
|
5357
|
+
// "positionSide": "BOTH",
|
|
5358
|
+
// "stopPrice": "0",
|
|
5359
|
+
// "workingType": "CONTRACT_PRICE",
|
|
5360
|
+
// "priceProtect": false,
|
|
5361
|
+
// "origType": "LIMIT",
|
|
5362
|
+
// "time": 1707893453199,
|
|
5363
|
+
// "updateTime": 1707893453199
|
|
5364
|
+
// }
|
|
5365
|
+
//
|
|
5366
|
+
// fetchOpenOrder: linear portfolio margin
|
|
5367
|
+
//
|
|
5368
|
+
// {
|
|
5369
|
+
// "orderId": 264895013409,
|
|
5370
|
+
// "symbol": "BTCUSDT",
|
|
5371
|
+
// "status": "NEW",
|
|
5372
|
+
// "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
|
|
5373
|
+
// "price": "35000",
|
|
5374
|
+
// "avgPrice": "0",
|
|
5375
|
+
// "origQty": "0.010",
|
|
5376
|
+
// "executedQty": "0",
|
|
5377
|
+
// "cumQuote": "0",
|
|
5378
|
+
// "timeInForce": "GTC",
|
|
5379
|
+
// "type": "LIMIT",
|
|
5380
|
+
// "reduceOnly": false,
|
|
5381
|
+
// "side": "BUY",
|
|
5382
|
+
// "positionSide": "LONG",
|
|
5383
|
+
// "origType": "LIMIT",
|
|
5384
|
+
// "time": 1707893839364,
|
|
5385
|
+
// "updateTime": 1707893839364,
|
|
5386
|
+
// "goodTillDate": 0,
|
|
5387
|
+
// "selfTradePreventionMode": "NONE"
|
|
5388
|
+
// }
|
|
5389
|
+
//
|
|
5390
|
+
// fetchOpenOrder: inverse portfolio margin
|
|
5391
|
+
//
|
|
5392
|
+
// {
|
|
5393
|
+
// "orderId": 71790316950,
|
|
5394
|
+
// "symbol": "ETHUSD_PERP",
|
|
5395
|
+
// "pair": "ETHUSD",
|
|
5396
|
+
// "status": "NEW",
|
|
5397
|
+
// "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
|
|
5398
|
+
// "price": "2500",
|
|
5399
|
+
// "avgPrice": "0",
|
|
5400
|
+
// "origQty": "1",
|
|
5401
|
+
// "executedQty": "0",
|
|
5402
|
+
// "cumBase": "0",
|
|
5403
|
+
// "timeInForce": "GTC",
|
|
5404
|
+
// "type": "LIMIT",
|
|
5405
|
+
// "reduceOnly": false,
|
|
5406
|
+
// "side": "BUY",
|
|
5407
|
+
// "positionSide": "LONG",
|
|
5408
|
+
// "origType": "LIMIT",
|
|
5409
|
+
// "time": 1707894181694,
|
|
5410
|
+
// "updateTime": 1707894181694
|
|
5411
|
+
// }
|
|
5412
|
+
//
|
|
5413
|
+
// fetchOpenOrder: inverse portfolio margin conditional
|
|
5414
|
+
//
|
|
5415
|
+
// {
|
|
5416
|
+
// "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
|
|
5417
|
+
// "strategyId": 1423501,
|
|
5418
|
+
// "strategyStatus": "NEW",
|
|
5419
|
+
// "strategyType": "STOP",
|
|
5420
|
+
// "origQty": "1",
|
|
5421
|
+
// "price": "2500",
|
|
5422
|
+
// "reduceOnly": false,
|
|
5423
|
+
// "side": "BUY",
|
|
5424
|
+
// "positionSide": "LONG",
|
|
5425
|
+
// "stopPrice": "4000",
|
|
5426
|
+
// "symbol": "ETHUSD_PERP",
|
|
5427
|
+
// "bookTime": 1707894782679,
|
|
5428
|
+
// "updateTime": 1707894782679,
|
|
5429
|
+
// "timeInForce": "GTC",
|
|
5430
|
+
// "workingType": "CONTRACT_PRICE",
|
|
5431
|
+
// "priceProtect": false
|
|
5432
|
+
// }
|
|
5433
|
+
//
|
|
5262
5434
|
const code = this.safeString(order, 'code');
|
|
5263
5435
|
if (code !== undefined) {
|
|
5264
5436
|
// cancelOrders/createOrders might have a partial success
|
|
@@ -5317,7 +5489,7 @@ class binance extends binance$1 {
|
|
|
5317
5489
|
}
|
|
5318
5490
|
return this.safeOrder({
|
|
5319
5491
|
'info': order,
|
|
5320
|
-
'id': this.safeString2(order, '
|
|
5492
|
+
'id': this.safeString2(order, 'strategyId', 'orderId'),
|
|
5321
5493
|
'clientOrderId': this.safeString2(order, 'clientOrderId', 'newClientStrategyId'),
|
|
5322
5494
|
'timestamp': timestamp,
|
|
5323
5495
|
'datetime': this.iso8601(timestamp),
|
|
@@ -5952,13 +6124,20 @@ class binance extends binance$1 {
|
|
|
5952
6124
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
|
|
5953
6125
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
|
|
5954
6126
|
* @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
|
|
6127
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
|
|
6128
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
|
|
6129
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
|
|
6130
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
|
|
6131
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
|
|
5955
6132
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
5956
6133
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
5957
6134
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
5958
6135
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5959
6136
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
|
5960
6137
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
5961
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
6138
|
+
* @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)
|
|
6139
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
|
|
6140
|
+
* @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
|
|
5962
6141
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5963
6142
|
*/
|
|
5964
6143
|
if (symbol === undefined) {
|
|
@@ -5971,17 +6150,18 @@ class binance extends binance$1 {
|
|
|
5971
6150
|
return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
|
|
5972
6151
|
}
|
|
5973
6152
|
const market = this.market(symbol);
|
|
5974
|
-
const defaultType = this.safeString2(this.options, 'fetchOrders', 'defaultType', '
|
|
6153
|
+
const defaultType = this.safeString2(this.options, 'fetchOrders', 'defaultType', market['type']);
|
|
5975
6154
|
const type = this.safeString(params, 'type', defaultType);
|
|
5976
|
-
|
|
5977
|
-
|
|
6155
|
+
let marginMode = undefined;
|
|
6156
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchOrders', params);
|
|
6157
|
+
let isPortfolioMargin = undefined;
|
|
6158
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOrders', 'papi', 'portfolioMargin', false);
|
|
6159
|
+
const isConditional = this.safeBool2(params, 'stop', 'conditional');
|
|
6160
|
+
params = this.omit(params, ['stop', 'conditional', 'type']);
|
|
6161
|
+
let request = {
|
|
5978
6162
|
'symbol': market['id'],
|
|
5979
6163
|
};
|
|
5980
|
-
|
|
5981
|
-
if (until !== undefined) {
|
|
5982
|
-
params = this.omit(params, 'until');
|
|
5983
|
-
request['endTime'] = until;
|
|
5984
|
-
}
|
|
6164
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
5985
6165
|
if (since !== undefined) {
|
|
5986
6166
|
request['startTime'] = since;
|
|
5987
6167
|
}
|
|
@@ -5990,22 +6170,47 @@ class binance extends binance$1 {
|
|
|
5990
6170
|
}
|
|
5991
6171
|
let response = undefined;
|
|
5992
6172
|
if (market['option']) {
|
|
5993
|
-
response = await this.eapiPrivateGetHistoryOrders(this.extend(request,
|
|
6173
|
+
response = await this.eapiPrivateGetHistoryOrders(this.extend(request, params));
|
|
5994
6174
|
}
|
|
5995
6175
|
else if (market['linear']) {
|
|
5996
|
-
|
|
6176
|
+
if (isPortfolioMargin) {
|
|
6177
|
+
if (isConditional) {
|
|
6178
|
+
response = await this.papiGetUmConditionalAllOrders(this.extend(request, params));
|
|
6179
|
+
}
|
|
6180
|
+
else {
|
|
6181
|
+
response = await this.papiGetUmAllOrders(this.extend(request, params));
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6184
|
+
else {
|
|
6185
|
+
response = await this.fapiPrivateGetAllOrders(this.extend(request, params));
|
|
6186
|
+
}
|
|
5997
6187
|
}
|
|
5998
6188
|
else if (market['inverse']) {
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6189
|
+
if (isPortfolioMargin) {
|
|
6190
|
+
if (isConditional) {
|
|
6191
|
+
response = await this.papiGetCmConditionalAllOrders(this.extend(request, params));
|
|
6192
|
+
}
|
|
6193
|
+
else {
|
|
6194
|
+
response = await this.papiGetCmAllOrders(this.extend(request, params));
|
|
6195
|
+
}
|
|
6196
|
+
}
|
|
6197
|
+
else {
|
|
6198
|
+
response = await this.dapiPrivateGetAllOrders(this.extend(request, params));
|
|
6004
6199
|
}
|
|
6005
|
-
response = await this.sapiGetMarginAllOrders(this.extend(request, query));
|
|
6006
6200
|
}
|
|
6007
6201
|
else {
|
|
6008
|
-
|
|
6202
|
+
if (isPortfolioMargin) {
|
|
6203
|
+
response = await this.papiGetMarginAllOrders(this.extend(request, params));
|
|
6204
|
+
}
|
|
6205
|
+
else if (type === 'margin' || marginMode !== undefined) {
|
|
6206
|
+
if (marginMode === 'isolated') {
|
|
6207
|
+
request['isIsolated'] = true;
|
|
6208
|
+
}
|
|
6209
|
+
response = await this.sapiGetMarginAllOrders(this.extend(request, params));
|
|
6210
|
+
}
|
|
6211
|
+
else {
|
|
6212
|
+
response = await this.privateGetAllOrders(this.extend(request, params));
|
|
6213
|
+
}
|
|
6009
6214
|
}
|
|
6010
6215
|
//
|
|
6011
6216
|
// spot
|
|
@@ -6081,6 +6286,112 @@ class binance extends binance$1 {
|
|
|
6081
6286
|
// }
|
|
6082
6287
|
// ]
|
|
6083
6288
|
//
|
|
6289
|
+
// inverse portfolio margin
|
|
6290
|
+
//
|
|
6291
|
+
// [
|
|
6292
|
+
// {
|
|
6293
|
+
// "orderId": 71328442983,
|
|
6294
|
+
// "symbol": "ETHUSD_PERP",
|
|
6295
|
+
// "pair": "ETHUSD",
|
|
6296
|
+
// "status": "CANCELED",
|
|
6297
|
+
// "clientOrderId": "x-xcKtGhcu4b3e3d8515dd4dc5ba9ccc",
|
|
6298
|
+
// "price": "2000",
|
|
6299
|
+
// "avgPrice": "0.00",
|
|
6300
|
+
// "origQty": "1",
|
|
6301
|
+
// "executedQty": "0",
|
|
6302
|
+
// "cumBase": "0",
|
|
6303
|
+
// "timeInForce": "GTC",
|
|
6304
|
+
// "type": "LIMIT",
|
|
6305
|
+
// "reduceOnly": false,
|
|
6306
|
+
// "side": "BUY",
|
|
6307
|
+
// "origType": "LIMIT",
|
|
6308
|
+
// "time": 1707197843046,
|
|
6309
|
+
// "updateTime": 1707197941373,
|
|
6310
|
+
// "positionSide": "BOTH"
|
|
6311
|
+
// },
|
|
6312
|
+
// ]
|
|
6313
|
+
//
|
|
6314
|
+
// linear portfolio margin
|
|
6315
|
+
//
|
|
6316
|
+
// [
|
|
6317
|
+
// {
|
|
6318
|
+
// "orderId": 259235347005,
|
|
6319
|
+
// "symbol": "BTCUSDT",
|
|
6320
|
+
// "status": "CANCELED",
|
|
6321
|
+
// "clientOrderId": "x-xcKtGhcu402881c9103f42bdb4183b",
|
|
6322
|
+
// "price": "35000",
|
|
6323
|
+
// "avgPrice": "0.00000",
|
|
6324
|
+
// "origQty": "0.010",
|
|
6325
|
+
// "executedQty": "0",
|
|
6326
|
+
// "cumQuote": "0",
|
|
6327
|
+
// "timeInForce": "GTC",
|
|
6328
|
+
// "type": "LIMIT",
|
|
6329
|
+
// "reduceOnly": false,
|
|
6330
|
+
// "side": "BUY",
|
|
6331
|
+
// "origType": "LIMIT",
|
|
6332
|
+
// "time": 1707194702167,
|
|
6333
|
+
// "updateTime": 1707197804748,
|
|
6334
|
+
// "positionSide": "BOTH",
|
|
6335
|
+
// "selfTradePreventionMode": "NONE",
|
|
6336
|
+
// "goodTillDate": 0
|
|
6337
|
+
// },
|
|
6338
|
+
// ]
|
|
6339
|
+
//
|
|
6340
|
+
// conditional portfolio margin
|
|
6341
|
+
//
|
|
6342
|
+
// [
|
|
6343
|
+
// {
|
|
6344
|
+
// "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
|
|
6345
|
+
// "strategyId": 3733211,
|
|
6346
|
+
// "strategyStatus": "CANCELLED",
|
|
6347
|
+
// "strategyType": "STOP",
|
|
6348
|
+
// "origQty": "0.010",
|
|
6349
|
+
// "price": "35000",
|
|
6350
|
+
// "orderId": 0,
|
|
6351
|
+
// "reduceOnly": false,
|
|
6352
|
+
// "side": "BUY",
|
|
6353
|
+
// "positionSide": "BOTH",
|
|
6354
|
+
// "stopPrice": "50000",
|
|
6355
|
+
// "symbol": "BTCUSDT",
|
|
6356
|
+
// "type": "LIMIT",
|
|
6357
|
+
// "bookTime": 1707270098774,
|
|
6358
|
+
// "updateTime": 1707270119261,
|
|
6359
|
+
// "timeInForce": "GTC",
|
|
6360
|
+
// "triggerTime": 0,
|
|
6361
|
+
// "workingType": "CONTRACT_PRICE",
|
|
6362
|
+
// "priceProtect": false,
|
|
6363
|
+
// "goodTillDate": 0,
|
|
6364
|
+
// "selfTradePreventionMode": "NONE"
|
|
6365
|
+
// },
|
|
6366
|
+
// ]
|
|
6367
|
+
//
|
|
6368
|
+
// spot margin portfolio margin
|
|
6369
|
+
//
|
|
6370
|
+
// [
|
|
6371
|
+
// {
|
|
6372
|
+
// "symbol": "BTCUSDT",
|
|
6373
|
+
// "orderId": 24684460474,
|
|
6374
|
+
// "clientOrderId": "x-R4BD3S82e9ef29d8346440f0b28b86",
|
|
6375
|
+
// "price": "35000.00000000",
|
|
6376
|
+
// "origQty": "0.00100000",
|
|
6377
|
+
// "executedQty": "0.00000000",
|
|
6378
|
+
// "cummulativeQuoteQty": "0.00000000",
|
|
6379
|
+
// "status": "CANCELED",
|
|
6380
|
+
// "timeInForce": "GTC",
|
|
6381
|
+
// "type": "LIMIT",
|
|
6382
|
+
// "side": "BUY",
|
|
6383
|
+
// "stopPrice": "0.00000000",
|
|
6384
|
+
// "icebergQty": "0.00000000",
|
|
6385
|
+
// "time": 1707113538870,
|
|
6386
|
+
// "updateTime": 1707113797688,
|
|
6387
|
+
// "isWorking": true,
|
|
6388
|
+
// "accountId": 200180970,
|
|
6389
|
+
// "selfTradePreventionMode": "EXPIRE_MAKER",
|
|
6390
|
+
// "preventedMatchId": null,
|
|
6391
|
+
// "preventedQuantity": null
|
|
6392
|
+
// },
|
|
6393
|
+
// ]
|
|
6394
|
+
//
|
|
6084
6395
|
return this.parseOrders(response, market, since, limit);
|
|
6085
6396
|
}
|
|
6086
6397
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -6119,7 +6430,7 @@ class binance extends binance$1 {
|
|
|
6119
6430
|
[marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
|
|
6120
6431
|
let isPortfolioMargin = undefined;
|
|
6121
6432
|
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOpenOrders', 'papi', 'portfolioMargin', false);
|
|
6122
|
-
const isConditional = this.
|
|
6433
|
+
const isConditional = this.safeBoolN(params, ['stop', 'conditional', 'trigger']);
|
|
6123
6434
|
if (symbol !== undefined) {
|
|
6124
6435
|
market = this.market(symbol);
|
|
6125
6436
|
request['symbol'] = market['id'];
|
|
@@ -6139,7 +6450,7 @@ class binance extends binance$1 {
|
|
|
6139
6450
|
}
|
|
6140
6451
|
let subType = undefined;
|
|
6141
6452
|
[subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
|
|
6142
|
-
params = this.omit(params, ['type', 'stop', 'conditional']);
|
|
6453
|
+
params = this.omit(params, ['type', 'stop', 'conditional', 'trigger']);
|
|
6143
6454
|
let response = undefined;
|
|
6144
6455
|
if (type === 'option') {
|
|
6145
6456
|
if (since !== undefined) {
|
|
@@ -6195,6 +6506,223 @@ class binance extends binance$1 {
|
|
|
6195
6506
|
}
|
|
6196
6507
|
return this.parseOrders(response, market, since, limit);
|
|
6197
6508
|
}
|
|
6509
|
+
async fetchOpenOrder(id, symbol = undefined, params = {}) {
|
|
6510
|
+
/**
|
|
6511
|
+
* @method
|
|
6512
|
+
* @name binance#fetchOpenOrder
|
|
6513
|
+
* @description fetch an open order by the id
|
|
6514
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#query-current-open-order-user_data
|
|
6515
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#query-current-open-order-user_data
|
|
6516
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-order-user_data
|
|
6517
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-order-user_data
|
|
6518
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-conditional-order-user_data
|
|
6519
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-conditional-order-user_data
|
|
6520
|
+
* @param {string} id order id
|
|
6521
|
+
* @param {string} symbol unified market symbol
|
|
6522
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6523
|
+
* @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
|
|
6524
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
6525
|
+
*/
|
|
6526
|
+
if (symbol === undefined) {
|
|
6527
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrder() requires a symbol argument');
|
|
6528
|
+
}
|
|
6529
|
+
await this.loadMarkets();
|
|
6530
|
+
const market = this.market(symbol);
|
|
6531
|
+
const request = {
|
|
6532
|
+
'symbol': market['id'],
|
|
6533
|
+
};
|
|
6534
|
+
let isPortfolioMargin = undefined;
|
|
6535
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOpenOrder', 'papi', 'portfolioMargin', false);
|
|
6536
|
+
const isConditional = this.safeBoolN(params, ['stop', 'conditional', 'trigger']);
|
|
6537
|
+
params = this.omit(params, ['stop', 'conditional', 'trigger']);
|
|
6538
|
+
const isPortfolioMarginConditional = (isPortfolioMargin && isConditional);
|
|
6539
|
+
const orderIdRequest = isPortfolioMarginConditional ? 'strategyId' : 'orderId';
|
|
6540
|
+
request[orderIdRequest] = id;
|
|
6541
|
+
let response = undefined;
|
|
6542
|
+
if (market['linear']) {
|
|
6543
|
+
if (isPortfolioMargin) {
|
|
6544
|
+
if (isConditional) {
|
|
6545
|
+
response = await this.papiGetUmConditionalOpenOrder(this.extend(request, params));
|
|
6546
|
+
}
|
|
6547
|
+
else {
|
|
6548
|
+
response = await this.papiGetUmOpenOrder(this.extend(request, params));
|
|
6549
|
+
}
|
|
6550
|
+
}
|
|
6551
|
+
else {
|
|
6552
|
+
response = await this.fapiPrivateGetOpenOrder(this.extend(request, params));
|
|
6553
|
+
}
|
|
6554
|
+
}
|
|
6555
|
+
else if (market['inverse']) {
|
|
6556
|
+
if (isPortfolioMargin) {
|
|
6557
|
+
if (isConditional) {
|
|
6558
|
+
response = await this.papiGetCmConditionalOpenOrder(this.extend(request, params));
|
|
6559
|
+
}
|
|
6560
|
+
else {
|
|
6561
|
+
response = await this.papiGetCmOpenOrder(this.extend(request, params));
|
|
6562
|
+
}
|
|
6563
|
+
}
|
|
6564
|
+
else {
|
|
6565
|
+
response = await this.dapiPrivateGetOpenOrder(this.extend(request, params));
|
|
6566
|
+
}
|
|
6567
|
+
}
|
|
6568
|
+
else {
|
|
6569
|
+
if (market['option']) {
|
|
6570
|
+
throw new errors.NotSupported(this.id + ' fetchOpenOrder() does not support option markets');
|
|
6571
|
+
}
|
|
6572
|
+
else if (market['spot']) {
|
|
6573
|
+
throw new errors.NotSupported(this.id + ' fetchOpenOrder() does not support spot markets');
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
//
|
|
6577
|
+
// linear swap
|
|
6578
|
+
//
|
|
6579
|
+
// {
|
|
6580
|
+
// "orderId": 3697213934,
|
|
6581
|
+
// "symbol": "BTCUSDT",
|
|
6582
|
+
// "status": "NEW",
|
|
6583
|
+
// "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
|
|
6584
|
+
// "price": "33000.00",
|
|
6585
|
+
// "avgPrice": "0.00000",
|
|
6586
|
+
// "origQty": "0.010",
|
|
6587
|
+
// "executedQty": "0.000",
|
|
6588
|
+
// "cumQuote": "0.00000",
|
|
6589
|
+
// "timeInForce": "GTC",
|
|
6590
|
+
// "type": "LIMIT",
|
|
6591
|
+
// "reduceOnly": false,
|
|
6592
|
+
// "closePosition": false,
|
|
6593
|
+
// "side": "BUY",
|
|
6594
|
+
// "positionSide": "BOTH",
|
|
6595
|
+
// "stopPrice": "0.00",
|
|
6596
|
+
// "workingType": "CONTRACT_PRICE",
|
|
6597
|
+
// "priceProtect": false,
|
|
6598
|
+
// "origType": "LIMIT",
|
|
6599
|
+
// "priceMatch": "NONE",
|
|
6600
|
+
// "selfTradePreventionMode": "NONE",
|
|
6601
|
+
// "goodTillDate": 0,
|
|
6602
|
+
// "time": 1707892893502,
|
|
6603
|
+
// "updateTime": 1707892893515
|
|
6604
|
+
// }
|
|
6605
|
+
//
|
|
6606
|
+
// inverse swap
|
|
6607
|
+
//
|
|
6608
|
+
// {
|
|
6609
|
+
// "orderId": 597368542,
|
|
6610
|
+
// "symbol": "BTCUSD_PERP",
|
|
6611
|
+
// "pair": "BTCUSD",
|
|
6612
|
+
// "status": "NEW",
|
|
6613
|
+
// "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
|
|
6614
|
+
// "price": "35000",
|
|
6615
|
+
// "avgPrice": "0",
|
|
6616
|
+
// "origQty": "1",
|
|
6617
|
+
// "executedQty": "0",
|
|
6618
|
+
// "cumBase": "0",
|
|
6619
|
+
// "timeInForce": "GTC",
|
|
6620
|
+
// "type": "LIMIT",
|
|
6621
|
+
// "reduceOnly": false,
|
|
6622
|
+
// "closePosition": false,
|
|
6623
|
+
// "side": "BUY",
|
|
6624
|
+
// "positionSide": "BOTH",
|
|
6625
|
+
// "stopPrice": "0",
|
|
6626
|
+
// "workingType": "CONTRACT_PRICE",
|
|
6627
|
+
// "priceProtect": false,
|
|
6628
|
+
// "origType": "LIMIT",
|
|
6629
|
+
// "time": 1707893453199,
|
|
6630
|
+
// "updateTime": 1707893453199
|
|
6631
|
+
// }
|
|
6632
|
+
//
|
|
6633
|
+
// linear portfolio margin
|
|
6634
|
+
//
|
|
6635
|
+
// {
|
|
6636
|
+
// "orderId": 264895013409,
|
|
6637
|
+
// "symbol": "BTCUSDT",
|
|
6638
|
+
// "status": "NEW",
|
|
6639
|
+
// "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
|
|
6640
|
+
// "price": "35000",
|
|
6641
|
+
// "avgPrice": "0",
|
|
6642
|
+
// "origQty": "0.010",
|
|
6643
|
+
// "executedQty": "0",
|
|
6644
|
+
// "cumQuote": "0",
|
|
6645
|
+
// "timeInForce": "GTC",
|
|
6646
|
+
// "type": "LIMIT",
|
|
6647
|
+
// "reduceOnly": false,
|
|
6648
|
+
// "side": "BUY",
|
|
6649
|
+
// "positionSide": "LONG",
|
|
6650
|
+
// "origType": "LIMIT",
|
|
6651
|
+
// "time": 1707893839364,
|
|
6652
|
+
// "updateTime": 1707893839364,
|
|
6653
|
+
// "goodTillDate": 0,
|
|
6654
|
+
// "selfTradePreventionMode": "NONE"
|
|
6655
|
+
// }
|
|
6656
|
+
//
|
|
6657
|
+
// inverse portfolio margin
|
|
6658
|
+
//
|
|
6659
|
+
// {
|
|
6660
|
+
// "orderId": 71790316950,
|
|
6661
|
+
// "symbol": "ETHUSD_PERP",
|
|
6662
|
+
// "pair": "ETHUSD",
|
|
6663
|
+
// "status": "NEW",
|
|
6664
|
+
// "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
|
|
6665
|
+
// "price": "2500",
|
|
6666
|
+
// "avgPrice": "0",
|
|
6667
|
+
// "origQty": "1",
|
|
6668
|
+
// "executedQty": "0",
|
|
6669
|
+
// "cumBase": "0",
|
|
6670
|
+
// "timeInForce": "GTC",
|
|
6671
|
+
// "type": "LIMIT",
|
|
6672
|
+
// "reduceOnly": false,
|
|
6673
|
+
// "side": "BUY",
|
|
6674
|
+
// "positionSide": "LONG",
|
|
6675
|
+
// "origType": "LIMIT",
|
|
6676
|
+
// "time": 1707894181694,
|
|
6677
|
+
// "updateTime": 1707894181694
|
|
6678
|
+
// }
|
|
6679
|
+
//
|
|
6680
|
+
// linear portfolio margin conditional
|
|
6681
|
+
//
|
|
6682
|
+
// {
|
|
6683
|
+
// "newClientStrategyId": "x-xcKtGhcu2205fde44418483ca21874",
|
|
6684
|
+
// "strategyId": 4084339,
|
|
6685
|
+
// "strategyStatus": "NEW",
|
|
6686
|
+
// "strategyType": "STOP",
|
|
6687
|
+
// "origQty": "0.010",
|
|
6688
|
+
// "price": "35000",
|
|
6689
|
+
// "reduceOnly": false,
|
|
6690
|
+
// "side": "BUY",
|
|
6691
|
+
// "positionSide": "LONG",
|
|
6692
|
+
// "stopPrice": "60000",
|
|
6693
|
+
// "symbol": "BTCUSDT",
|
|
6694
|
+
// "bookTime": 1707894490094,
|
|
6695
|
+
// "updateTime": 1707894490094,
|
|
6696
|
+
// "timeInForce": "GTC",
|
|
6697
|
+
// "workingType": "CONTRACT_PRICE",
|
|
6698
|
+
// "priceProtect": false,
|
|
6699
|
+
// "goodTillDate": 0,
|
|
6700
|
+
// "selfTradePreventionMode": "NONE"
|
|
6701
|
+
// }
|
|
6702
|
+
//
|
|
6703
|
+
// inverse portfolio margin conditional
|
|
6704
|
+
//
|
|
6705
|
+
// {
|
|
6706
|
+
// "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
|
|
6707
|
+
// "strategyId": 1423501,
|
|
6708
|
+
// "strategyStatus": "NEW",
|
|
6709
|
+
// "strategyType": "STOP",
|
|
6710
|
+
// "origQty": "1",
|
|
6711
|
+
// "price": "2500",
|
|
6712
|
+
// "reduceOnly": false,
|
|
6713
|
+
// "side": "BUY",
|
|
6714
|
+
// "positionSide": "LONG",
|
|
6715
|
+
// "stopPrice": "4000",
|
|
6716
|
+
// "symbol": "ETHUSD_PERP",
|
|
6717
|
+
// "bookTime": 1707894782679,
|
|
6718
|
+
// "updateTime": 1707894782679,
|
|
6719
|
+
// "timeInForce": "GTC",
|
|
6720
|
+
// "workingType": "CONTRACT_PRICE",
|
|
6721
|
+
// "priceProtect": false
|
|
6722
|
+
// }
|
|
6723
|
+
//
|
|
6724
|
+
return this.parseOrder(response, market);
|
|
6725
|
+
}
|
|
6198
6726
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
6199
6727
|
/**
|
|
6200
6728
|
* @method
|
|
@@ -6205,13 +6733,23 @@ class binance extends binance$1 {
|
|
|
6205
6733
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
|
|
6206
6734
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
|
|
6207
6735
|
* @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
|
|
6736
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
|
|
6737
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
|
|
6738
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
|
|
6739
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
|
|
6740
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
|
|
6208
6741
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
6209
6742
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
6210
6743
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
6211
6744
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6212
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
6745
|
+
* @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)
|
|
6746
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
|
|
6747
|
+
* @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
|
|
6213
6748
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
6214
6749
|
*/
|
|
6750
|
+
if (symbol === undefined) {
|
|
6751
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
|
|
6752
|
+
}
|
|
6215
6753
|
const orders = await this.fetchOrders(symbol, since, undefined, params);
|
|
6216
6754
|
const filteredOrders = this.filterBy(orders, 'status', 'closed');
|
|
6217
6755
|
return this.filterBySinceLimit(filteredOrders, since, limit);
|
|
@@ -6224,22 +6762,23 @@ class binance extends binance$1 {
|
|
|
6224
6762
|
* @see https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
|
|
6225
6763
|
* @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
|
|
6226
6764
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
|
|
6765
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
|
|
6766
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
|
|
6767
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
|
|
6768
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
|
|
6769
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
|
|
6227
6770
|
* @param {string} symbol unified market symbol of the market the orders were made in
|
|
6228
6771
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
6229
6772
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
6230
6773
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6231
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
6774
|
+
* @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)
|
|
6775
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
|
|
6776
|
+
* @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
|
|
6232
6777
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
6233
6778
|
*/
|
|
6234
6779
|
if (symbol === undefined) {
|
|
6235
6780
|
throw new errors.ArgumentsRequired(this.id + ' fetchCanceledOrders() requires a symbol argument');
|
|
6236
6781
|
}
|
|
6237
|
-
await this.loadMarkets();
|
|
6238
|
-
const market = this.market(symbol);
|
|
6239
|
-
if (market['swap'] || market['future']) {
|
|
6240
|
-
throw new errors.NotSupported(this.id + ' fetchCanceledOrders() supports spot, margin and option markets only');
|
|
6241
|
-
}
|
|
6242
|
-
params = this.omit(params, 'type');
|
|
6243
6782
|
const orders = await this.fetchOrders(symbol, since, undefined, params);
|
|
6244
6783
|
const filteredOrders = this.filterBy(orders, 'status', 'canceled');
|
|
6245
6784
|
return this.filterBySinceLimit(filteredOrders, since, limit);
|
|
@@ -7988,35 +8527,48 @@ class binance extends binance$1 {
|
|
|
7988
8527
|
* @see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
|
|
7989
8528
|
* @see https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
|
|
7990
8529
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
|
|
8530
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-user-commission-rate-for-um-user_data
|
|
8531
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-user-commission-rate-for-cm-user_data
|
|
7991
8532
|
* @param {string} symbol unified market symbol
|
|
7992
8533
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8534
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
|
|
7993
8535
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
7994
8536
|
*/
|
|
7995
8537
|
await this.loadMarkets();
|
|
7996
8538
|
const market = this.market(symbol);
|
|
7997
|
-
const
|
|
7998
|
-
const type = this.safeString(params, 'type', defaultType);
|
|
7999
|
-
params = this.omit(params, 'type');
|
|
8539
|
+
const type = market['type'];
|
|
8000
8540
|
let subType = undefined;
|
|
8001
8541
|
[subType, params] = this.handleSubTypeAndParams('fetchTradingFee', market, params);
|
|
8002
|
-
|
|
8542
|
+
let isPortfolioMargin = undefined;
|
|
8543
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchTradingFee', 'papi', 'portfolioMargin', false);
|
|
8003
8544
|
const isLinear = this.isLinear(type, subType);
|
|
8004
8545
|
const isInverse = this.isInverse(type, subType);
|
|
8005
8546
|
const request = {
|
|
8006
8547
|
'symbol': market['id'],
|
|
8007
8548
|
};
|
|
8008
8549
|
let response = undefined;
|
|
8009
|
-
if (
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8550
|
+
if (isLinear) {
|
|
8551
|
+
if (isPortfolioMargin) {
|
|
8552
|
+
response = await this.papiGetUmCommissionRate(this.extend(request, params));
|
|
8553
|
+
}
|
|
8554
|
+
else {
|
|
8555
|
+
response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
|
|
8556
|
+
}
|
|
8014
8557
|
}
|
|
8015
8558
|
else if (isInverse) {
|
|
8016
|
-
|
|
8559
|
+
if (isPortfolioMargin) {
|
|
8560
|
+
response = await this.papiGetCmCommissionRate(this.extend(request, params));
|
|
8561
|
+
}
|
|
8562
|
+
else {
|
|
8563
|
+
response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
|
|
8564
|
+
}
|
|
8565
|
+
}
|
|
8566
|
+
else {
|
|
8567
|
+
response = await this.sapiGetAssetTradeFee(this.extend(request, params));
|
|
8017
8568
|
}
|
|
8018
8569
|
//
|
|
8019
8570
|
// spot
|
|
8571
|
+
//
|
|
8020
8572
|
// [
|
|
8021
8573
|
// {
|
|
8022
8574
|
// "symbol": "BTCUSDT",
|
|
@@ -8026,6 +8578,7 @@ class binance extends binance$1 {
|
|
|
8026
8578
|
// ]
|
|
8027
8579
|
//
|
|
8028
8580
|
// swap
|
|
8581
|
+
//
|
|
8029
8582
|
// {
|
|
8030
8583
|
// "symbol": "BTCUSD_PERP",
|
|
8031
8584
|
// "makerCommissionRate": "0.00015", // 0.015%
|
|
@@ -8036,7 +8589,7 @@ class binance extends binance$1 {
|
|
|
8036
8589
|
if (Array.isArray(data)) {
|
|
8037
8590
|
data = this.safeDict(data, 0, {});
|
|
8038
8591
|
}
|
|
8039
|
-
return this.parseTradingFee(data);
|
|
8592
|
+
return this.parseTradingFee(data, market);
|
|
8040
8593
|
}
|
|
8041
8594
|
async fetchTradingFees(params = {}) {
|
|
8042
8595
|
/**
|
|
@@ -11083,12 +11636,16 @@ class binance extends binance$1 {
|
|
|
11083
11636
|
* @see https://binance-docs.github.io/apidocs/spot/en/#get-force-liquidation-record-user_data
|
|
11084
11637
|
* @see https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data
|
|
11085
11638
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
|
|
11639
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-margin-force-orders-user_data
|
|
11640
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-um-force-orders-user_data
|
|
11641
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-cm-force-orders-user_data
|
|
11086
11642
|
* @param {string} [symbol] unified CCXT market symbol
|
|
11087
11643
|
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
11088
11644
|
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
11089
11645
|
* @param {object} [params] exchange specific parameters for the binance api endpoint
|
|
11090
11646
|
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
11091
11647
|
* @param {boolean} [params.paginate] *spot only* 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)
|
|
11648
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
|
|
11092
11649
|
* @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
|
|
11093
11650
|
*/
|
|
11094
11651
|
await this.loadMarkets();
|
|
@@ -11105,13 +11662,17 @@ class binance extends binance$1 {
|
|
|
11105
11662
|
[type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
|
|
11106
11663
|
let subType = undefined;
|
|
11107
11664
|
[subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params, 'linear');
|
|
11665
|
+
let isPortfolioMargin = undefined;
|
|
11666
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchMyLiquidations', 'papi', 'portfolioMargin', false);
|
|
11108
11667
|
let request = {};
|
|
11109
11668
|
if (type !== 'spot') {
|
|
11110
11669
|
request['autoCloseType'] = 'LIQUIDATION';
|
|
11111
11670
|
}
|
|
11112
11671
|
if (market !== undefined) {
|
|
11113
11672
|
const symbolKey = market['spot'] ? 'isolatedSymbol' : 'symbol';
|
|
11114
|
-
|
|
11673
|
+
if (!isPortfolioMargin) {
|
|
11674
|
+
request[symbolKey] = market['id'];
|
|
11675
|
+
}
|
|
11115
11676
|
}
|
|
11116
11677
|
if (since !== undefined) {
|
|
11117
11678
|
request['startTime'] = since;
|
|
@@ -11127,13 +11688,28 @@ class binance extends binance$1 {
|
|
|
11127
11688
|
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
11128
11689
|
let response = undefined;
|
|
11129
11690
|
if (type === 'spot') {
|
|
11130
|
-
|
|
11691
|
+
if (isPortfolioMargin) {
|
|
11692
|
+
response = await this.papiGetMarginForceOrders(this.extend(request, params));
|
|
11693
|
+
}
|
|
11694
|
+
else {
|
|
11695
|
+
response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
|
|
11696
|
+
}
|
|
11131
11697
|
}
|
|
11132
11698
|
else if (subType === 'linear') {
|
|
11133
|
-
|
|
11699
|
+
if (isPortfolioMargin) {
|
|
11700
|
+
response = await this.papiGetUmForceOrders(this.extend(request, params));
|
|
11701
|
+
}
|
|
11702
|
+
else {
|
|
11703
|
+
response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
|
|
11704
|
+
}
|
|
11134
11705
|
}
|
|
11135
11706
|
else if (subType === 'inverse') {
|
|
11136
|
-
|
|
11707
|
+
if (isPortfolioMargin) {
|
|
11708
|
+
response = await this.papiGetCmForceOrders(this.extend(request, params));
|
|
11709
|
+
}
|
|
11710
|
+
else {
|
|
11711
|
+
response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
|
|
11712
|
+
}
|
|
11137
11713
|
}
|
|
11138
11714
|
else {
|
|
11139
11715
|
throw new errors.NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
|
|
@@ -11215,7 +11791,7 @@ class binance extends binance$1 {
|
|
|
11215
11791
|
// },
|
|
11216
11792
|
// ]
|
|
11217
11793
|
//
|
|
11218
|
-
const liquidations = this.
|
|
11794
|
+
const liquidations = this.safeList(response, 'rows', response);
|
|
11219
11795
|
return this.parseLiquidations(liquidations, market, since, limit);
|
|
11220
11796
|
}
|
|
11221
11797
|
parseLiquidation(liquidation, market = undefined) {
|