ccxt 4.2.39 → 4.2.41
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 +1140 -341
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +28 -24
- package/dist/cjs/src/base/Exchange.js +14 -14
- package/dist/cjs/src/binance.js +561 -168
- package/dist/cjs/src/bingx.js +271 -25
- package/dist/cjs/src/bitforex.js +2 -2
- package/dist/cjs/src/bitget.js +13 -2
- package/dist/cjs/src/bybit.js +3 -1
- package/dist/cjs/src/coinbase.js +8 -6
- package/dist/cjs/src/coinbasepro.js +1 -0
- package/dist/cjs/src/coinlist.js +9 -7
- package/dist/cjs/src/coinmetro.js +2 -1
- package/dist/cjs/src/currencycom.js +1 -1
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/krakenfutures.js +126 -2
- package/dist/cjs/src/mexc.js +44 -44
- package/dist/cjs/src/okx.js +9 -15
- package/dist/cjs/src/phemex.js +1 -0
- package/dist/cjs/src/pro/bitmart.js +38 -20
- package/dist/cjs/src/pro/bybit.js +5 -5
- package/dist/cjs/src/pro/cex.js +1 -1
- package/dist/cjs/src/pro/gemini.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bingx.d.ts +4 -0
- package/js/src/abstract/coinbasepro.d.ts +1 -0
- package/js/src/ascendex.js +28 -24
- package/js/src/base/Exchange.d.ts +8 -8
- package/js/src/base/Exchange.js +14 -14
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +561 -168
- package/js/src/bingx.d.ts +2 -0
- package/js/src/bingx.js +271 -25
- package/js/src/bitforex.js +2 -2
- package/js/src/bitget.js +13 -2
- package/js/src/bybit.js +3 -1
- package/js/src/coinbase.js +8 -6
- package/js/src/coinbasepro.js +1 -0
- package/js/src/coinlist.js +9 -7
- package/js/src/coinmetro.js +2 -1
- package/js/src/currencycom.js +1 -1
- package/js/src/htx.js +1 -1
- package/js/src/krakenfutures.d.ts +2 -0
- package/js/src/krakenfutures.js +126 -2
- package/js/src/mexc.js +44 -44
- package/js/src/okx.js +9 -15
- package/js/src/phemex.js +1 -0
- package/js/src/pro/bitmart.d.ts +2 -0
- package/js/src/pro/bitmart.js +38 -20
- package/js/src/pro/bybit.d.ts +1 -1
- package/js/src/pro/bybit.js +5 -5
- package/js/src/pro/cex.js +1 -1
- package/js/src/pro/gemini.js +1 -1
- package/package.json +1 -1
package/dist/ccxt.browser.js
CHANGED
|
@@ -3928,11 +3928,14 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
3928
3928
|
'fillResponseFromRequest': true,
|
|
3929
3929
|
},
|
|
3930
3930
|
'networks': {
|
|
3931
|
-
'BSC': 'BEP20 (BSC)',
|
|
3931
|
+
'BSC': 'BEP20 ' + '(BSC)',
|
|
3932
3932
|
'ARB': 'arbitrum',
|
|
3933
3933
|
'SOL': 'Solana',
|
|
3934
3934
|
'AVAX': 'avalanche C chain',
|
|
3935
3935
|
'OMNI': 'Omni',
|
|
3936
|
+
'TRC': 'TRC20',
|
|
3937
|
+
'TRX': 'TRC20',
|
|
3938
|
+
'ERC': 'ERC20',
|
|
3936
3939
|
},
|
|
3937
3940
|
'networksById': {
|
|
3938
3941
|
'BEP20 (BSC)': 'BSC',
|
|
@@ -3940,6 +3943,16 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
3940
3943
|
'Solana': 'SOL',
|
|
3941
3944
|
'avalanche C chain': 'AVAX',
|
|
3942
3945
|
'Omni': 'OMNI',
|
|
3946
|
+
'TRC20': 'TRC20',
|
|
3947
|
+
'ERC20': 'ERC20',
|
|
3948
|
+
'GO20': 'GO20',
|
|
3949
|
+
'BEP2': 'BEP2',
|
|
3950
|
+
'Bitcoin': 'BTC',
|
|
3951
|
+
'Bitcoin ABC': 'BCH',
|
|
3952
|
+
'Litecoin': 'LTC',
|
|
3953
|
+
'Matic Network': 'MATIC',
|
|
3954
|
+
'xDai': 'STAKE',
|
|
3955
|
+
'Akash': 'AKT',
|
|
3943
3956
|
},
|
|
3944
3957
|
},
|
|
3945
3958
|
'exceptions': {
|
|
@@ -6029,8 +6042,8 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
6029
6042
|
const tag = this.safeString(depositAddress, tagId);
|
|
6030
6043
|
this.checkAddress(address);
|
|
6031
6044
|
const code = (currency === undefined) ? undefined : currency['code'];
|
|
6032
|
-
const chainName = this.safeString(depositAddress, '
|
|
6033
|
-
const network = this.
|
|
6045
|
+
const chainName = this.safeString(depositAddress, 'blockchain');
|
|
6046
|
+
const network = this.networkIdToCode(chainName, code);
|
|
6034
6047
|
return {
|
|
6035
6048
|
'currency': code,
|
|
6036
6049
|
'address': address,
|
|
@@ -6040,20 +6053,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
6040
6053
|
};
|
|
6041
6054
|
}
|
|
6042
6055
|
safeNetwork(networkId) {
|
|
6043
|
-
const networksById =
|
|
6044
|
-
'TRC20': 'TRC20',
|
|
6045
|
-
'ERC20': 'ERC20',
|
|
6046
|
-
'GO20': 'GO20',
|
|
6047
|
-
'BEP2': 'BEP2',
|
|
6048
|
-
'BEP20 (BSC)': 'BEP20',
|
|
6049
|
-
'Bitcoin': 'BTC',
|
|
6050
|
-
'Bitcoin ABC': 'BCH',
|
|
6051
|
-
'Litecoin': 'LTC',
|
|
6052
|
-
'Matic Network': 'MATIC',
|
|
6053
|
-
'Solana': 'SOL',
|
|
6054
|
-
'xDai': 'STAKE',
|
|
6055
|
-
'Akash': 'AKT',
|
|
6056
|
-
};
|
|
6056
|
+
const networksById = this.safeDict(this.options, 'networksById');
|
|
6057
6057
|
return this.safeString(networksById, networkId, networkId);
|
|
6058
6058
|
}
|
|
6059
6059
|
async fetchDepositAddress(code, params = {}) {
|
|
@@ -6061,16 +6061,20 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
6061
6061
|
* @method
|
|
6062
6062
|
* @name ascendex#fetchDepositAddress
|
|
6063
6063
|
* @description fetch the deposit address for a currency associated with this account
|
|
6064
|
+
* @see https://ascendex.github.io/ascendex-pro-api/#query-deposit-addresses
|
|
6064
6065
|
* @param {string} code unified currency code
|
|
6065
6066
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6067
|
+
* @param {string} [params.network] unified network code for deposit chain
|
|
6066
6068
|
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
6067
6069
|
*/
|
|
6068
6070
|
await this.loadMarkets();
|
|
6069
6071
|
const currency = this.currency(code);
|
|
6070
|
-
const
|
|
6071
|
-
|
|
6072
|
+
const networkCode = this.safeString2(params, 'network', 'chainName');
|
|
6073
|
+
const networkId = this.networkCodeToId(networkCode);
|
|
6074
|
+
params = this.omit(params, ['chainName']);
|
|
6072
6075
|
const request = {
|
|
6073
6076
|
'asset': currency['id'],
|
|
6077
|
+
'blockchain': networkId,
|
|
6074
6078
|
};
|
|
6075
6079
|
const response = await this.v1PrivateGetWalletDepositAddress(this.extend(request, params));
|
|
6076
6080
|
//
|
|
@@ -6106,22 +6110,22 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
6106
6110
|
// }
|
|
6107
6111
|
// }
|
|
6108
6112
|
//
|
|
6109
|
-
const data = this.
|
|
6110
|
-
const addresses = this.
|
|
6113
|
+
const data = this.safeDict(response, 'data', {});
|
|
6114
|
+
const addresses = this.safeList(data, 'address', []);
|
|
6111
6115
|
const numAddresses = addresses.length;
|
|
6112
6116
|
let address = undefined;
|
|
6113
6117
|
if (numAddresses > 1) {
|
|
6114
6118
|
const addressesByChainName = this.indexBy(addresses, 'chainName');
|
|
6115
|
-
if (
|
|
6119
|
+
if (networkId === undefined) {
|
|
6116
6120
|
const chainNames = Object.keys(addressesByChainName);
|
|
6117
6121
|
const chains = chainNames.join(', ');
|
|
6118
6122
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchDepositAddress() returned more than one address, a chainName parameter is required, one of ' + chains);
|
|
6119
6123
|
}
|
|
6120
|
-
address = this.
|
|
6124
|
+
address = this.safeDict(addressesByChainName, networkId, {});
|
|
6121
6125
|
}
|
|
6122
6126
|
else {
|
|
6123
6127
|
// first address
|
|
6124
|
-
address = this.
|
|
6128
|
+
address = this.safeDict(addresses, 0, {});
|
|
6125
6129
|
}
|
|
6126
6130
|
const result = this.parseDepositAddress(address, currency);
|
|
6127
6131
|
return this.extend(result, {
|
|
@@ -10225,14 +10229,14 @@ class Exchange {
|
|
|
10225
10229
|
}
|
|
10226
10230
|
defaultNetworkCode(currencyCode) {
|
|
10227
10231
|
let defaultNetworkCode = undefined;
|
|
10228
|
-
const defaultNetworks = this.
|
|
10232
|
+
const defaultNetworks = this.safeDict(this.options, 'defaultNetworks', {});
|
|
10229
10233
|
if (currencyCode in defaultNetworks) {
|
|
10230
10234
|
// if currency had set its network in "defaultNetworks", use it
|
|
10231
10235
|
defaultNetworkCode = defaultNetworks[currencyCode];
|
|
10232
10236
|
}
|
|
10233
10237
|
else {
|
|
10234
10238
|
// otherwise, try to use the global-scope 'defaultNetwork' value (even if that network is not supported by currency, it doesn't make any problem, this will be just used "at first" if currency supports this network at all)
|
|
10235
|
-
const defaultNetwork = this.
|
|
10239
|
+
const defaultNetwork = this.safeDict(this.options, 'defaultNetwork');
|
|
10236
10240
|
if (defaultNetwork !== undefined) {
|
|
10237
10241
|
defaultNetworkCode = defaultNetwork;
|
|
10238
10242
|
}
|
|
@@ -10737,14 +10741,14 @@ class Exchange {
|
|
|
10737
10741
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchStatus() is not supported yet');
|
|
10738
10742
|
}
|
|
10739
10743
|
async fetchFundingFee(code, params = {}) {
|
|
10740
|
-
const warnOnFetchFundingFee = this.
|
|
10744
|
+
const warnOnFetchFundingFee = this.safeBool(this.options, 'warnOnFetchFundingFee', true);
|
|
10741
10745
|
if (warnOnFetchFundingFee) {
|
|
10742
10746
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchFundingFee() method is deprecated, it will be removed in July 2022, please, use fetchTransactionFee() or set exchange.options["warnOnFetchFundingFee"] = false to suppress this warning');
|
|
10743
10747
|
}
|
|
10744
10748
|
return await this.fetchTransactionFee(code, params);
|
|
10745
10749
|
}
|
|
10746
10750
|
async fetchFundingFees(codes = undefined, params = {}) {
|
|
10747
|
-
const warnOnFetchFundingFees = this.
|
|
10751
|
+
const warnOnFetchFundingFees = this.safeBool(this.options, 'warnOnFetchFundingFees', true);
|
|
10748
10752
|
if (warnOnFetchFundingFees) {
|
|
10749
10753
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchFundingFees() method is deprecated, it will be removed in July 2022. Please, use fetchTransactionFees() or set exchange.options["warnOnFetchFundingFees"] = false to suppress this warning');
|
|
10750
10754
|
}
|
|
@@ -10795,7 +10799,7 @@ class Exchange {
|
|
|
10795
10799
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchIsolatedBorrowRate() is not supported yet');
|
|
10796
10800
|
}
|
|
10797
10801
|
const borrowRates = await this.fetchIsolatedBorrowRates(params);
|
|
10798
|
-
const rate = this.
|
|
10802
|
+
const rate = this.safeDict(borrowRates, symbol);
|
|
10799
10803
|
if (rate === undefined) {
|
|
10800
10804
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError(this.id + ' fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ' + symbol);
|
|
10801
10805
|
}
|
|
@@ -10856,7 +10860,7 @@ class Exchange {
|
|
|
10856
10860
|
}
|
|
10857
10861
|
handleMarketTypeAndParams(methodName, market = undefined, params = {}) {
|
|
10858
10862
|
const defaultType = this.safeString2(this.options, 'defaultType', 'type', 'spot');
|
|
10859
|
-
const methodOptions = this.
|
|
10863
|
+
const methodOptions = this.safeDict(this.options, methodName);
|
|
10860
10864
|
let methodType = defaultType;
|
|
10861
10865
|
if (methodOptions !== undefined) {
|
|
10862
10866
|
if (typeof methodOptions === 'string') {
|
|
@@ -10892,7 +10896,7 @@ class Exchange {
|
|
|
10892
10896
|
}
|
|
10893
10897
|
// if it was not defined in market object
|
|
10894
10898
|
if (subType === undefined) {
|
|
10895
|
-
const values = this.handleOptionAndParams(
|
|
10899
|
+
const values = this.handleOptionAndParams({}, methodName, 'subType', defaultValue); // no need to re-test params here
|
|
10896
10900
|
subType = values[0];
|
|
10897
10901
|
}
|
|
10898
10902
|
}
|
|
@@ -10948,7 +10952,7 @@ class Exchange {
|
|
|
10948
10952
|
const market = this.market(symbol);
|
|
10949
10953
|
symbol = market['symbol'];
|
|
10950
10954
|
const tickers = await this.fetchTickers([symbol], params);
|
|
10951
|
-
const ticker = this.
|
|
10955
|
+
const ticker = this.safeDict(tickers, symbol);
|
|
10952
10956
|
if (ticker === undefined) {
|
|
10953
10957
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NullResponse(this.id + ' fetchTickers() could not find a ticker for ' + symbol);
|
|
10954
10958
|
}
|
|
@@ -10985,7 +10989,7 @@ class Exchange {
|
|
|
10985
10989
|
return order['status'];
|
|
10986
10990
|
}
|
|
10987
10991
|
async fetchUnifiedOrder(order, params = {}) {
|
|
10988
|
-
return await this.fetchOrder(this.
|
|
10992
|
+
return await this.fetchOrder(this.safeString(order, 'id'), this.safeString(order, 'symbol'), params);
|
|
10989
10993
|
}
|
|
10990
10994
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
10991
10995
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrder() is not supported yet');
|
|
@@ -11255,7 +11259,7 @@ class Exchange {
|
|
|
11255
11259
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' cancelAllOrdersWs() is not supported yet');
|
|
11256
11260
|
}
|
|
11257
11261
|
async cancelUnifiedOrder(order, params = {}) {
|
|
11258
|
-
return this.cancelOrder(this.
|
|
11262
|
+
return this.cancelOrder(this.safeString(order, 'id'), this.safeString(order, 'symbol'), params);
|
|
11259
11263
|
}
|
|
11260
11264
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
11261
11265
|
if (this.has['fetchOpenOrders'] && this.has['fetchClosedOrders']) {
|
|
@@ -11747,7 +11751,7 @@ class Exchange {
|
|
|
11747
11751
|
return result;
|
|
11748
11752
|
}
|
|
11749
11753
|
isTriggerOrder(params) {
|
|
11750
|
-
const isTrigger = this.
|
|
11754
|
+
const isTrigger = this.safeBool2(params, 'trigger', 'stop');
|
|
11751
11755
|
if (isTrigger) {
|
|
11752
11756
|
params = this.omit(params, ['trigger', 'stop']);
|
|
11753
11757
|
}
|
|
@@ -11763,7 +11767,7 @@ class Exchange {
|
|
|
11763
11767
|
* @returns {boolean} true if a post only order, false otherwise
|
|
11764
11768
|
*/
|
|
11765
11769
|
const timeInForce = this.safeStringUpper(params, 'timeInForce');
|
|
11766
|
-
let postOnly = this.
|
|
11770
|
+
let postOnly = this.safeBool2(params, 'postOnly', 'post_only', false);
|
|
11767
11771
|
// we assume timeInForce is uppercase from safeStringUpper (params, 'timeInForce')
|
|
11768
11772
|
const ioc = timeInForce === 'IOC';
|
|
11769
11773
|
const fok = timeInForce === 'FOK';
|
|
@@ -11957,7 +11961,7 @@ class Exchange {
|
|
|
11957
11961
|
* @param {string} account key for account name in this.options['accountsByType']
|
|
11958
11962
|
* @returns the exchange specific account name or the isolated margin id for transfers
|
|
11959
11963
|
*/
|
|
11960
|
-
const accountsByType = this.
|
|
11964
|
+
const accountsByType = this.safeDict(this.options, 'accountsByType', {});
|
|
11961
11965
|
const lowercaseAccount = account.toLowerCase();
|
|
11962
11966
|
if (lowercaseAccount in accountsByType) {
|
|
11963
11967
|
return accountsByType[lowercaseAccount];
|
|
@@ -12434,7 +12438,7 @@ class Exchange {
|
|
|
12434
12438
|
return input;
|
|
12435
12439
|
}
|
|
12436
12440
|
handleUntilOption(key, request, params, multiplier = 1) {
|
|
12437
|
-
const until = this.
|
|
12441
|
+
const until = this.safeInteger2(params, 'until', 'till');
|
|
12438
12442
|
if (until !== undefined) {
|
|
12439
12443
|
request[key] = this.parseToInt(until * multiplier);
|
|
12440
12444
|
params = this.omit(params, ['until', 'till']);
|
|
@@ -20633,7 +20637,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
20633
20637
|
let minPrecision = undefined;
|
|
20634
20638
|
let isWithdrawEnabled = true;
|
|
20635
20639
|
let isDepositEnabled = true;
|
|
20636
|
-
const networkList = this.
|
|
20640
|
+
const networkList = this.safeList(entry, 'networkList', []);
|
|
20637
20641
|
const fees = {};
|
|
20638
20642
|
let fee = undefined;
|
|
20639
20643
|
for (let j = 0; j < networkList.length; j++) {
|
|
@@ -20641,12 +20645,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
20641
20645
|
const network = this.safeString(networkItem, 'network');
|
|
20642
20646
|
// const name = this.safeString (networkItem, 'name');
|
|
20643
20647
|
const withdrawFee = this.safeNumber(networkItem, 'withdrawFee');
|
|
20644
|
-
const depositEnable = this.
|
|
20645
|
-
const withdrawEnable = this.
|
|
20648
|
+
const depositEnable = this.safeBool(networkItem, 'depositEnable');
|
|
20649
|
+
const withdrawEnable = this.safeBool(networkItem, 'withdrawEnable');
|
|
20646
20650
|
isDepositEnabled = isDepositEnabled || depositEnable;
|
|
20647
20651
|
isWithdrawEnabled = isWithdrawEnabled || withdrawEnable;
|
|
20648
20652
|
fees[network] = withdrawFee;
|
|
20649
|
-
const isDefault = this.
|
|
20653
|
+
const isDefault = this.safeBool(networkItem, 'isDefault');
|
|
20650
20654
|
if (isDefault || (fee === undefined)) {
|
|
20651
20655
|
fee = withdrawFee;
|
|
20652
20656
|
}
|
|
@@ -20657,7 +20661,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
20657
20661
|
minPrecision = (minPrecision === undefined) ? precisionTick : _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMin(minPrecision, precisionTick);
|
|
20658
20662
|
}
|
|
20659
20663
|
}
|
|
20660
|
-
const trading = this.
|
|
20664
|
+
const trading = this.safeBool(entry, 'trading');
|
|
20661
20665
|
const active = (isWithdrawEnabled && isDepositEnabled && trading);
|
|
20662
20666
|
let maxDecimalPlaces = undefined;
|
|
20663
20667
|
if (minPrecision !== undefined) {
|
|
@@ -20693,8 +20697,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
20693
20697
|
* @returns {object[]} an array of objects representing market data
|
|
20694
20698
|
*/
|
|
20695
20699
|
const promisesRaw = [];
|
|
20696
|
-
const rawFetchMarkets = this.
|
|
20697
|
-
const sandboxMode = this.
|
|
20700
|
+
const rawFetchMarkets = this.safeList(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']);
|
|
20701
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
20698
20702
|
const fetchMarkets = [];
|
|
20699
20703
|
for (let i = 0; i < rawFetchMarkets.length; i++) {
|
|
20700
20704
|
const type = rawFetchMarkets[i];
|
|
@@ -20972,7 +20976,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
20972
20976
|
}
|
|
20973
20977
|
const settle = this.safeCurrencyCode(settleId);
|
|
20974
20978
|
const spot = !contract;
|
|
20975
|
-
const filters = this.
|
|
20979
|
+
const filters = this.safeList(market, 'filters', []);
|
|
20976
20980
|
const filtersByType = this.indexBy(filters, 'filterType');
|
|
20977
20981
|
const status = this.safeString2(market, 'status', 'contractStatus');
|
|
20978
20982
|
let contractSize = undefined;
|
|
@@ -20995,11 +20999,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
20995
20999
|
linear = settle === quote;
|
|
20996
21000
|
inverse = settle === base;
|
|
20997
21001
|
const feesType = linear ? 'linear' : 'inverse';
|
|
20998
|
-
fees = this.
|
|
21002
|
+
fees = this.safeDict(this.fees, feesType, {});
|
|
20999
21003
|
}
|
|
21000
21004
|
let active = (status === 'TRADING');
|
|
21001
21005
|
if (spot) {
|
|
21002
|
-
const permissions = this.
|
|
21006
|
+
const permissions = this.safeList(market, 'permissions', []);
|
|
21003
21007
|
for (let j = 0; j < permissions.length; j++) {
|
|
21004
21008
|
if (permissions[j] === 'TRD_GRP_003') {
|
|
21005
21009
|
active = false;
|
|
@@ -21077,7 +21081,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21077
21081
|
'created': this.safeInteger(market, 'onboardDate'), // present in inverse & linear apis
|
|
21078
21082
|
};
|
|
21079
21083
|
if ('PRICE_FILTER' in filtersByType) {
|
|
21080
|
-
const filter = this.
|
|
21084
|
+
const filter = this.safeDict(filtersByType, 'PRICE_FILTER', {});
|
|
21081
21085
|
// PRICE_FILTER reports zero values for maxPrice
|
|
21082
21086
|
// since they updated filter types in November 2018
|
|
21083
21087
|
// https://github.com/ccxt/ccxt/issues/4286
|
|
@@ -21089,7 +21093,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21089
21093
|
entry['precision']['price'] = this.precisionFromString(filter['tickSize']);
|
|
21090
21094
|
}
|
|
21091
21095
|
if ('LOT_SIZE' in filtersByType) {
|
|
21092
|
-
const filter = this.
|
|
21096
|
+
const filter = this.safeDict(filtersByType, 'LOT_SIZE', {});
|
|
21093
21097
|
const stepSize = this.safeString(filter, 'stepSize');
|
|
21094
21098
|
entry['precision']['amount'] = this.precisionFromString(stepSize);
|
|
21095
21099
|
entry['limits']['amount'] = {
|
|
@@ -21098,14 +21102,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21098
21102
|
};
|
|
21099
21103
|
}
|
|
21100
21104
|
if ('MARKET_LOT_SIZE' in filtersByType) {
|
|
21101
|
-
const filter = this.
|
|
21105
|
+
const filter = this.safeDict(filtersByType, 'MARKET_LOT_SIZE', {});
|
|
21102
21106
|
entry['limits']['market'] = {
|
|
21103
21107
|
'min': this.safeNumber(filter, 'minQty'),
|
|
21104
21108
|
'max': this.safeNumber(filter, 'maxQty'),
|
|
21105
21109
|
};
|
|
21106
21110
|
}
|
|
21107
21111
|
if (('MIN_NOTIONAL' in filtersByType) || ('NOTIONAL' in filtersByType)) { // notional added in 12/04/23 to spot testnet
|
|
21108
|
-
const filter = this.
|
|
21112
|
+
const filter = this.safeDict2(filtersByType, 'MIN_NOTIONAL', 'NOTIONAL', {});
|
|
21109
21113
|
entry['limits']['cost']['min'] = this.safeNumber2(filter, 'minNotional', 'notional');
|
|
21110
21114
|
entry['limits']['cost']['max'] = this.safeNumber(filter, 'maxNotional');
|
|
21111
21115
|
}
|
|
@@ -21799,7 +21803,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
21799
21803
|
}
|
|
21800
21804
|
}
|
|
21801
21805
|
if (Array.isArray(response)) {
|
|
21802
|
-
const firstTicker = this.
|
|
21806
|
+
const firstTicker = this.safeDict(response, 0, {});
|
|
21803
21807
|
return this.parseTicker(firstTicker, market);
|
|
21804
21808
|
}
|
|
21805
21809
|
return this.parseTicker(response, market);
|
|
@@ -22321,20 +22325,73 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
22321
22325
|
// "time": 1676366446072
|
|
22322
22326
|
// }
|
|
22323
22327
|
//
|
|
22328
|
+
// fetchMyTrades: linear portfolio margin
|
|
22329
|
+
//
|
|
22330
|
+
// {
|
|
22331
|
+
// "symbol": "BTCUSDT",
|
|
22332
|
+
// "id": 4575108247,
|
|
22333
|
+
// "orderId": 261942655610,
|
|
22334
|
+
// "side": "SELL",
|
|
22335
|
+
// "price": "47263.40",
|
|
22336
|
+
// "qty": "0.010",
|
|
22337
|
+
// "realizedPnl": "27.38400000",
|
|
22338
|
+
// "marginAsset": "USDT",
|
|
22339
|
+
// "quoteQty": "472.63",
|
|
22340
|
+
// "commission": "0.18905360",
|
|
22341
|
+
// "commissionAsset": "USDT",
|
|
22342
|
+
// "time": 1707530039409,
|
|
22343
|
+
// "buyer": false,
|
|
22344
|
+
// "maker": false,
|
|
22345
|
+
// "positionSide": "LONG"
|
|
22346
|
+
// }
|
|
22347
|
+
//
|
|
22348
|
+
// fetchMyTrades: inverse portfolio margin
|
|
22349
|
+
//
|
|
22350
|
+
// {
|
|
22351
|
+
// "symbol": "ETHUSD_PERP",
|
|
22352
|
+
// "id": 701907838,
|
|
22353
|
+
// "orderId": 71548909034,
|
|
22354
|
+
// "pair": "ETHUSD",
|
|
22355
|
+
// "side": "SELL",
|
|
22356
|
+
// "price": "2498.15",
|
|
22357
|
+
// "qty": "1",
|
|
22358
|
+
// "realizedPnl": "0.00012517",
|
|
22359
|
+
// "marginAsset": "ETH",
|
|
22360
|
+
// "baseQty": "0.00400296",
|
|
22361
|
+
// "commission": "0.00000160",
|
|
22362
|
+
// "commissionAsset": "ETH",
|
|
22363
|
+
// "time": 1707530317519,
|
|
22364
|
+
// "positionSide": "LONG",
|
|
22365
|
+
// "buyer": false,
|
|
22366
|
+
// "maker": false
|
|
22367
|
+
// }
|
|
22368
|
+
//
|
|
22369
|
+
// fetchMyTrades: spot margin portfolio margin
|
|
22370
|
+
//
|
|
22371
|
+
// {
|
|
22372
|
+
// "symbol": "ADAUSDT",
|
|
22373
|
+
// "id": 470227543,
|
|
22374
|
+
// "orderId": 4421170947,
|
|
22375
|
+
// "price": "0.53880000",
|
|
22376
|
+
// "qty": "10.00000000",
|
|
22377
|
+
// "quoteQty": "5.38800000",
|
|
22378
|
+
// "commission": "0.00538800",
|
|
22379
|
+
// "commissionAsset": "USDT",
|
|
22380
|
+
// "time": 1707545780522,
|
|
22381
|
+
// "isBuyer": false,
|
|
22382
|
+
// "isMaker": false,
|
|
22383
|
+
// "isBestMatch": true
|
|
22384
|
+
// }
|
|
22385
|
+
//
|
|
22324
22386
|
const timestamp = this.safeInteger2(trade, 'T', 'time');
|
|
22325
|
-
const price = this.safeString2(trade, 'p', 'price');
|
|
22326
22387
|
let amount = this.safeString2(trade, 'q', 'qty');
|
|
22327
22388
|
amount = this.safeString(trade, 'quantity', amount);
|
|
22328
|
-
const cost = this.safeString2(trade, 'quoteQty', 'baseQty'); // inverse futures
|
|
22329
22389
|
const marketId = this.safeString(trade, 'symbol');
|
|
22330
|
-
const isSpotTrade = ('isIsolated' in trade) || ('M' in trade) || ('orderListId' in trade);
|
|
22390
|
+
const isSpotTrade = ('isIsolated' in trade) || ('M' in trade) || ('orderListId' in trade) || ('isMaker' in trade);
|
|
22331
22391
|
const marketType = isSpotTrade ? 'spot' : 'contract';
|
|
22332
22392
|
market = this.safeMarket(marketId, market, undefined, marketType);
|
|
22333
22393
|
const symbol = market['symbol'];
|
|
22334
|
-
let id = this.safeString2(trade, 't', 'a');
|
|
22335
|
-
id = this.safeString2(trade, 'tradeId', 'id', id);
|
|
22336
22394
|
let side = undefined;
|
|
22337
|
-
const orderId = this.safeString(trade, 'orderId');
|
|
22338
22395
|
const buyerMaker = this.safeValue2(trade, 'm', 'isBuyerMaker');
|
|
22339
22396
|
let takerOrMaker = undefined;
|
|
22340
22397
|
if (buyerMaker !== undefined) {
|
|
@@ -22384,14 +22441,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
22384
22441
|
'timestamp': timestamp,
|
|
22385
22442
|
'datetime': this.iso8601(timestamp),
|
|
22386
22443
|
'symbol': symbol,
|
|
22387
|
-
'id': id,
|
|
22388
|
-
'order': orderId,
|
|
22444
|
+
'id': this.safeStringN(trade, ['t', 'a', 'tradeId', 'id']),
|
|
22445
|
+
'order': this.safeString(trade, 'orderId'),
|
|
22389
22446
|
'type': this.safeStringLower(trade, 'type'),
|
|
22390
22447
|
'side': side,
|
|
22391
22448
|
'takerOrMaker': takerOrMaker,
|
|
22392
|
-
'price': price,
|
|
22449
|
+
'price': this.safeString2(trade, 'p', 'price'),
|
|
22393
22450
|
'amount': amount,
|
|
22394
|
-
'cost':
|
|
22451
|
+
'cost': this.safeString2(trade, 'quoteQty', 'baseQty'),
|
|
22395
22452
|
'fee': fee,
|
|
22396
22453
|
}, market);
|
|
22397
22454
|
}
|
|
@@ -23225,7 +23282,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23225
23282
|
cost = this.safeString(order, 'cumBase', cost);
|
|
23226
23283
|
let type = this.safeStringLower(order, 'type');
|
|
23227
23284
|
const side = this.safeStringLower(order, 'side');
|
|
23228
|
-
const fills = this.
|
|
23285
|
+
const fills = this.safeList(order, 'fills', []);
|
|
23229
23286
|
let timeInForce = this.safeString(order, 'timeInForce');
|
|
23230
23287
|
if (timeInForce === 'GTX') {
|
|
23231
23288
|
// GTX means "Good Till Crossing" and is an equivalent way of saying Post Only
|
|
@@ -23258,7 +23315,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23258
23315
|
'type': type,
|
|
23259
23316
|
'timeInForce': timeInForce,
|
|
23260
23317
|
'postOnly': postOnly,
|
|
23261
|
-
'reduceOnly': this.
|
|
23318
|
+
'reduceOnly': this.safeBool(order, 'reduceOnly'),
|
|
23262
23319
|
'side': side,
|
|
23263
23320
|
'price': price,
|
|
23264
23321
|
'triggerPrice': stopPrice,
|
|
@@ -23292,7 +23349,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23292
23349
|
const side = this.safeString(rawOrder, 'side');
|
|
23293
23350
|
const amount = this.safeValue(rawOrder, 'amount');
|
|
23294
23351
|
const price = this.safeValue(rawOrder, 'price');
|
|
23295
|
-
const orderParams = this.
|
|
23352
|
+
const orderParams = this.safeDict(rawOrder, 'params', {});
|
|
23296
23353
|
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
23297
23354
|
ordersRequests.push(orderRequest);
|
|
23298
23355
|
}
|
|
@@ -24480,12 +24537,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24480
24537
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data
|
|
24481
24538
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-trade-list-user_data
|
|
24482
24539
|
* @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-trade-list-user_data
|
|
24540
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#margin-account-trade-list-user_data
|
|
24541
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#um-account-trade-list-user_data
|
|
24542
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#cm-account-trade-list-user_data
|
|
24483
24543
|
* @param {string} symbol unified market symbol
|
|
24484
24544
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
24485
24545
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
24486
24546
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
24487
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
24547
|
+
* @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)
|
|
24488
24548
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
24549
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trades for a portfolio margin account
|
|
24489
24550
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
24490
24551
|
*/
|
|
24491
24552
|
await this.loadMarkets();
|
|
@@ -24539,8 +24600,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24539
24600
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
|
|
24540
24601
|
}
|
|
24541
24602
|
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
24603
|
+
let isPortfolioMargin = undefined;
|
|
24604
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchMyTrades', 'papi', 'portfolioMargin', false);
|
|
24542
24605
|
if (type === 'spot' || type === 'margin') {
|
|
24543
|
-
if (
|
|
24606
|
+
if (isPortfolioMargin) {
|
|
24607
|
+
response = await this.papiGetMarginMyTrades(this.extend(request, params));
|
|
24608
|
+
}
|
|
24609
|
+
else if ((type === 'margin') || (marginMode !== undefined)) {
|
|
24544
24610
|
if (marginMode === 'isolated') {
|
|
24545
24611
|
request['isIsolated'] = true;
|
|
24546
24612
|
}
|
|
@@ -24551,10 +24617,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24551
24617
|
}
|
|
24552
24618
|
}
|
|
24553
24619
|
else if (market['linear']) {
|
|
24554
|
-
|
|
24620
|
+
if (isPortfolioMargin) {
|
|
24621
|
+
response = await this.papiGetUmUserTrades(this.extend(request, params));
|
|
24622
|
+
}
|
|
24623
|
+
else {
|
|
24624
|
+
response = await this.fapiPrivateGetUserTrades(this.extend(request, params));
|
|
24625
|
+
}
|
|
24555
24626
|
}
|
|
24556
24627
|
else if (market['inverse']) {
|
|
24557
|
-
|
|
24628
|
+
if (isPortfolioMargin) {
|
|
24629
|
+
response = await this.papiGetCmUserTrades(this.extend(request, params));
|
|
24630
|
+
}
|
|
24631
|
+
else {
|
|
24632
|
+
response = await this.dapiPrivateGetUserTrades(this.extend(request, params));
|
|
24633
|
+
}
|
|
24558
24634
|
}
|
|
24559
24635
|
}
|
|
24560
24636
|
//
|
|
@@ -24622,6 +24698,70 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24622
24698
|
// }
|
|
24623
24699
|
// ]
|
|
24624
24700
|
//
|
|
24701
|
+
// linear portfolio margin
|
|
24702
|
+
//
|
|
24703
|
+
// [
|
|
24704
|
+
// {
|
|
24705
|
+
// "symbol": "BTCUSDT",
|
|
24706
|
+
// "id": 4575108247,
|
|
24707
|
+
// "orderId": 261942655610,
|
|
24708
|
+
// "side": "SELL",
|
|
24709
|
+
// "price": "47263.40",
|
|
24710
|
+
// "qty": "0.010",
|
|
24711
|
+
// "realizedPnl": "27.38400000",
|
|
24712
|
+
// "marginAsset": "USDT",
|
|
24713
|
+
// "quoteQty": "472.63",
|
|
24714
|
+
// "commission": "0.18905360",
|
|
24715
|
+
// "commissionAsset": "USDT",
|
|
24716
|
+
// "time": 1707530039409,
|
|
24717
|
+
// "buyer": false,
|
|
24718
|
+
// "maker": false,
|
|
24719
|
+
// "positionSide": "LONG"
|
|
24720
|
+
// }
|
|
24721
|
+
// ]
|
|
24722
|
+
//
|
|
24723
|
+
// inverse portfolio margin
|
|
24724
|
+
//
|
|
24725
|
+
// [
|
|
24726
|
+
// {
|
|
24727
|
+
// "symbol": "ETHUSD_PERP",
|
|
24728
|
+
// "id": 701907838,
|
|
24729
|
+
// "orderId": 71548909034,
|
|
24730
|
+
// "pair": "ETHUSD",
|
|
24731
|
+
// "side": "SELL",
|
|
24732
|
+
// "price": "2498.15",
|
|
24733
|
+
// "qty": "1",
|
|
24734
|
+
// "realizedPnl": "0.00012517",
|
|
24735
|
+
// "marginAsset": "ETH",
|
|
24736
|
+
// "baseQty": "0.00400296",
|
|
24737
|
+
// "commission": "0.00000160",
|
|
24738
|
+
// "commissionAsset": "ETH",
|
|
24739
|
+
// "time": 1707530317519,
|
|
24740
|
+
// "positionSide": "LONG",
|
|
24741
|
+
// "buyer": false,
|
|
24742
|
+
// "maker": false
|
|
24743
|
+
// }
|
|
24744
|
+
// ]
|
|
24745
|
+
//
|
|
24746
|
+
// spot margin portfolio margin
|
|
24747
|
+
//
|
|
24748
|
+
// [
|
|
24749
|
+
// {
|
|
24750
|
+
// "symbol": "ADAUSDT",
|
|
24751
|
+
// "id": 470227543,
|
|
24752
|
+
// "orderId": 4421170947,
|
|
24753
|
+
// "price": "0.53880000",
|
|
24754
|
+
// "qty": "10.00000000",
|
|
24755
|
+
// "quoteQty": "5.38800000",
|
|
24756
|
+
// "commission": "0.00538800",
|
|
24757
|
+
// "commissionAsset": "USDT",
|
|
24758
|
+
// "time": 1707545780522,
|
|
24759
|
+
// "isBuyer": false,
|
|
24760
|
+
// "isMaker": false,
|
|
24761
|
+
// "isBestMatch": true
|
|
24762
|
+
// }
|
|
24763
|
+
// ]
|
|
24764
|
+
//
|
|
24625
24765
|
return this.parseTrades(response, market, since, limit);
|
|
24626
24766
|
}
|
|
24627
24767
|
async fetchMyDustTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -24684,11 +24824,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24684
24824
|
// },
|
|
24685
24825
|
// ]
|
|
24686
24826
|
// }
|
|
24687
|
-
const results = this.
|
|
24827
|
+
const results = this.safeList(response, 'userAssetDribblets', []);
|
|
24688
24828
|
const rows = this.safeInteger(response, 'total', 0);
|
|
24689
24829
|
const data = [];
|
|
24690
24830
|
for (let i = 0; i < rows; i++) {
|
|
24691
|
-
const logs = this.
|
|
24831
|
+
const logs = this.safeList(results[i], 'userAssetDribbletDetails', []);
|
|
24692
24832
|
for (let j = 0; j < logs.length; j++) {
|
|
24693
24833
|
logs[j]['isDustTrade'] = true;
|
|
24694
24834
|
data.push(logs[j]);
|
|
@@ -24795,7 +24935,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24795
24935
|
let currency = undefined;
|
|
24796
24936
|
let response = undefined;
|
|
24797
24937
|
const request = {};
|
|
24798
|
-
const legalMoney = this.
|
|
24938
|
+
const legalMoney = this.safeDict(this.options, 'legalMoney', {});
|
|
24799
24939
|
const fiatOnly = this.safeBool(params, 'fiat', false);
|
|
24800
24940
|
params = this.omit(params, 'fiatOnly');
|
|
24801
24941
|
const until = this.safeInteger(params, 'until');
|
|
@@ -24907,7 +25047,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24907
25047
|
if (paginate) {
|
|
24908
25048
|
return await this.fetchPaginatedCallDynamic('fetchWithdrawals', code, since, limit, params);
|
|
24909
25049
|
}
|
|
24910
|
-
const legalMoney = this.
|
|
25050
|
+
const legalMoney = this.safeDict(this.options, 'legalMoney', {});
|
|
24911
25051
|
const fiatOnly = this.safeBool(params, 'fiat', false);
|
|
24912
25052
|
params = this.omit(params, 'fiatOnly');
|
|
24913
25053
|
const request = {};
|
|
@@ -25051,7 +25191,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25051
25191
|
'Refund Failed': 'failed',
|
|
25052
25192
|
},
|
|
25053
25193
|
};
|
|
25054
|
-
const statuses = this.
|
|
25194
|
+
const statuses = this.safeDict(statusesByType, type, {});
|
|
25055
25195
|
return this.safeString(statuses, status, status);
|
|
25056
25196
|
}
|
|
25057
25197
|
parseTransaction(transaction, currency = undefined) {
|
|
@@ -25216,7 +25356,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25216
25356
|
const type = this.safeString(transfer, 'type');
|
|
25217
25357
|
let fromAccount = undefined;
|
|
25218
25358
|
let toAccount = undefined;
|
|
25219
|
-
const accountsById = this.
|
|
25359
|
+
const accountsById = this.safeDict(this.options, 'accountsById', {});
|
|
25220
25360
|
if (type !== undefined) {
|
|
25221
25361
|
const parts = type.split('_');
|
|
25222
25362
|
fromAccount = this.safeValue(parts, 0);
|
|
@@ -25252,20 +25392,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25252
25392
|
// }
|
|
25253
25393
|
//
|
|
25254
25394
|
const marketId = this.safeString(income, 'symbol');
|
|
25255
|
-
const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
|
|
25256
|
-
const amount = this.safeNumber(income, 'income');
|
|
25257
25395
|
const currencyId = this.safeString(income, 'asset');
|
|
25258
|
-
const code = this.safeCurrencyCode(currencyId);
|
|
25259
|
-
const id = this.safeString(income, 'tranId');
|
|
25260
25396
|
const timestamp = this.safeInteger(income, 'time');
|
|
25261
25397
|
return {
|
|
25262
25398
|
'info': income,
|
|
25263
|
-
'symbol':
|
|
25264
|
-
'code':
|
|
25399
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
25400
|
+
'code': this.safeCurrencyCode(currencyId),
|
|
25265
25401
|
'timestamp': timestamp,
|
|
25266
25402
|
'datetime': this.iso8601(timestamp),
|
|
25267
|
-
'id':
|
|
25268
|
-
'amount':
|
|
25403
|
+
'id': this.safeString(income, 'tranId'),
|
|
25404
|
+
'amount': this.safeNumber(income, 'income'),
|
|
25269
25405
|
};
|
|
25270
25406
|
}
|
|
25271
25407
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
@@ -25314,7 +25450,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25314
25450
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' transfer () requires params["symbol"] when toAccount is ' + toAccount);
|
|
25315
25451
|
}
|
|
25316
25452
|
}
|
|
25317
|
-
const accountsById = this.
|
|
25453
|
+
const accountsById = this.safeDict(this.options, 'accountsById', {});
|
|
25318
25454
|
const fromIsolated = !(fromId in accountsById);
|
|
25319
25455
|
const toIsolated = !(toId in accountsById);
|
|
25320
25456
|
if (fromIsolated && (market === undefined)) {
|
|
@@ -25404,7 +25540,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25404
25540
|
const defaultTo = (fromAccount === 'future') ? 'spot' : 'future';
|
|
25405
25541
|
const toAccount = this.safeString(params, 'toAccount', defaultTo);
|
|
25406
25542
|
let type = this.safeString(params, 'type');
|
|
25407
|
-
const accountsByType = this.
|
|
25543
|
+
const accountsByType = this.safeDict(this.options, 'accountsByType', {});
|
|
25408
25544
|
const fromId = this.safeString(accountsByType, fromAccount);
|
|
25409
25545
|
const toId = this.safeString(accountsByType, toAccount);
|
|
25410
25546
|
if (type === undefined) {
|
|
@@ -25448,7 +25584,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25448
25584
|
// ]
|
|
25449
25585
|
// }
|
|
25450
25586
|
//
|
|
25451
|
-
const rows = this.
|
|
25587
|
+
const rows = this.safeList(response, 'rows', []);
|
|
25452
25588
|
return this.parseTransfers(rows, currency, since, limit);
|
|
25453
25589
|
}
|
|
25454
25590
|
async fetchDepositAddress(code, params = {}) {
|
|
@@ -25467,7 +25603,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25467
25603
|
'coin': currency['id'],
|
|
25468
25604
|
// 'network': 'ETH', // 'BSC', 'XMR', you can get network and isDefault in networkList in the response of sapiGetCapitalConfigDetail
|
|
25469
25605
|
};
|
|
25470
|
-
const networks = this.
|
|
25606
|
+
const networks = this.safeDict(this.options, 'networks', {});
|
|
25471
25607
|
let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
|
|
25472
25608
|
network = this.safeString(networks, network, network); // handle ERC20>ETH alias
|
|
25473
25609
|
if (network !== undefined) {
|
|
@@ -25494,7 +25630,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25494
25630
|
const url = this.safeString(response, 'url');
|
|
25495
25631
|
let impliedNetwork = undefined;
|
|
25496
25632
|
if (url !== undefined) {
|
|
25497
|
-
const reverseNetworks = this.
|
|
25633
|
+
const reverseNetworks = this.safeDict(this.options, 'reverseNetworks', {});
|
|
25498
25634
|
const parts = url.split('/');
|
|
25499
25635
|
let topLevel = this.safeString(parts, 2);
|
|
25500
25636
|
if ((topLevel === 'blockchair.com') || (topLevel === 'viewblock.io')) {
|
|
@@ -25509,7 +25645,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25509
25645
|
'TRX': { 'TRC20': 'TRX' },
|
|
25510
25646
|
});
|
|
25511
25647
|
if (code in impliedNetworks) {
|
|
25512
|
-
const conversion = this.
|
|
25648
|
+
const conversion = this.safeDict(impliedNetworks, code, {});
|
|
25513
25649
|
impliedNetwork = this.safeString(conversion, impliedNetwork, impliedNetwork);
|
|
25514
25650
|
}
|
|
25515
25651
|
}
|
|
@@ -25625,7 +25761,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25625
25761
|
const entry = response[i];
|
|
25626
25762
|
const currencyId = this.safeString(entry, 'coin');
|
|
25627
25763
|
const code = this.safeCurrencyCode(currencyId);
|
|
25628
|
-
const networkList = this.
|
|
25764
|
+
const networkList = this.safeList(entry, 'networkList', []);
|
|
25629
25765
|
withdrawFees[code] = {};
|
|
25630
25766
|
for (let j = 0; j < networkList.length; j++) {
|
|
25631
25767
|
const networkEntry = networkList[j];
|
|
@@ -25738,14 +25874,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25738
25874
|
// ]
|
|
25739
25875
|
// }
|
|
25740
25876
|
//
|
|
25741
|
-
const networkList = this.
|
|
25877
|
+
const networkList = this.safeList(fee, 'networkList', []);
|
|
25742
25878
|
const result = this.depositWithdrawFee(fee);
|
|
25743
25879
|
for (let j = 0; j < networkList.length; j++) {
|
|
25744
25880
|
const networkEntry = networkList[j];
|
|
25745
25881
|
const networkId = this.safeString(networkEntry, 'network');
|
|
25746
25882
|
const networkCode = this.networkIdToCode(networkId);
|
|
25747
25883
|
const withdrawFee = this.safeNumber(networkEntry, 'withdrawFee');
|
|
25748
|
-
const isDefault = this.
|
|
25884
|
+
const isDefault = this.safeBool(networkEntry, 'isDefault');
|
|
25749
25885
|
if (isDefault === true) {
|
|
25750
25886
|
result['withdraw'] = {
|
|
25751
25887
|
'fee': withdrawFee,
|
|
@@ -25793,7 +25929,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25793
25929
|
if (tag !== undefined) {
|
|
25794
25930
|
request['addressTag'] = tag;
|
|
25795
25931
|
}
|
|
25796
|
-
const networks = this.
|
|
25932
|
+
const networks = this.safeDict(this.options, 'networks', {});
|
|
25797
25933
|
let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
|
|
25798
25934
|
network = this.safeString(networks, network, network); // handle ERC20>ETH alias
|
|
25799
25935
|
if (network !== undefined) {
|
|
@@ -25885,7 +26021,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
25885
26021
|
//
|
|
25886
26022
|
let data = response;
|
|
25887
26023
|
if (Array.isArray(data)) {
|
|
25888
|
-
data = this.
|
|
26024
|
+
data = this.safeDict(data, 0, {});
|
|
25889
26025
|
}
|
|
25890
26026
|
return this.parseTradingFee(data);
|
|
25891
26027
|
}
|
|
@@ -26299,8 +26435,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26299
26435
|
};
|
|
26300
26436
|
}
|
|
26301
26437
|
parseAccountPositions(account) {
|
|
26302
|
-
const positions = this.
|
|
26303
|
-
const assets = this.
|
|
26438
|
+
const positions = this.safeList(account, 'positions');
|
|
26439
|
+
const assets = this.safeList(account, 'assets', []);
|
|
26304
26440
|
const balances = {};
|
|
26305
26441
|
for (let i = 0; i < assets.length; i++) {
|
|
26306
26442
|
const entry = assets[i];
|
|
@@ -26319,13 +26455,17 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26319
26455
|
const marketId = this.safeString(position, 'symbol');
|
|
26320
26456
|
const market = this.safeMarket(marketId, undefined, undefined, 'contract');
|
|
26321
26457
|
const code = market['linear'] ? market['quote'] : market['base'];
|
|
26322
|
-
|
|
26323
|
-
|
|
26324
|
-
|
|
26325
|
-
|
|
26326
|
-
|
|
26327
|
-
|
|
26328
|
-
|
|
26458
|
+
const maintenanceMargin = this.safeString(position, 'maintMargin');
|
|
26459
|
+
// check for maintenance margin so empty positions are not returned
|
|
26460
|
+
if ((maintenanceMargin !== '0') && (maintenanceMargin !== '0.00000000')) {
|
|
26461
|
+
// sometimes not all the codes are correctly returned...
|
|
26462
|
+
if (code in balances) {
|
|
26463
|
+
const parsed = this.parseAccountPosition(this.extend(position, {
|
|
26464
|
+
'crossMargin': balances[code]['crossMargin'],
|
|
26465
|
+
'crossWalletBalance': balances[code]['crossWalletBalance'],
|
|
26466
|
+
}), market);
|
|
26467
|
+
result.push(parsed);
|
|
26468
|
+
}
|
|
26329
26469
|
}
|
|
26330
26470
|
}
|
|
26331
26471
|
return result;
|
|
@@ -26333,6 +26473,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26333
26473
|
parseAccountPosition(position, market = undefined) {
|
|
26334
26474
|
//
|
|
26335
26475
|
// usdm
|
|
26476
|
+
//
|
|
26336
26477
|
// {
|
|
26337
26478
|
// "symbol": "BTCBUSD",
|
|
26338
26479
|
// "initialMargin": "0",
|
|
@@ -26353,6 +26494,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26353
26494
|
// }
|
|
26354
26495
|
//
|
|
26355
26496
|
// coinm
|
|
26497
|
+
//
|
|
26356
26498
|
// {
|
|
26357
26499
|
// "symbol": "BTCUSD_210625",
|
|
26358
26500
|
// "initialMargin": "0.00024393",
|
|
@@ -26371,6 +26513,46 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26371
26513
|
// "crossWalletBalance": "34",
|
|
26372
26514
|
// }
|
|
26373
26515
|
//
|
|
26516
|
+
// linear portfolio margin
|
|
26517
|
+
//
|
|
26518
|
+
// {
|
|
26519
|
+
// "symbol": "CTSIUSDT",
|
|
26520
|
+
// "initialMargin": "0",
|
|
26521
|
+
// "maintMargin": "0",
|
|
26522
|
+
// "unrealizedProfit": "0.00000000",
|
|
26523
|
+
// "positionInitialMargin": "0",
|
|
26524
|
+
// "openOrderInitialMargin": "0",
|
|
26525
|
+
// "leverage": "20",
|
|
26526
|
+
// "entryPrice": "0.0",
|
|
26527
|
+
// "maxNotional": "25000",
|
|
26528
|
+
// "bidNotional": "0",
|
|
26529
|
+
// "askNotional": "0",
|
|
26530
|
+
// "positionSide": "SHORT",
|
|
26531
|
+
// "positionAmt": "0",
|
|
26532
|
+
// "updateTime": 0,
|
|
26533
|
+
// "notional": "0",
|
|
26534
|
+
// "breakEvenPrice": "0.0"
|
|
26535
|
+
// }
|
|
26536
|
+
//
|
|
26537
|
+
// inverse portoflio margin
|
|
26538
|
+
//
|
|
26539
|
+
// {
|
|
26540
|
+
// "symbol": "TRXUSD_PERP",
|
|
26541
|
+
// "initialMargin": "0",
|
|
26542
|
+
// "maintMargin": "0",
|
|
26543
|
+
// "unrealizedProfit": "0.00000000",
|
|
26544
|
+
// "positionInitialMargin": "0",
|
|
26545
|
+
// "openOrderInitialMargin": "0",
|
|
26546
|
+
// "leverage": "20",
|
|
26547
|
+
// "entryPrice": "0.00000000",
|
|
26548
|
+
// "positionSide": "SHORT",
|
|
26549
|
+
// "positionAmt": "0",
|
|
26550
|
+
// "maxQty": "5000000",
|
|
26551
|
+
// "updateTime": 0,
|
|
26552
|
+
// "notionalValue": "0",
|
|
26553
|
+
// "breakEvenPrice": "0.00000000"
|
|
26554
|
+
// }
|
|
26555
|
+
//
|
|
26374
26556
|
const marketId = this.safeString(position, 'symbol');
|
|
26375
26557
|
market = this.safeMarket(marketId, market, undefined, 'contract');
|
|
26376
26558
|
const symbol = this.safeString(market, 'symbol');
|
|
@@ -26401,8 +26583,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26401
26583
|
contractsStringAbs = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(contractsString, '0.5'), '1', 0);
|
|
26402
26584
|
}
|
|
26403
26585
|
const contracts = this.parseNumber(contractsStringAbs);
|
|
26404
|
-
const leverageBrackets = this.
|
|
26405
|
-
const leverageBracket = this.
|
|
26586
|
+
const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
|
|
26587
|
+
const leverageBracket = this.safeList(leverageBrackets, symbol, []);
|
|
26406
26588
|
let maintenanceMarginPercentageString = undefined;
|
|
26407
26589
|
for (let i = 0; i < leverageBracket.length; i++) {
|
|
26408
26590
|
const bracket = leverageBracket[i];
|
|
@@ -26418,7 +26600,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26418
26600
|
if (timestamp === 0) {
|
|
26419
26601
|
timestamp = undefined;
|
|
26420
26602
|
}
|
|
26421
|
-
const isolated = this.
|
|
26603
|
+
const isolated = this.safeBool(position, 'isolated');
|
|
26422
26604
|
let marginMode = undefined;
|
|
26423
26605
|
let collateralString = undefined;
|
|
26424
26606
|
let walletBalance = undefined;
|
|
@@ -26571,11 +26753,45 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26571
26753
|
// "isolatedWallet": "0.00268058"
|
|
26572
26754
|
// }
|
|
26573
26755
|
//
|
|
26756
|
+
// inverse portfolio margin
|
|
26757
|
+
//
|
|
26758
|
+
// {
|
|
26759
|
+
// "symbol": "ETHUSD_PERP",
|
|
26760
|
+
// "positionAmt": "1",
|
|
26761
|
+
// "entryPrice": "2422.400000007",
|
|
26762
|
+
// "markPrice": "2424.51267823",
|
|
26763
|
+
// "unRealizedProfit": "0.0000036",
|
|
26764
|
+
// "liquidationPrice": "293.57678898",
|
|
26765
|
+
// "leverage": "100",
|
|
26766
|
+
// "positionSide": "LONG",
|
|
26767
|
+
// "updateTime": 1707371941861,
|
|
26768
|
+
// "maxQty": "15",
|
|
26769
|
+
// "notionalValue": "0.00412454",
|
|
26770
|
+
// "breakEvenPrice": "2423.368960034"
|
|
26771
|
+
// }
|
|
26772
|
+
//
|
|
26773
|
+
// linear portfolio margin
|
|
26774
|
+
//
|
|
26775
|
+
// {
|
|
26776
|
+
// "symbol": "BTCUSDT",
|
|
26777
|
+
// "positionAmt": "0.01",
|
|
26778
|
+
// "entryPrice": "44525.0",
|
|
26779
|
+
// "markPrice": "45464.1735922",
|
|
26780
|
+
// "unRealizedProfit": "9.39173592",
|
|
26781
|
+
// "liquidationPrice": "38007.16308568",
|
|
26782
|
+
// "leverage": "100",
|
|
26783
|
+
// "positionSide": "LONG",
|
|
26784
|
+
// "updateTime": 1707371879042,
|
|
26785
|
+
// "maxNotionalValue": "500000.0",
|
|
26786
|
+
// "notional": "454.64173592",
|
|
26787
|
+
// "breakEvenPrice": "44542.81"
|
|
26788
|
+
// }
|
|
26789
|
+
//
|
|
26574
26790
|
const marketId = this.safeString(position, 'symbol');
|
|
26575
26791
|
market = this.safeMarket(marketId, market, undefined, 'contract');
|
|
26576
26792
|
const symbol = this.safeString(market, 'symbol');
|
|
26577
|
-
const leverageBrackets = this.
|
|
26578
|
-
const leverageBracket = this.
|
|
26793
|
+
const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
|
|
26794
|
+
const leverageBracket = this.safeList(leverageBrackets, symbol, []);
|
|
26579
26795
|
const notionalString = this.safeString2(position, 'notional', 'notionalValue');
|
|
26580
26796
|
const notionalStringAbs = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(notionalString);
|
|
26581
26797
|
let maintenanceMarginPercentageString = undefined;
|
|
@@ -26612,7 +26828,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26612
26828
|
const linear = ('notional' in position);
|
|
26613
26829
|
if (marginMode === 'cross') {
|
|
26614
26830
|
// calculate collateral
|
|
26615
|
-
const precision = this.
|
|
26831
|
+
const precision = this.safeDict(market, 'precision', {});
|
|
26616
26832
|
if (linear) {
|
|
26617
26833
|
// walletBalance = (liquidationPrice * (±1 + mmp) ± entryPrice) * contracts
|
|
26618
26834
|
let onePlusMaintenanceMarginPercentageString = undefined;
|
|
@@ -26719,12 +26935,24 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26719
26935
|
const query = this.omit(params, 'type');
|
|
26720
26936
|
let subType = undefined;
|
|
26721
26937
|
[subType, params] = this.handleSubTypeAndParams('loadLeverageBrackets', undefined, params, 'linear');
|
|
26938
|
+
let isPortfolioMargin = undefined;
|
|
26939
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'loadLeverageBrackets', 'papi', 'portfolioMargin', false);
|
|
26722
26940
|
let response = undefined;
|
|
26723
26941
|
if (this.isLinear(type, subType)) {
|
|
26724
|
-
|
|
26942
|
+
if (isPortfolioMargin) {
|
|
26943
|
+
response = await this.papiGetUmLeverageBracket(query);
|
|
26944
|
+
}
|
|
26945
|
+
else {
|
|
26946
|
+
response = await this.fapiPrivateGetLeverageBracket(query);
|
|
26947
|
+
}
|
|
26725
26948
|
}
|
|
26726
26949
|
else if (this.isInverse(type, subType)) {
|
|
26727
|
-
|
|
26950
|
+
if (isPortfolioMargin) {
|
|
26951
|
+
response = await this.papiGetCmLeverageBracket(query);
|
|
26952
|
+
}
|
|
26953
|
+
else {
|
|
26954
|
+
response = await this.dapiPrivateV2GetLeverageBracket(query);
|
|
26955
|
+
}
|
|
26728
26956
|
}
|
|
26729
26957
|
else {
|
|
26730
26958
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' loadLeverageBrackets() supports linear and inverse contracts only');
|
|
@@ -26734,7 +26962,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26734
26962
|
const entry = response[i];
|
|
26735
26963
|
const marketId = this.safeString(entry, 'symbol');
|
|
26736
26964
|
const symbol = this.safeSymbol(marketId, undefined, undefined, 'contract');
|
|
26737
|
-
const brackets = this.
|
|
26965
|
+
const brackets = this.safeList(entry, 'brackets', []);
|
|
26738
26966
|
const result = [];
|
|
26739
26967
|
for (let j = 0; j < brackets.length; j++) {
|
|
26740
26968
|
const bracket = brackets[j];
|
|
@@ -26754,8 +26982,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26754
26982
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
|
26755
26983
|
* @see https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-user_data
|
|
26756
26984
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#notional-bracket-for-symbol-user_data
|
|
26985
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#um-notional-and-leverage-brackets-user_data
|
|
26986
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#cm-notional-and-leverage-brackets-user_data
|
|
26757
26987
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
26758
26988
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
26989
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the leverage tiers for a portfolio margin account
|
|
26759
26990
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
26760
26991
|
*/
|
|
26761
26992
|
await this.loadMarkets();
|
|
@@ -26763,12 +26994,24 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26763
26994
|
[type, params] = this.handleMarketTypeAndParams('fetchLeverageTiers', undefined, params);
|
|
26764
26995
|
let subType = undefined;
|
|
26765
26996
|
[subType, params] = this.handleSubTypeAndParams('fetchLeverageTiers', undefined, params, 'linear');
|
|
26997
|
+
let isPortfolioMargin = undefined;
|
|
26998
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverageTiers', 'papi', 'portfolioMargin', false);
|
|
26766
26999
|
let response = undefined;
|
|
26767
27000
|
if (this.isLinear(type, subType)) {
|
|
26768
|
-
|
|
27001
|
+
if (isPortfolioMargin) {
|
|
27002
|
+
response = await this.papiGetUmLeverageBracket(params);
|
|
27003
|
+
}
|
|
27004
|
+
else {
|
|
27005
|
+
response = await this.fapiPrivateGetLeverageBracket(params);
|
|
27006
|
+
}
|
|
26769
27007
|
}
|
|
26770
27008
|
else if (this.isInverse(type, subType)) {
|
|
26771
|
-
|
|
27009
|
+
if (isPortfolioMargin) {
|
|
27010
|
+
response = await this.papiGetCmLeverageBracket(params);
|
|
27011
|
+
}
|
|
27012
|
+
else {
|
|
27013
|
+
response = await this.dapiPrivateV2GetLeverageBracket(params);
|
|
27014
|
+
}
|
|
26772
27015
|
}
|
|
26773
27016
|
else {
|
|
26774
27017
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverageTiers() supports linear and inverse contracts only');
|
|
@@ -26838,7 +27081,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
26838
27081
|
//
|
|
26839
27082
|
const marketId = this.safeString(info, 'symbol');
|
|
26840
27083
|
market = this.safeMarket(marketId, market, undefined, 'contract');
|
|
26841
|
-
const brackets = this.
|
|
27084
|
+
const brackets = this.safeList(info, 'brackets', []);
|
|
26842
27085
|
const tiers = [];
|
|
26843
27086
|
for (let j = 0; j < brackets.length; j++) {
|
|
26844
27087
|
const bracket = brackets[j];
|
|
@@ -27053,8 +27296,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27053
27296
|
* @description fetch account positions
|
|
27054
27297
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
27055
27298
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
27299
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
|
|
27300
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
|
27056
27301
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
27057
27302
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
27303
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
|
|
27058
27304
|
* @returns {object} data on account positions
|
|
27059
27305
|
*/
|
|
27060
27306
|
if (symbols !== undefined) {
|
|
@@ -27066,15 +27312,27 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27066
27312
|
await this.loadLeverageBrackets(false, params);
|
|
27067
27313
|
const defaultType = this.safeString(this.options, 'defaultType', 'future');
|
|
27068
27314
|
const type = this.safeString(params, 'type', defaultType);
|
|
27069
|
-
|
|
27315
|
+
params = this.omit(params, 'type');
|
|
27070
27316
|
let subType = undefined;
|
|
27071
|
-
[subType,
|
|
27317
|
+
[subType, params] = this.handleSubTypeAndParams('fetchAccountPositions', undefined, params, 'linear');
|
|
27318
|
+
let isPortfolioMargin = undefined;
|
|
27319
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchAccountPositions', 'papi', 'portfolioMargin', false);
|
|
27072
27320
|
let response = undefined;
|
|
27073
27321
|
if (this.isLinear(type, subType)) {
|
|
27074
|
-
|
|
27322
|
+
if (isPortfolioMargin) {
|
|
27323
|
+
response = await this.papiGetUmAccount(params);
|
|
27324
|
+
}
|
|
27325
|
+
else {
|
|
27326
|
+
response = await this.fapiPrivateV2GetAccount(params);
|
|
27327
|
+
}
|
|
27075
27328
|
}
|
|
27076
27329
|
else if (this.isInverse(type, subType)) {
|
|
27077
|
-
|
|
27330
|
+
if (isPortfolioMargin) {
|
|
27331
|
+
response = await this.papiGetCmAccount(params);
|
|
27332
|
+
}
|
|
27333
|
+
else {
|
|
27334
|
+
response = await this.dapiPrivateGetAccount(params);
|
|
27335
|
+
}
|
|
27078
27336
|
}
|
|
27079
27337
|
else {
|
|
27080
27338
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
|
|
@@ -27091,8 +27349,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27091
27349
|
* @description fetch positions risk
|
|
27092
27350
|
* @see https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
|
|
27093
27351
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
|
|
27352
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-um-position-information-user_data
|
|
27353
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#query-cm-position-information-user_data
|
|
27094
27354
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
27095
27355
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
27356
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
|
|
27096
27357
|
* @returns {object} data on the positions risk
|
|
27097
27358
|
*/
|
|
27098
27359
|
if (symbols !== undefined) {
|
|
@@ -27108,71 +27369,124 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27108
27369
|
const type = this.safeString(params, 'type', defaultType);
|
|
27109
27370
|
let subType = undefined;
|
|
27110
27371
|
[subType, params] = this.handleSubTypeAndParams('fetchPositionsRisk', undefined, params, 'linear');
|
|
27372
|
+
let isPortfolioMargin = undefined;
|
|
27373
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchPositionsRisk', 'papi', 'portfolioMargin', false);
|
|
27111
27374
|
params = this.omit(params, 'type');
|
|
27112
27375
|
let response = undefined;
|
|
27113
27376
|
if (this.isLinear(type, subType)) {
|
|
27114
|
-
|
|
27115
|
-
|
|
27116
|
-
|
|
27117
|
-
|
|
27118
|
-
|
|
27119
|
-
|
|
27120
|
-
// "entryPrice": "0.00000",
|
|
27121
|
-
// "marginType": "isolated",
|
|
27122
|
-
// "isAutoAddMargin": "false",
|
|
27123
|
-
// "isolatedMargin": "0.00000000",
|
|
27124
|
-
// "leverage": "10",
|
|
27125
|
-
// "liquidationPrice": "0",
|
|
27126
|
-
// "markPrice": "6679.50671178",
|
|
27127
|
-
// "maxNotionalValue": "20000000",
|
|
27128
|
-
// "positionAmt": "0.000",
|
|
27129
|
-
// "symbol": "BTCUSDT",
|
|
27130
|
-
// "unRealizedProfit": "0.00000000",
|
|
27131
|
-
// "positionSide": "BOTH",
|
|
27132
|
-
// "updateTime": 0
|
|
27133
|
-
// }
|
|
27134
|
-
// ]
|
|
27135
|
-
//
|
|
27136
|
-
// For Hedge position mode:
|
|
27137
|
-
// [
|
|
27138
|
-
// {
|
|
27139
|
-
// "entryPrice": "6563.66500",
|
|
27140
|
-
// "marginType": "isolated",
|
|
27141
|
-
// "isAutoAddMargin": "false",
|
|
27142
|
-
// "isolatedMargin": "15517.54150468",
|
|
27143
|
-
// "leverage": "10",
|
|
27144
|
-
// "liquidationPrice": "5930.78",
|
|
27145
|
-
// "markPrice": "6679.50671178",
|
|
27146
|
-
// "maxNotionalValue": "20000000",
|
|
27147
|
-
// "positionAmt": "20.000",
|
|
27148
|
-
// "symbol": "BTCUSDT",
|
|
27149
|
-
// "unRealizedProfit": "2316.83423560"
|
|
27150
|
-
// "positionSide": "LONG",
|
|
27151
|
-
// "updateTime": 1625474304765
|
|
27152
|
-
// },
|
|
27153
|
-
// {
|
|
27154
|
-
// "entryPrice": "0.00000",
|
|
27155
|
-
// "marginType": "isolated",
|
|
27156
|
-
// "isAutoAddMargin": "false",
|
|
27157
|
-
// "isolatedMargin": "5413.95799991",
|
|
27158
|
-
// "leverage": "10",
|
|
27159
|
-
// "liquidationPrice": "7189.95",
|
|
27160
|
-
// "markPrice": "6679.50671178",
|
|
27161
|
-
// "maxNotionalValue": "20000000",
|
|
27162
|
-
// "positionAmt": "-10.000",
|
|
27163
|
-
// "symbol": "BTCUSDT",
|
|
27164
|
-
// "unRealizedProfit": "-1156.46711780",
|
|
27165
|
-
// "positionSide": "SHORT",
|
|
27166
|
-
// "updateTime": 0
|
|
27167
|
-
// }
|
|
27168
|
-
// ]
|
|
27377
|
+
if (isPortfolioMargin) {
|
|
27378
|
+
response = await this.papiGetUmPositionRisk(this.extend(request, params));
|
|
27379
|
+
}
|
|
27380
|
+
else {
|
|
27381
|
+
response = await this.fapiPrivateV2GetPositionRisk(this.extend(request, params));
|
|
27382
|
+
}
|
|
27169
27383
|
}
|
|
27170
27384
|
else if (this.isInverse(type, subType)) {
|
|
27171
|
-
|
|
27385
|
+
if (isPortfolioMargin) {
|
|
27386
|
+
response = await this.papiGetCmPositionRisk(this.extend(request, params));
|
|
27387
|
+
}
|
|
27388
|
+
else {
|
|
27389
|
+
response = await this.dapiPrivateGetPositionRisk(this.extend(request, params));
|
|
27390
|
+
}
|
|
27172
27391
|
}
|
|
27173
27392
|
else {
|
|
27174
27393
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositionsRisk() supports linear and inverse contracts only');
|
|
27175
27394
|
}
|
|
27395
|
+
// ### Response examples ###
|
|
27396
|
+
//
|
|
27397
|
+
// For One-way position mode:
|
|
27398
|
+
//
|
|
27399
|
+
// [
|
|
27400
|
+
// {
|
|
27401
|
+
// "entryPrice": "0.00000",
|
|
27402
|
+
// "marginType": "isolated",
|
|
27403
|
+
// "isAutoAddMargin": "false",
|
|
27404
|
+
// "isolatedMargin": "0.00000000",
|
|
27405
|
+
// "leverage": "10",
|
|
27406
|
+
// "liquidationPrice": "0",
|
|
27407
|
+
// "markPrice": "6679.50671178",
|
|
27408
|
+
// "maxNotionalValue": "20000000",
|
|
27409
|
+
// "positionAmt": "0.000",
|
|
27410
|
+
// "symbol": "BTCUSDT",
|
|
27411
|
+
// "unRealizedProfit": "0.00000000",
|
|
27412
|
+
// "positionSide": "BOTH",
|
|
27413
|
+
// "updateTime": 0
|
|
27414
|
+
// }
|
|
27415
|
+
// ]
|
|
27416
|
+
//
|
|
27417
|
+
// For Hedge position mode:
|
|
27418
|
+
//
|
|
27419
|
+
// [
|
|
27420
|
+
// {
|
|
27421
|
+
// "entryPrice": "6563.66500",
|
|
27422
|
+
// "marginType": "isolated",
|
|
27423
|
+
// "isAutoAddMargin": "false",
|
|
27424
|
+
// "isolatedMargin": "15517.54150468",
|
|
27425
|
+
// "leverage": "10",
|
|
27426
|
+
// "liquidationPrice": "5930.78",
|
|
27427
|
+
// "markPrice": "6679.50671178",
|
|
27428
|
+
// "maxNotionalValue": "20000000",
|
|
27429
|
+
// "positionAmt": "20.000",
|
|
27430
|
+
// "symbol": "BTCUSDT",
|
|
27431
|
+
// "unRealizedProfit": "2316.83423560"
|
|
27432
|
+
// "positionSide": "LONG",
|
|
27433
|
+
// "updateTime": 1625474304765
|
|
27434
|
+
// },
|
|
27435
|
+
// {
|
|
27436
|
+
// "entryPrice": "0.00000",
|
|
27437
|
+
// "marginType": "isolated",
|
|
27438
|
+
// "isAutoAddMargin": "false",
|
|
27439
|
+
// "isolatedMargin": "5413.95799991",
|
|
27440
|
+
// "leverage": "10",
|
|
27441
|
+
// "liquidationPrice": "7189.95",
|
|
27442
|
+
// "markPrice": "6679.50671178",
|
|
27443
|
+
// "maxNotionalValue": "20000000",
|
|
27444
|
+
// "positionAmt": "-10.000",
|
|
27445
|
+
// "symbol": "BTCUSDT",
|
|
27446
|
+
// "unRealizedProfit": "-1156.46711780",
|
|
27447
|
+
// "positionSide": "SHORT",
|
|
27448
|
+
// "updateTime": 0
|
|
27449
|
+
// }
|
|
27450
|
+
// ]
|
|
27451
|
+
//
|
|
27452
|
+
// inverse portfolio margin:
|
|
27453
|
+
//
|
|
27454
|
+
// [
|
|
27455
|
+
// {
|
|
27456
|
+
// "symbol": "ETHUSD_PERP",
|
|
27457
|
+
// "positionAmt": "1",
|
|
27458
|
+
// "entryPrice": "2422.400000007",
|
|
27459
|
+
// "markPrice": "2424.51267823",
|
|
27460
|
+
// "unRealizedProfit": "0.0000036",
|
|
27461
|
+
// "liquidationPrice": "293.57678898",
|
|
27462
|
+
// "leverage": "100",
|
|
27463
|
+
// "positionSide": "LONG",
|
|
27464
|
+
// "updateTime": 1707371941861,
|
|
27465
|
+
// "maxQty": "15",
|
|
27466
|
+
// "notionalValue": "0.00412454",
|
|
27467
|
+
// "breakEvenPrice": "2423.368960034"
|
|
27468
|
+
// }
|
|
27469
|
+
// ]
|
|
27470
|
+
//
|
|
27471
|
+
// linear portfolio margin:
|
|
27472
|
+
//
|
|
27473
|
+
// [
|
|
27474
|
+
// {
|
|
27475
|
+
// "symbol": "BTCUSDT",
|
|
27476
|
+
// "positionAmt": "0.01",
|
|
27477
|
+
// "entryPrice": "44525.0",
|
|
27478
|
+
// "markPrice": "45464.1735922",
|
|
27479
|
+
// "unRealizedProfit": "9.39173592",
|
|
27480
|
+
// "liquidationPrice": "38007.16308568",
|
|
27481
|
+
// "leverage": "100",
|
|
27482
|
+
// "positionSide": "LONG",
|
|
27483
|
+
// "updateTime": 1707371879042,
|
|
27484
|
+
// "maxNotionalValue": "500000.0",
|
|
27485
|
+
// "notional": "454.64173592",
|
|
27486
|
+
// "breakEvenPrice": "44542.81"
|
|
27487
|
+
// }
|
|
27488
|
+
// ]
|
|
27489
|
+
//
|
|
27176
27490
|
const result = [];
|
|
27177
27491
|
for (let i = 0; i < response.length; i++) {
|
|
27178
27492
|
const parsed = this.parsePositionRisk(response[i]);
|
|
@@ -27188,15 +27502,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27188
27502
|
* @description fetch the history of funding payments paid and received on this account
|
|
27189
27503
|
* @see https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data
|
|
27190
27504
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data
|
|
27505
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-income-history-user_data
|
|
27506
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-income-history-user_data
|
|
27191
27507
|
* @param {string} symbol unified market symbol
|
|
27192
27508
|
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
27193
27509
|
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
|
27194
27510
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
27511
|
+
* @param {int} [params.until] timestamp in ms of the latest funding history entry
|
|
27512
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the funding history for a portfolio margin account
|
|
27195
27513
|
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
|
27196
27514
|
*/
|
|
27197
27515
|
await this.loadMarkets();
|
|
27198
27516
|
let market = undefined;
|
|
27199
|
-
|
|
27517
|
+
let request = {
|
|
27200
27518
|
'incomeType': 'FUNDING_FEE', // "TRANSFER","WELCOME_BONUS", "REALIZED_PNL","FUNDING_FEE", "COMMISSION" and "INSURANCE_CLEAR"
|
|
27201
27519
|
};
|
|
27202
27520
|
if (symbol !== undefined) {
|
|
@@ -27208,6 +27526,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27208
27526
|
}
|
|
27209
27527
|
let subType = undefined;
|
|
27210
27528
|
[subType, params] = this.handleSubTypeAndParams('fetchFundingHistory', market, params, 'linear');
|
|
27529
|
+
let isPortfolioMargin = undefined;
|
|
27530
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchFundingHistory', 'papi', 'portfolioMargin', false);
|
|
27531
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
27211
27532
|
if (since !== undefined) {
|
|
27212
27533
|
request['startTime'] = since;
|
|
27213
27534
|
}
|
|
@@ -27219,10 +27540,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27219
27540
|
params = this.omit(params, 'type');
|
|
27220
27541
|
let response = undefined;
|
|
27221
27542
|
if (this.isLinear(type, subType)) {
|
|
27222
|
-
|
|
27543
|
+
if (isPortfolioMargin) {
|
|
27544
|
+
response = await this.papiGetUmIncome(this.extend(request, params));
|
|
27545
|
+
}
|
|
27546
|
+
else {
|
|
27547
|
+
response = await this.fapiPrivateGetIncome(this.extend(request, params));
|
|
27548
|
+
}
|
|
27223
27549
|
}
|
|
27224
27550
|
else if (this.isInverse(type, subType)) {
|
|
27225
|
-
|
|
27551
|
+
if (isPortfolioMargin) {
|
|
27552
|
+
response = await this.papiGetCmIncome(this.extend(request, params));
|
|
27553
|
+
}
|
|
27554
|
+
else {
|
|
27555
|
+
response = await this.dapiPrivateGetIncome(this.extend(request, params));
|
|
27556
|
+
}
|
|
27226
27557
|
}
|
|
27227
27558
|
else {
|
|
27228
27559
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingHistory() supports linear and inverse contracts only');
|
|
@@ -27597,12 +27928,15 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27597
27928
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#account-funding-flow-user_data
|
|
27598
27929
|
* @see https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data
|
|
27599
27930
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data
|
|
27931
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-income-history-user_data
|
|
27932
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-income-history-user_data
|
|
27600
27933
|
* @param {string} code unified currency code
|
|
27601
27934
|
* @param {int} [since] timestamp in ms of the earliest ledger entry
|
|
27602
27935
|
* @param {int} [limit] max number of ledger entrys to return
|
|
27603
27936
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
27604
27937
|
* @param {int} [params.until] timestamp in ms of the latest ledger entry
|
|
27605
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
27938
|
+
* @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)
|
|
27939
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the ledger for a portfolio margin account
|
|
27606
27940
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
27607
27941
|
*/
|
|
27608
27942
|
await this.loadMarkets();
|
|
@@ -27631,6 +27965,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27631
27965
|
params = this.omit(params, 'until');
|
|
27632
27966
|
request['endTime'] = until;
|
|
27633
27967
|
}
|
|
27968
|
+
let isPortfolioMargin = undefined;
|
|
27969
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLedger', 'papi', 'portfolioMargin', false);
|
|
27634
27970
|
let response = undefined;
|
|
27635
27971
|
if (type === 'option') {
|
|
27636
27972
|
this.checkRequiredArgument('fetchLedger', code, 'code');
|
|
@@ -27638,10 +27974,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27638
27974
|
response = await this.eapiPrivateGetBill(this.extend(request, params));
|
|
27639
27975
|
}
|
|
27640
27976
|
else if (this.isLinear(type, subType)) {
|
|
27641
|
-
|
|
27977
|
+
if (isPortfolioMargin) {
|
|
27978
|
+
response = await this.papiGetUmIncome(this.extend(request, params));
|
|
27979
|
+
}
|
|
27980
|
+
else {
|
|
27981
|
+
response = await this.fapiPrivateGetIncome(this.extend(request, params));
|
|
27982
|
+
}
|
|
27642
27983
|
}
|
|
27643
27984
|
else if (this.isInverse(type, subType)) {
|
|
27644
|
-
|
|
27985
|
+
if (isPortfolioMargin) {
|
|
27986
|
+
response = await this.papiGetCmIncome(this.extend(request, params));
|
|
27987
|
+
}
|
|
27988
|
+
else {
|
|
27989
|
+
response = await this.dapiPrivateGetIncome(this.extend(request, params));
|
|
27990
|
+
}
|
|
27645
27991
|
}
|
|
27646
27992
|
else {
|
|
27647
27993
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLedger() supports contract wallets only');
|
|
@@ -27659,7 +28005,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27659
28005
|
// }
|
|
27660
28006
|
// ]
|
|
27661
28007
|
//
|
|
27662
|
-
// futures (fapi, dapi)
|
|
28008
|
+
// futures (fapi, dapi, papi)
|
|
27663
28009
|
//
|
|
27664
28010
|
// [
|
|
27665
28011
|
// {
|
|
@@ -27688,7 +28034,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27688
28034
|
// "createDate": 1676621042489
|
|
27689
28035
|
// }
|
|
27690
28036
|
//
|
|
27691
|
-
// futures (fapi, dapi)
|
|
28037
|
+
// futures (fapi, dapi, papi)
|
|
27692
28038
|
//
|
|
27693
28039
|
// {
|
|
27694
28040
|
// "symbol": "",
|
|
@@ -27797,7 +28143,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27797
28143
|
const isSpotOrMargin = (api.indexOf('sapi') > -1 || api === 'private');
|
|
27798
28144
|
const marketType = isSpotOrMargin ? 'spot' : 'future';
|
|
27799
28145
|
const defaultId = (!isSpotOrMargin) ? 'x-xcKtGhcu' : 'x-R4BD3S82';
|
|
27800
|
-
const broker = this.
|
|
28146
|
+
const broker = this.safeDict(this.options, 'broker', {});
|
|
27801
28147
|
const brokerId = this.safeString(broker, marketType, defaultId);
|
|
27802
28148
|
params['newClientOrderId'] = brokerId + this.uuid22();
|
|
27803
28149
|
}
|
|
@@ -27825,8 +28171,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27825
28171
|
}
|
|
27826
28172
|
else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path.indexOf('staking') >= 0)) {
|
|
27827
28173
|
if ((method === 'DELETE') && (path === 'batchOrders')) {
|
|
27828
|
-
const orderidlist = this.
|
|
27829
|
-
const origclientorderidlist = this.
|
|
28174
|
+
const orderidlist = this.safeList(extendedParams, 'orderidlist', []);
|
|
28175
|
+
const origclientorderidlist = this.safeList(extendedParams, 'origclientorderidlist', []);
|
|
27830
28176
|
extendedParams = this.omit(extendedParams, ['orderidlist', 'origclientorderidlist']);
|
|
27831
28177
|
query = this.rawencode(extendedParams);
|
|
27832
28178
|
const orderidlistLength = orderidlist.length;
|
|
@@ -27895,8 +28241,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
27895
28241
|
marketType = 'portfoliomargin';
|
|
27896
28242
|
}
|
|
27897
28243
|
if (marketType !== undefined) {
|
|
27898
|
-
const exceptionsForMarketType = this.
|
|
27899
|
-
return this.
|
|
28244
|
+
const exceptionsForMarketType = this.safeDict(this.exceptions, marketType, {});
|
|
28245
|
+
return this.safeDict(exceptionsForMarketType, exactOrBroad, {});
|
|
27900
28246
|
}
|
|
27901
28247
|
return {};
|
|
27902
28248
|
}
|
|
@@ -28130,7 +28476,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28130
28476
|
// },
|
|
28131
28477
|
// ]
|
|
28132
28478
|
//
|
|
28133
|
-
const rate = this.
|
|
28479
|
+
const rate = this.safeDict(response, 0);
|
|
28134
28480
|
return this.parseBorrowRate(rate);
|
|
28135
28481
|
}
|
|
28136
28482
|
async fetchBorrowRateHistory(code, since = undefined, limit = undefined, params = {}) {
|
|
@@ -28234,7 +28580,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28234
28580
|
// "success": true
|
|
28235
28581
|
// }
|
|
28236
28582
|
//
|
|
28237
|
-
const data = this.
|
|
28583
|
+
const data = this.safeDict(response, 'data');
|
|
28238
28584
|
const giftcardCode = this.safeString(data, 'code');
|
|
28239
28585
|
const id = this.safeString(data, 'referenceNo');
|
|
28240
28586
|
return {
|
|
@@ -28302,15 +28648,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28302
28648
|
* @name binance#fetchBorrowInterest
|
|
28303
28649
|
* @description fetch the interest owed by the user for borrowing currency for margin trading
|
|
28304
28650
|
* @see https://binance-docs.github.io/apidocs/spot/en/#get-interest-history-user_data
|
|
28305
|
-
* @
|
|
28306
|
-
* @param {string}
|
|
28651
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-margin-borrow-loan-interest-history-user_data
|
|
28652
|
+
* @param {string} [code] unified currency code
|
|
28653
|
+
* @param {string} [symbol] unified market symbol when fetch interest in isolated markets
|
|
28307
28654
|
* @param {int} [since] the earliest time in ms to fetch borrrow interest for
|
|
28308
28655
|
* @param {int} [limit] the maximum number of structures to retrieve
|
|
28309
28656
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
28657
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the borrow interest in a portfolio margin account
|
|
28310
28658
|
* @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
|
|
28311
28659
|
*/
|
|
28312
28660
|
await this.loadMarkets();
|
|
28313
|
-
|
|
28661
|
+
let isPortfolioMargin = undefined;
|
|
28662
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchBorrowInterest', 'papi', 'portfolioMargin', false);
|
|
28663
|
+
let request = {};
|
|
28314
28664
|
let market = undefined;
|
|
28315
28665
|
if (code !== undefined) {
|
|
28316
28666
|
const currency = this.currency(code);
|
|
@@ -28322,11 +28672,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28322
28672
|
if (limit !== undefined) {
|
|
28323
28673
|
request['size'] = limit;
|
|
28324
28674
|
}
|
|
28325
|
-
|
|
28326
|
-
|
|
28327
|
-
|
|
28675
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
28676
|
+
let response = undefined;
|
|
28677
|
+
if (isPortfolioMargin) {
|
|
28678
|
+
response = await this.papiGetMarginMarginInterestHistory(this.extend(request, params));
|
|
28679
|
+
}
|
|
28680
|
+
else {
|
|
28681
|
+
if (symbol !== undefined) {
|
|
28682
|
+
market = this.market(symbol);
|
|
28683
|
+
request['isolatedSymbol'] = market['id'];
|
|
28684
|
+
}
|
|
28685
|
+
response = await this.sapiGetMarginInterestHistory(this.extend(request, params));
|
|
28328
28686
|
}
|
|
28329
|
-
|
|
28687
|
+
//
|
|
28688
|
+
// spot margin
|
|
28330
28689
|
//
|
|
28331
28690
|
// {
|
|
28332
28691
|
// "rows":[
|
|
@@ -28343,13 +28702,31 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28343
28702
|
// "total": 1
|
|
28344
28703
|
// }
|
|
28345
28704
|
//
|
|
28346
|
-
|
|
28705
|
+
// spot margin portfolio margin
|
|
28706
|
+
//
|
|
28707
|
+
// {
|
|
28708
|
+
// "total": 49,
|
|
28709
|
+
// "rows": [
|
|
28710
|
+
// {
|
|
28711
|
+
// "txId": 1656187724899910076,
|
|
28712
|
+
// "interestAccuredTime": 1707541200000,
|
|
28713
|
+
// "asset": "USDT",
|
|
28714
|
+
// "rawAsset": "USDT",
|
|
28715
|
+
// "principal": "0.00011146",
|
|
28716
|
+
// "interest": "0.00000001",
|
|
28717
|
+
// "interestRate": "0.00089489",
|
|
28718
|
+
// "type": "PERIODIC"
|
|
28719
|
+
// },
|
|
28720
|
+
// ]
|
|
28721
|
+
// }
|
|
28722
|
+
//
|
|
28723
|
+
const rows = this.safeList(response, 'rows');
|
|
28347
28724
|
const interest = this.parseBorrowInterests(rows, market);
|
|
28348
28725
|
return this.filterByCurrencySinceLimit(interest, code, since, limit);
|
|
28349
28726
|
}
|
|
28350
28727
|
parseBorrowInterest(info, market = undefined) {
|
|
28351
28728
|
const symbol = this.safeString(info, 'isolatedSymbol');
|
|
28352
|
-
const timestamp = this.
|
|
28729
|
+
const timestamp = this.safeInteger(info, 'interestAccuredTime');
|
|
28353
28730
|
const marginMode = (symbol === undefined) ? 'cross' : 'isolated';
|
|
28354
28731
|
return {
|
|
28355
28732
|
'account': (symbol === undefined) ? 'cross' : symbol,
|
|
@@ -28370,9 +28747,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28370
28747
|
* @name binance#repayCrossMargin
|
|
28371
28748
|
* @description repay borrowed margin and interest
|
|
28372
28749
|
* @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-repay-margin
|
|
28750
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#margin-account-repay-margin
|
|
28373
28751
|
* @param {string} code unified currency code of the currency to repay
|
|
28374
28752
|
* @param {float} amount the amount to repay
|
|
28375
28753
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
28754
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to repay margin in a portfolio margin account
|
|
28376
28755
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
28377
28756
|
*/
|
|
28378
28757
|
await this.loadMarkets();
|
|
@@ -28380,10 +28759,18 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28380
28759
|
const request = {
|
|
28381
28760
|
'asset': currency['id'],
|
|
28382
28761
|
'amount': this.currencyToPrecision(code, amount),
|
|
28383
|
-
'isIsolated': 'FALSE',
|
|
28384
|
-
'type': 'REPAY',
|
|
28385
28762
|
};
|
|
28386
|
-
|
|
28763
|
+
let response = undefined;
|
|
28764
|
+
let isPortfolioMargin = undefined;
|
|
28765
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'repayCrossMargin', 'papi', 'portfolioMargin', false);
|
|
28766
|
+
if (isPortfolioMargin) {
|
|
28767
|
+
response = await this.papiPostRepayLoan(this.extend(request, params));
|
|
28768
|
+
}
|
|
28769
|
+
else {
|
|
28770
|
+
request['isIsolated'] = 'FALSE';
|
|
28771
|
+
request['type'] = 'REPAY';
|
|
28772
|
+
response = await this.sapiPostMarginBorrowRepay(this.extend(request, params));
|
|
28773
|
+
}
|
|
28387
28774
|
//
|
|
28388
28775
|
// {
|
|
28389
28776
|
// "tranId": 108988250265,
|
|
@@ -28429,9 +28816,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28429
28816
|
* @name binance#borrowCrossMargin
|
|
28430
28817
|
* @description create a loan to borrow margin
|
|
28431
28818
|
* @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-repay-margin
|
|
28819
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#margin-account-borrow-margin
|
|
28432
28820
|
* @param {string} code unified currency code of the currency to borrow
|
|
28433
28821
|
* @param {float} amount the amount to borrow
|
|
28434
28822
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
28823
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to borrow margin in a portfolio margin account
|
|
28435
28824
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
28436
28825
|
*/
|
|
28437
28826
|
await this.loadMarkets();
|
|
@@ -28439,10 +28828,18 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28439
28828
|
const request = {
|
|
28440
28829
|
'asset': currency['id'],
|
|
28441
28830
|
'amount': this.currencyToPrecision(code, amount),
|
|
28442
|
-
'isIsolated': 'FALSE',
|
|
28443
|
-
'type': 'BORROW',
|
|
28444
28831
|
};
|
|
28445
|
-
|
|
28832
|
+
let response = undefined;
|
|
28833
|
+
let isPortfolioMargin = undefined;
|
|
28834
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'borrowCrossMargin', 'papi', 'portfolioMargin', false);
|
|
28835
|
+
if (isPortfolioMargin) {
|
|
28836
|
+
response = await this.papiPostMarginLoan(this.extend(request, params));
|
|
28837
|
+
}
|
|
28838
|
+
else {
|
|
28839
|
+
request['isIsolated'] = 'FALSE';
|
|
28840
|
+
request['type'] = 'BORROW';
|
|
28841
|
+
response = await this.sapiPostMarginBorrowRepay(this.extend(request, params));
|
|
28842
|
+
}
|
|
28446
28843
|
//
|
|
28447
28844
|
// {
|
|
28448
28845
|
// "tranId": 108988250265,
|
|
@@ -29454,6 +29851,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
29454
29851
|
'trade/order': 3,
|
|
29455
29852
|
'trade/cancel': 3,
|
|
29456
29853
|
'trade/batchOrders': 3,
|
|
29854
|
+
'trade/order/cancelReplace': 3,
|
|
29457
29855
|
'trade/cancelOrders': 3,
|
|
29458
29856
|
'trade/cancelOpenOrders': 3,
|
|
29459
29857
|
},
|
|
@@ -29475,12 +29873,19 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
29475
29873
|
},
|
|
29476
29874
|
'swap': {
|
|
29477
29875
|
'v1': {
|
|
29876
|
+
'public': {
|
|
29877
|
+
'get': {
|
|
29878
|
+
'ticker/price': 1,
|
|
29879
|
+
},
|
|
29880
|
+
},
|
|
29478
29881
|
'private': {
|
|
29479
29882
|
'get': {
|
|
29480
29883
|
'positionSide/dual': 1,
|
|
29481
29884
|
'market/markPriceKlines': 1,
|
|
29885
|
+
'trade/batchCancelReplace': 1,
|
|
29482
29886
|
},
|
|
29483
29887
|
'post': {
|
|
29888
|
+
'trade/cancelReplace': 1,
|
|
29484
29889
|
'positionSide/dual': 1,
|
|
29485
29890
|
},
|
|
29486
29891
|
},
|
|
@@ -31103,6 +31508,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31103
31508
|
if (timeInForce === 'IOC') {
|
|
31104
31509
|
request['timeInForce'] = 'IOC';
|
|
31105
31510
|
}
|
|
31511
|
+
const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
31106
31512
|
if (isSpot) {
|
|
31107
31513
|
[postOnly, params] = this.handlePostOnly(isMarketOrder, timeInForce === 'POC', params);
|
|
31108
31514
|
if (postOnly || (timeInForce === 'POC')) {
|
|
@@ -31114,7 +31520,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31114
31520
|
request['quoteOrderQty'] = this.parseToNumeric(this.costToPrecision(symbol, cost));
|
|
31115
31521
|
}
|
|
31116
31522
|
else {
|
|
31117
|
-
if (
|
|
31523
|
+
if (isMarketOrder && (price !== undefined)) {
|
|
31118
31524
|
// keep the legacy behavior, to avoid breaking the old spot-market-buying code
|
|
31119
31525
|
const calculatedCost = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(this.numberToString(amount), this.numberToString(price));
|
|
31120
31526
|
request['quoteOrderQty'] = this.parseToNumeric(calculatedCost);
|
|
@@ -31126,6 +31532,18 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31126
31532
|
if (!isMarketOrder) {
|
|
31127
31533
|
request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
|
|
31128
31534
|
}
|
|
31535
|
+
if (triggerPrice !== undefined) {
|
|
31536
|
+
if (isMarketOrder && this.safeString(request, 'quoteOrderQty') === undefined) {
|
|
31537
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' createOrder() requires the cost parameter (or the amount + price) for placing spot market-buy trigger orders');
|
|
31538
|
+
}
|
|
31539
|
+
request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
31540
|
+
if (type === 'LIMIT') {
|
|
31541
|
+
request['type'] = 'TRIGGER_LIMIT';
|
|
31542
|
+
}
|
|
31543
|
+
else if (type === 'MARKET') {
|
|
31544
|
+
request['type'] = 'TRIGGER_MARKET';
|
|
31545
|
+
}
|
|
31546
|
+
}
|
|
31129
31547
|
}
|
|
31130
31548
|
else {
|
|
31131
31549
|
[postOnly, params] = this.handlePostOnly(isMarketOrder, timeInForce === 'PostOnly', params);
|
|
@@ -31138,7 +31556,6 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31138
31556
|
else if (timeInForce === 'FOK') {
|
|
31139
31557
|
request['timeInForce'] = 'FOK';
|
|
31140
31558
|
}
|
|
31141
|
-
const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
31142
31559
|
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
31143
31560
|
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
31144
31561
|
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
@@ -31438,6 +31855,13 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31438
31855
|
};
|
|
31439
31856
|
return this.safeString(sides, side, side);
|
|
31440
31857
|
}
|
|
31858
|
+
parseOrderType(type) {
|
|
31859
|
+
const types = {
|
|
31860
|
+
'trigger_market': 'market',
|
|
31861
|
+
'trigger_limit': 'limit',
|
|
31862
|
+
};
|
|
31863
|
+
return this.safeString(types, type, type);
|
|
31864
|
+
}
|
|
31441
31865
|
parseOrder(order, market = undefined) {
|
|
31442
31866
|
//
|
|
31443
31867
|
// spot
|
|
@@ -31555,22 +31979,104 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31555
31979
|
// reduceOnly: false
|
|
31556
31980
|
// }
|
|
31557
31981
|
//
|
|
31982
|
+
// editOrder (swap)
|
|
31983
|
+
//
|
|
31984
|
+
// {
|
|
31985
|
+
// cancelResult: 'true',
|
|
31986
|
+
// cancelMsg: '',
|
|
31987
|
+
// cancelResponse: {
|
|
31988
|
+
// cancelClientOrderId: '',
|
|
31989
|
+
// cancelOrderId: '1755336244265705472',
|
|
31990
|
+
// symbol: 'SOL-USDT',
|
|
31991
|
+
// orderId: '1755336244265705472',
|
|
31992
|
+
// side: 'SELL',
|
|
31993
|
+
// positionSide: 'SHORT',
|
|
31994
|
+
// type: 'LIMIT',
|
|
31995
|
+
// origQty: '1',
|
|
31996
|
+
// price: '100.000',
|
|
31997
|
+
// executedQty: '0',
|
|
31998
|
+
// avgPrice: '0.000',
|
|
31999
|
+
// cumQuote: '0',
|
|
32000
|
+
// stopPrice: '',
|
|
32001
|
+
// profit: '0.0000',
|
|
32002
|
+
// commission: '0.000000',
|
|
32003
|
+
// status: 'PENDING',
|
|
32004
|
+
// time: '1707339747860',
|
|
32005
|
+
// updateTime: '1707339747860',
|
|
32006
|
+
// clientOrderId: '',
|
|
32007
|
+
// leverage: '20X',
|
|
32008
|
+
// workingType: 'MARK_PRICE',
|
|
32009
|
+
// onlyOnePosition: false,
|
|
32010
|
+
// reduceOnly: false
|
|
32011
|
+
// },
|
|
32012
|
+
// replaceResult: 'true',
|
|
32013
|
+
// replaceMsg: '',
|
|
32014
|
+
// newOrderResponse: {
|
|
32015
|
+
// orderId: '1755338440612995072',
|
|
32016
|
+
// symbol: 'SOL-USDT',
|
|
32017
|
+
// positionSide: 'SHORT',
|
|
32018
|
+
// side: 'SELL',
|
|
32019
|
+
// type: 'LIMIT',
|
|
32020
|
+
// price: '99',
|
|
32021
|
+
// quantity: '2',
|
|
32022
|
+
// stopPrice: '0',
|
|
32023
|
+
// workingType: 'MARK_PRICE',
|
|
32024
|
+
// clientOrderID: '',
|
|
32025
|
+
// timeInForce: 'GTC',
|
|
32026
|
+
// priceRate: '0',
|
|
32027
|
+
// stopLoss: '',
|
|
32028
|
+
// takeProfit: '',
|
|
32029
|
+
// reduceOnly: false
|
|
32030
|
+
// }
|
|
32031
|
+
// }
|
|
32032
|
+
//
|
|
32033
|
+
// editOrder (spot)
|
|
32034
|
+
//
|
|
32035
|
+
// {
|
|
32036
|
+
// cancelResult: { code: '0', msg: '', result: true },
|
|
32037
|
+
// openResult: { code: '0', msg: '', result: true },
|
|
32038
|
+
// orderOpenResponse: {
|
|
32039
|
+
// symbol: 'SOL-USDT',
|
|
32040
|
+
// orderId: '1755334007697866752',
|
|
32041
|
+
// transactTime: '1707339214620',
|
|
32042
|
+
// price: '99',
|
|
32043
|
+
// stopPrice: '0',
|
|
32044
|
+
// origQty: '0.2',
|
|
32045
|
+
// executedQty: '0',
|
|
32046
|
+
// cummulativeQuoteQty: '0',
|
|
32047
|
+
// status: 'PENDING',
|
|
32048
|
+
// type: 'LIMIT',
|
|
32049
|
+
// side: 'SELL',
|
|
32050
|
+
// clientOrderID: ''
|
|
32051
|
+
// },
|
|
32052
|
+
// orderCancelResponse: {
|
|
32053
|
+
// symbol: 'SOL-USDT',
|
|
32054
|
+
// orderId: '1755117055251480576',
|
|
32055
|
+
// price: '100',
|
|
32056
|
+
// stopPrice: '0',
|
|
32057
|
+
// origQty: '0.2',
|
|
32058
|
+
// executedQty: '0',
|
|
32059
|
+
// cummulativeQuoteQty: '0',
|
|
32060
|
+
// status: 'CANCELED',
|
|
32061
|
+
// type: 'LIMIT',
|
|
32062
|
+
// side: 'SELL'
|
|
32063
|
+
// }
|
|
32064
|
+
// }
|
|
32065
|
+
//
|
|
32066
|
+
const info = order;
|
|
32067
|
+
const newOrder = this.safeDict2(order, 'newOrderResponse', 'orderOpenResponse');
|
|
32068
|
+
if (newOrder !== undefined) {
|
|
32069
|
+
order = newOrder;
|
|
32070
|
+
}
|
|
31558
32071
|
const positionSide = this.safeString2(order, 'positionSide', 'ps');
|
|
31559
32072
|
const marketType = (positionSide === undefined) ? 'spot' : 'swap';
|
|
31560
32073
|
const marketId = this.safeString2(order, 'symbol', 's');
|
|
31561
32074
|
if (market === undefined) {
|
|
31562
32075
|
market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
31563
32076
|
}
|
|
31564
|
-
const symbol = this.safeSymbol(marketId, market, '-', marketType);
|
|
31565
|
-
const orderId = this.safeString2(order, 'orderId', 'i');
|
|
31566
32077
|
const side = this.safeStringLower2(order, 'side', 'S');
|
|
31567
|
-
const type = this.safeStringLower2(order, 'type', 'o');
|
|
31568
32078
|
const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E']);
|
|
31569
32079
|
const lastTradeTimestamp = this.safeInteger2(order, 'updateTime', 'T');
|
|
31570
|
-
const price = this.safeString2(order, 'price', 'p');
|
|
31571
|
-
const average = this.safeString2(order, 'avgPrice', 'ap');
|
|
31572
|
-
const amount = this.safeString2(order, 'origQty', 'q');
|
|
31573
|
-
const filled = this.safeString2(order, 'executedQty', 'z');
|
|
31574
32080
|
const statusId = this.safeString2(order, 'status', 'X');
|
|
31575
32081
|
let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
|
|
31576
32082
|
const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
|
|
@@ -31587,11 +32093,6 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31587
32093
|
feeCurrencyCode = market['quote'];
|
|
31588
32094
|
}
|
|
31589
32095
|
}
|
|
31590
|
-
const fee = {
|
|
31591
|
-
'currency': feeCurrencyCode,
|
|
31592
|
-
'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeCost),
|
|
31593
|
-
};
|
|
31594
|
-
const clientOrderId = this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']);
|
|
31595
32096
|
let stopLoss = this.safeValue(order, 'stopLoss');
|
|
31596
32097
|
let stopLossPrice = undefined;
|
|
31597
32098
|
if ((stopLoss !== undefined) && (stopLoss !== '')) {
|
|
@@ -31617,31 +32118,35 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31617
32118
|
takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
|
|
31618
32119
|
}
|
|
31619
32120
|
return this.safeOrder({
|
|
31620
|
-
'info':
|
|
31621
|
-
'id': orderId,
|
|
31622
|
-
'clientOrderId':
|
|
32121
|
+
'info': info,
|
|
32122
|
+
'id': this.safeString2(order, 'orderId', 'i'),
|
|
32123
|
+
'clientOrderId': this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']),
|
|
32124
|
+
'symbol': this.safeSymbol(marketId, market, '-', marketType),
|
|
31623
32125
|
'timestamp': timestamp,
|
|
31624
32126
|
'datetime': this.iso8601(timestamp),
|
|
31625
32127
|
'lastTradeTimestamp': lastTradeTimestamp,
|
|
31626
32128
|
'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
|
|
31627
|
-
'
|
|
31628
|
-
'
|
|
31629
|
-
'timeInForce': undefined,
|
|
32129
|
+
'type': this.parseOrderType(this.safeStringLower2(order, 'type', 'o')),
|
|
32130
|
+
'timeInForce': this.safeString(order, 'timeInForce'),
|
|
31630
32131
|
'postOnly': undefined,
|
|
31631
32132
|
'side': this.parseOrderSide(side),
|
|
31632
|
-
'price': price,
|
|
32133
|
+
'price': this.safeString2(order, 'price', 'p'),
|
|
31633
32134
|
'stopPrice': this.safeNumber(order, 'stopPrice'),
|
|
31634
32135
|
'triggerPrice': this.safeNumber(order, 'stopPrice'),
|
|
31635
32136
|
'stopLossPrice': stopLossPrice,
|
|
31636
32137
|
'takeProfitPrice': takeProfitPrice,
|
|
31637
|
-
'average':
|
|
32138
|
+
'average': this.safeString2(order, 'avgPrice', 'ap'),
|
|
31638
32139
|
'cost': undefined,
|
|
31639
|
-
'amount':
|
|
31640
|
-
'filled':
|
|
32140
|
+
'amount': this.safeStringN(order, ['origQty', 'q', 'quantity']),
|
|
32141
|
+
'filled': this.safeString2(order, 'executedQty', 'z'),
|
|
31641
32142
|
'remaining': undefined,
|
|
31642
32143
|
'status': this.parseOrderStatus(statusId),
|
|
31643
|
-
'fee':
|
|
32144
|
+
'fee': {
|
|
32145
|
+
'currency': feeCurrencyCode,
|
|
32146
|
+
'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeCost),
|
|
32147
|
+
},
|
|
31644
32148
|
'trades': undefined,
|
|
32149
|
+
'reduceOnly': this.safeBool(order, 'reduceOnly'),
|
|
31645
32150
|
}, market);
|
|
31646
32151
|
}
|
|
31647
32152
|
parseOrderStatus(status) {
|
|
@@ -33150,6 +33655,144 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
33150
33655
|
//
|
|
33151
33656
|
return await this.swapV1PrivatePostPositionSideDual(this.extend(request, params));
|
|
33152
33657
|
}
|
|
33658
|
+
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
33659
|
+
/**
|
|
33660
|
+
* @method
|
|
33661
|
+
* @name bingx#editOrder
|
|
33662
|
+
* @description cancels an order and places a new order
|
|
33663
|
+
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20order%20and%20place%20a%20new%20order // spot
|
|
33664
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20an%20order%20and%20then%20Place%20a%20new%20order // swap
|
|
33665
|
+
* @param {string} id order id
|
|
33666
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
33667
|
+
* @param {string} type 'market' or 'limit'
|
|
33668
|
+
* @param {string} side 'buy' or 'sell'
|
|
33669
|
+
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
33670
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
33671
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
33672
|
+
* @param {string} [params.stopPrice] Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
|
|
33673
|
+
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
|
|
33674
|
+
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
33675
|
+
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
|
|
33676
|
+
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
33677
|
+
*
|
|
33678
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
33679
|
+
* @param {string} [params.cancelClientOrderID] the user-defined id of the order to be canceled, 1-40 characters, different orders cannot use the same clientOrderID, only supports a query range of 2 hours
|
|
33680
|
+
* @param {string} [params.cancelRestrictions] cancel orders with specified status, NEW: New order, PENDING: Pending order, PARTIALLY_FILLED: Partially filled
|
|
33681
|
+
* @param {string} [params.cancelReplaceMode] STOP_ON_FAILURE - if the cancel order fails, it will not continue to place a new order, ALLOW_FAILURE - regardless of whether the cancel order succeeds or fails, it will continue to place a new order
|
|
33682
|
+
* @param {float} [params.quoteOrderQty] order amount
|
|
33683
|
+
* @param {string} [params.newClientOrderId] custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
|
|
33684
|
+
* @param {string} [params.positionSide] *contract only* position direction, required for single position as BOTH, for both long and short positions only LONG or SHORT can be chosen, defaults to LONG if empty
|
|
33685
|
+
* @param {string} [params.reduceOnly] *contract only* true or false, default=false for single position mode. this parameter is not accepted for both long and short positions mode
|
|
33686
|
+
* @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market, Max = 1
|
|
33687
|
+
* @param {string} [params.workingType] *contract only* StopPrice trigger price types, MARK_PRICE (default), CONTRACT_PRICE, or INDEX_PRICE
|
|
33688
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
33689
|
+
*/
|
|
33690
|
+
await this.loadMarkets();
|
|
33691
|
+
const market = this.market(symbol);
|
|
33692
|
+
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
33693
|
+
request['cancelOrderId'] = id;
|
|
33694
|
+
request['cancelReplaceMode'] = 'STOP_ON_FAILURE';
|
|
33695
|
+
let response = undefined;
|
|
33696
|
+
if (market['swap']) {
|
|
33697
|
+
response = await this.swapV1PrivatePostTradeCancelReplace(this.extend(request, params));
|
|
33698
|
+
//
|
|
33699
|
+
// {
|
|
33700
|
+
// code: '0',
|
|
33701
|
+
// msg: '',
|
|
33702
|
+
// data: {
|
|
33703
|
+
// cancelResult: 'true',
|
|
33704
|
+
// cancelMsg: '',
|
|
33705
|
+
// cancelResponse: {
|
|
33706
|
+
// cancelClientOrderId: '',
|
|
33707
|
+
// cancelOrderId: '1755336244265705472',
|
|
33708
|
+
// symbol: 'SOL-USDT',
|
|
33709
|
+
// orderId: '1755336244265705472',
|
|
33710
|
+
// side: 'SELL',
|
|
33711
|
+
// positionSide: 'SHORT',
|
|
33712
|
+
// type: 'LIMIT',
|
|
33713
|
+
// origQty: '1',
|
|
33714
|
+
// price: '100.000',
|
|
33715
|
+
// executedQty: '0',
|
|
33716
|
+
// avgPrice: '0.000',
|
|
33717
|
+
// cumQuote: '0',
|
|
33718
|
+
// stopPrice: '',
|
|
33719
|
+
// profit: '0.0000',
|
|
33720
|
+
// commission: '0.000000',
|
|
33721
|
+
// status: 'PENDING',
|
|
33722
|
+
// time: '1707339747860',
|
|
33723
|
+
// updateTime: '1707339747860',
|
|
33724
|
+
// clientOrderId: '',
|
|
33725
|
+
// leverage: '20X',
|
|
33726
|
+
// workingType: 'MARK_PRICE',
|
|
33727
|
+
// onlyOnePosition: false,
|
|
33728
|
+
// reduceOnly: false
|
|
33729
|
+
// },
|
|
33730
|
+
// replaceResult: 'true',
|
|
33731
|
+
// replaceMsg: '',
|
|
33732
|
+
// newOrderResponse: {
|
|
33733
|
+
// orderId: '1755338440612995072',
|
|
33734
|
+
// symbol: 'SOL-USDT',
|
|
33735
|
+
// positionSide: 'SHORT',
|
|
33736
|
+
// side: 'SELL',
|
|
33737
|
+
// type: 'LIMIT',
|
|
33738
|
+
// price: '99',
|
|
33739
|
+
// quantity: '2',
|
|
33740
|
+
// stopPrice: '0',
|
|
33741
|
+
// workingType: 'MARK_PRICE',
|
|
33742
|
+
// clientOrderID: '',
|
|
33743
|
+
// timeInForce: 'GTC',
|
|
33744
|
+
// priceRate: '0',
|
|
33745
|
+
// stopLoss: '',
|
|
33746
|
+
// takeProfit: '',
|
|
33747
|
+
// reduceOnly: false
|
|
33748
|
+
// }
|
|
33749
|
+
// }
|
|
33750
|
+
// }
|
|
33751
|
+
//
|
|
33752
|
+
}
|
|
33753
|
+
else {
|
|
33754
|
+
response = await this.spotV1PrivatePostTradeOrderCancelReplace(this.extend(request, params));
|
|
33755
|
+
//
|
|
33756
|
+
// {
|
|
33757
|
+
// code: '0',
|
|
33758
|
+
// msg: '',
|
|
33759
|
+
// debugMsg: '',
|
|
33760
|
+
// data: {
|
|
33761
|
+
// cancelResult: { code: '0', msg: '', result: true },
|
|
33762
|
+
// openResult: { code: '0', msg: '', result: true },
|
|
33763
|
+
// orderOpenResponse: {
|
|
33764
|
+
// symbol: 'SOL-USDT',
|
|
33765
|
+
// orderId: '1755334007697866752',
|
|
33766
|
+
// transactTime: '1707339214620',
|
|
33767
|
+
// price: '99',
|
|
33768
|
+
// stopPrice: '0',
|
|
33769
|
+
// origQty: '0.2',
|
|
33770
|
+
// executedQty: '0',
|
|
33771
|
+
// cummulativeQuoteQty: '0',
|
|
33772
|
+
// status: 'PENDING',
|
|
33773
|
+
// type: 'LIMIT',
|
|
33774
|
+
// side: 'SELL',
|
|
33775
|
+
// clientOrderID: ''
|
|
33776
|
+
// },
|
|
33777
|
+
// orderCancelResponse: {
|
|
33778
|
+
// symbol: 'SOL-USDT',
|
|
33779
|
+
// orderId: '1755117055251480576',
|
|
33780
|
+
// price: '100',
|
|
33781
|
+
// stopPrice: '0',
|
|
33782
|
+
// origQty: '0.2',
|
|
33783
|
+
// executedQty: '0',
|
|
33784
|
+
// cummulativeQuoteQty: '0',
|
|
33785
|
+
// status: 'CANCELED',
|
|
33786
|
+
// type: 'LIMIT',
|
|
33787
|
+
// side: 'SELL'
|
|
33788
|
+
// }
|
|
33789
|
+
// }
|
|
33790
|
+
// }
|
|
33791
|
+
//
|
|
33792
|
+
}
|
|
33793
|
+
const data = this.safeDict(response, 'data');
|
|
33794
|
+
return this.parseOrder(data, market);
|
|
33795
|
+
}
|
|
33153
33796
|
sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
33154
33797
|
const type = section[0];
|
|
33155
33798
|
const version = section[1];
|
|
@@ -43566,8 +44209,8 @@ class bitforex extends _abstract_bitforex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
43566
44209
|
}
|
|
43567
44210
|
parseOrder(order, market = undefined) {
|
|
43568
44211
|
const id = this.safeString(order, 'orderId');
|
|
43569
|
-
const timestamp = this.
|
|
43570
|
-
const lastTradeTimestamp = this.
|
|
44212
|
+
const timestamp = this.safeInteger(order, 'createTime');
|
|
44213
|
+
const lastTradeTimestamp = this.safeInteger(order, 'lastTime');
|
|
43571
44214
|
const symbol = market['symbol'];
|
|
43572
44215
|
const sideId = this.safeInteger(order, 'tradeType');
|
|
43573
44216
|
const side = this.parseSide(sideId);
|
|
@@ -47767,6 +48410,13 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
47767
48410
|
size = this.safeString(order, 'size');
|
|
47768
48411
|
filled = this.safeString(order, 'baseVolume');
|
|
47769
48412
|
}
|
|
48413
|
+
let side = this.safeString(order, 'side');
|
|
48414
|
+
const posMode = this.safeString(order, 'posMode');
|
|
48415
|
+
if (posMode === 'hedge_mode' && reduceOnly) {
|
|
48416
|
+
side = (side === 'buy') ? 'sell' : 'buy';
|
|
48417
|
+
// on bitget hedge mode if the position is long the side is always buy, and if the position is short the side is always sell
|
|
48418
|
+
// so the side of the reduceOnly order is inversed
|
|
48419
|
+
}
|
|
47770
48420
|
return this.safeOrder({
|
|
47771
48421
|
'info': order,
|
|
47772
48422
|
'id': this.safeString2(order, 'orderId', 'data'),
|
|
@@ -47777,7 +48427,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
47777
48427
|
'lastUpdateTimestamp': updateTimestamp,
|
|
47778
48428
|
'symbol': market['symbol'],
|
|
47779
48429
|
'type': this.safeString(order, 'orderType'),
|
|
47780
|
-
'side':
|
|
48430
|
+
'side': side,
|
|
47781
48431
|
'price': price,
|
|
47782
48432
|
'amount': size,
|
|
47783
48433
|
'cost': this.safeString2(order, 'quoteVolume', 'quoteSize'),
|
|
@@ -52104,7 +52754,11 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
52104
52754
|
}
|
|
52105
52755
|
else {
|
|
52106
52756
|
if (Object.keys(params).length) {
|
|
52107
|
-
|
|
52757
|
+
let queryInner = '?' + this.urlencode(this.keysort(params));
|
|
52758
|
+
// check #21169 pr
|
|
52759
|
+
if (queryInner.indexOf('%24') > -1) {
|
|
52760
|
+
queryInner = queryInner.replace('%24', '$');
|
|
52761
|
+
}
|
|
52108
52762
|
url += queryInner;
|
|
52109
52763
|
auth += queryInner;
|
|
52110
52764
|
}
|
|
@@ -83774,6 +84428,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
83774
84428
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
83775
84429
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
83776
84430
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
84431
|
+
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
83777
84432
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
83778
84433
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
83779
84434
|
*/
|
|
@@ -83787,7 +84442,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
83787
84442
|
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
|
|
83788
84443
|
}
|
|
83789
84444
|
const market = this.market(symbol);
|
|
83790
|
-
|
|
84445
|
+
let request = {
|
|
83791
84446
|
'symbol': market['id'],
|
|
83792
84447
|
};
|
|
83793
84448
|
if (limit === undefined) {
|
|
@@ -83799,6 +84454,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
83799
84454
|
if (limit !== undefined) {
|
|
83800
84455
|
request['limit'] = limit; // max 1000, default 1000
|
|
83801
84456
|
}
|
|
84457
|
+
[request, params] = this.handleUntilOption('end', request, params);
|
|
83802
84458
|
request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
83803
84459
|
let response = undefined;
|
|
83804
84460
|
if (market['spot']) {
|
|
@@ -91370,11 +92026,12 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
91370
92026
|
// ]
|
|
91371
92027
|
// }
|
|
91372
92028
|
//
|
|
91373
|
-
const data = this.
|
|
91374
|
-
const pagination = this.
|
|
92029
|
+
const data = this.safeList(response, 'data', []);
|
|
92030
|
+
const pagination = this.safeDict(response, 'pagination', {});
|
|
91375
92031
|
const cursor = this.safeString(pagination, 'next_starting_after');
|
|
91376
|
-
const accounts = this.
|
|
91377
|
-
const
|
|
92032
|
+
const accounts = this.safeList(response, 'data', []);
|
|
92033
|
+
const length = accounts.length;
|
|
92034
|
+
const lastIndex = length - 1;
|
|
91378
92035
|
const last = this.safeValue(accounts, lastIndex);
|
|
91379
92036
|
if ((cursor !== undefined) && (cursor !== '')) {
|
|
91380
92037
|
last['next_starting_after'] = cursor;
|
|
@@ -91423,8 +92080,9 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
91423
92080
|
// "size": 9
|
|
91424
92081
|
// }
|
|
91425
92082
|
//
|
|
91426
|
-
const accounts = this.
|
|
91427
|
-
const
|
|
92083
|
+
const accounts = this.safeList(response, 'accounts', []);
|
|
92084
|
+
const length = accounts.length;
|
|
92085
|
+
const lastIndex = length - 1;
|
|
91428
92086
|
const last = this.safeValue(accounts, lastIndex);
|
|
91429
92087
|
const cursor = this.safeString(response, 'cursor');
|
|
91430
92088
|
if ((cursor !== undefined) && (cursor !== '')) {
|
|
@@ -94557,6 +95215,7 @@ class coinbasepro extends _abstract_coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/
|
|
|
94557
95215
|
'users/self/trailing-volume',
|
|
94558
95216
|
'withdrawals/fee-estimate',
|
|
94559
95217
|
'conversions/{conversion_id}',
|
|
95218
|
+
'conversions/fees',
|
|
94560
95219
|
],
|
|
94561
95220
|
'post': [
|
|
94562
95221
|
'conversions',
|
|
@@ -103648,13 +104307,15 @@ class coinlist extends _abstract_coinlist_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
103648
104307
|
}
|
|
103649
104308
|
takerFees = this.sortBy(takerFees, 1, true);
|
|
103650
104309
|
makerFees = this.sortBy(makerFees, 1, true);
|
|
103651
|
-
const firstTier = this.
|
|
103652
|
-
const exchangeFees = this.
|
|
103653
|
-
const exchangeFeesTrading = this.
|
|
103654
|
-
const exchangeFeesTradingTiers = this.
|
|
103655
|
-
const exchangeFeesTradingTiersTaker = this.
|
|
103656
|
-
const exchangeFeesTradingTiersMaker = this.
|
|
103657
|
-
|
|
104310
|
+
const firstTier = this.safeDict(takerFees, 0, []);
|
|
104311
|
+
const exchangeFees = this.safeDict(this, 'fees', {});
|
|
104312
|
+
const exchangeFeesTrading = this.safeDict(exchangeFees, 'trading', {});
|
|
104313
|
+
const exchangeFeesTradingTiers = this.safeDict(exchangeFeesTrading, 'tiers', {});
|
|
104314
|
+
const exchangeFeesTradingTiersTaker = this.safeList(exchangeFeesTradingTiers, 'taker', []);
|
|
104315
|
+
const exchangeFeesTradingTiersMaker = this.safeList(exchangeFeesTradingTiers, 'maker', []);
|
|
104316
|
+
const exchangeFeesTradingTiersTakerLength = exchangeFeesTradingTiersTaker.length;
|
|
104317
|
+
const firstTierLength = firstTier.length;
|
|
104318
|
+
if ((keysLength === exchangeFeesTradingTiersTakerLength) && (firstTierLength > 0)) {
|
|
103658
104319
|
for (let i = 0; i < keysLength; i++) {
|
|
103659
104320
|
takerFees[i][0] = exchangeFeesTradingTiersTaker[i][0];
|
|
103660
104321
|
makerFees[i][0] = exchangeFeesTradingTiersMaker[i][0];
|
|
@@ -107125,7 +107786,8 @@ class coinmetro extends _abstract_coinmetro_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
107125
107786
|
}
|
|
107126
107787
|
let type = undefined;
|
|
107127
107788
|
let referenceId = undefined;
|
|
107128
|
-
|
|
107789
|
+
const length = descriptionArray.length;
|
|
107790
|
+
if (length > 1) {
|
|
107129
107791
|
type = this.parseLedgerEntryType(descriptionArray[0]);
|
|
107130
107792
|
if (descriptionArray[1] !== '-') {
|
|
107131
107793
|
referenceId = descriptionArray[1];
|
|
@@ -116533,7 +117195,7 @@ class currencycom extends _abstract_currencycom_js__WEBPACK_IMPORTED_MODULE_0__/
|
|
|
116533
117195
|
//
|
|
116534
117196
|
market = this.safeMarket(this.safeString(position, 'symbol'), market);
|
|
116535
117197
|
const symbol = market['symbol'];
|
|
116536
|
-
const timestamp = this.
|
|
117198
|
+
const timestamp = this.safeInteger(position, 'createdTimestamp');
|
|
116537
117199
|
const quantityRaw = this.safeString(position, 'openQuantity');
|
|
116538
117200
|
const side = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringGt(quantityRaw, '0') ? 'long' : 'short';
|
|
116539
117201
|
const quantity = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(quantityRaw);
|
|
@@ -151951,7 +152613,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
151951
152613
|
const marginMode = (marketId === undefined) ? 'cross' : 'isolated';
|
|
151952
152614
|
market = this.safeMarket(marketId);
|
|
151953
152615
|
const symbol = this.safeString(market, 'symbol');
|
|
151954
|
-
const timestamp = this.
|
|
152616
|
+
const timestamp = this.safeInteger(info, 'accrued-at');
|
|
151955
152617
|
return {
|
|
151956
152618
|
'account': (marginMode === 'isolated') ? symbol : 'cross',
|
|
151957
152619
|
'symbol': symbol,
|
|
@@ -162615,7 +163277,8 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
162615
163277
|
'fetchBalance': true,
|
|
162616
163278
|
'fetchBorrowRateHistories': false,
|
|
162617
163279
|
'fetchBorrowRateHistory': false,
|
|
162618
|
-
'
|
|
163280
|
+
'fetchCanceledOrders': true,
|
|
163281
|
+
'fetchClosedOrders': true,
|
|
162619
163282
|
'fetchCrossBorrowRate': false,
|
|
162620
163283
|
'fetchCrossBorrowRates': false,
|
|
162621
163284
|
'fetchDepositAddress': false,
|
|
@@ -163762,6 +164425,102 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
163762
164425
|
const orders = this.safeValue(response, 'openOrders', []);
|
|
163763
164426
|
return this.parseOrders(orders, market, since, limit);
|
|
163764
164427
|
}
|
|
164428
|
+
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
164429
|
+
/**
|
|
164430
|
+
* @method
|
|
164431
|
+
* @name krakenfutures#fetchClosedOrders
|
|
164432
|
+
* @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
|
|
164433
|
+
* @description Gets all closed orders, including trigger orders, for an account from the exchange api
|
|
164434
|
+
* @param {string} symbol Unified market symbol
|
|
164435
|
+
* @param {int} [since] Timestamp (ms) of earliest order.
|
|
164436
|
+
* @param {int} [limit] How many orders to return.
|
|
164437
|
+
* @param {object} [params] Exchange specific parameters
|
|
164438
|
+
* @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
164439
|
+
*/
|
|
164440
|
+
await this.loadMarkets();
|
|
164441
|
+
let market = undefined;
|
|
164442
|
+
if (symbol !== undefined) {
|
|
164443
|
+
market = this.market(symbol);
|
|
164444
|
+
}
|
|
164445
|
+
const request = {};
|
|
164446
|
+
if (limit !== undefined) {
|
|
164447
|
+
request['count'] = limit;
|
|
164448
|
+
}
|
|
164449
|
+
if (since !== undefined) {
|
|
164450
|
+
request['from'] = since;
|
|
164451
|
+
}
|
|
164452
|
+
const response = await this.historyGetOrders(this.extend(request, params));
|
|
164453
|
+
const allOrders = this.safeList(response, 'elements', []);
|
|
164454
|
+
const closedOrders = [];
|
|
164455
|
+
for (let i = 0; i < allOrders.length; i++) {
|
|
164456
|
+
const order = allOrders[i];
|
|
164457
|
+
const event = this.safeDict(order, 'event', {});
|
|
164458
|
+
const orderPlaced = this.safeDict(event, 'OrderPlaced');
|
|
164459
|
+
if (orderPlaced !== undefined) {
|
|
164460
|
+
const innerOrder = this.safeDict(orderPlaced, 'order', {});
|
|
164461
|
+
const filled = this.safeString(innerOrder, 'filled');
|
|
164462
|
+
if (filled !== '0') {
|
|
164463
|
+
innerOrder['status'] = 'closed'; // status not available in the response
|
|
164464
|
+
closedOrders.push(innerOrder);
|
|
164465
|
+
}
|
|
164466
|
+
}
|
|
164467
|
+
}
|
|
164468
|
+
return this.parseOrders(closedOrders, market, since, limit);
|
|
164469
|
+
}
|
|
164470
|
+
async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
164471
|
+
/**
|
|
164472
|
+
* @method
|
|
164473
|
+
* @name krakenfutures#fetchCanceledOrders
|
|
164474
|
+
* @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
|
|
164475
|
+
* @description Gets all canceled orders, including trigger orders, for an account from the exchange api
|
|
164476
|
+
* @param {string} symbol Unified market symbol
|
|
164477
|
+
* @param {int} [since] Timestamp (ms) of earliest order.
|
|
164478
|
+
* @param {int} [limit] How many orders to return.
|
|
164479
|
+
* @param {object} [params] Exchange specific parameters
|
|
164480
|
+
* @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
164481
|
+
*/
|
|
164482
|
+
await this.loadMarkets();
|
|
164483
|
+
let market = undefined;
|
|
164484
|
+
if (symbol !== undefined) {
|
|
164485
|
+
market = this.market(symbol);
|
|
164486
|
+
}
|
|
164487
|
+
const request = {};
|
|
164488
|
+
if (limit !== undefined) {
|
|
164489
|
+
request['count'] = limit;
|
|
164490
|
+
}
|
|
164491
|
+
if (since !== undefined) {
|
|
164492
|
+
request['from'] = since;
|
|
164493
|
+
}
|
|
164494
|
+
const response = await this.historyGetOrders(this.extend(request, params));
|
|
164495
|
+
const allOrders = this.safeList(response, 'elements', []);
|
|
164496
|
+
const canceledAndRejected = [];
|
|
164497
|
+
for (let i = 0; i < allOrders.length; i++) {
|
|
164498
|
+
const order = allOrders[i];
|
|
164499
|
+
const event = this.safeDict(order, 'event', {});
|
|
164500
|
+
const orderPlaced = this.safeDict(event, 'OrderPlaced');
|
|
164501
|
+
if (orderPlaced !== undefined) {
|
|
164502
|
+
const innerOrder = this.safeDict(orderPlaced, 'order', {});
|
|
164503
|
+
const filled = this.safeString(innerOrder, 'filled');
|
|
164504
|
+
if (filled === '0') {
|
|
164505
|
+
innerOrder['status'] = 'canceled'; // status not available in the response
|
|
164506
|
+
canceledAndRejected.push(innerOrder);
|
|
164507
|
+
}
|
|
164508
|
+
}
|
|
164509
|
+
const orderCanceled = this.safeDict(event, 'OrderCancelled');
|
|
164510
|
+
if (orderCanceled !== undefined) {
|
|
164511
|
+
const innerOrder = this.safeDict(orderCanceled, 'order', {});
|
|
164512
|
+
innerOrder['status'] = 'canceled'; // status not available in the response
|
|
164513
|
+
canceledAndRejected.push(innerOrder);
|
|
164514
|
+
}
|
|
164515
|
+
const orderRejected = this.safeDict(event, 'OrderRejected');
|
|
164516
|
+
if (orderRejected !== undefined) {
|
|
164517
|
+
const innerOrder = this.safeDict(orderRejected, 'order', {});
|
|
164518
|
+
innerOrder['status'] = 'rejected'; // status not available in the response
|
|
164519
|
+
canceledAndRejected.push(innerOrder);
|
|
164520
|
+
}
|
|
164521
|
+
}
|
|
164522
|
+
return this.parseOrders(canceledAndRejected, market, since, limit);
|
|
164523
|
+
}
|
|
163765
164524
|
parseOrderType(orderType) {
|
|
163766
164525
|
const map = {
|
|
163767
164526
|
'lmt': 'limit',
|
|
@@ -164005,6 +164764,32 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
164005
164764
|
// "status": "requiredArgumentMissing",
|
|
164006
164765
|
// "orderEvents": []
|
|
164007
164766
|
// }
|
|
164767
|
+
// closed orders
|
|
164768
|
+
// {
|
|
164769
|
+
// uid: '2f00cd63-e61d-44f8-8569-adabde885941',
|
|
164770
|
+
// timestamp: '1707258274849',
|
|
164771
|
+
// event: {
|
|
164772
|
+
// OrderPlaced: {
|
|
164773
|
+
// order: {
|
|
164774
|
+
// uid: '85805e01-9eed-4395-8360-ed1a228237c9',
|
|
164775
|
+
// accountUid: '406142dd-7c5c-4a8b-acbc-5f16eca30009',
|
|
164776
|
+
// tradeable: 'PF_LTCUSD',
|
|
164777
|
+
// direction: 'Buy',
|
|
164778
|
+
// quantity: '0',
|
|
164779
|
+
// filled: '0.1',
|
|
164780
|
+
// timestamp: '1707258274849',
|
|
164781
|
+
// limitPrice: '69.2200000000',
|
|
164782
|
+
// orderType: 'IoC',
|
|
164783
|
+
// clientId: '',
|
|
164784
|
+
// reduceOnly: false,
|
|
164785
|
+
// lastUpdateTimestamp: '1707258274849'
|
|
164786
|
+
// },
|
|
164787
|
+
// reason: 'new_user_order',
|
|
164788
|
+
// reducedQuantity: '',
|
|
164789
|
+
// algoId: ''
|
|
164790
|
+
// }
|
|
164791
|
+
// }
|
|
164792
|
+
// }
|
|
164008
164793
|
//
|
|
164009
164794
|
const orderEvents = this.safeValue(order, 'orderEvents', []);
|
|
164010
164795
|
const errorStatus = this.safeString(order, 'status');
|
|
@@ -164067,7 +164852,8 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
164067
164852
|
let remaining = this.safeString(details, 'unfilledSize');
|
|
164068
164853
|
let average = undefined;
|
|
164069
164854
|
let filled2 = '0.0';
|
|
164070
|
-
|
|
164855
|
+
const tradesLength = trades.length;
|
|
164856
|
+
if (tradesLength > 0) {
|
|
164071
164857
|
let vwapSum = '0.0';
|
|
164072
164858
|
for (let i = 0; i < trades.length; i++) {
|
|
164073
164859
|
const trade = trades[i];
|
|
@@ -182795,7 +183581,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
182795
183581
|
async fetchStatus(params = {}) {
|
|
182796
183582
|
/**
|
|
182797
183583
|
* @method
|
|
182798
|
-
* @name
|
|
183584
|
+
* @name mexc#fetchStatus
|
|
182799
183585
|
* @description the latest known information on the availability of the exchange API
|
|
182800
183586
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
182801
183587
|
* @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
|
|
@@ -182832,7 +183618,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
182832
183618
|
async fetchTime(params = {}) {
|
|
182833
183619
|
/**
|
|
182834
183620
|
* @method
|
|
182835
|
-
* @name
|
|
183621
|
+
* @name mexc#fetchTime
|
|
182836
183622
|
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
182837
183623
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
182838
183624
|
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
@@ -182858,7 +183644,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
182858
183644
|
async fetchCurrencies(params = {}) {
|
|
182859
183645
|
/**
|
|
182860
183646
|
* @method
|
|
182861
|
-
* @name
|
|
183647
|
+
* @name mexc#fetchCurrencies
|
|
182862
183648
|
* @description fetches all available currencies on an exchange
|
|
182863
183649
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
|
|
182864
183650
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -183023,8 +183809,8 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
183023
183809
|
async fetchMarkets(params = {}) {
|
|
183024
183810
|
/**
|
|
183025
183811
|
* @method
|
|
183026
|
-
* @name
|
|
183027
|
-
* @description retrieves data on all markets for
|
|
183812
|
+
* @name mexc#fetchMarkets
|
|
183813
|
+
* @description retrieves data on all markets for mexc
|
|
183028
183814
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
183029
183815
|
* @returns {object[]} an array of objects representing market data
|
|
183030
183816
|
*/
|
|
@@ -183264,7 +184050,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
183264
184050
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
183265
184051
|
/**
|
|
183266
184052
|
* @method
|
|
183267
|
-
* @name
|
|
184053
|
+
* @name mexc#fetchOrderBook
|
|
183268
184054
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
|
|
183269
184055
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
|
|
183270
184056
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
@@ -183341,7 +184127,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
183341
184127
|
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
183342
184128
|
/**
|
|
183343
184129
|
* @method
|
|
183344
|
-
* @name
|
|
184130
|
+
* @name mexc#fetchTrades
|
|
183345
184131
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#recent-trades-list
|
|
183346
184132
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#compressed-aggregate-trades-list
|
|
183347
184133
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-transaction-data
|
|
@@ -183617,7 +184403,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
183617
184403
|
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
183618
184404
|
/**
|
|
183619
184405
|
* @method
|
|
183620
|
-
* @name
|
|
184406
|
+
* @name mexc#fetchOHLCV
|
|
183621
184407
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
|
|
183622
184408
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#k-line-data
|
|
183623
184409
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
@@ -183739,7 +184525,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
183739
184525
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
183740
184526
|
/**
|
|
183741
184527
|
* @method
|
|
183742
|
-
* @name
|
|
184528
|
+
* @name mexc#fetchTickers
|
|
183743
184529
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
183744
184530
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
183745
184531
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -183827,7 +184613,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
183827
184613
|
async fetchTicker(symbol, params = {}) {
|
|
183828
184614
|
/**
|
|
183829
184615
|
* @method
|
|
183830
|
-
* @name
|
|
184616
|
+
* @name mexc#fetchTicker
|
|
183831
184617
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
183832
184618
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
183833
184619
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -184017,7 +184803,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184017
184803
|
async fetchBidsAsks(symbols = undefined, params = {}) {
|
|
184018
184804
|
/**
|
|
184019
184805
|
* @method
|
|
184020
|
-
* @name
|
|
184806
|
+
* @name mexc#fetchBidsAsks
|
|
184021
184807
|
* @description fetches the bid and ask price and volume for multiple markets
|
|
184022
184808
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
|
184023
184809
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -184078,7 +184864,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184078
184864
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
184079
184865
|
/**
|
|
184080
184866
|
* @method
|
|
184081
|
-
* @name
|
|
184867
|
+
* @name mexc#createOrder
|
|
184082
184868
|
* @description create a trade order
|
|
184083
184869
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
|
|
184084
184870
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
|
|
@@ -184359,7 +185145,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184359
185145
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
184360
185146
|
/**
|
|
184361
185147
|
* @method
|
|
184362
|
-
* @name
|
|
185148
|
+
* @name mexc#fetchOrder
|
|
184363
185149
|
* @description fetches information on an order made by the user
|
|
184364
185150
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
184365
185151
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -184481,7 +185267,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184481
185267
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
184482
185268
|
/**
|
|
184483
185269
|
* @method
|
|
184484
|
-
* @name
|
|
185270
|
+
* @name mexc#fetchOrders
|
|
184485
185271
|
* @description fetches information on multiple orders made by the user
|
|
184486
185272
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
184487
185273
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
@@ -184713,7 +185499,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184713
185499
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
184714
185500
|
/**
|
|
184715
185501
|
* @method
|
|
184716
|
-
* @name
|
|
185502
|
+
* @name mexc#fetchOpenOrders
|
|
184717
185503
|
* @description fetch all unfilled currently open orders
|
|
184718
185504
|
* @param {string} symbol unified market symbol
|
|
184719
185505
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
@@ -184804,7 +185590,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184804
185590
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
184805
185591
|
/**
|
|
184806
185592
|
* @method
|
|
184807
|
-
* @name
|
|
185593
|
+
* @name mexc#fetchClosedOrders
|
|
184808
185594
|
* @description fetches information on multiple closed orders made by the user
|
|
184809
185595
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
184810
185596
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
@@ -184817,7 +185603,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184817
185603
|
async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
184818
185604
|
/**
|
|
184819
185605
|
* @method
|
|
184820
|
-
* @name
|
|
185606
|
+
* @name mexc#fetchCanceledOrders
|
|
184821
185607
|
* @description fetches information on multiple canceled orders made by the user
|
|
184822
185608
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
184823
185609
|
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
|
|
@@ -184846,7 +185632,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184846
185632
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
184847
185633
|
/**
|
|
184848
185634
|
* @method
|
|
184849
|
-
* @name
|
|
185635
|
+
* @name mexc#cancelOrder
|
|
184850
185636
|
* @description cancels an open order
|
|
184851
185637
|
* @param {string} id order id
|
|
184852
185638
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
@@ -184963,7 +185749,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184963
185749
|
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
184964
185750
|
/**
|
|
184965
185751
|
* @method
|
|
184966
|
-
* @name
|
|
185752
|
+
* @name mexc#cancelOrders
|
|
184967
185753
|
* @description cancel multiple orders
|
|
184968
185754
|
* @param {string[]} ids order ids
|
|
184969
185755
|
* @param {string} symbol unified market symbol, default is undefined
|
|
@@ -184998,7 +185784,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
184998
185784
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
184999
185785
|
/**
|
|
185000
185786
|
* @method
|
|
185001
|
-
* @name
|
|
185787
|
+
* @name mexc#cancelAllOrders
|
|
185002
185788
|
* @description cancel all open orders
|
|
185003
185789
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
185004
185790
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -185401,7 +186187,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185401
186187
|
async fetchAccounts(params = {}) {
|
|
185402
186188
|
/**
|
|
185403
186189
|
* @method
|
|
185404
|
-
* @name
|
|
186190
|
+
* @name mexc#fetchAccounts
|
|
185405
186191
|
* @description fetch all the accounts associated with a profile
|
|
185406
186192
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
185407
186193
|
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
|
|
@@ -185428,7 +186214,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185428
186214
|
async fetchTradingFees(params = {}) {
|
|
185429
186215
|
/**
|
|
185430
186216
|
* @method
|
|
185431
|
-
* @name
|
|
186217
|
+
* @name mexc#fetchTradingFees
|
|
185432
186218
|
* @description fetch the trading fees for multiple markets
|
|
185433
186219
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
185434
186220
|
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
@@ -185579,7 +186365,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185579
186365
|
async fetchBalance(params = {}) {
|
|
185580
186366
|
/**
|
|
185581
186367
|
* @method
|
|
185582
|
-
* @name
|
|
186368
|
+
* @name mexc#fetchBalance
|
|
185583
186369
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
185584
186370
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
|
|
185585
186371
|
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
|
|
@@ -185713,7 +186499,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185713
186499
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
185714
186500
|
/**
|
|
185715
186501
|
* @method
|
|
185716
|
-
* @name
|
|
186502
|
+
* @name mexc#fetchMyTrades
|
|
185717
186503
|
* @description fetch all trades made by the user
|
|
185718
186504
|
* @param {string} symbol unified market symbol
|
|
185719
186505
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
@@ -185803,7 +186589,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185803
186589
|
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
185804
186590
|
/**
|
|
185805
186591
|
* @method
|
|
185806
|
-
* @name
|
|
186592
|
+
* @name mexc#fetchOrderTrades
|
|
185807
186593
|
* @description fetch all the trades made from a single order
|
|
185808
186594
|
* @param {string} id order id
|
|
185809
186595
|
* @param {string} symbol unified market symbol
|
|
@@ -185901,7 +186687,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185901
186687
|
async reduceMargin(symbol, amount, params = {}) {
|
|
185902
186688
|
/**
|
|
185903
186689
|
* @method
|
|
185904
|
-
* @name
|
|
186690
|
+
* @name mexc#reduceMargin
|
|
185905
186691
|
* @description remove margin from a position
|
|
185906
186692
|
* @param {string} symbol unified market symbol
|
|
185907
186693
|
* @param {float} amount the amount of margin to remove
|
|
@@ -185913,7 +186699,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185913
186699
|
async addMargin(symbol, amount, params = {}) {
|
|
185914
186700
|
/**
|
|
185915
186701
|
* @method
|
|
185916
|
-
* @name
|
|
186702
|
+
* @name mexc#addMargin
|
|
185917
186703
|
* @description add margin
|
|
185918
186704
|
* @param {string} symbol unified market symbol
|
|
185919
186705
|
* @param {float} amount amount of margin to add
|
|
@@ -185925,7 +186711,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185925
186711
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
185926
186712
|
/**
|
|
185927
186713
|
* @method
|
|
185928
|
-
* @name
|
|
186714
|
+
* @name mexc#setLeverage
|
|
185929
186715
|
* @description set the level of leverage for a market
|
|
185930
186716
|
* @param {float} leverage the rate of leverage
|
|
185931
186717
|
* @param {string} symbol unified market symbol
|
|
@@ -185958,7 +186744,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
185958
186744
|
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
185959
186745
|
/**
|
|
185960
186746
|
* @method
|
|
185961
|
-
* @name
|
|
186747
|
+
* @name mexc#fetchFundingHistory
|
|
185962
186748
|
* @description fetch the history of funding payments paid and received on this account
|
|
185963
186749
|
* @param {string} symbol unified market symbol
|
|
185964
186750
|
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
@@ -186073,7 +186859,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186073
186859
|
async fetchFundingRate(symbol, params = {}) {
|
|
186074
186860
|
/**
|
|
186075
186861
|
* @method
|
|
186076
|
-
* @name
|
|
186862
|
+
* @name mexc#fetchFundingRate
|
|
186077
186863
|
* @description fetch the current funding rate
|
|
186078
186864
|
* @param {string} symbol unified market symbol
|
|
186079
186865
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -186174,7 +186960,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186174
186960
|
async fetchLeverageTiers(symbols = undefined, params = {}) {
|
|
186175
186961
|
/**
|
|
186176
186962
|
* @method
|
|
186177
|
-
* @name
|
|
186963
|
+
* @name mexc#fetchLeverageTiers
|
|
186178
186964
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
|
186179
186965
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
186180
186966
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -186287,7 +187073,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186287
187073
|
async fetchDepositAddressesByNetwork(code, params = {}) {
|
|
186288
187074
|
/**
|
|
186289
187075
|
* @method
|
|
186290
|
-
* @name
|
|
187076
|
+
* @name mexc#fetchDepositAddressesByNetwork
|
|
186291
187077
|
* @description fetch a dictionary of addresses for a currency, indexed by network
|
|
186292
187078
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
|
|
186293
187079
|
* @param {string} code unified currency code of the currency for the deposit address
|
|
@@ -186327,7 +187113,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186327
187113
|
async createDepositAddress(code, params = {}) {
|
|
186328
187114
|
/**
|
|
186329
187115
|
* @method
|
|
186330
|
-
* @name
|
|
187116
|
+
* @name mexc#createDepositAddress
|
|
186331
187117
|
* @description create a currency deposit address
|
|
186332
187118
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
|
|
186333
187119
|
* @param {string} code unified currency code of the currency for the deposit address
|
|
@@ -186367,7 +187153,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186367
187153
|
async fetchDepositAddress(code, params = {}) {
|
|
186368
187154
|
/**
|
|
186369
187155
|
* @method
|
|
186370
|
-
* @name
|
|
187156
|
+
* @name mexc#fetchDepositAddress
|
|
186371
187157
|
* @description fetch the deposit address for a currency associated with this account
|
|
186372
187158
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
|
|
186373
187159
|
* @param {string} code unified currency code
|
|
@@ -186395,7 +187181,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186395
187181
|
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
186396
187182
|
/**
|
|
186397
187183
|
* @method
|
|
186398
|
-
* @name
|
|
187184
|
+
* @name mexc#fetchDeposits
|
|
186399
187185
|
* @description fetch all deposits made to an account
|
|
186400
187186
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
|
|
186401
187187
|
* @param {string} code unified currency code
|
|
@@ -186455,7 +187241,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186455
187241
|
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
186456
187242
|
/**
|
|
186457
187243
|
* @method
|
|
186458
|
-
* @name
|
|
187244
|
+
* @name mexc#fetchWithdrawals
|
|
186459
187245
|
* @description fetch all withdrawals made from an account
|
|
186460
187246
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
|
|
186461
187247
|
* @param {string} code unified currency code
|
|
@@ -186632,7 +187418,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186632
187418
|
async fetchPosition(symbol, params = {}) {
|
|
186633
187419
|
/**
|
|
186634
187420
|
* @method
|
|
186635
|
-
* @name
|
|
187421
|
+
* @name mexc#fetchPosition
|
|
186636
187422
|
* @description fetch data on a single open contract trade position
|
|
186637
187423
|
* @param {string} symbol unified market symbol of the market the position is held in, default is undefined
|
|
186638
187424
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -186649,7 +187435,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186649
187435
|
async fetchPositions(symbols = undefined, params = {}) {
|
|
186650
187436
|
/**
|
|
186651
187437
|
* @method
|
|
186652
|
-
* @name
|
|
187438
|
+
* @name mexc#fetchPositions
|
|
186653
187439
|
* @description fetch all open positions
|
|
186654
187440
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
186655
187441
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -186726,7 +187512,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186726
187512
|
const marginType = (openType === '1') ? 'isolated' : 'cross';
|
|
186727
187513
|
const leverage = this.safeNumber(position, 'leverage');
|
|
186728
187514
|
const liquidationPrice = this.safeNumber(position, 'liquidatePrice');
|
|
186729
|
-
const timestamp = this.
|
|
187515
|
+
const timestamp = this.safeInteger(position, 'updateTime');
|
|
186730
187516
|
return this.safePosition({
|
|
186731
187517
|
'info': position,
|
|
186732
187518
|
'id': undefined,
|
|
@@ -186789,7 +187575,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186789
187575
|
async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
186790
187576
|
/**
|
|
186791
187577
|
* @method
|
|
186792
|
-
* @name
|
|
187578
|
+
* @name mexc#fetchTransfers
|
|
186793
187579
|
* @description fetch a history of internal transfers made on an account
|
|
186794
187580
|
* @param {string} code unified currency code of the currency transferred
|
|
186795
187581
|
* @param {int} [since] the earliest time in ms to fetch transfers for
|
|
@@ -186876,7 +187662,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
186876
187662
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
186877
187663
|
/**
|
|
186878
187664
|
* @method
|
|
186879
|
-
* @name
|
|
187665
|
+
* @name mexc#transfer
|
|
186880
187666
|
* @description transfer currency internally between wallets on the same account
|
|
186881
187667
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
|
|
186882
187668
|
* @param {string} code unified currency code
|
|
@@ -187009,7 +187795,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
187009
187795
|
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
187010
187796
|
/**
|
|
187011
187797
|
* @method
|
|
187012
|
-
* @name
|
|
187798
|
+
* @name mexc#withdraw
|
|
187013
187799
|
* @description make a withdrawal
|
|
187014
187800
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw
|
|
187015
187801
|
* @param {string} code unified currency code
|
|
@@ -187077,7 +187863,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
187077
187863
|
async fetchTransactionFees(codes = undefined, params = {}) {
|
|
187078
187864
|
/**
|
|
187079
187865
|
* @method
|
|
187080
|
-
* @name
|
|
187866
|
+
* @name mexc#fetchTransactionFees
|
|
187081
187867
|
* @description fetch deposit and withdrawal fees
|
|
187082
187868
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
|
|
187083
187869
|
* @param {string[]|undefined} codes returns fees for all currencies if undefined
|
|
@@ -187175,7 +187961,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
187175
187961
|
async fetchDepositWithdrawFees(codes = undefined, params = {}) {
|
|
187176
187962
|
/**
|
|
187177
187963
|
* @method
|
|
187178
|
-
* @name
|
|
187964
|
+
* @name mexc#fetchDepositWithdrawFees
|
|
187179
187965
|
* @description fetch deposit and withdrawal fees
|
|
187180
187966
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
|
|
187181
187967
|
* @param {string[]|undefined} codes returns fees for all currencies if undefined
|
|
@@ -199214,12 +200000,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
199214
200000
|
if (trailing) {
|
|
199215
200001
|
request['ordType'] = 'move_order_stop';
|
|
199216
200002
|
}
|
|
199217
|
-
else if (stop
|
|
199218
|
-
|
|
199219
|
-
if (ordType === undefined) {
|
|
199220
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
|
|
199221
|
-
}
|
|
199222
|
-
}
|
|
200003
|
+
else if (stop && (ordType === undefined)) {
|
|
200004
|
+
request['ordType'] = 'trigger';
|
|
199223
200005
|
}
|
|
199224
200006
|
const query = this.omit(params, ['method', 'stop', 'trigger', 'trailing']);
|
|
199225
200007
|
let response = undefined;
|
|
@@ -199526,7 +200308,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
199526
200308
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
199527
200309
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
199528
200310
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
199529
|
-
* @param {bool} [params.
|
|
200311
|
+
* @param {bool} [params.trigger] True if fetching trigger or conditional orders
|
|
199530
200312
|
* @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
|
|
199531
200313
|
* @param {string} [params.algoId] Algo ID "'433845797218942976'"
|
|
199532
200314
|
* @param {int} [params.until] timestamp in ms to fetch orders for
|
|
@@ -199564,12 +200346,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
199564
200346
|
if (limit !== undefined) {
|
|
199565
200347
|
request['limit'] = limit; // default 100, max 100
|
|
199566
200348
|
}
|
|
199567
|
-
const options = this.
|
|
199568
|
-
const algoOrderTypes = this.
|
|
200349
|
+
const options = this.safeDict(this.options, 'fetchClosedOrders', {});
|
|
200350
|
+
const algoOrderTypes = this.safeDict(this.options, 'algoOrderTypes', {});
|
|
199569
200351
|
const defaultMethod = this.safeString(options, 'method', 'privateGetTradeOrdersHistory');
|
|
199570
200352
|
let method = this.safeString(params, 'method', defaultMethod);
|
|
199571
200353
|
const ordType = this.safeString(params, 'ordType');
|
|
199572
|
-
const stop = this.
|
|
200354
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
199573
200355
|
const trailing = this.safeBool(params, 'trailing', false);
|
|
199574
200356
|
if (trailing || stop || (ordType in algoOrderTypes)) {
|
|
199575
200357
|
method = 'privateGetTradeOrdersAlgoHistory';
|
|
@@ -199578,11 +200360,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
199578
200360
|
if (trailing) {
|
|
199579
200361
|
request['ordType'] = 'move_order_stop';
|
|
199580
200362
|
}
|
|
199581
|
-
else if (stop
|
|
199582
|
-
if (
|
|
199583
|
-
|
|
199584
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchClosedOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"');
|
|
199585
|
-
}
|
|
200363
|
+
else if (stop) {
|
|
200364
|
+
if (ordType === undefined) {
|
|
200365
|
+
request['ordType'] = 'trigger';
|
|
199586
200366
|
}
|
|
199587
200367
|
}
|
|
199588
200368
|
else {
|
|
@@ -206831,6 +207611,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
206831
207611
|
'addMargin': false,
|
|
206832
207612
|
'cancelAllOrders': true,
|
|
206833
207613
|
'cancelOrder': true,
|
|
207614
|
+
'closePosition': false,
|
|
206834
207615
|
'createOrder': true,
|
|
206835
207616
|
'createReduceOnlyOrder': true,
|
|
206836
207617
|
'createStopLimitOrder': true,
|
|
@@ -225185,6 +225966,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
225185
225966
|
'watchOrderBookForSymbols': true,
|
|
225186
225967
|
'watchOrders': true,
|
|
225187
225968
|
'watchTrades': true,
|
|
225969
|
+
'watchTradesForSymbols': true,
|
|
225188
225970
|
'watchOHLCV': true,
|
|
225189
225971
|
'watchPosition': 'emulated',
|
|
225190
225972
|
'watchPositions': true,
|
|
@@ -225429,17 +226211,43 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
225429
226211
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
225430
226212
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
225431
226213
|
*/
|
|
226214
|
+
return await this.watchTradesForSymbols([symbol], since, limit, params);
|
|
226215
|
+
}
|
|
226216
|
+
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
226217
|
+
/**
|
|
226218
|
+
* @method
|
|
226219
|
+
* @name bitmart#watchTradesForSymbols
|
|
226220
|
+
* @see https://developer-pro.bitmart.com/en/spot/#public-trade-channel
|
|
226221
|
+
* @description get the list of most recent trades for a list of symbols
|
|
226222
|
+
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
226223
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
226224
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
226225
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
226226
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
226227
|
+
*/
|
|
225432
226228
|
await this.loadMarkets();
|
|
225433
|
-
|
|
225434
|
-
|
|
225435
|
-
|
|
225436
|
-
|
|
225437
|
-
const trades = await this.subscribe('trade', symbol, type, params);
|
|
226229
|
+
let marketType = undefined;
|
|
226230
|
+
[symbols, marketType, params] = this.getParamsForMultipleSub('watchTradesForSymbols', symbols, limit, params);
|
|
226231
|
+
const channelName = 'trade';
|
|
226232
|
+
const trades = await this.subscribeMultiple(channelName, marketType, symbols, params);
|
|
225438
226233
|
if (this.newUpdates) {
|
|
225439
|
-
|
|
226234
|
+
const first = this.safeDict(trades, 0);
|
|
226235
|
+
const tradeSymbol = this.safeString(first, 'symbol');
|
|
226236
|
+
limit = trades.getLimit(tradeSymbol, limit);
|
|
225440
226237
|
}
|
|
225441
226238
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
225442
226239
|
}
|
|
226240
|
+
getParamsForMultipleSub(methodName, symbols, limit = undefined, params = {}) {
|
|
226241
|
+
symbols = this.marketSymbols(symbols, undefined, false, true);
|
|
226242
|
+
const length = symbols.length;
|
|
226243
|
+
if (length > 20) {
|
|
226244
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' ' + methodName + '() accepts a maximum of 20 symbols in one request');
|
|
226245
|
+
}
|
|
226246
|
+
const market = this.market(symbols[0]);
|
|
226247
|
+
let marketType = undefined;
|
|
226248
|
+
[marketType, params] = this.handleMarketTypeAndParams(methodName, market, params);
|
|
226249
|
+
return [symbols, marketType, params];
|
|
226250
|
+
}
|
|
225443
226251
|
async watchTicker(symbol, params = {}) {
|
|
225444
226252
|
/**
|
|
225445
226253
|
* @method
|
|
@@ -225977,16 +226785,15 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
225977
226785
|
// ]
|
|
225978
226786
|
// }
|
|
225979
226787
|
//
|
|
225980
|
-
const channel = this.safeString2(message, 'table', 'group');
|
|
225981
|
-
const isSpot = (channel.indexOf('spot') >= 0);
|
|
225982
226788
|
const data = this.safeValue(message, 'data');
|
|
225983
226789
|
if (data === undefined) {
|
|
225984
226790
|
return;
|
|
225985
226791
|
}
|
|
225986
226792
|
let stored = undefined;
|
|
226793
|
+
let symbol = undefined;
|
|
225987
226794
|
for (let i = 0; i < data.length; i++) {
|
|
225988
226795
|
const trade = this.parseWsTrade(data[i]);
|
|
225989
|
-
|
|
226796
|
+
symbol = trade['symbol'];
|
|
225990
226797
|
const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
225991
226798
|
stored = this.safeValue(this.trades, symbol);
|
|
225992
226799
|
if (stored === undefined) {
|
|
@@ -225995,10 +226802,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
225995
226802
|
}
|
|
225996
226803
|
stored.append(trade);
|
|
225997
226804
|
}
|
|
225998
|
-
|
|
225999
|
-
if (isSpot) {
|
|
226000
|
-
messageHash += ':' + this.safeString(data[0], 'symbol');
|
|
226001
|
-
}
|
|
226805
|
+
const messageHash = 'trade:' + symbol;
|
|
226002
226806
|
client.resolve(stored, messageHash);
|
|
226003
226807
|
}
|
|
226004
226808
|
parseWsTrade(trade, market = undefined) {
|
|
@@ -226531,15 +227335,10 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
226531
227335
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
226532
227336
|
*/
|
|
226533
227337
|
await this.loadMarkets();
|
|
226534
|
-
|
|
226535
|
-
|
|
226536
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' watchOrderBookForSymbols() accepts a maximum of 20 symbols in one request');
|
|
226537
|
-
}
|
|
226538
|
-
const market = this.market(symbols[0]);
|
|
227338
|
+
let type = undefined;
|
|
227339
|
+
[symbols, type, params] = this.getParamsForMultipleSub('watchOrderBookForSymbols', symbols, limit, params);
|
|
226539
227340
|
let channel = undefined;
|
|
226540
227341
|
[channel, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'depth', 'depth/increase100');
|
|
226541
|
-
let type = 'spot';
|
|
226542
|
-
[type, params] = this.handleMarketTypeAndParams('watchOrderBookForSymbols', market, params);
|
|
226543
227342
|
if (type === 'swap' && channel === 'depth/increase100') {
|
|
226544
227343
|
channel = 'depth50';
|
|
226545
227344
|
}
|
|
@@ -232231,7 +233030,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
232231
233030
|
const market = this.market(symbol);
|
|
232232
233031
|
symbol = market['symbol'];
|
|
232233
233032
|
const messageHash = 'ticker:' + symbol;
|
|
232234
|
-
const url = this.getUrlByMarketType(symbol, false, params);
|
|
233033
|
+
const url = this.getUrlByMarketType(symbol, false, 'watchTicker', params);
|
|
232235
233034
|
params = this.cleanParams(params);
|
|
232236
233035
|
const options = this.safeValue(this.options, 'watchTicker', {});
|
|
232237
233036
|
let topic = this.safeString(options, 'name', 'tickers');
|
|
@@ -232256,7 +233055,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
232256
233055
|
await this.loadMarkets();
|
|
232257
233056
|
symbols = this.marketSymbols(symbols, undefined, false);
|
|
232258
233057
|
const messageHashes = [];
|
|
232259
|
-
const url = this.getUrlByMarketType(symbols[0], false, params);
|
|
233058
|
+
const url = this.getUrlByMarketType(symbols[0], false, 'watchTickers', params);
|
|
232260
233059
|
params = this.cleanParams(params);
|
|
232261
233060
|
const options = this.safeValue(this.options, 'watchTickers', {});
|
|
232262
233061
|
const topic = this.safeString(options, 'name', 'tickers');
|
|
@@ -232423,7 +233222,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
232423
233222
|
await this.loadMarkets();
|
|
232424
233223
|
const market = this.market(symbol);
|
|
232425
233224
|
symbol = market['symbol'];
|
|
232426
|
-
const url = this.getUrlByMarketType(symbol, false, params);
|
|
233225
|
+
const url = this.getUrlByMarketType(symbol, false, 'watchOHLCV', params);
|
|
232427
233226
|
params = this.cleanParams(params);
|
|
232428
233227
|
let ohlcv = undefined;
|
|
232429
233228
|
const timeframeId = this.safeString(this.timeframes, timeframe, timeframe);
|
|
@@ -232541,7 +233340,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
232541
233340
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols');
|
|
232542
233341
|
}
|
|
232543
233342
|
symbols = this.marketSymbols(symbols);
|
|
232544
|
-
const url = this.getUrlByMarketType(symbols[0], false, params);
|
|
233343
|
+
const url = this.getUrlByMarketType(symbols[0], false, 'watchOrderBook', params);
|
|
232545
233344
|
params = this.cleanParams(params);
|
|
232546
233345
|
const market = this.market(symbols[0]);
|
|
232547
233346
|
if (limit === undefined) {
|
|
@@ -232673,7 +233472,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
232673
233472
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
|
|
232674
233473
|
}
|
|
232675
233474
|
params = this.cleanParams(params);
|
|
232676
|
-
const url = this.getUrlByMarketType(symbols[0], false, params);
|
|
233475
|
+
const url = this.getUrlByMarketType(symbols[0], false, 'watchTrades', params);
|
|
232677
233476
|
const topics = [];
|
|
232678
233477
|
const messageHashes = [];
|
|
232679
233478
|
for (let i = 0; i < symbols.length; i++) {
|
|
@@ -234085,7 +234884,7 @@ class cex extends _cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
234085
234884
|
trade = trade.split(':');
|
|
234086
234885
|
}
|
|
234087
234886
|
const side = this.safeString(trade, 0);
|
|
234088
|
-
const timestamp = this.
|
|
234887
|
+
const timestamp = this.safeInteger(trade, 1);
|
|
234089
234888
|
const amount = this.safeString(trade, 2);
|
|
234090
234889
|
const price = this.safeString(trade, 3);
|
|
234091
234890
|
const id = this.safeString(trade, 4);
|
|
@@ -243802,7 +244601,7 @@ class gemini extends _gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
243802
244601
|
// "socket_sequence": 139
|
|
243803
244602
|
// }
|
|
243804
244603
|
//
|
|
243805
|
-
const timestamp = this.
|
|
244604
|
+
const timestamp = this.safeInteger(order, 'timestampms');
|
|
243806
244605
|
const status = this.safeString(order, 'type');
|
|
243807
244606
|
const marketId = this.safeString(order, 'symbol');
|
|
243808
244607
|
const typeId = this.safeString(order, 'order_type');
|
|
@@ -304456,7 +305255,7 @@ SOFTWARE.
|
|
|
304456
305255
|
|
|
304457
305256
|
//-----------------------------------------------------------------------------
|
|
304458
305257
|
// this is updated by vss.js when building
|
|
304459
|
-
const version = '4.2.
|
|
305258
|
+
const version = '4.2.41';
|
|
304460
305259
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
304461
305260
|
//-----------------------------------------------------------------------------
|
|
304462
305261
|
|