ccxt 4.2.71 → 4.2.72
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 +195 -16
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +149 -2
- package/dist/cjs/src/pro/bingx.js +29 -6
- package/dist/cjs/src/pro/hitbtc.js +16 -7
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/ascendex.d.ts +5 -1
- package/js/src/ascendex.js +149 -2
- package/js/src/base/Exchange.d.ts +56 -56
- package/js/src/base/types.d.ts +10 -0
- package/js/src/binance.d.ts +1 -1
- package/js/src/bitfinex2.d.ts +1 -1
- package/js/src/bitrue.d.ts +3 -3
- package/js/src/cex.d.ts +1 -1
- package/js/src/gate.d.ts +1 -1
- package/js/src/htx.d.ts +1 -1
- package/js/src/idex.d.ts +1 -1
- package/js/src/kucoinfutures.d.ts +1 -1
- package/js/src/poloniexfutures.d.ts +2 -2
- package/js/src/pro/bingx.d.ts +1 -0
- package/js/src/pro/bingx.js +29 -6
- package/js/src/pro/bitvavo.d.ts +8 -8
- package/js/src/pro/bybit.d.ts +1 -1
- package/js/src/pro/cex.d.ts +5 -5
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/hitbtc.js +16 -7
- package/js/src/pro/poloniex.d.ts +3 -3
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -178,7 +178,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
178
178
|
|
|
179
179
|
//-----------------------------------------------------------------------------
|
|
180
180
|
// this is updated by vss.js when building
|
|
181
|
-
const version = '4.2.
|
|
181
|
+
const version = '4.2.72';
|
|
182
182
|
Exchange["default"].ccxtVersion = version;
|
|
183
183
|
const exchanges = {
|
|
184
184
|
'ace': ace,
|
package/dist/cjs/src/ascendex.js
CHANGED
|
@@ -57,9 +57,11 @@ class ascendex extends ascendex$1 {
|
|
|
57
57
|
'fetchFundingRateHistory': false,
|
|
58
58
|
'fetchFundingRates': true,
|
|
59
59
|
'fetchIndexOHLCV': false,
|
|
60
|
-
'fetchLeverage':
|
|
60
|
+
'fetchLeverage': 'emulated',
|
|
61
|
+
'fetchLeverages': true,
|
|
61
62
|
'fetchLeverageTiers': true,
|
|
62
|
-
'fetchMarginMode':
|
|
63
|
+
'fetchMarginMode': 'emulated',
|
|
64
|
+
'fetchMarginModes': true,
|
|
63
65
|
'fetchMarketLeverageTiers': 'emulated',
|
|
64
66
|
'fetchMarkets': true,
|
|
65
67
|
'fetchMarkOHLCV': false,
|
|
@@ -3275,6 +3277,151 @@ class ascendex extends ascendex$1 {
|
|
|
3275
3277
|
'amount': this.safeNumber(income, 'paymentInUSDT'),
|
|
3276
3278
|
};
|
|
3277
3279
|
}
|
|
3280
|
+
async fetchMarginModes(symbols = undefined, params = {}) {
|
|
3281
|
+
/**
|
|
3282
|
+
* @method
|
|
3283
|
+
* @name ascendex#fetchMarginMode
|
|
3284
|
+
* @description fetches the set margin mode of the user
|
|
3285
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
|
|
3286
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
3287
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3288
|
+
* @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
3289
|
+
*/
|
|
3290
|
+
await this.loadMarkets();
|
|
3291
|
+
await this.loadAccounts();
|
|
3292
|
+
const account = this.safeValue(this.accounts, 0, {});
|
|
3293
|
+
const accountGroup = this.safeString(account, 'id');
|
|
3294
|
+
const request = {
|
|
3295
|
+
'account-group': accountGroup,
|
|
3296
|
+
};
|
|
3297
|
+
const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
|
|
3298
|
+
//
|
|
3299
|
+
// {
|
|
3300
|
+
// "code": 0,
|
|
3301
|
+
// "data": {
|
|
3302
|
+
// "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
|
3303
|
+
// "ac": "FUTURES",
|
|
3304
|
+
// "collaterals": [
|
|
3305
|
+
// {
|
|
3306
|
+
// "asset": "USDT",
|
|
3307
|
+
// "balance": "44.570287262",
|
|
3308
|
+
// "referencePrice": "1",
|
|
3309
|
+
// "discountFactor": "1"
|
|
3310
|
+
// }
|
|
3311
|
+
// ],
|
|
3312
|
+
// "contracts": [
|
|
3313
|
+
// {
|
|
3314
|
+
// "symbol": "BTC-PERP",
|
|
3315
|
+
// "side": "LONG",
|
|
3316
|
+
// "position": "0.0001",
|
|
3317
|
+
// "referenceCost": "-3.12277254",
|
|
3318
|
+
// "unrealizedPnl": "-0.001700233",
|
|
3319
|
+
// "realizedPnl": "0",
|
|
3320
|
+
// "avgOpenPrice": "31209",
|
|
3321
|
+
// "marginType": "isolated",
|
|
3322
|
+
// "isolatedMargin": "1.654972977",
|
|
3323
|
+
// "leverage": "2",
|
|
3324
|
+
// "takeProfitPrice": "0",
|
|
3325
|
+
// "takeProfitTrigger": "market",
|
|
3326
|
+
// "stopLossPrice": "0",
|
|
3327
|
+
// "stopLossTrigger": "market",
|
|
3328
|
+
// "buyOpenOrderNotional": "0",
|
|
3329
|
+
// "sellOpenOrderNotional": "0",
|
|
3330
|
+
// "markPrice": "31210.723063672",
|
|
3331
|
+
// "indexPrice": "31223.148857925"
|
|
3332
|
+
// },
|
|
3333
|
+
// ]
|
|
3334
|
+
// }
|
|
3335
|
+
// }
|
|
3336
|
+
//
|
|
3337
|
+
const data = this.safeDict(response, 'data', {});
|
|
3338
|
+
const marginModes = this.safeList(data, 'contracts', []);
|
|
3339
|
+
return this.parseMarginModes(marginModes, symbols, 'symbol');
|
|
3340
|
+
}
|
|
3341
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
3342
|
+
const marketId = this.safeString(marginMode, 'symbol');
|
|
3343
|
+
const marginType = this.safeString(marginMode, 'marginType');
|
|
3344
|
+
const margin = (marginType === 'crossed') ? 'cross' : 'isolated';
|
|
3345
|
+
return {
|
|
3346
|
+
'info': marginMode,
|
|
3347
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3348
|
+
'marginMode': margin,
|
|
3349
|
+
};
|
|
3350
|
+
}
|
|
3351
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
3352
|
+
/**
|
|
3353
|
+
* @method
|
|
3354
|
+
* @name ascendex#fetchLeverages
|
|
3355
|
+
* @description fetch the set leverage for all contract markets
|
|
3356
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
|
|
3357
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
3358
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3359
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
3360
|
+
*/
|
|
3361
|
+
await this.loadMarkets();
|
|
3362
|
+
await this.loadAccounts();
|
|
3363
|
+
const account = this.safeValue(this.accounts, 0, {});
|
|
3364
|
+
const accountGroup = this.safeString(account, 'id');
|
|
3365
|
+
const request = {
|
|
3366
|
+
'account-group': accountGroup,
|
|
3367
|
+
};
|
|
3368
|
+
const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
|
|
3369
|
+
//
|
|
3370
|
+
// {
|
|
3371
|
+
// "code": 0,
|
|
3372
|
+
// "data": {
|
|
3373
|
+
// "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
|
3374
|
+
// "ac": "FUTURES",
|
|
3375
|
+
// "collaterals": [
|
|
3376
|
+
// {
|
|
3377
|
+
// "asset": "USDT",
|
|
3378
|
+
// "balance": "44.570287262",
|
|
3379
|
+
// "referencePrice": "1",
|
|
3380
|
+
// "discountFactor": "1"
|
|
3381
|
+
// }
|
|
3382
|
+
// ],
|
|
3383
|
+
// "contracts": [
|
|
3384
|
+
// {
|
|
3385
|
+
// "symbol": "BTC-PERP",
|
|
3386
|
+
// "side": "LONG",
|
|
3387
|
+
// "position": "0.0001",
|
|
3388
|
+
// "referenceCost": "-3.12277254",
|
|
3389
|
+
// "unrealizedPnl": "-0.001700233",
|
|
3390
|
+
// "realizedPnl": "0",
|
|
3391
|
+
// "avgOpenPrice": "31209",
|
|
3392
|
+
// "marginType": "isolated",
|
|
3393
|
+
// "isolatedMargin": "1.654972977",
|
|
3394
|
+
// "leverage": "2",
|
|
3395
|
+
// "takeProfitPrice": "0",
|
|
3396
|
+
// "takeProfitTrigger": "market",
|
|
3397
|
+
// "stopLossPrice": "0",
|
|
3398
|
+
// "stopLossTrigger": "market",
|
|
3399
|
+
// "buyOpenOrderNotional": "0",
|
|
3400
|
+
// "sellOpenOrderNotional": "0",
|
|
3401
|
+
// "markPrice": "31210.723063672",
|
|
3402
|
+
// "indexPrice": "31223.148857925"
|
|
3403
|
+
// },
|
|
3404
|
+
// ]
|
|
3405
|
+
// }
|
|
3406
|
+
// }
|
|
3407
|
+
//
|
|
3408
|
+
const data = this.safeDict(response, 'data', {});
|
|
3409
|
+
const leverages = this.safeList(data, 'contracts', []);
|
|
3410
|
+
return this.parseLeverages(leverages, symbols, 'symbol');
|
|
3411
|
+
}
|
|
3412
|
+
parseLeverage(leverage, market = undefined) {
|
|
3413
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
3414
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
3415
|
+
const marginType = this.safeString(leverage, 'marginType');
|
|
3416
|
+
const marginMode = (marginType === 'crossed') ? 'cross' : 'isolated';
|
|
3417
|
+
return {
|
|
3418
|
+
'info': leverage,
|
|
3419
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3420
|
+
'marginMode': marginMode,
|
|
3421
|
+
'longLeverage': leverageValue,
|
|
3422
|
+
'shortLeverage': leverageValue,
|
|
3423
|
+
};
|
|
3424
|
+
}
|
|
3278
3425
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3279
3426
|
const version = api[0];
|
|
3280
3427
|
const access = api[1];
|
|
@@ -762,21 +762,44 @@ class bingx extends bingx$1 {
|
|
|
762
762
|
}
|
|
763
763
|
return true;
|
|
764
764
|
}
|
|
765
|
-
async
|
|
766
|
-
const time = this.milliseconds();
|
|
765
|
+
async keepAliveListenKey(params = {}) {
|
|
767
766
|
const listenKey = this.safeString(this.options, 'listenKey');
|
|
768
767
|
if (listenKey === undefined) {
|
|
769
|
-
|
|
770
|
-
this.options['listenKey'] = this.safeString(response, 'listenKey');
|
|
771
|
-
this.options['lastAuthenticatedTime'] = time;
|
|
768
|
+
// A network error happened: we can't renew a listen key that does not exist.
|
|
772
769
|
return;
|
|
773
770
|
}
|
|
771
|
+
try {
|
|
772
|
+
await this.userAuthPrivatePutUserDataStream({ 'listenKey': listenKey }); // extend the expiry
|
|
773
|
+
}
|
|
774
|
+
catch (error) {
|
|
775
|
+
const types = ['spot', 'swap'];
|
|
776
|
+
for (let i = 0; i < types.length; i++) {
|
|
777
|
+
const type = types[i];
|
|
778
|
+
const url = this.urls['api']['ws'][type] + '?listenKey=' + listenKey;
|
|
779
|
+
const client = this.client(url);
|
|
780
|
+
const messageHashes = Object.keys(client.futures);
|
|
781
|
+
for (let j = 0; j < messageHashes.length; j++) {
|
|
782
|
+
const messageHash = messageHashes[j];
|
|
783
|
+
client.reject(error, messageHash);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
this.options['listenKey'] = undefined;
|
|
787
|
+
this.options['lastAuthenticatedTime'] = 0;
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
// whether or not to schedule another listenKey keepAlive request
|
|
791
|
+
const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 3600000);
|
|
792
|
+
this.delay(listenKeyRefreshRate, this.keepAliveListenKey, params);
|
|
793
|
+
}
|
|
794
|
+
async authenticate(params = {}) {
|
|
795
|
+
const time = this.milliseconds();
|
|
774
796
|
const lastAuthenticatedTime = this.safeInteger(this.options, 'lastAuthenticatedTime', 0);
|
|
775
797
|
const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 3600000); // 1 hour
|
|
776
798
|
if (time - lastAuthenticatedTime > listenKeyRefreshRate) {
|
|
777
|
-
const response = await this.
|
|
799
|
+
const response = await this.userAuthPrivatePostUserDataStream();
|
|
778
800
|
this.options['listenKey'] = this.safeString(response, 'listenKey');
|
|
779
801
|
this.options['lastAuthenticatedTime'] = time;
|
|
802
|
+
this.delay(listenKeyRefreshRate, this.keepAliveListenKey, params);
|
|
780
803
|
}
|
|
781
804
|
}
|
|
782
805
|
async pong(client, message) {
|
|
@@ -247,7 +247,10 @@ class hitbtc extends hitbtc$1 {
|
|
|
247
247
|
// }
|
|
248
248
|
// }
|
|
249
249
|
//
|
|
250
|
-
const
|
|
250
|
+
const snapshot = this.safeDict(message, 'snapshot');
|
|
251
|
+
const update = this.safeDict(message, 'update');
|
|
252
|
+
const data = snapshot ? snapshot : update;
|
|
253
|
+
const type = snapshot ? 'snapshot' : 'update';
|
|
251
254
|
const marketIds = Object.keys(data);
|
|
252
255
|
for (let i = 0; i < marketIds.length; i++) {
|
|
253
256
|
const marketId = marketIds[i];
|
|
@@ -256,17 +259,23 @@ class hitbtc extends hitbtc$1 {
|
|
|
256
259
|
const item = data[marketId];
|
|
257
260
|
const messageHash = 'orderbooks::' + symbol;
|
|
258
261
|
if (!(symbol in this.orderbooks)) {
|
|
259
|
-
const subscription = this.
|
|
262
|
+
const subscription = this.safeDict(client.subscriptions, messageHash, {});
|
|
260
263
|
const limit = this.safeInteger(subscription, 'limit');
|
|
261
264
|
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
262
265
|
}
|
|
266
|
+
const orderbook = this.orderbooks[symbol];
|
|
263
267
|
const timestamp = this.safeInteger(item, 't');
|
|
264
268
|
const nonce = this.safeInteger(item, 's');
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
if (type === 'snapshot') {
|
|
270
|
+
const parsedSnapshot = this.parseOrderBook(item, symbol, timestamp, 'b', 'a');
|
|
271
|
+
orderbook.reset(parsedSnapshot);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
const asks = this.safeList(item, 'a', []);
|
|
275
|
+
const bids = this.safeList(item, 'b', []);
|
|
276
|
+
this.handleDeltas(orderbook['asks'], asks);
|
|
277
|
+
this.handleDeltas(orderbook['bids'], bids);
|
|
278
|
+
}
|
|
270
279
|
orderbook['timestamp'] = timestamp;
|
|
271
280
|
orderbook['datetime'] = this.iso8601(timestamp);
|
|
272
281
|
orderbook['nonce'] = nonce;
|
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.71";
|
|
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.72';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/ascendex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/ascendex.js';
|
|
2
|
-
import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, Leverage, Leverages, MarginModes, MarginMode } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class ascendex
|
|
5
5
|
* @augments Exchange
|
|
@@ -126,6 +126,10 @@ export default class ascendex extends Exchange {
|
|
|
126
126
|
id: any;
|
|
127
127
|
amount: number;
|
|
128
128
|
};
|
|
129
|
+
fetchMarginModes(symbols?: string[], params?: {}): Promise<MarginModes>;
|
|
130
|
+
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
131
|
+
fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
|
|
132
|
+
parseLeverage(leverage: any, market?: any): Leverage;
|
|
129
133
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
130
134
|
url: string;
|
|
131
135
|
method: string;
|
package/js/src/ascendex.js
CHANGED
|
@@ -60,9 +60,11 @@ export default class ascendex extends Exchange {
|
|
|
60
60
|
'fetchFundingRateHistory': false,
|
|
61
61
|
'fetchFundingRates': true,
|
|
62
62
|
'fetchIndexOHLCV': false,
|
|
63
|
-
'fetchLeverage':
|
|
63
|
+
'fetchLeverage': 'emulated',
|
|
64
|
+
'fetchLeverages': true,
|
|
64
65
|
'fetchLeverageTiers': true,
|
|
65
|
-
'fetchMarginMode':
|
|
66
|
+
'fetchMarginMode': 'emulated',
|
|
67
|
+
'fetchMarginModes': true,
|
|
66
68
|
'fetchMarketLeverageTiers': 'emulated',
|
|
67
69
|
'fetchMarkets': true,
|
|
68
70
|
'fetchMarkOHLCV': false,
|
|
@@ -3278,6 +3280,151 @@ export default class ascendex extends Exchange {
|
|
|
3278
3280
|
'amount': this.safeNumber(income, 'paymentInUSDT'),
|
|
3279
3281
|
};
|
|
3280
3282
|
}
|
|
3283
|
+
async fetchMarginModes(symbols = undefined, params = {}) {
|
|
3284
|
+
/**
|
|
3285
|
+
* @method
|
|
3286
|
+
* @name ascendex#fetchMarginMode
|
|
3287
|
+
* @description fetches the set margin mode of the user
|
|
3288
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
|
|
3289
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
3290
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3291
|
+
* @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
3292
|
+
*/
|
|
3293
|
+
await this.loadMarkets();
|
|
3294
|
+
await this.loadAccounts();
|
|
3295
|
+
const account = this.safeValue(this.accounts, 0, {});
|
|
3296
|
+
const accountGroup = this.safeString(account, 'id');
|
|
3297
|
+
const request = {
|
|
3298
|
+
'account-group': accountGroup,
|
|
3299
|
+
};
|
|
3300
|
+
const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
|
|
3301
|
+
//
|
|
3302
|
+
// {
|
|
3303
|
+
// "code": 0,
|
|
3304
|
+
// "data": {
|
|
3305
|
+
// "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
|
3306
|
+
// "ac": "FUTURES",
|
|
3307
|
+
// "collaterals": [
|
|
3308
|
+
// {
|
|
3309
|
+
// "asset": "USDT",
|
|
3310
|
+
// "balance": "44.570287262",
|
|
3311
|
+
// "referencePrice": "1",
|
|
3312
|
+
// "discountFactor": "1"
|
|
3313
|
+
// }
|
|
3314
|
+
// ],
|
|
3315
|
+
// "contracts": [
|
|
3316
|
+
// {
|
|
3317
|
+
// "symbol": "BTC-PERP",
|
|
3318
|
+
// "side": "LONG",
|
|
3319
|
+
// "position": "0.0001",
|
|
3320
|
+
// "referenceCost": "-3.12277254",
|
|
3321
|
+
// "unrealizedPnl": "-0.001700233",
|
|
3322
|
+
// "realizedPnl": "0",
|
|
3323
|
+
// "avgOpenPrice": "31209",
|
|
3324
|
+
// "marginType": "isolated",
|
|
3325
|
+
// "isolatedMargin": "1.654972977",
|
|
3326
|
+
// "leverage": "2",
|
|
3327
|
+
// "takeProfitPrice": "0",
|
|
3328
|
+
// "takeProfitTrigger": "market",
|
|
3329
|
+
// "stopLossPrice": "0",
|
|
3330
|
+
// "stopLossTrigger": "market",
|
|
3331
|
+
// "buyOpenOrderNotional": "0",
|
|
3332
|
+
// "sellOpenOrderNotional": "0",
|
|
3333
|
+
// "markPrice": "31210.723063672",
|
|
3334
|
+
// "indexPrice": "31223.148857925"
|
|
3335
|
+
// },
|
|
3336
|
+
// ]
|
|
3337
|
+
// }
|
|
3338
|
+
// }
|
|
3339
|
+
//
|
|
3340
|
+
const data = this.safeDict(response, 'data', {});
|
|
3341
|
+
const marginModes = this.safeList(data, 'contracts', []);
|
|
3342
|
+
return this.parseMarginModes(marginModes, symbols, 'symbol');
|
|
3343
|
+
}
|
|
3344
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
3345
|
+
const marketId = this.safeString(marginMode, 'symbol');
|
|
3346
|
+
const marginType = this.safeString(marginMode, 'marginType');
|
|
3347
|
+
const margin = (marginType === 'crossed') ? 'cross' : 'isolated';
|
|
3348
|
+
return {
|
|
3349
|
+
'info': marginMode,
|
|
3350
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3351
|
+
'marginMode': margin,
|
|
3352
|
+
};
|
|
3353
|
+
}
|
|
3354
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
3355
|
+
/**
|
|
3356
|
+
* @method
|
|
3357
|
+
* @name ascendex#fetchLeverages
|
|
3358
|
+
* @description fetch the set leverage for all contract markets
|
|
3359
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
|
|
3360
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
3361
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3362
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
3363
|
+
*/
|
|
3364
|
+
await this.loadMarkets();
|
|
3365
|
+
await this.loadAccounts();
|
|
3366
|
+
const account = this.safeValue(this.accounts, 0, {});
|
|
3367
|
+
const accountGroup = this.safeString(account, 'id');
|
|
3368
|
+
const request = {
|
|
3369
|
+
'account-group': accountGroup,
|
|
3370
|
+
};
|
|
3371
|
+
const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
|
|
3372
|
+
//
|
|
3373
|
+
// {
|
|
3374
|
+
// "code": 0,
|
|
3375
|
+
// "data": {
|
|
3376
|
+
// "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
|
|
3377
|
+
// "ac": "FUTURES",
|
|
3378
|
+
// "collaterals": [
|
|
3379
|
+
// {
|
|
3380
|
+
// "asset": "USDT",
|
|
3381
|
+
// "balance": "44.570287262",
|
|
3382
|
+
// "referencePrice": "1",
|
|
3383
|
+
// "discountFactor": "1"
|
|
3384
|
+
// }
|
|
3385
|
+
// ],
|
|
3386
|
+
// "contracts": [
|
|
3387
|
+
// {
|
|
3388
|
+
// "symbol": "BTC-PERP",
|
|
3389
|
+
// "side": "LONG",
|
|
3390
|
+
// "position": "0.0001",
|
|
3391
|
+
// "referenceCost": "-3.12277254",
|
|
3392
|
+
// "unrealizedPnl": "-0.001700233",
|
|
3393
|
+
// "realizedPnl": "0",
|
|
3394
|
+
// "avgOpenPrice": "31209",
|
|
3395
|
+
// "marginType": "isolated",
|
|
3396
|
+
// "isolatedMargin": "1.654972977",
|
|
3397
|
+
// "leverage": "2",
|
|
3398
|
+
// "takeProfitPrice": "0",
|
|
3399
|
+
// "takeProfitTrigger": "market",
|
|
3400
|
+
// "stopLossPrice": "0",
|
|
3401
|
+
// "stopLossTrigger": "market",
|
|
3402
|
+
// "buyOpenOrderNotional": "0",
|
|
3403
|
+
// "sellOpenOrderNotional": "0",
|
|
3404
|
+
// "markPrice": "31210.723063672",
|
|
3405
|
+
// "indexPrice": "31223.148857925"
|
|
3406
|
+
// },
|
|
3407
|
+
// ]
|
|
3408
|
+
// }
|
|
3409
|
+
// }
|
|
3410
|
+
//
|
|
3411
|
+
const data = this.safeDict(response, 'data', {});
|
|
3412
|
+
const leverages = this.safeList(data, 'contracts', []);
|
|
3413
|
+
return this.parseLeverages(leverages, symbols, 'symbol');
|
|
3414
|
+
}
|
|
3415
|
+
parseLeverage(leverage, market = undefined) {
|
|
3416
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
3417
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
3418
|
+
const marginType = this.safeString(leverage, 'marginType');
|
|
3419
|
+
const marginMode = (marginType === 'crossed') ? 'cross' : 'isolated';
|
|
3420
|
+
return {
|
|
3421
|
+
'info': leverage,
|
|
3422
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3423
|
+
'marginMode': marginMode,
|
|
3424
|
+
'longLeverage': leverageValue,
|
|
3425
|
+
'shortLeverage': leverageValue,
|
|
3426
|
+
};
|
|
3427
|
+
}
|
|
3281
3428
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3282
3429
|
const version = api[0];
|
|
3283
3430
|
const access = api[1];
|