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