ccxt 4.2.21 → 4.2.23
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 +574 -81
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bigone.js +1 -0
- package/dist/cjs/src/binance.js +14 -3
- package/dist/cjs/src/bitfinex2.js +89 -0
- package/dist/cjs/src/bitget.js +11 -1
- package/dist/cjs/src/bitrue.js +1 -0
- package/dist/cjs/src/bybit.js +57 -9
- package/dist/cjs/src/coinbasepro.js +1 -0
- package/dist/cjs/src/coinex.js +60 -14
- package/dist/cjs/src/deribit.js +164 -0
- package/dist/cjs/src/okcoin.js +3 -0
- package/dist/cjs/src/okx.js +81 -31
- package/dist/cjs/src/phemex.js +17 -5
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/bequant.js +6 -1
- package/dist/cjs/src/pro/binance.js +8 -5
- package/dist/cjs/src/pro/binancecoinm.js +6 -1
- package/dist/cjs/src/pro/binanceus.js +6 -1
- package/dist/cjs/src/pro/bitcoincom.js +6 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitrue.js +6 -1
- package/dist/cjs/src/pro/hitbtc.js +6 -0
- package/dist/cjs/src/pro/okx.js +23 -5
- package/dist/cjs/src/woo.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +3 -0
- package/js/src/abstract/binancecoinm.d.ts +3 -0
- package/js/src/abstract/binanceus.d.ts +4 -0
- package/js/src/abstract/binanceusdm.d.ts +3 -0
- package/js/src/bigone.js +1 -0
- package/js/src/binance.js +14 -3
- package/js/src/bitfinex2.d.ts +2 -0
- package/js/src/bitfinex2.js +89 -0
- package/js/src/bitget.js +11 -1
- package/js/src/bitrue.js +1 -0
- package/js/src/bybit.d.ts +2 -1
- package/js/src/bybit.js +57 -9
- package/js/src/coinbasepro.js +1 -0
- package/js/src/coinex.d.ts +1 -0
- package/js/src/coinex.js +60 -14
- package/js/src/deribit.d.ts +6 -1
- package/js/src/deribit.js +164 -0
- package/js/src/okcoin.js +3 -0
- package/js/src/okx.js +81 -31
- package/js/src/phemex.js +17 -5
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/bequant.js +6 -1
- package/js/src/pro/binance.js +8 -5
- package/js/src/pro/binancecoinm.js +6 -1
- package/js/src/pro/binanceus.js +6 -1
- package/js/src/pro/bitcoincom.js +6 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitrue.js +6 -1
- package/js/src/pro/hitbtc.js +6 -0
- package/js/src/pro/okx.js +23 -5
- package/js/src/woo.js +1 -1
- package/jsdoc2md.js +38 -16
- package/package.json +4 -1
- package/skip-tests.json +4 -0
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.22";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.23';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -93,6 +93,7 @@ interface Exchange {
|
|
|
93
93
|
sapiGetConvertExchangeInfo(params?: {}): Promise<implicitReturnType>;
|
|
94
94
|
sapiGetConvertAssetInfo(params?: {}): Promise<implicitReturnType>;
|
|
95
95
|
sapiGetConvertOrderStatus(params?: {}): Promise<implicitReturnType>;
|
|
96
|
+
sapiGetConvertLimitQueryOpenOrders(params?: {}): Promise<implicitReturnType>;
|
|
96
97
|
sapiGetAccountStatus(params?: {}): Promise<implicitReturnType>;
|
|
97
98
|
sapiGetAccountApiTradingStatus(params?: {}): Promise<implicitReturnType>;
|
|
98
99
|
sapiGetAccountApiRestrictionsIpRestriction(params?: {}): Promise<implicitReturnType>;
|
|
@@ -338,6 +339,8 @@ interface Exchange {
|
|
|
338
339
|
sapiPostLoanVipRepay(params?: {}): Promise<implicitReturnType>;
|
|
339
340
|
sapiPostConvertGetQuote(params?: {}): Promise<implicitReturnType>;
|
|
340
341
|
sapiPostConvertAcceptQuote(params?: {}): Promise<implicitReturnType>;
|
|
342
|
+
sapiPostConvertLimitPlaceOrder(params?: {}): Promise<implicitReturnType>;
|
|
343
|
+
sapiPostConvertLimitCancelOrder(params?: {}): Promise<implicitReturnType>;
|
|
341
344
|
sapiPostPortfolioAutoCollection(params?: {}): Promise<implicitReturnType>;
|
|
342
345
|
sapiPostPortfolioAssetCollection(params?: {}): Promise<implicitReturnType>;
|
|
343
346
|
sapiPostPortfolioBnbTransfer(params?: {}): Promise<implicitReturnType>;
|
|
@@ -93,6 +93,7 @@ interface binance {
|
|
|
93
93
|
sapiGetConvertExchangeInfo(params?: {}): Promise<implicitReturnType>;
|
|
94
94
|
sapiGetConvertAssetInfo(params?: {}): Promise<implicitReturnType>;
|
|
95
95
|
sapiGetConvertOrderStatus(params?: {}): Promise<implicitReturnType>;
|
|
96
|
+
sapiGetConvertLimitQueryOpenOrders(params?: {}): Promise<implicitReturnType>;
|
|
96
97
|
sapiGetAccountStatus(params?: {}): Promise<implicitReturnType>;
|
|
97
98
|
sapiGetAccountApiTradingStatus(params?: {}): Promise<implicitReturnType>;
|
|
98
99
|
sapiGetAccountApiRestrictionsIpRestriction(params?: {}): Promise<implicitReturnType>;
|
|
@@ -338,6 +339,8 @@ interface binance {
|
|
|
338
339
|
sapiPostLoanVipRepay(params?: {}): Promise<implicitReturnType>;
|
|
339
340
|
sapiPostConvertGetQuote(params?: {}): Promise<implicitReturnType>;
|
|
340
341
|
sapiPostConvertAcceptQuote(params?: {}): Promise<implicitReturnType>;
|
|
342
|
+
sapiPostConvertLimitPlaceOrder(params?: {}): Promise<implicitReturnType>;
|
|
343
|
+
sapiPostConvertLimitCancelOrder(params?: {}): Promise<implicitReturnType>;
|
|
341
344
|
sapiPostPortfolioAutoCollection(params?: {}): Promise<implicitReturnType>;
|
|
342
345
|
sapiPostPortfolioAssetCollection(params?: {}): Promise<implicitReturnType>;
|
|
343
346
|
sapiPostPortfolioBnbTransfer(params?: {}): Promise<implicitReturnType>;
|
|
@@ -93,6 +93,7 @@ interface binance {
|
|
|
93
93
|
sapiGetConvertExchangeInfo(params?: {}): Promise<implicitReturnType>;
|
|
94
94
|
sapiGetConvertAssetInfo(params?: {}): Promise<implicitReturnType>;
|
|
95
95
|
sapiGetConvertOrderStatus(params?: {}): Promise<implicitReturnType>;
|
|
96
|
+
sapiGetConvertLimitQueryOpenOrders(params?: {}): Promise<implicitReturnType>;
|
|
96
97
|
sapiGetAccountStatus(params?: {}): Promise<implicitReturnType>;
|
|
97
98
|
sapiGetAccountApiTradingStatus(params?: {}): Promise<implicitReturnType>;
|
|
98
99
|
sapiGetAccountApiRestrictionsIpRestriction(params?: {}): Promise<implicitReturnType>;
|
|
@@ -338,6 +339,8 @@ interface binance {
|
|
|
338
339
|
sapiPostLoanVipRepay(params?: {}): Promise<implicitReturnType>;
|
|
339
340
|
sapiPostConvertGetQuote(params?: {}): Promise<implicitReturnType>;
|
|
340
341
|
sapiPostConvertAcceptQuote(params?: {}): Promise<implicitReturnType>;
|
|
342
|
+
sapiPostConvertLimitPlaceOrder(params?: {}): Promise<implicitReturnType>;
|
|
343
|
+
sapiPostConvertLimitCancelOrder(params?: {}): Promise<implicitReturnType>;
|
|
341
344
|
sapiPostPortfolioAutoCollection(params?: {}): Promise<implicitReturnType>;
|
|
342
345
|
sapiPostPortfolioAssetCollection(params?: {}): Promise<implicitReturnType>;
|
|
343
346
|
sapiPostPortfolioBnbTransfer(params?: {}): Promise<implicitReturnType>;
|
|
@@ -591,6 +594,7 @@ interface binance {
|
|
|
591
594
|
privateGetMyPreventedMatches(params?: {}): Promise<implicitReturnType>;
|
|
592
595
|
privateGetMyAllocations(params?: {}): Promise<implicitReturnType>;
|
|
593
596
|
privateGetAccountCommission(params?: {}): Promise<implicitReturnType>;
|
|
597
|
+
privateGetStatus(params?: {}): Promise<implicitReturnType>;
|
|
594
598
|
privatePostOrderOco(params?: {}): Promise<implicitReturnType>;
|
|
595
599
|
privatePostSorOrder(params?: {}): Promise<implicitReturnType>;
|
|
596
600
|
privatePostSorOrderTest(params?: {}): Promise<implicitReturnType>;
|
|
@@ -93,6 +93,7 @@ interface binance {
|
|
|
93
93
|
sapiGetConvertExchangeInfo(params?: {}): Promise<implicitReturnType>;
|
|
94
94
|
sapiGetConvertAssetInfo(params?: {}): Promise<implicitReturnType>;
|
|
95
95
|
sapiGetConvertOrderStatus(params?: {}): Promise<implicitReturnType>;
|
|
96
|
+
sapiGetConvertLimitQueryOpenOrders(params?: {}): Promise<implicitReturnType>;
|
|
96
97
|
sapiGetAccountStatus(params?: {}): Promise<implicitReturnType>;
|
|
97
98
|
sapiGetAccountApiTradingStatus(params?: {}): Promise<implicitReturnType>;
|
|
98
99
|
sapiGetAccountApiRestrictionsIpRestriction(params?: {}): Promise<implicitReturnType>;
|
|
@@ -338,6 +339,8 @@ interface binance {
|
|
|
338
339
|
sapiPostLoanVipRepay(params?: {}): Promise<implicitReturnType>;
|
|
339
340
|
sapiPostConvertGetQuote(params?: {}): Promise<implicitReturnType>;
|
|
340
341
|
sapiPostConvertAcceptQuote(params?: {}): Promise<implicitReturnType>;
|
|
342
|
+
sapiPostConvertLimitPlaceOrder(params?: {}): Promise<implicitReturnType>;
|
|
343
|
+
sapiPostConvertLimitCancelOrder(params?: {}): Promise<implicitReturnType>;
|
|
341
344
|
sapiPostPortfolioAutoCollection(params?: {}): Promise<implicitReturnType>;
|
|
342
345
|
sapiPostPortfolioAssetCollection(params?: {}): Promise<implicitReturnType>;
|
|
343
346
|
sapiPostPortfolioBnbTransfer(params?: {}): Promise<implicitReturnType>;
|
package/js/src/bigone.js
CHANGED
package/js/src/binance.js
CHANGED
|
@@ -311,6 +311,7 @@ export default class binance extends Exchange {
|
|
|
311
311
|
'convert/exchangeInfo': 50,
|
|
312
312
|
'convert/assetInfo': 10,
|
|
313
313
|
'convert/orderStatus': 0.6667,
|
|
314
|
+
'convert/limit/queryOpenOrders': 20.001,
|
|
314
315
|
'account/status': 0.1,
|
|
315
316
|
'account/apiTradingStatus': 0.1,
|
|
316
317
|
'account/apiRestrictions/ipRestriction': 0.1,
|
|
@@ -582,6 +583,8 @@ export default class binance extends Exchange {
|
|
|
582
583
|
'loan/vip/repay': 40.002,
|
|
583
584
|
'convert/getQuote': 1.3334,
|
|
584
585
|
'convert/acceptQuote': 3.3335,
|
|
586
|
+
'convert/limit/placeOrder': 3.3335,
|
|
587
|
+
'convert/limit/cancelOrder': 1.3334,
|
|
585
588
|
'portfolio/auto-collection': 150,
|
|
586
589
|
'portfolio/asset-collection': 6,
|
|
587
590
|
'portfolio/bnb-transfer': 150,
|
|
@@ -7968,12 +7971,20 @@ export default class binance extends Exchange {
|
|
|
7968
7971
|
/**
|
|
7969
7972
|
* @method
|
|
7970
7973
|
* @name binance#fetchPositions
|
|
7974
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
|
|
7975
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
|
|
7976
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
7977
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
7978
|
+
* @see https://binance-docs.github.io/apidocs/voptions/en/#option-position-information-user_data
|
|
7971
7979
|
* @description fetch all open positions
|
|
7972
|
-
* @param {string[]
|
|
7980
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
7973
7981
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7982
|
+
* @param {string} [method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
|
|
7974
7983
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
7975
7984
|
*/
|
|
7976
|
-
const
|
|
7985
|
+
const defaultValue = this.safeString(this.options, 'fetchPositions', 'positionRisk');
|
|
7986
|
+
let defaultMethod = undefined;
|
|
7987
|
+
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', defaultValue);
|
|
7977
7988
|
if (defaultMethod === 'positionRisk') {
|
|
7978
7989
|
return await this.fetchPositionsRisk(symbols, params);
|
|
7979
7990
|
}
|
|
@@ -7984,7 +7995,7 @@ export default class binance extends Exchange {
|
|
|
7984
7995
|
return await this.fetchOptionPositions(symbols, params);
|
|
7985
7996
|
}
|
|
7986
7997
|
else {
|
|
7987
|
-
throw new NotSupported(this.id + '.options["fetchPositions"] = "' + defaultMethod + '" is invalid, please choose between "account", "positionRisk" and "option"');
|
|
7998
|
+
throw new NotSupported(this.id + '.options["fetchPositions"]/params["method"] = "' + defaultMethod + '" is invalid, please choose between "account", "positionRisk" and "option"');
|
|
7988
7999
|
}
|
|
7989
8000
|
}
|
|
7990
8001
|
async fetchAccountPositions(symbols = undefined, params = {}) {
|
package/js/src/bitfinex2.d.ts
CHANGED
|
@@ -156,4 +156,6 @@ export default class bitfinex2 extends Exchange {
|
|
|
156
156
|
previousFundingTimestamp: any;
|
|
157
157
|
previousFundingDatetime: any;
|
|
158
158
|
};
|
|
159
|
+
fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
|
|
160
|
+
parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
|
|
159
161
|
}
|
package/js/src/bitfinex2.js
CHANGED
|
@@ -57,6 +57,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
57
57
|
'fetchMarkOHLCV': false,
|
|
58
58
|
'fetchMyTrades': true,
|
|
59
59
|
'fetchOHLCV': true,
|
|
60
|
+
'fetchOpenInterest': true,
|
|
60
61
|
'fetchOpenOrder': true,
|
|
61
62
|
'fetchOpenOrders': true,
|
|
62
63
|
'fetchOrder': true,
|
|
@@ -2988,4 +2989,92 @@ export default class bitfinex2 extends Exchange {
|
|
|
2988
2989
|
'previousFundingDatetime': undefined,
|
|
2989
2990
|
};
|
|
2990
2991
|
}
|
|
2992
|
+
async fetchOpenInterest(symbol, params = {}) {
|
|
2993
|
+
/**
|
|
2994
|
+
* @method
|
|
2995
|
+
* @name bitfinex2#fetchOpenInterest
|
|
2996
|
+
* @description retrieves the open interest of a contract trading pair
|
|
2997
|
+
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2998
|
+
* @param {string} symbol unified CCXT market symbol
|
|
2999
|
+
* @param {object} [params] exchange specific parameters
|
|
3000
|
+
* @returns {object} an [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
3001
|
+
*/
|
|
3002
|
+
await this.loadMarkets();
|
|
3003
|
+
const market = this.market(symbol);
|
|
3004
|
+
const request = {
|
|
3005
|
+
'keys': market['id'],
|
|
3006
|
+
};
|
|
3007
|
+
const response = await this.publicGetStatusDeriv(this.extend(request, params));
|
|
3008
|
+
//
|
|
3009
|
+
// [
|
|
3010
|
+
// [
|
|
3011
|
+
// "tXRPF0:USTF0", // market id
|
|
3012
|
+
// 1706256986000, // millisecond timestamp
|
|
3013
|
+
// null,
|
|
3014
|
+
// 0.512705, // derivative mid price
|
|
3015
|
+
// 0.512395, // underlying spot mid price
|
|
3016
|
+
// null,
|
|
3017
|
+
// 37671483.04, // insurance fund balance
|
|
3018
|
+
// null,
|
|
3019
|
+
// 1706284800000, // timestamp of next funding
|
|
3020
|
+
// 0.00002353, // accrued funding for next period
|
|
3021
|
+
// 317, // next funding step
|
|
3022
|
+
// null,
|
|
3023
|
+
// 0, // current funding
|
|
3024
|
+
// null,
|
|
3025
|
+
// null,
|
|
3026
|
+
// 0.5123016, // mark price
|
|
3027
|
+
// null,
|
|
3028
|
+
// null,
|
|
3029
|
+
// 2233562.03115, // open interest in contracts
|
|
3030
|
+
// null,
|
|
3031
|
+
// null,
|
|
3032
|
+
// null,
|
|
3033
|
+
// 0.0005, // average spread without funding payment
|
|
3034
|
+
// 0.0025 // funding payment cap
|
|
3035
|
+
// ]
|
|
3036
|
+
// ]
|
|
3037
|
+
//
|
|
3038
|
+
return this.parseOpenInterest(response[0], market);
|
|
3039
|
+
}
|
|
3040
|
+
parseOpenInterest(interest, market = undefined) {
|
|
3041
|
+
//
|
|
3042
|
+
// [
|
|
3043
|
+
// "tXRPF0:USTF0", // market id
|
|
3044
|
+
// 1706256986000, // millisecond timestamp
|
|
3045
|
+
// null,
|
|
3046
|
+
// 0.512705, // derivative mid price
|
|
3047
|
+
// 0.512395, // underlying spot mid price
|
|
3048
|
+
// null,
|
|
3049
|
+
// 37671483.04, // insurance fund balance
|
|
3050
|
+
// null,
|
|
3051
|
+
// 1706284800000, // timestamp of next funding
|
|
3052
|
+
// 0.00002353, // accrued funding for next period
|
|
3053
|
+
// 317, // next funding step
|
|
3054
|
+
// null,
|
|
3055
|
+
// 0, // current funding
|
|
3056
|
+
// null,
|
|
3057
|
+
// null,
|
|
3058
|
+
// 0.5123016, // mark price
|
|
3059
|
+
// null,
|
|
3060
|
+
// null,
|
|
3061
|
+
// 2233562.03115, // open interest in contracts
|
|
3062
|
+
// null,
|
|
3063
|
+
// null,
|
|
3064
|
+
// null,
|
|
3065
|
+
// 0.0005, // average spread without funding payment
|
|
3066
|
+
// 0.0025 // funding payment cap
|
|
3067
|
+
// ]
|
|
3068
|
+
//
|
|
3069
|
+
const timestamp = this.safeInteger(interest, 1);
|
|
3070
|
+
const marketId = this.safeString(interest, 0);
|
|
3071
|
+
return this.safeOpenInterest({
|
|
3072
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3073
|
+
'openInterestAmount': this.safeNumber(interest, 18),
|
|
3074
|
+
'openInterestValue': undefined,
|
|
3075
|
+
'timestamp': timestamp,
|
|
3076
|
+
'datetime': this.iso8601(timestamp),
|
|
3077
|
+
'info': interest,
|
|
3078
|
+
}, market);
|
|
3079
|
+
}
|
|
2991
3080
|
}
|
package/js/src/bitget.js
CHANGED
|
@@ -40,15 +40,21 @@ export default class bitget extends Exchange {
|
|
|
40
40
|
'cancelOrders': true,
|
|
41
41
|
'closeAllPositions': true,
|
|
42
42
|
'closePosition': true,
|
|
43
|
+
'createDepositAddress': false,
|
|
43
44
|
'createMarketBuyOrderWithCost': true,
|
|
44
45
|
'createMarketOrderWithCost': false,
|
|
45
46
|
'createMarketSellOrderWithCost': false,
|
|
46
47
|
'createOrder': true,
|
|
47
48
|
'createOrders': true,
|
|
48
49
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
50
|
+
'createPostOnlyOrder': true,
|
|
49
51
|
'createReduceOnlyOrder': false,
|
|
52
|
+
'createStopLimitOrder': true,
|
|
50
53
|
'createStopLossOrder': true,
|
|
54
|
+
'createStopMarketOrder': true,
|
|
55
|
+
'createStopOrder': true,
|
|
51
56
|
'createTakeProfitOrder': true,
|
|
57
|
+
'createTrailingAmountOrder': false,
|
|
52
58
|
'createTrailingPercentOrder': true,
|
|
53
59
|
'createTriggerOrder': true,
|
|
54
60
|
'editOrder': true,
|
|
@@ -66,6 +72,7 @@ export default class bitget extends Exchange {
|
|
|
66
72
|
'fetchDepositAddress': true,
|
|
67
73
|
'fetchDepositAddresses': false,
|
|
68
74
|
'fetchDeposits': true,
|
|
75
|
+
'fetchDepositsWithdrawals': false,
|
|
69
76
|
'fetchDepositWithdrawFee': 'emulated',
|
|
70
77
|
'fetchDepositWithdrawFees': true,
|
|
71
78
|
'fetchFundingHistory': true,
|
|
@@ -79,7 +86,7 @@ export default class bitget extends Exchange {
|
|
|
79
86
|
'fetchLeverage': true,
|
|
80
87
|
'fetchLeverageTiers': false,
|
|
81
88
|
'fetchLiquidations': false,
|
|
82
|
-
'fetchMarginMode':
|
|
89
|
+
'fetchMarginMode': false,
|
|
83
90
|
'fetchMarketLeverageTiers': true,
|
|
84
91
|
'fetchMarkets': true,
|
|
85
92
|
'fetchMarkOHLCV': true,
|
|
@@ -104,8 +111,10 @@ export default class bitget extends Exchange {
|
|
|
104
111
|
'fetchTrades': true,
|
|
105
112
|
'fetchTradingFee': true,
|
|
106
113
|
'fetchTradingFees': true,
|
|
114
|
+
'fetchTransactions': false,
|
|
107
115
|
'fetchTransfer': false,
|
|
108
116
|
'fetchTransfers': true,
|
|
117
|
+
'fetchWithdrawAddresses': false,
|
|
109
118
|
'fetchWithdrawal': false,
|
|
110
119
|
'fetchWithdrawals': true,
|
|
111
120
|
'reduceMargin': true,
|
|
@@ -114,6 +123,7 @@ export default class bitget extends Exchange {
|
|
|
114
123
|
'setLeverage': true,
|
|
115
124
|
'setMarginMode': true,
|
|
116
125
|
'setPositionMode': true,
|
|
126
|
+
'signIn': false,
|
|
117
127
|
'transfer': true,
|
|
118
128
|
'withdraw': true,
|
|
119
129
|
},
|
package/js/src/bitrue.js
CHANGED
|
@@ -55,6 +55,7 @@ export default class bitrue extends Exchange {
|
|
|
55
55
|
'fetchDepositsWithdrawals': false,
|
|
56
56
|
'fetchDepositWithdrawFee': 'emulated',
|
|
57
57
|
'fetchDepositWithdrawFees': true,
|
|
58
|
+
'fetchFundingRate': false,
|
|
58
59
|
'fetchIsolatedBorrowRate': false,
|
|
59
60
|
'fetchIsolatedBorrowRates': false,
|
|
60
61
|
'fetchMarginMode': false,
|
package/js/src/bybit.d.ts
CHANGED
|
@@ -58,8 +58,9 @@ export default class bybit extends Exchange {
|
|
|
58
58
|
parseOrder(order: any, market?: Market): Order;
|
|
59
59
|
fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
60
60
|
createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
61
|
+
createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
61
62
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
62
|
-
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
|
|
63
|
+
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}, isUTA?: boolean): any;
|
|
63
64
|
createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
|
|
64
65
|
createUsdcOrder(symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
65
66
|
editUsdcOrder(id: any, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
|
package/js/src/bybit.js
CHANGED
|
@@ -41,7 +41,7 @@ export default class bybit extends Exchange {
|
|
|
41
41
|
'closeAllPositions': false,
|
|
42
42
|
'closePosition': false,
|
|
43
43
|
'createMarketBuyOrderWithCost': true,
|
|
44
|
-
'createMarketSellOrderWithCost':
|
|
44
|
+
'createMarketSellOrderWithCost': true,
|
|
45
45
|
'createOrder': true,
|
|
46
46
|
'createOrders': true,
|
|
47
47
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
@@ -3471,8 +3471,30 @@ export default class bybit extends Exchange {
|
|
|
3471
3471
|
if (!market['spot']) {
|
|
3472
3472
|
throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
3473
3473
|
}
|
|
3474
|
-
|
|
3475
|
-
|
|
3474
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, 1, params);
|
|
3475
|
+
}
|
|
3476
|
+
async createMarketSellOrderWithCost(symbol, cost, params = {}) {
|
|
3477
|
+
/**
|
|
3478
|
+
* @method
|
|
3479
|
+
* @name bybit#createMarkeSellOrderWithCost
|
|
3480
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/create-order
|
|
3481
|
+
* @description create a market sell order by providing the symbol and cost
|
|
3482
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
3483
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
3484
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3485
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3486
|
+
*/
|
|
3487
|
+
await this.loadMarkets();
|
|
3488
|
+
const types = await this.isUnifiedEnabled();
|
|
3489
|
+
const enableUnifiedAccount = types[1];
|
|
3490
|
+
if (!enableUnifiedAccount) {
|
|
3491
|
+
throw new NotSupported(this.id + ' createMarketSellOrderWithCost() supports UTA accounts only');
|
|
3492
|
+
}
|
|
3493
|
+
const market = this.market(symbol);
|
|
3494
|
+
if (!market['spot']) {
|
|
3495
|
+
throw new NotSupported(this.id + ' createMarketSellOrderWithCost() supports spot orders only');
|
|
3496
|
+
}
|
|
3497
|
+
return await this.createOrder(symbol, 'market', 'sell', cost, 1, params);
|
|
3476
3498
|
}
|
|
3477
3499
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
3478
3500
|
/**
|
|
@@ -3516,7 +3538,7 @@ export default class bybit extends Exchange {
|
|
|
3516
3538
|
}
|
|
3517
3539
|
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
|
|
3518
3540
|
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
3519
|
-
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
3541
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount);
|
|
3520
3542
|
let response = undefined;
|
|
3521
3543
|
if (isTrailingAmountOrder) {
|
|
3522
3544
|
response = await this.privatePostV5PositionTradingStop(orderRequest);
|
|
@@ -3539,7 +3561,7 @@ export default class bybit extends Exchange {
|
|
|
3539
3561
|
const order = this.safeValue(response, 'result', {});
|
|
3540
3562
|
return this.parseOrder(order, market);
|
|
3541
3563
|
}
|
|
3542
|
-
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
3564
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}, isUTA = true) {
|
|
3543
3565
|
const market = this.market(symbol);
|
|
3544
3566
|
symbol = market['symbol'];
|
|
3545
3567
|
const lowerCaseType = type.toLowerCase();
|
|
@@ -3583,12 +3605,36 @@ export default class bybit extends Exchange {
|
|
|
3583
3605
|
else if (market['option']) {
|
|
3584
3606
|
request['category'] = 'option';
|
|
3585
3607
|
}
|
|
3586
|
-
|
|
3608
|
+
const cost = this.safeString(params, 'cost');
|
|
3609
|
+
params = this.omit(params, 'cost');
|
|
3610
|
+
// if the cost is inferable, let's keep the old logic and ignore marketUnit, to minimize the impact of the changes
|
|
3611
|
+
const isMarketBuyAndCostInferable = (lowerCaseType === 'market') && (side === 'buy') && ((price !== undefined) || (cost !== undefined));
|
|
3612
|
+
if (market['spot'] && (type === 'market') && isUTA && !isMarketBuyAndCostInferable) {
|
|
3613
|
+
// UTA account can specify the cost of the order on both sides
|
|
3614
|
+
if ((cost !== undefined) || (price !== undefined)) {
|
|
3615
|
+
request['marketUnit'] = 'quoteCoin';
|
|
3616
|
+
let orderCost = undefined;
|
|
3617
|
+
if (cost !== undefined) {
|
|
3618
|
+
orderCost = cost;
|
|
3619
|
+
}
|
|
3620
|
+
else {
|
|
3621
|
+
const amountString = this.numberToString(amount);
|
|
3622
|
+
const priceString = this.numberToString(price);
|
|
3623
|
+
const quoteAmount = Precise.stringMul(amountString, priceString);
|
|
3624
|
+
orderCost = quoteAmount;
|
|
3625
|
+
}
|
|
3626
|
+
request['qty'] = this.costToPrecision(symbol, orderCost);
|
|
3627
|
+
}
|
|
3628
|
+
else {
|
|
3629
|
+
request['marketUnit'] = 'baseCoin';
|
|
3630
|
+
request['qty'] = this.amountToPrecision(symbol, amount);
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
else if (market['spot'] && (type === 'market') && (side === 'buy')) {
|
|
3634
|
+
// classic accounts
|
|
3587
3635
|
// for market buy it requires the amount of quote currency to spend
|
|
3588
3636
|
let createMarketBuyOrderRequiresPrice = true;
|
|
3589
3637
|
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
3590
|
-
const cost = this.safeNumber(params, 'cost');
|
|
3591
|
-
params = this.omit(params, 'cost');
|
|
3592
3638
|
if (createMarketBuyOrderRequiresPrice) {
|
|
3593
3639
|
if ((price === undefined) && (cost === undefined)) {
|
|
3594
3640
|
throw new InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
|
|
@@ -3715,6 +3761,8 @@ export default class bybit extends Exchange {
|
|
|
3715
3761
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3716
3762
|
*/
|
|
3717
3763
|
await this.loadMarkets();
|
|
3764
|
+
const accounts = await this.isUnifiedEnabled();
|
|
3765
|
+
const isUta = accounts[1];
|
|
3718
3766
|
const ordersRequests = [];
|
|
3719
3767
|
const orderSymbols = [];
|
|
3720
3768
|
for (let i = 0; i < orders.length; i++) {
|
|
@@ -3726,7 +3774,7 @@ export default class bybit extends Exchange {
|
|
|
3726
3774
|
const amount = this.safeValue(rawOrder, 'amount');
|
|
3727
3775
|
const price = this.safeValue(rawOrder, 'price');
|
|
3728
3776
|
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
3729
|
-
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
3777
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams, isUta);
|
|
3730
3778
|
ordersRequests.push(orderRequest);
|
|
3731
3779
|
}
|
|
3732
3780
|
const symbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
|
package/js/src/coinbasepro.js
CHANGED
package/js/src/coinex.d.ts
CHANGED
|
@@ -207,6 +207,7 @@ export default class coinex extends Exchange {
|
|
|
207
207
|
};
|
|
208
208
|
fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<{}>;
|
|
209
209
|
parseDepositWithdrawFees(response: any, codes?: any, currencyIdKey?: any): {};
|
|
210
|
+
handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
|
|
210
211
|
nonce(): number;
|
|
211
212
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
212
213
|
url: string;
|
package/js/src/coinex.js
CHANGED
|
@@ -1580,8 +1580,9 @@ export default class coinex extends Exchange {
|
|
|
1580
1580
|
*/
|
|
1581
1581
|
let marketType = undefined;
|
|
1582
1582
|
[marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1583
|
-
|
|
1584
|
-
|
|
1583
|
+
let marginMode = undefined;
|
|
1584
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
1585
|
+
marketType = (marginMode !== undefined) ? 'margin' : marketType;
|
|
1585
1586
|
params = this.omit(params, 'margin');
|
|
1586
1587
|
if (marketType === 'margin') {
|
|
1587
1588
|
return await this.fetchMarginBalance(params);
|
|
@@ -2111,8 +2112,9 @@ export default class coinex extends Exchange {
|
|
|
2111
2112
|
}
|
|
2112
2113
|
}
|
|
2113
2114
|
const accountId = this.safeInteger(params, 'account_id');
|
|
2114
|
-
|
|
2115
|
-
|
|
2115
|
+
let marginMode = undefined;
|
|
2116
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
2117
|
+
if (marginMode !== undefined) {
|
|
2116
2118
|
if (accountId === undefined) {
|
|
2117
2119
|
throw new BadRequest(this.id + ' createOrder() requires an account_id parameter for margin orders');
|
|
2118
2120
|
}
|
|
@@ -2631,9 +2633,10 @@ export default class coinex extends Exchange {
|
|
|
2631
2633
|
'market': market['id'],
|
|
2632
2634
|
};
|
|
2633
2635
|
const accountId = this.safeInteger(params, 'account_id');
|
|
2634
|
-
|
|
2636
|
+
let marginMode = undefined;
|
|
2637
|
+
[marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
2635
2638
|
const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
|
|
2636
|
-
if (
|
|
2639
|
+
if (marginMode !== undefined) {
|
|
2637
2640
|
if (accountId === undefined) {
|
|
2638
2641
|
throw new BadRequest(this.id + ' cancelOrder() requires an account_id parameter for margin orders');
|
|
2639
2642
|
}
|
|
@@ -3005,8 +3008,9 @@ export default class coinex extends Exchange {
|
|
|
3005
3008
|
}
|
|
3006
3009
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
|
|
3007
3010
|
const accountId = this.safeInteger(params, 'account_id');
|
|
3008
|
-
|
|
3009
|
-
|
|
3011
|
+
let marginMode = undefined;
|
|
3012
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchOrdersByStatus', params);
|
|
3013
|
+
if (marginMode !== undefined) {
|
|
3010
3014
|
if (accountId === undefined) {
|
|
3011
3015
|
throw new BadRequest(this.id + ' fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin orders');
|
|
3012
3016
|
}
|
|
@@ -3409,8 +3413,9 @@ export default class coinex extends Exchange {
|
|
|
3409
3413
|
}
|
|
3410
3414
|
const swap = (type === 'swap');
|
|
3411
3415
|
const accountId = this.safeInteger(params, 'account_id');
|
|
3412
|
-
|
|
3413
|
-
|
|
3416
|
+
let marginMode = undefined;
|
|
3417
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
3418
|
+
if (marginMode !== undefined) {
|
|
3414
3419
|
if (accountId === undefined) {
|
|
3415
3420
|
throw new BadRequest(this.id + ' fetchMyTrades() requires an account_id parameter for margin trades');
|
|
3416
3421
|
}
|
|
@@ -3512,11 +3517,17 @@ export default class coinex extends Exchange {
|
|
|
3512
3517
|
* @name coinex#fetchPositions
|
|
3513
3518
|
* @description fetch all open positions
|
|
3514
3519
|
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033_pending_position
|
|
3515
|
-
* @
|
|
3520
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_finished_position
|
|
3521
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
3516
3522
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3523
|
+
* @param {string} [params.method] the method to use 'perpetualPrivateGetPositionPending' or 'perpetualPrivateGetPositionFinished' default is 'perpetualPrivateGetPositionPending'
|
|
3524
|
+
* @param {int} [params.side] *history endpoint only* 0: All, 1: Sell, 2: Buy, default is 0
|
|
3517
3525
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3518
3526
|
*/
|
|
3519
3527
|
await this.loadMarkets();
|
|
3528
|
+
let defaultMethod = undefined;
|
|
3529
|
+
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'perpetualPrivateGetPositionPending');
|
|
3530
|
+
const isHistory = (defaultMethod === 'perpetualPrivateGetPositionFinished');
|
|
3520
3531
|
symbols = this.marketSymbols(symbols);
|
|
3521
3532
|
const request = {};
|
|
3522
3533
|
let market = undefined;
|
|
@@ -3535,7 +3546,22 @@ export default class coinex extends Exchange {
|
|
|
3535
3546
|
market = this.market(symbol);
|
|
3536
3547
|
request['market'] = market['id'];
|
|
3537
3548
|
}
|
|
3538
|
-
|
|
3549
|
+
else {
|
|
3550
|
+
if (isHistory) {
|
|
3551
|
+
throw new ArgumentsRequired(this.id + ' fetchPositions() requires a symbol argument for closed positions');
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
if (isHistory) {
|
|
3555
|
+
request['limit'] = 100;
|
|
3556
|
+
request['side'] = this.safeInteger(params, 'side', 0); // 0: All, 1: Sell, 2: Buy
|
|
3557
|
+
}
|
|
3558
|
+
let response = undefined;
|
|
3559
|
+
if (defaultMethod === 'perpetualPrivateGetPositionPending') {
|
|
3560
|
+
response = await this.perpetualPrivateGetPositionPending(this.extend(request, params));
|
|
3561
|
+
}
|
|
3562
|
+
else {
|
|
3563
|
+
response = await this.perpetualPrivateGetPositionFinished(this.extend(request, params));
|
|
3564
|
+
}
|
|
3539
3565
|
//
|
|
3540
3566
|
// {
|
|
3541
3567
|
// "code": 0,
|
|
@@ -4735,9 +4761,10 @@ export default class coinex extends Exchange {
|
|
|
4735
4761
|
request['limit'] = 100;
|
|
4736
4762
|
}
|
|
4737
4763
|
params = this.omit(params, 'page');
|
|
4738
|
-
|
|
4764
|
+
let marginMode = undefined;
|
|
4765
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
|
|
4739
4766
|
let response = undefined;
|
|
4740
|
-
if (
|
|
4767
|
+
if (marginMode !== undefined) {
|
|
4741
4768
|
response = await this.privateGetMarginTransferHistory(this.extend(request, params));
|
|
4742
4769
|
}
|
|
4743
4770
|
else {
|
|
@@ -5318,6 +5345,25 @@ export default class coinex extends Exchange {
|
|
|
5318
5345
|
}
|
|
5319
5346
|
return depositWithdrawFees;
|
|
5320
5347
|
}
|
|
5348
|
+
handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
|
|
5349
|
+
/**
|
|
5350
|
+
* @ignore
|
|
5351
|
+
* @method
|
|
5352
|
+
* @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
|
|
5353
|
+
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
5354
|
+
* @returns {Array} the marginMode in lowercase
|
|
5355
|
+
*/
|
|
5356
|
+
const defaultType = this.safeString(this.options, 'defaultType');
|
|
5357
|
+
const isMargin = this.safeValue(params, 'margin', false);
|
|
5358
|
+
let marginMode = undefined;
|
|
5359
|
+
[marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
|
|
5360
|
+
if (marginMode === undefined) {
|
|
5361
|
+
if ((defaultType === 'margin') || (isMargin === true)) {
|
|
5362
|
+
marginMode = 'isolated';
|
|
5363
|
+
}
|
|
5364
|
+
}
|
|
5365
|
+
return [marginMode, params];
|
|
5366
|
+
}
|
|
5321
5367
|
nonce() {
|
|
5322
5368
|
return this.milliseconds();
|
|
5323
5369
|
}
|