ccxt 4.2.69 → 4.2.70
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 +207 -32
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +32 -30
- package/dist/cjs/src/gate.js +174 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -2
- package/js/src/base/Exchange.js +32 -30
- package/js/src/gate.d.ts +4 -1
- package/js/src/gate.js +174 -1
- package/package.json +1 -1
- package/skip-tests.json +16 -0
package/dist/cjs/ccxt.js
CHANGED
|
@@ -177,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
177
177
|
|
|
178
178
|
//-----------------------------------------------------------------------------
|
|
179
179
|
// this is updated by vss.js when building
|
|
180
|
-
const version = '4.2.
|
|
180
|
+
const version = '4.2.70';
|
|
181
181
|
Exchange["default"].ccxtVersion = version;
|
|
182
182
|
const exchanges = {
|
|
183
183
|
'ace': ace,
|
|
@@ -236,7 +236,7 @@ class Exchange {
|
|
|
236
236
|
this.socksProxyAgentModule = undefined;
|
|
237
237
|
this.socksProxyAgentModuleChecked = false;
|
|
238
238
|
this.proxyDictionaries = {};
|
|
239
|
-
this.
|
|
239
|
+
this.proxiesModulesLoading = undefined;
|
|
240
240
|
Object.assign(this, functions);
|
|
241
241
|
//
|
|
242
242
|
// if (isNode) {
|
|
@@ -731,36 +731,38 @@ class Exchange {
|
|
|
731
731
|
console.log(...args);
|
|
732
732
|
}
|
|
733
733
|
async loadProxyModules() {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
734
|
+
// when loading markets, multiple parallel calls are made, so need one promise
|
|
735
|
+
if (this.proxiesModulesLoading === undefined) {
|
|
736
|
+
this.proxiesModulesLoading = (async () => {
|
|
737
|
+
// we have to handle it with below nested way, because of dynamic
|
|
738
|
+
// import issues (https://github.com/ccxt/ccxt/pull/20687)
|
|
739
|
+
try {
|
|
740
|
+
// todo: possible sync alternatives: https://stackoverflow.com/questions/51069002/convert-import-to-synchronous
|
|
741
|
+
this.httpProxyAgentModule = await Promise.resolve().then(function () { return require(/* webpackIgnore: true */ '../static_dependencies/proxies/http-proxy-agent/index.js'); });
|
|
742
|
+
this.httpsProxyAgentModule = await Promise.resolve().then(function () { return require(/* webpackIgnore: true */ '../static_dependencies/proxies/https-proxy-agent/index.js'); });
|
|
743
|
+
}
|
|
744
|
+
catch (e) {
|
|
745
|
+
// if several users are using those frameworks which cause exceptions,
|
|
746
|
+
// let them to be able to load modules still, by installing them
|
|
747
|
+
try {
|
|
748
|
+
// @ts-ignore
|
|
749
|
+
this.httpProxyAgentModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'http-proxy-agent')); });
|
|
750
|
+
// @ts-ignore
|
|
751
|
+
this.httpProxyAgentModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'https-proxy-agent')); });
|
|
752
|
+
}
|
|
753
|
+
catch (e) { }
|
|
754
|
+
}
|
|
755
|
+
if (this.socksProxyAgentModuleChecked === false) {
|
|
756
|
+
try {
|
|
757
|
+
// @ts-ignore
|
|
758
|
+
this.socksProxyAgentModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'socks-proxy-agent')); });
|
|
759
|
+
}
|
|
760
|
+
catch (e) { }
|
|
761
|
+
this.socksProxyAgentModuleChecked = true;
|
|
762
|
+
}
|
|
763
|
+
})();
|
|
763
764
|
}
|
|
765
|
+
return await this.proxiesModulesLoading;
|
|
764
766
|
}
|
|
765
767
|
setProxyAgents(httpProxy, httpsProxy, socksProxy) {
|
|
766
768
|
let chosenAgent = undefined;
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -115,7 +115,8 @@ class gate extends gate$1 {
|
|
|
115
115
|
'fetchIsolatedBorrowRate': false,
|
|
116
116
|
'fetchIsolatedBorrowRates': false,
|
|
117
117
|
'fetchLedger': true,
|
|
118
|
-
'fetchLeverage':
|
|
118
|
+
'fetchLeverage': true,
|
|
119
|
+
'fetchLeverages': true,
|
|
119
120
|
'fetchLeverageTiers': true,
|
|
120
121
|
'fetchLiquidations': true,
|
|
121
122
|
'fetchMarginMode': false,
|
|
@@ -7015,6 +7016,178 @@ class gate extends gate$1 {
|
|
|
7015
7016
|
}
|
|
7016
7017
|
return await this.createOrder(symbol, 'market', side, 0, undefined, params);
|
|
7017
7018
|
}
|
|
7019
|
+
async fetchLeverage(symbol, params = {}) {
|
|
7020
|
+
/**
|
|
7021
|
+
* @method
|
|
7022
|
+
* @name gate#fetchLeverage
|
|
7023
|
+
* @description fetch the set leverage for a market
|
|
7024
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#get-unified-account-information
|
|
7025
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#get-detail-of-lending-market
|
|
7026
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#query-one-single-margin-currency-pair-deprecated
|
|
7027
|
+
* @param {string} symbol unified market symbol
|
|
7028
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7029
|
+
* @param {boolean} [params.unified] default false, set to true for fetching the unified accounts leverage
|
|
7030
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
7031
|
+
*/
|
|
7032
|
+
await this.loadMarkets();
|
|
7033
|
+
let market = undefined;
|
|
7034
|
+
if (symbol !== undefined) {
|
|
7035
|
+
// unified account does not require a symbol
|
|
7036
|
+
market = this.market(symbol);
|
|
7037
|
+
}
|
|
7038
|
+
const request = {};
|
|
7039
|
+
let response = undefined;
|
|
7040
|
+
const isUnified = this.safeBool(params, 'unified');
|
|
7041
|
+
params = this.omit(params, 'unified');
|
|
7042
|
+
if (market['spot']) {
|
|
7043
|
+
request['currency_pair'] = market['id'];
|
|
7044
|
+
if (isUnified) {
|
|
7045
|
+
response = await this.publicMarginGetUniCurrencyPairsCurrencyPair(this.extend(request, params));
|
|
7046
|
+
//
|
|
7047
|
+
// {
|
|
7048
|
+
// "currency_pair": "BTC_USDT",
|
|
7049
|
+
// "base_min_borrow_amount": "0.0001",
|
|
7050
|
+
// "quote_min_borrow_amount": "1",
|
|
7051
|
+
// "leverage": "10"
|
|
7052
|
+
// }
|
|
7053
|
+
//
|
|
7054
|
+
}
|
|
7055
|
+
else {
|
|
7056
|
+
response = await this.publicMarginGetCurrencyPairsCurrencyPair(this.extend(request, params));
|
|
7057
|
+
//
|
|
7058
|
+
// {
|
|
7059
|
+
// "id": "BTC_USDT",
|
|
7060
|
+
// "base": "BTC",
|
|
7061
|
+
// "quote": "USDT",
|
|
7062
|
+
// "leverage": 10,
|
|
7063
|
+
// "min_base_amount": "0.0001",
|
|
7064
|
+
// "min_quote_amount": "1",
|
|
7065
|
+
// "max_quote_amount": "40000000",
|
|
7066
|
+
// "status": 1
|
|
7067
|
+
// }
|
|
7068
|
+
//
|
|
7069
|
+
}
|
|
7070
|
+
}
|
|
7071
|
+
else if (isUnified) {
|
|
7072
|
+
response = await this.privateUnifiedGetAccounts(this.extend(request, params));
|
|
7073
|
+
//
|
|
7074
|
+
// {
|
|
7075
|
+
// "user_id": 10001,
|
|
7076
|
+
// "locked": false,
|
|
7077
|
+
// "balances": {
|
|
7078
|
+
// "ETH": {
|
|
7079
|
+
// "available": "0",
|
|
7080
|
+
// "freeze": "0",
|
|
7081
|
+
// "borrowed": "0.075393666654",
|
|
7082
|
+
// "negative_liab": "0",
|
|
7083
|
+
// "futures_pos_liab": "0",
|
|
7084
|
+
// "equity": "1016.1",
|
|
7085
|
+
// "total_freeze": "0",
|
|
7086
|
+
// "total_liab": "0"
|
|
7087
|
+
// },
|
|
7088
|
+
// "POINT": {
|
|
7089
|
+
// "available": "9999999999.017023138734",
|
|
7090
|
+
// "freeze": "0",
|
|
7091
|
+
// "borrowed": "0",
|
|
7092
|
+
// "negative_liab": "0",
|
|
7093
|
+
// "futures_pos_liab": "0",
|
|
7094
|
+
// "equity": "12016.1",
|
|
7095
|
+
// "total_freeze": "0",
|
|
7096
|
+
// "total_liab": "0"
|
|
7097
|
+
// },
|
|
7098
|
+
// "USDT": {
|
|
7099
|
+
// "available": "0.00000062023",
|
|
7100
|
+
// "freeze": "0",
|
|
7101
|
+
// "borrowed": "0",
|
|
7102
|
+
// "negative_liab": "0",
|
|
7103
|
+
// "futures_pos_liab": "0",
|
|
7104
|
+
// "equity": "16.1",
|
|
7105
|
+
// "total_freeze": "0",
|
|
7106
|
+
// "total_liab": "0"
|
|
7107
|
+
// }
|
|
7108
|
+
// },
|
|
7109
|
+
// "total": "230.94621713",
|
|
7110
|
+
// "borrowed": "161.66395521",
|
|
7111
|
+
// "total_initial_margin": "1025.0524665088",
|
|
7112
|
+
// "total_margin_balance": "3382495.944473949183",
|
|
7113
|
+
// "total_maintenance_margin": "205.01049330176",
|
|
7114
|
+
// "total_initial_margin_rate": "3299.827135672679",
|
|
7115
|
+
// "total_maintenance_margin_rate": "16499.135678363399",
|
|
7116
|
+
// "total_available_margin": "3381470.892007440383",
|
|
7117
|
+
// "unified_account_total": "3381470.892007440383",
|
|
7118
|
+
// "unified_account_total_liab": "0",
|
|
7119
|
+
// "unified_account_total_equity": "100016.1",
|
|
7120
|
+
// "leverage": "2"
|
|
7121
|
+
// }
|
|
7122
|
+
//
|
|
7123
|
+
}
|
|
7124
|
+
else {
|
|
7125
|
+
throw new errors.NotSupported(this.id + ' fetchLeverage() does not support ' + market['type'] + ' markets');
|
|
7126
|
+
}
|
|
7127
|
+
return this.parseLeverage(response, market);
|
|
7128
|
+
}
|
|
7129
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
7130
|
+
/**
|
|
7131
|
+
* @method
|
|
7132
|
+
* @name gate#fetchLeverages
|
|
7133
|
+
* @description fetch the set leverage for all leverage markets, only spot margin is supported on gate
|
|
7134
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-lending-markets
|
|
7135
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-supported-currency-pairs-supported-in-margin-trading-deprecated
|
|
7136
|
+
* @param {string[]} symbols a list of unified market symbols
|
|
7137
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7138
|
+
* @param {boolean} [params.unified] default false, set to true for fetching unified account leverages
|
|
7139
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
7140
|
+
*/
|
|
7141
|
+
await this.loadMarkets();
|
|
7142
|
+
symbols = this.marketSymbols(symbols);
|
|
7143
|
+
let response = undefined;
|
|
7144
|
+
const isUnified = this.safeBool(params, 'unified');
|
|
7145
|
+
params = this.omit(params, 'unified');
|
|
7146
|
+
let marketIdRequest = 'id';
|
|
7147
|
+
if (isUnified) {
|
|
7148
|
+
marketIdRequest = 'currency_pair';
|
|
7149
|
+
response = await this.publicMarginGetUniCurrencyPairs(params);
|
|
7150
|
+
//
|
|
7151
|
+
// [
|
|
7152
|
+
// {
|
|
7153
|
+
// "currency_pair": "1INCH_USDT",
|
|
7154
|
+
// "base_min_borrow_amount": "8",
|
|
7155
|
+
// "quote_min_borrow_amount": "1",
|
|
7156
|
+
// "leverage": "3"
|
|
7157
|
+
// },
|
|
7158
|
+
// ]
|
|
7159
|
+
//
|
|
7160
|
+
}
|
|
7161
|
+
else {
|
|
7162
|
+
response = await this.publicMarginGetCurrencyPairs(params);
|
|
7163
|
+
//
|
|
7164
|
+
// [
|
|
7165
|
+
// {
|
|
7166
|
+
// "id": "1CAT_USDT",
|
|
7167
|
+
// "base": "1CAT",
|
|
7168
|
+
// "quote": "USDT",
|
|
7169
|
+
// "leverage": 3,
|
|
7170
|
+
// "min_base_amount": "71",
|
|
7171
|
+
// "min_quote_amount": "1",
|
|
7172
|
+
// "max_quote_amount": "10000",
|
|
7173
|
+
// "status": 1
|
|
7174
|
+
// },
|
|
7175
|
+
// ]
|
|
7176
|
+
//
|
|
7177
|
+
}
|
|
7178
|
+
return this.parseLeverages(response, symbols, marketIdRequest, 'spot');
|
|
7179
|
+
}
|
|
7180
|
+
parseLeverage(leverage, market = undefined) {
|
|
7181
|
+
const marketId = this.safeString2(leverage, 'currency_pair', 'id');
|
|
7182
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
7183
|
+
return {
|
|
7184
|
+
'info': leverage,
|
|
7185
|
+
'symbol': this.safeSymbol(marketId, market, '_', 'spot'),
|
|
7186
|
+
'marginMode': undefined,
|
|
7187
|
+
'longLeverage': leverageValue,
|
|
7188
|
+
'shortLeverage': leverageValue,
|
|
7189
|
+
};
|
|
7190
|
+
}
|
|
7018
7191
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
7019
7192
|
if (response === undefined) {
|
|
7020
7193
|
return undefined;
|
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, Leverage, Leverages } 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.69";
|
|
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.70';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -573,8 +573,8 @@ export default class Exchange {
|
|
|
573
573
|
socksProxyAgentModule: any;
|
|
574
574
|
socksProxyAgentModuleChecked: boolean;
|
|
575
575
|
proxyDictionaries: any;
|
|
576
|
-
|
|
577
|
-
loadProxyModules(): Promise<
|
|
576
|
+
proxiesModulesLoading: Promise<any>;
|
|
577
|
+
loadProxyModules(): Promise<any>;
|
|
578
578
|
setProxyAgents(httpProxy: any, httpsProxy: any, socksProxy: any): any;
|
|
579
579
|
loadHttpProxyAgent(): Promise<any>;
|
|
580
580
|
getHttpAgentIfNeeded(url: any): any;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -215,7 +215,7 @@ export default class Exchange {
|
|
|
215
215
|
this.socksProxyAgentModule = undefined;
|
|
216
216
|
this.socksProxyAgentModuleChecked = false;
|
|
217
217
|
this.proxyDictionaries = {};
|
|
218
|
-
this.
|
|
218
|
+
this.proxiesModulesLoading = undefined;
|
|
219
219
|
Object.assign(this, functions);
|
|
220
220
|
//
|
|
221
221
|
// if (isNode) {
|
|
@@ -716,36 +716,38 @@ export default class Exchange {
|
|
|
716
716
|
console.log(...args);
|
|
717
717
|
}
|
|
718
718
|
async loadProxyModules() {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
719
|
+
// when loading markets, multiple parallel calls are made, so need one promise
|
|
720
|
+
if (this.proxiesModulesLoading === undefined) {
|
|
721
|
+
this.proxiesModulesLoading = (async () => {
|
|
722
|
+
// we have to handle it with below nested way, because of dynamic
|
|
723
|
+
// import issues (https://github.com/ccxt/ccxt/pull/20687)
|
|
724
|
+
try {
|
|
725
|
+
// todo: possible sync alternatives: https://stackoverflow.com/questions/51069002/convert-import-to-synchronous
|
|
726
|
+
this.httpProxyAgentModule = await import(/* webpackIgnore: true */ '../static_dependencies/proxies/http-proxy-agent/index.js');
|
|
727
|
+
this.httpsProxyAgentModule = await import(/* webpackIgnore: true */ '../static_dependencies/proxies/https-proxy-agent/index.js');
|
|
728
|
+
}
|
|
729
|
+
catch (e) {
|
|
730
|
+
// if several users are using those frameworks which cause exceptions,
|
|
731
|
+
// let them to be able to load modules still, by installing them
|
|
732
|
+
try {
|
|
733
|
+
// @ts-ignore
|
|
734
|
+
this.httpProxyAgentModule = await import(/* webpackIgnore: true */ 'http-proxy-agent');
|
|
735
|
+
// @ts-ignore
|
|
736
|
+
this.httpProxyAgentModule = await import(/* webpackIgnore: true */ 'https-proxy-agent');
|
|
737
|
+
}
|
|
738
|
+
catch (e) { }
|
|
739
|
+
}
|
|
740
|
+
if (this.socksProxyAgentModuleChecked === false) {
|
|
741
|
+
try {
|
|
742
|
+
// @ts-ignore
|
|
743
|
+
this.socksProxyAgentModule = await import(/* webpackIgnore: true */ 'socks-proxy-agent');
|
|
744
|
+
}
|
|
745
|
+
catch (e) { }
|
|
746
|
+
this.socksProxyAgentModuleChecked = true;
|
|
747
|
+
}
|
|
748
|
+
})();
|
|
748
749
|
}
|
|
750
|
+
return await this.proxiesModulesLoading;
|
|
749
751
|
}
|
|
750
752
|
setProxyAgents(httpProxy, httpsProxy, socksProxy) {
|
|
751
753
|
let chosenAgent = undefined;
|
package/js/src/gate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/gate.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Leverage, Leverages } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class gate
|
|
5
5
|
* @augments Exchange
|
|
@@ -361,5 +361,8 @@ export default class gate extends Exchange {
|
|
|
361
361
|
info: any;
|
|
362
362
|
};
|
|
363
363
|
closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
|
|
364
|
+
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
365
|
+
fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
|
|
366
|
+
parseLeverage(leverage: any, market?: any): Leverage;
|
|
364
367
|
handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
365
368
|
}
|
package/js/src/gate.js
CHANGED
|
@@ -118,7 +118,8 @@ export default class gate extends Exchange {
|
|
|
118
118
|
'fetchIsolatedBorrowRate': false,
|
|
119
119
|
'fetchIsolatedBorrowRates': false,
|
|
120
120
|
'fetchLedger': true,
|
|
121
|
-
'fetchLeverage':
|
|
121
|
+
'fetchLeverage': true,
|
|
122
|
+
'fetchLeverages': true,
|
|
122
123
|
'fetchLeverageTiers': true,
|
|
123
124
|
'fetchLiquidations': true,
|
|
124
125
|
'fetchMarginMode': false,
|
|
@@ -7018,6 +7019,178 @@ export default class gate extends Exchange {
|
|
|
7018
7019
|
}
|
|
7019
7020
|
return await this.createOrder(symbol, 'market', side, 0, undefined, params);
|
|
7020
7021
|
}
|
|
7022
|
+
async fetchLeverage(symbol, params = {}) {
|
|
7023
|
+
/**
|
|
7024
|
+
* @method
|
|
7025
|
+
* @name gate#fetchLeverage
|
|
7026
|
+
* @description fetch the set leverage for a market
|
|
7027
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#get-unified-account-information
|
|
7028
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#get-detail-of-lending-market
|
|
7029
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#query-one-single-margin-currency-pair-deprecated
|
|
7030
|
+
* @param {string} symbol unified market symbol
|
|
7031
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7032
|
+
* @param {boolean} [params.unified] default false, set to true for fetching the unified accounts leverage
|
|
7033
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
7034
|
+
*/
|
|
7035
|
+
await this.loadMarkets();
|
|
7036
|
+
let market = undefined;
|
|
7037
|
+
if (symbol !== undefined) {
|
|
7038
|
+
// unified account does not require a symbol
|
|
7039
|
+
market = this.market(symbol);
|
|
7040
|
+
}
|
|
7041
|
+
const request = {};
|
|
7042
|
+
let response = undefined;
|
|
7043
|
+
const isUnified = this.safeBool(params, 'unified');
|
|
7044
|
+
params = this.omit(params, 'unified');
|
|
7045
|
+
if (market['spot']) {
|
|
7046
|
+
request['currency_pair'] = market['id'];
|
|
7047
|
+
if (isUnified) {
|
|
7048
|
+
response = await this.publicMarginGetUniCurrencyPairsCurrencyPair(this.extend(request, params));
|
|
7049
|
+
//
|
|
7050
|
+
// {
|
|
7051
|
+
// "currency_pair": "BTC_USDT",
|
|
7052
|
+
// "base_min_borrow_amount": "0.0001",
|
|
7053
|
+
// "quote_min_borrow_amount": "1",
|
|
7054
|
+
// "leverage": "10"
|
|
7055
|
+
// }
|
|
7056
|
+
//
|
|
7057
|
+
}
|
|
7058
|
+
else {
|
|
7059
|
+
response = await this.publicMarginGetCurrencyPairsCurrencyPair(this.extend(request, params));
|
|
7060
|
+
//
|
|
7061
|
+
// {
|
|
7062
|
+
// "id": "BTC_USDT",
|
|
7063
|
+
// "base": "BTC",
|
|
7064
|
+
// "quote": "USDT",
|
|
7065
|
+
// "leverage": 10,
|
|
7066
|
+
// "min_base_amount": "0.0001",
|
|
7067
|
+
// "min_quote_amount": "1",
|
|
7068
|
+
// "max_quote_amount": "40000000",
|
|
7069
|
+
// "status": 1
|
|
7070
|
+
// }
|
|
7071
|
+
//
|
|
7072
|
+
}
|
|
7073
|
+
}
|
|
7074
|
+
else if (isUnified) {
|
|
7075
|
+
response = await this.privateUnifiedGetAccounts(this.extend(request, params));
|
|
7076
|
+
//
|
|
7077
|
+
// {
|
|
7078
|
+
// "user_id": 10001,
|
|
7079
|
+
// "locked": false,
|
|
7080
|
+
// "balances": {
|
|
7081
|
+
// "ETH": {
|
|
7082
|
+
// "available": "0",
|
|
7083
|
+
// "freeze": "0",
|
|
7084
|
+
// "borrowed": "0.075393666654",
|
|
7085
|
+
// "negative_liab": "0",
|
|
7086
|
+
// "futures_pos_liab": "0",
|
|
7087
|
+
// "equity": "1016.1",
|
|
7088
|
+
// "total_freeze": "0",
|
|
7089
|
+
// "total_liab": "0"
|
|
7090
|
+
// },
|
|
7091
|
+
// "POINT": {
|
|
7092
|
+
// "available": "9999999999.017023138734",
|
|
7093
|
+
// "freeze": "0",
|
|
7094
|
+
// "borrowed": "0",
|
|
7095
|
+
// "negative_liab": "0",
|
|
7096
|
+
// "futures_pos_liab": "0",
|
|
7097
|
+
// "equity": "12016.1",
|
|
7098
|
+
// "total_freeze": "0",
|
|
7099
|
+
// "total_liab": "0"
|
|
7100
|
+
// },
|
|
7101
|
+
// "USDT": {
|
|
7102
|
+
// "available": "0.00000062023",
|
|
7103
|
+
// "freeze": "0",
|
|
7104
|
+
// "borrowed": "0",
|
|
7105
|
+
// "negative_liab": "0",
|
|
7106
|
+
// "futures_pos_liab": "0",
|
|
7107
|
+
// "equity": "16.1",
|
|
7108
|
+
// "total_freeze": "0",
|
|
7109
|
+
// "total_liab": "0"
|
|
7110
|
+
// }
|
|
7111
|
+
// },
|
|
7112
|
+
// "total": "230.94621713",
|
|
7113
|
+
// "borrowed": "161.66395521",
|
|
7114
|
+
// "total_initial_margin": "1025.0524665088",
|
|
7115
|
+
// "total_margin_balance": "3382495.944473949183",
|
|
7116
|
+
// "total_maintenance_margin": "205.01049330176",
|
|
7117
|
+
// "total_initial_margin_rate": "3299.827135672679",
|
|
7118
|
+
// "total_maintenance_margin_rate": "16499.135678363399",
|
|
7119
|
+
// "total_available_margin": "3381470.892007440383",
|
|
7120
|
+
// "unified_account_total": "3381470.892007440383",
|
|
7121
|
+
// "unified_account_total_liab": "0",
|
|
7122
|
+
// "unified_account_total_equity": "100016.1",
|
|
7123
|
+
// "leverage": "2"
|
|
7124
|
+
// }
|
|
7125
|
+
//
|
|
7126
|
+
}
|
|
7127
|
+
else {
|
|
7128
|
+
throw new NotSupported(this.id + ' fetchLeverage() does not support ' + market['type'] + ' markets');
|
|
7129
|
+
}
|
|
7130
|
+
return this.parseLeverage(response, market);
|
|
7131
|
+
}
|
|
7132
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
7133
|
+
/**
|
|
7134
|
+
* @method
|
|
7135
|
+
* @name gate#fetchLeverages
|
|
7136
|
+
* @description fetch the set leverage for all leverage markets, only spot margin is supported on gate
|
|
7137
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-lending-markets
|
|
7138
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-supported-currency-pairs-supported-in-margin-trading-deprecated
|
|
7139
|
+
* @param {string[]} symbols a list of unified market symbols
|
|
7140
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7141
|
+
* @param {boolean} [params.unified] default false, set to true for fetching unified account leverages
|
|
7142
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
7143
|
+
*/
|
|
7144
|
+
await this.loadMarkets();
|
|
7145
|
+
symbols = this.marketSymbols(symbols);
|
|
7146
|
+
let response = undefined;
|
|
7147
|
+
const isUnified = this.safeBool(params, 'unified');
|
|
7148
|
+
params = this.omit(params, 'unified');
|
|
7149
|
+
let marketIdRequest = 'id';
|
|
7150
|
+
if (isUnified) {
|
|
7151
|
+
marketIdRequest = 'currency_pair';
|
|
7152
|
+
response = await this.publicMarginGetUniCurrencyPairs(params);
|
|
7153
|
+
//
|
|
7154
|
+
// [
|
|
7155
|
+
// {
|
|
7156
|
+
// "currency_pair": "1INCH_USDT",
|
|
7157
|
+
// "base_min_borrow_amount": "8",
|
|
7158
|
+
// "quote_min_borrow_amount": "1",
|
|
7159
|
+
// "leverage": "3"
|
|
7160
|
+
// },
|
|
7161
|
+
// ]
|
|
7162
|
+
//
|
|
7163
|
+
}
|
|
7164
|
+
else {
|
|
7165
|
+
response = await this.publicMarginGetCurrencyPairs(params);
|
|
7166
|
+
//
|
|
7167
|
+
// [
|
|
7168
|
+
// {
|
|
7169
|
+
// "id": "1CAT_USDT",
|
|
7170
|
+
// "base": "1CAT",
|
|
7171
|
+
// "quote": "USDT",
|
|
7172
|
+
// "leverage": 3,
|
|
7173
|
+
// "min_base_amount": "71",
|
|
7174
|
+
// "min_quote_amount": "1",
|
|
7175
|
+
// "max_quote_amount": "10000",
|
|
7176
|
+
// "status": 1
|
|
7177
|
+
// },
|
|
7178
|
+
// ]
|
|
7179
|
+
//
|
|
7180
|
+
}
|
|
7181
|
+
return this.parseLeverages(response, symbols, marketIdRequest, 'spot');
|
|
7182
|
+
}
|
|
7183
|
+
parseLeverage(leverage, market = undefined) {
|
|
7184
|
+
const marketId = this.safeString2(leverage, 'currency_pair', 'id');
|
|
7185
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
7186
|
+
return {
|
|
7187
|
+
'info': leverage,
|
|
7188
|
+
'symbol': this.safeSymbol(marketId, market, '_', 'spot'),
|
|
7189
|
+
'marginMode': undefined,
|
|
7190
|
+
'longLeverage': leverageValue,
|
|
7191
|
+
'shortLeverage': leverageValue,
|
|
7192
|
+
};
|
|
7193
|
+
}
|
|
7021
7194
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
7022
7195
|
if (response === undefined) {
|
|
7023
7196
|
return undefined;
|
package/package.json
CHANGED
package/skip-tests.json
CHANGED
|
@@ -327,6 +327,7 @@
|
|
|
327
327
|
"currencyIdAndCode": "broken currencies"
|
|
328
328
|
},
|
|
329
329
|
"fetchCurrencies": {
|
|
330
|
+
"currencyIdAndCode": "broken currencies",
|
|
330
331
|
"precision":"not provided",
|
|
331
332
|
"networks": "missing"
|
|
332
333
|
},
|
|
@@ -983,6 +984,18 @@
|
|
|
983
984
|
"quoteVolume": "same",
|
|
984
985
|
"baseVolume": "same"
|
|
985
986
|
},
|
|
987
|
+
"watchTicker": {
|
|
988
|
+
"bid":"same",
|
|
989
|
+
"ask":"same",
|
|
990
|
+
"quoteVolume": "same",
|
|
991
|
+
"baseVolume": "same"
|
|
992
|
+
},
|
|
993
|
+
"watchTickers": {
|
|
994
|
+
"bid":"same",
|
|
995
|
+
"ask":"same",
|
|
996
|
+
"quoteVolume": "same",
|
|
997
|
+
"baseVolume": "same"
|
|
998
|
+
},
|
|
986
999
|
"fetchPositions": "currently returns a lot of default/non open positions",
|
|
987
1000
|
"fetchLedger": {
|
|
988
1001
|
"currency": "undefined",
|
|
@@ -1149,6 +1162,9 @@
|
|
|
1149
1162
|
},
|
|
1150
1163
|
"fetchPositions": {
|
|
1151
1164
|
"percentage": "percentage is not provided"
|
|
1165
|
+
},
|
|
1166
|
+
"watchOrderBook": {
|
|
1167
|
+
"spread": "https://app.travis-ci.com/github/ccxt/ccxt/builds/269407124#L3464"
|
|
1152
1168
|
}
|
|
1153
1169
|
}
|
|
1154
1170
|
},
|