ccxt 4.2.64 → 4.2.65
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/build.sh +1 -1
- package/dist/ccxt.browser.js +295 -74
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +12 -0
- package/dist/cjs/src/binance.js +26 -3
- package/dist/cjs/src/bingx.js +13 -4
- package/dist/cjs/src/bitmex.js +3 -1
- package/dist/cjs/src/blofin.js +35 -0
- package/dist/cjs/src/btcmarkets.js +12 -0
- package/dist/cjs/src/coinbase.js +12 -2
- package/dist/cjs/src/delta.js +95 -1
- package/dist/cjs/src/kucoin.js +85 -61
- package/dist/cjs/src/pro/currencycom.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/blofin.d.ts +1 -0
- package/js/src/abstract/kucoin.d.ts +9 -0
- package/js/src/abstract/kucoinfutures.d.ts +9 -0
- package/js/src/base/Exchange.js +12 -0
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +26 -3
- package/js/src/bingx.js +13 -4
- package/js/src/bitmex.js +3 -1
- package/js/src/blofin.d.ts +3 -1
- package/js/src/blofin.js +35 -0
- package/js/src/btcmarkets.js +12 -0
- package/js/src/coinbase.js +12 -2
- package/js/src/delta.d.ts +3 -1
- package/js/src/delta.js +95 -1
- package/js/src/gate.d.ts +1 -1
- package/js/src/kucoin.js +85 -61
- package/js/src/okx.d.ts +1 -1
- package/js/src/pro/currencycom.d.ts +1 -1
- package/js/src/pro/currencycom.js +1 -1
- package/js/src/woo.d.ts +1 -1
- package/package.json +2 -2
- package/skip-tests.json +35 -13
package/js/src/binance.js
CHANGED
|
@@ -2528,6 +2528,7 @@ export default class binance extends Exchange {
|
|
|
2528
2528
|
* @see https://binance-docs.github.io/apidocs/futures/en/#check-server-time // swap
|
|
2529
2529
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#check-server-time // future
|
|
2530
2530
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2531
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
2531
2532
|
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
2532
2533
|
*/
|
|
2533
2534
|
const defaultType = this.safeString2(this.options, 'fetchTime', 'defaultType', 'spot');
|
|
@@ -3323,6 +3324,7 @@ export default class binance extends Exchange {
|
|
|
3323
3324
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
|
|
3324
3325
|
* @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
|
|
3325
3326
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
|
|
3327
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
3326
3328
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
3327
3329
|
*/
|
|
3328
3330
|
await this.loadMarkets();
|
|
@@ -3901,6 +3903,7 @@ export default class binance extends Exchange {
|
|
|
3901
3903
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker // future
|
|
3902
3904
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
|
3903
3905
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3906
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
3904
3907
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
3905
3908
|
*/
|
|
3906
3909
|
await this.loadMarkets();
|
|
@@ -3941,6 +3944,7 @@ export default class binance extends Exchange {
|
|
|
3941
3944
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker // future
|
|
3942
3945
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
|
|
3943
3946
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3947
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
3944
3948
|
* @returns {object} a dictionary of lastprices structures
|
|
3945
3949
|
*/
|
|
3946
3950
|
await this.loadMarkets();
|
|
@@ -4046,6 +4050,7 @@ export default class binance extends Exchange {
|
|
|
4046
4050
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics // option
|
|
4047
4051
|
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
4048
4052
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4053
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
4049
4054
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
4050
4055
|
*/
|
|
4051
4056
|
await this.loadMarkets();
|
|
@@ -6472,6 +6477,7 @@ export default class binance extends Exchange {
|
|
|
6472
6477
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
|
6473
6478
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch open orders in the portfolio margin account
|
|
6474
6479
|
* @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account conditional orders
|
|
6480
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
6475
6481
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
6476
6482
|
*/
|
|
6477
6483
|
await this.loadMarkets();
|
|
@@ -8615,6 +8621,7 @@ export default class binance extends Exchange {
|
|
|
8615
8621
|
* @param {string} symbol unified market symbol
|
|
8616
8622
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8617
8623
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
|
|
8624
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
8618
8625
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
8619
8626
|
*/
|
|
8620
8627
|
await this.loadMarkets();
|
|
@@ -8683,6 +8690,7 @@ export default class binance extends Exchange {
|
|
|
8683
8690
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
8684
8691
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
8685
8692
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8693
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
8686
8694
|
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
8687
8695
|
*/
|
|
8688
8696
|
await this.loadMarkets();
|
|
@@ -8940,6 +8948,7 @@ export default class binance extends Exchange {
|
|
|
8940
8948
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8941
8949
|
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
8942
8950
|
* @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)
|
|
8951
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
8943
8952
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
8944
8953
|
*/
|
|
8945
8954
|
await this.loadMarkets();
|
|
@@ -9013,6 +9022,7 @@ export default class binance extends Exchange {
|
|
|
9013
9022
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
|
|
9014
9023
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
9015
9024
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
9025
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
9016
9026
|
* @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
|
|
9017
9027
|
*/
|
|
9018
9028
|
await this.loadMarkets();
|
|
@@ -9636,6 +9646,7 @@ export default class binance extends Exchange {
|
|
|
9636
9646
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
9637
9647
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
9638
9648
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the leverage tiers for a portfolio margin account
|
|
9649
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
9639
9650
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
9640
9651
|
*/
|
|
9641
9652
|
await this.loadMarkets();
|
|
@@ -9950,6 +9961,7 @@ export default class binance extends Exchange {
|
|
|
9950
9961
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
9951
9962
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
9952
9963
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
|
|
9964
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
9953
9965
|
* @returns {object} data on account positions
|
|
9954
9966
|
*/
|
|
9955
9967
|
if (symbols !== undefined) {
|
|
@@ -10003,6 +10015,7 @@ export default class binance extends Exchange {
|
|
|
10003
10015
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
10004
10016
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
10005
10017
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
|
|
10018
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
10006
10019
|
* @returns {object} data on the positions risk
|
|
10007
10020
|
*/
|
|
10008
10021
|
if (symbols !== undefined) {
|
|
@@ -10162,6 +10175,7 @@ export default class binance extends Exchange {
|
|
|
10162
10175
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
10163
10176
|
* @param {int} [params.until] timestamp in ms of the latest funding history entry
|
|
10164
10177
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the funding history for a portfolio margin account
|
|
10178
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
10165
10179
|
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
|
10166
10180
|
*/
|
|
10167
10181
|
await this.loadMarkets();
|
|
@@ -10346,6 +10360,7 @@ export default class binance extends Exchange {
|
|
|
10346
10360
|
* @param {string} symbol not used by binance setPositionMode ()
|
|
10347
10361
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
10348
10362
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to set the position mode for a portfolio margin account
|
|
10363
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
10349
10364
|
* @returns {object} response from the exchange
|
|
10350
10365
|
*/
|
|
10351
10366
|
const defaultType = this.safeString(this.options, 'defaultType', 'future');
|
|
@@ -10374,7 +10389,7 @@ export default class binance extends Exchange {
|
|
|
10374
10389
|
response = await this.dapiPrivatePostPositionSideDual(this.extend(request, params));
|
|
10375
10390
|
}
|
|
10376
10391
|
}
|
|
10377
|
-
else {
|
|
10392
|
+
else if (this.isLinear(type, subType)) {
|
|
10378
10393
|
if (isPortfolioMargin) {
|
|
10379
10394
|
response = await this.papiPostUmPositionSideDual(this.extend(request, params));
|
|
10380
10395
|
}
|
|
@@ -10382,6 +10397,9 @@ export default class binance extends Exchange {
|
|
|
10382
10397
|
response = await this.fapiPrivatePostPositionSideDual(this.extend(request, params));
|
|
10383
10398
|
}
|
|
10384
10399
|
}
|
|
10400
|
+
else {
|
|
10401
|
+
throw new BadRequest(this.id + ' setPositionMode() supports linear and inverse contracts only');
|
|
10402
|
+
}
|
|
10385
10403
|
//
|
|
10386
10404
|
// {
|
|
10387
10405
|
// "code": 200,
|
|
@@ -10401,6 +10419,7 @@ export default class binance extends Exchange {
|
|
|
10401
10419
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
|
10402
10420
|
* @param {string[]} [symbols] a list of unified market symbols
|
|
10403
10421
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
10422
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
10404
10423
|
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
10405
10424
|
*/
|
|
10406
10425
|
await this.loadMarkets();
|
|
@@ -10675,6 +10694,7 @@ export default class binance extends Exchange {
|
|
|
10675
10694
|
* @param {int} [params.until] timestamp in ms of the latest ledger entry
|
|
10676
10695
|
* @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)
|
|
10677
10696
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the ledger for a portfolio margin account
|
|
10697
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
10678
10698
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
10679
10699
|
*/
|
|
10680
10700
|
await this.loadMarkets();
|
|
@@ -11818,6 +11838,8 @@ export default class binance extends Exchange {
|
|
|
11818
11838
|
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
11819
11839
|
* @param {boolean} [params.paginate] *spot only* default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
11820
11840
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
|
|
11841
|
+
* @param {string} [params.type] "spot"
|
|
11842
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
11821
11843
|
* @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
|
|
11822
11844
|
*/
|
|
11823
11845
|
await this.loadMarkets();
|
|
@@ -12143,8 +12165,8 @@ export default class binance extends Exchange {
|
|
|
12143
12165
|
* @name binance#fetchPositionMode
|
|
12144
12166
|
* @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
|
|
12145
12167
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
12146
|
-
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
12147
|
-
* @param {string} params.subType "linear" or "inverse"
|
|
12168
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
12169
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
12148
12170
|
* @returns {object} an object detailing whether the market is in hedged or one-way mode
|
|
12149
12171
|
*/
|
|
12150
12172
|
let market = undefined;
|
|
@@ -12182,6 +12204,7 @@ export default class binance extends Exchange {
|
|
|
12182
12204
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
12183
12205
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
12184
12206
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
12207
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
12185
12208
|
* @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
12186
12209
|
*/
|
|
12187
12210
|
await this.loadMarkets();
|
package/js/src/bingx.js
CHANGED
|
@@ -1867,6 +1867,7 @@ export default class bingx extends Exchange {
|
|
|
1867
1867
|
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
1868
1868
|
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
1869
1869
|
const trailingPercent = this.safeString2(params, 'trailingPercent', 'priceRate');
|
|
1870
|
+
const trailingType = this.safeString(params, 'trailingType', 'TRAILING_STOP_MARKET');
|
|
1870
1871
|
const isTriggerOrder = triggerPrice !== undefined;
|
|
1871
1872
|
const isStopLossPriceOrder = stopLossPrice !== undefined;
|
|
1872
1873
|
const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
|
|
@@ -1913,7 +1914,7 @@ export default class bingx extends Exchange {
|
|
|
1913
1914
|
}
|
|
1914
1915
|
}
|
|
1915
1916
|
else if (isTrailing) {
|
|
1916
|
-
request['type'] =
|
|
1917
|
+
request['type'] = trailingType;
|
|
1917
1918
|
if (isTrailingAmountOrder) {
|
|
1918
1919
|
request['price'] = this.parseToNumeric(trailingAmount);
|
|
1919
1920
|
}
|
|
@@ -1968,7 +1969,7 @@ export default class bingx extends Exchange {
|
|
|
1968
1969
|
}
|
|
1969
1970
|
request['positionSide'] = positionSide;
|
|
1970
1971
|
request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
|
|
1971
|
-
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss', 'clientOrderId']);
|
|
1972
|
+
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
|
|
1972
1973
|
}
|
|
1973
1974
|
return this.extend(request, params);
|
|
1974
1975
|
}
|
|
@@ -1999,14 +2000,22 @@ export default class bingx extends Exchange {
|
|
|
1999
2000
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
2000
2001
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
|
|
2001
2002
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
2003
|
+
* @param {boolean} [params.test] *swap only* whether to use the test endpoint or not, default is false
|
|
2002
2004
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2003
2005
|
*/
|
|
2004
2006
|
await this.loadMarkets();
|
|
2005
2007
|
const market = this.market(symbol);
|
|
2008
|
+
const test = this.safeBool(params, 'test', false);
|
|
2009
|
+
params = this.omit(params, 'test');
|
|
2006
2010
|
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
2007
2011
|
let response = undefined;
|
|
2008
2012
|
if (market['swap']) {
|
|
2009
|
-
|
|
2013
|
+
if (test) {
|
|
2014
|
+
response = await this.swapV2PrivatePostTradeOrderTest(request);
|
|
2015
|
+
}
|
|
2016
|
+
else {
|
|
2017
|
+
response = await this.swapV2PrivatePostTradeOrder(request);
|
|
2018
|
+
}
|
|
2010
2019
|
}
|
|
2011
2020
|
else {
|
|
2012
2021
|
response = await this.spotV1PrivatePostTradeOrder(request);
|
|
@@ -4060,7 +4069,7 @@ export default class bingx extends Exchange {
|
|
|
4060
4069
|
* @param {string} [params.newClientOrderId] custom order id consisting of letters, numbers, and _, 1-40 characters, different orders cannot use the same newClientOrderId.
|
|
4061
4070
|
* @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
|
|
4062
4071
|
* @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
|
|
4063
|
-
* @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market, Max = 1
|
|
4072
|
+
* @param {float} [params.priceRate] *contract only* for type TRAILING_STOP_Market or TRAILING_TP_SL, Max = 1
|
|
4064
4073
|
* @param {string} [params.workingType] *contract only* StopPrice trigger price types, MARK_PRICE (default), CONTRACT_PRICE, or INDEX_PRICE
|
|
4065
4074
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4066
4075
|
*/
|
package/js/src/bitmex.js
CHANGED
|
@@ -2550,7 +2550,9 @@ export default class bitmex extends Exchange {
|
|
|
2550
2550
|
if (until !== undefined) {
|
|
2551
2551
|
request['endTime'] = this.iso8601(until);
|
|
2552
2552
|
}
|
|
2553
|
-
|
|
2553
|
+
if ((since === undefined) && (until === undefined)) {
|
|
2554
|
+
request['reverse'] = true;
|
|
2555
|
+
}
|
|
2554
2556
|
const response = await this.publicGetFunding(this.extend(request, params));
|
|
2555
2557
|
//
|
|
2556
2558
|
// [
|
package/js/src/blofin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/blofin.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages, MarginMode } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class blofin
|
|
5
5
|
* @augments Exchange
|
|
@@ -116,6 +116,8 @@ export default class blofin extends Exchange {
|
|
|
116
116
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
117
117
|
closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
|
|
118
118
|
fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
119
|
+
fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
|
|
120
|
+
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
119
121
|
handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
120
122
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
121
123
|
url: string;
|
package/js/src/blofin.js
CHANGED
|
@@ -85,6 +85,8 @@ export default class blofin extends Exchange {
|
|
|
85
85
|
'fetchLeverage': true,
|
|
86
86
|
'fetchLeverages': true,
|
|
87
87
|
'fetchLeverageTiers': false,
|
|
88
|
+
'fetchMarginMode': true,
|
|
89
|
+
'fetchMarginModes': false,
|
|
88
90
|
'fetchMarketLeverageTiers': false,
|
|
89
91
|
'fetchMarkets': true,
|
|
90
92
|
'fetchMarkOHLCV': false,
|
|
@@ -188,6 +190,7 @@ export default class blofin extends Exchange {
|
|
|
188
190
|
'account/balance': 1,
|
|
189
191
|
'account/positions': 1,
|
|
190
192
|
'account/leverage-info': 1,
|
|
193
|
+
'account/margin-mode': 1,
|
|
191
194
|
'account/batch-leverage-info': 1,
|
|
192
195
|
'trade/orders-tpsl-pending': 1,
|
|
193
196
|
'trade/orders-history': 1,
|
|
@@ -2108,6 +2111,38 @@ export default class blofin extends Exchange {
|
|
|
2108
2111
|
const data = this.safeList(response, 'data', []);
|
|
2109
2112
|
return this.parseOrders(data, market, since, limit);
|
|
2110
2113
|
}
|
|
2114
|
+
async fetchMarginMode(symbol, params = {}) {
|
|
2115
|
+
/**
|
|
2116
|
+
* @method
|
|
2117
|
+
* @name blofin#fetchMarginMode
|
|
2118
|
+
* @description fetches the margin mode of a trading pair
|
|
2119
|
+
* @see https://docs.blofin.com/index.html#get-margin-mode
|
|
2120
|
+
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
|
2121
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2122
|
+
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
2123
|
+
*/
|
|
2124
|
+
await this.loadMarkets();
|
|
2125
|
+
const market = this.market(symbol);
|
|
2126
|
+
const response = await this.privateGetAccountMarginMode(params);
|
|
2127
|
+
//
|
|
2128
|
+
// {
|
|
2129
|
+
// "code": "0",
|
|
2130
|
+
// "msg": "success",
|
|
2131
|
+
// "data": {
|
|
2132
|
+
// "marginMode": "cross"
|
|
2133
|
+
// }
|
|
2134
|
+
// }
|
|
2135
|
+
//
|
|
2136
|
+
const data = this.safeDict(response, 'data', {});
|
|
2137
|
+
return this.parseMarginMode(data, market);
|
|
2138
|
+
}
|
|
2139
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
2140
|
+
return {
|
|
2141
|
+
'info': marginMode,
|
|
2142
|
+
'symbol': market['symbol'],
|
|
2143
|
+
'marginMode': this.safeString(marginMode, 'marginMode'),
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2111
2146
|
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2112
2147
|
if (response === undefined) {
|
|
2113
2148
|
return undefined; // fallback to default error handler
|
package/js/src/btcmarkets.js
CHANGED
|
@@ -917,6 +917,18 @@ export default class btcmarkets extends Exchange {
|
|
|
917
917
|
return await this.privateDeleteOrdersId(this.extend(request, params));
|
|
918
918
|
}
|
|
919
919
|
calculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) {
|
|
920
|
+
/**
|
|
921
|
+
* @method
|
|
922
|
+
* @description calculates the presumptive fee that would be charged for an order
|
|
923
|
+
* @param {string} symbol unified market symbol
|
|
924
|
+
* @param {string} type not used by btcmarkets.calculateFee
|
|
925
|
+
* @param {string} side not used by btcmarkets.calculateFee
|
|
926
|
+
* @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts
|
|
927
|
+
* @param {float} price the price for the order to be filled at, in units of the quote currency
|
|
928
|
+
* @param {string} takerOrMaker 'taker' or 'maker'
|
|
929
|
+
* @param {object} params
|
|
930
|
+
* @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
|
|
931
|
+
*/
|
|
920
932
|
const market = this.markets[symbol];
|
|
921
933
|
let currency = undefined;
|
|
922
934
|
let cost = undefined;
|
package/js/src/coinbase.js
CHANGED
|
@@ -3724,7 +3724,8 @@ export default class coinbase extends Exchange {
|
|
|
3724
3724
|
sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3725
3725
|
const version = api[0];
|
|
3726
3726
|
const signed = api[1] === 'private';
|
|
3727
|
-
const
|
|
3727
|
+
const isV3 = version === 'v3';
|
|
3728
|
+
const pathPart = (isV3) ? 'api/v3' : 'v2';
|
|
3728
3729
|
let fullPath = '/' + pathPart + '/' + this.implodeParams(path, params);
|
|
3729
3730
|
const query = this.omit(params, this.extractParams(path));
|
|
3730
3731
|
const savedPath = fullPath;
|
|
@@ -3768,8 +3769,17 @@ export default class coinbase extends Exchange {
|
|
|
3768
3769
|
payload = body;
|
|
3769
3770
|
}
|
|
3770
3771
|
}
|
|
3771
|
-
|
|
3772
|
+
else {
|
|
3773
|
+
if (!isV3) {
|
|
3774
|
+
if (Object.keys(query).length) {
|
|
3775
|
+
payload += '?' + this.urlencode(query);
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
// v3: 'GET' doesn't need payload in the signature. inside url is enough
|
|
3772
3780
|
// https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#example-request
|
|
3781
|
+
// v2: 'GET' require payload in the signature
|
|
3782
|
+
// https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-key-authentication
|
|
3773
3783
|
const auth = timestampString + method + savedPath + payload;
|
|
3774
3784
|
const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
|
|
3775
3785
|
headers = {
|
package/js/src/delta.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/delta.js';
|
|
2
|
-
import type { Balances, Currency, Greeks, Int, Market, MarketInterface, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Position, Leverage } from './base/types.js';
|
|
2
|
+
import type { Balances, Currency, Greeks, Int, Market, MarketInterface, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Position, Leverage, MarginMode } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class delta
|
|
5
5
|
* @augments Exchange
|
|
@@ -188,6 +188,8 @@ export default class delta extends Exchange {
|
|
|
188
188
|
info: any;
|
|
189
189
|
};
|
|
190
190
|
closeAllPositions(params?: {}): Promise<Position[]>;
|
|
191
|
+
fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
|
|
192
|
+
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
191
193
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
192
194
|
url: string;
|
|
193
195
|
method: string;
|
package/js/src/delta.js
CHANGED
|
@@ -54,7 +54,8 @@ export default class delta extends Exchange {
|
|
|
54
54
|
'fetchLedger': true,
|
|
55
55
|
'fetchLeverage': true,
|
|
56
56
|
'fetchLeverageTiers': false,
|
|
57
|
-
'fetchMarginMode':
|
|
57
|
+
'fetchMarginMode': true,
|
|
58
|
+
'fetchMarginModes': false,
|
|
58
59
|
'fetchMarketLeverageTiers': false,
|
|
59
60
|
'fetchMarkets': true,
|
|
60
61
|
'fetchMarkOHLCV': true,
|
|
@@ -3204,6 +3205,99 @@ export default class delta extends Exchange {
|
|
|
3204
3205
|
const position = this.parsePosition(this.safeValue(response, 'result', {}));
|
|
3205
3206
|
return [position];
|
|
3206
3207
|
}
|
|
3208
|
+
async fetchMarginMode(symbol, params = {}) {
|
|
3209
|
+
/**
|
|
3210
|
+
* @method
|
|
3211
|
+
* @name delta#fetchMarginMode
|
|
3212
|
+
* @description fetches the margin mode of a trading pair
|
|
3213
|
+
* @see https://docs.delta.exchange/#get-user
|
|
3214
|
+
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
|
3215
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3216
|
+
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
3217
|
+
*/
|
|
3218
|
+
await this.loadMarkets();
|
|
3219
|
+
let market = undefined;
|
|
3220
|
+
if (symbol !== undefined) {
|
|
3221
|
+
market = this.market(symbol);
|
|
3222
|
+
}
|
|
3223
|
+
const response = await this.privateGetProfile(params);
|
|
3224
|
+
//
|
|
3225
|
+
// {
|
|
3226
|
+
// "result": {
|
|
3227
|
+
// "is_password_set": true,
|
|
3228
|
+
// "kyc_expiry_date": null,
|
|
3229
|
+
// "phishing_code": "12345",
|
|
3230
|
+
// "preferences": {
|
|
3231
|
+
// "favorites": []
|
|
3232
|
+
// },
|
|
3233
|
+
// "is_kyc_provisioned": false,
|
|
3234
|
+
// "country": "Canada",
|
|
3235
|
+
// "margin_mode": "isolated",
|
|
3236
|
+
// "mfa_updated_at": "2023-07-19T01:04:43Z",
|
|
3237
|
+
// "last_name": "",
|
|
3238
|
+
// "oauth_apple_active": false,
|
|
3239
|
+
// "pf_index_symbol": null,
|
|
3240
|
+
// "proof_of_identity_status": "approved",
|
|
3241
|
+
// "dob": null,
|
|
3242
|
+
// "email": "abc_123@gmail.com",
|
|
3243
|
+
// "force_change_password": false,
|
|
3244
|
+
// "nick_name": "still-breeze-123",
|
|
3245
|
+
// "oauth_google_active": false,
|
|
3246
|
+
// "phone_verification_status": "verified",
|
|
3247
|
+
// "id": 12345678,
|
|
3248
|
+
// "last_seen": null,
|
|
3249
|
+
// "is_withdrawal_enabled": true,
|
|
3250
|
+
// "force_change_mfa": false,
|
|
3251
|
+
// "enable_bots": false,
|
|
3252
|
+
// "kyc_verified_on": null,
|
|
3253
|
+
// "created_at": "2023-07-19T01:02:32Z",
|
|
3254
|
+
// "withdrawal_blocked_till": null,
|
|
3255
|
+
// "proof_of_address_status": "approved",
|
|
3256
|
+
// "is_password_change_blocked": false,
|
|
3257
|
+
// "is_mfa_enabled": true,
|
|
3258
|
+
// "is_kyc_done": true,
|
|
3259
|
+
// "oauth": null,
|
|
3260
|
+
// "account_name": "Main",
|
|
3261
|
+
// "sub_account_permissions": null,
|
|
3262
|
+
// "phone_number": null,
|
|
3263
|
+
// "tracking_info": {
|
|
3264
|
+
// "ga_cid": "1234.4321",
|
|
3265
|
+
// "is_kyc_gtm_tracked": true,
|
|
3266
|
+
// "sub_account_config": {
|
|
3267
|
+
// "cross": 2,
|
|
3268
|
+
// "isolated": 2,
|
|
3269
|
+
// "portfolio": 2
|
|
3270
|
+
// }
|
|
3271
|
+
// },
|
|
3272
|
+
// "first_name": "",
|
|
3273
|
+
// "phone_verified_on": null,
|
|
3274
|
+
// "seen_intro": false,
|
|
3275
|
+
// "password_updated_at": null,
|
|
3276
|
+
// "is_login_enabled": true,
|
|
3277
|
+
// "registration_date": "2023-07-19T01:02:32Z",
|
|
3278
|
+
// "permissions": {},
|
|
3279
|
+
// "max_sub_accounts_limit": 2,
|
|
3280
|
+
// "country_calling_code": null,
|
|
3281
|
+
// "is_sub_account": false,
|
|
3282
|
+
// "is_kyc_refresh_required": false
|
|
3283
|
+
// },
|
|
3284
|
+
// "success": true
|
|
3285
|
+
// }
|
|
3286
|
+
//
|
|
3287
|
+
const result = this.safeDict(response, 'result', {});
|
|
3288
|
+
return this.parseMarginMode(result, market);
|
|
3289
|
+
}
|
|
3290
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
3291
|
+
let symbol = undefined;
|
|
3292
|
+
if (market !== undefined) {
|
|
3293
|
+
symbol = market['symbol'];
|
|
3294
|
+
}
|
|
3295
|
+
return {
|
|
3296
|
+
'info': marginMode,
|
|
3297
|
+
'symbol': symbol,
|
|
3298
|
+
'marginMode': this.safeString(marginMode, 'margin_mode'),
|
|
3299
|
+
};
|
|
3300
|
+
}
|
|
3207
3301
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3208
3302
|
const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
|
|
3209
3303
|
let url = this.urls['api'][api] + requestPath;
|
package/js/src/gate.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenI
|
|
|
6
6
|
*/
|
|
7
7
|
export default class gate extends Exchange {
|
|
8
8
|
describe(): any;
|
|
9
|
-
setSandboxMode(enable:
|
|
9
|
+
setSandboxMode(enable: boolean): void;
|
|
10
10
|
convertExpireDate(date: any): string;
|
|
11
11
|
createExpiredOptionMarket(symbol: string): MarketInterface;
|
|
12
12
|
safeMarket(marketId?: any, market?: any, delimiter?: any, marketType?: any): MarketInterface;
|