ccxt 4.2.55 → 4.2.57
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 +4 -3
- package/build.sh +2 -2
- package/dist/ccxt.browser.js +540 -185
- package/dist/ccxt.browser.min.js +6 -6
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +31 -2
- package/dist/cjs/src/binance.js +155 -0
- package/dist/cjs/src/bingx.js +3 -1
- package/dist/cjs/src/bitmex.js +42 -1
- package/dist/cjs/src/hitbtc.js +51 -54
- package/dist/cjs/src/mexc.js +75 -0
- package/dist/cjs/src/pro/bitget.js +69 -73
- package/dist/cjs/src/pro/bitmex.js +23 -32
- package/dist/cjs/src/pro/bybit.js +19 -5
- package/dist/cjs/src/pro/cex.js +6 -2
- package/dist/cjs/src/pro/coinex.js +6 -3
- package/dist/cjs/src/pro/currencycom.js +2 -1
- package/dist/cjs/src/pro/kraken.js +1 -1
- package/dist/cjs/src/pro/mexc.js +2 -2
- package/dist/cjs/src/pro/whitebit.js +11 -7
- package/dist/cjs/src/upbit.js +1 -1
- package/dist/cjs/src/woo.js +41 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/woo.d.ts +9 -0
- package/js/src/base/Exchange.d.ts +11 -5
- package/js/src/base/Exchange.js +31 -2
- package/js/src/base/types.d.ts +5 -3
- package/js/src/binance.d.ts +3 -1
- package/js/src/binance.js +155 -0
- package/js/src/bingx.d.ts +4 -4
- package/js/src/bingx.js +3 -1
- package/js/src/bitmex.d.ts +2 -0
- package/js/src/bitmex.js +42 -1
- package/js/src/hitbtc.d.ts +3 -2
- package/js/src/hitbtc.js +51 -54
- package/js/src/mexc.d.ts +12 -0
- package/js/src/mexc.js +75 -0
- package/js/src/pro/bitget.d.ts +0 -1
- package/js/src/pro/bitget.js +69 -73
- package/js/src/pro/bitmex.js +24 -31
- package/js/src/pro/bybit.js +19 -5
- package/js/src/pro/cex.js +6 -2
- package/js/src/pro/coinex.js +6 -3
- package/js/src/pro/currencycom.js +2 -1
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/mexc.js +2 -2
- package/js/src/pro/whitebit.js +11 -7
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/js/src/upbit.js +1 -1
- package/js/src/woo.d.ts +1 -0
- package/js/src/woo.js +41 -0
- package/package.json +1 -1
- package/skip-tests.json +21 -163
|
@@ -3,9 +3,9 @@ import { // eslint-disable-line object-curly-newline
|
|
|
3
3
|
ExchangeError, AuthenticationError, DDoSProtection, RequestTimeout, ExchangeNotAvailable, RateLimitExceeded } from "./errors.js";
|
|
4
4
|
import WsClient from './ws/WsClient.js';
|
|
5
5
|
import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
|
|
6
|
-
import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Str, Num, MarketInterface, CurrencyInterface, Account } from './types.js';
|
|
6
|
+
import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Str, Num, MarketInterface, CurrencyInterface, Account, MarginModes, MarketType } from './types.js';
|
|
7
7
|
export type { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRateHistory, Liquidation, FundingHistory, Greeks } from './types.js';
|
|
8
|
-
import { ArrayCache } from './ws/Cache.js';
|
|
8
|
+
import { ArrayCache, ArrayCacheByTimestamp } from './ws/Cache.js';
|
|
9
9
|
import { OrderBook as Ob } from './ws/OrderBook.js';
|
|
10
10
|
/**
|
|
11
11
|
* @class Exchange
|
|
@@ -82,7 +82,7 @@ export default class Exchange {
|
|
|
82
82
|
triggerOrders: ArrayCache;
|
|
83
83
|
trades: Dictionary<ArrayCache>;
|
|
84
84
|
transactions: {};
|
|
85
|
-
ohlcvs:
|
|
85
|
+
ohlcvs: Dictionary<Dictionary<ArrayCacheByTimestamp>>;
|
|
86
86
|
myTrades: ArrayCache;
|
|
87
87
|
positions: any;
|
|
88
88
|
urls: {
|
|
@@ -375,9 +375,11 @@ export default class Exchange {
|
|
|
375
375
|
fetchLedger: any;
|
|
376
376
|
fetchLedgerEntry: any;
|
|
377
377
|
fetchLeverage: any;
|
|
378
|
+
fetchLeverages: any;
|
|
378
379
|
fetchLeverageTiers: any;
|
|
379
380
|
fetchLiquidations: any;
|
|
380
381
|
fetchMarginMode: any;
|
|
382
|
+
fetchMarginModes: any;
|
|
381
383
|
fetchMarketLeverageTiers: any;
|
|
382
384
|
fetchMarkets: boolean;
|
|
383
385
|
fetchMarketsWs: any;
|
|
@@ -636,7 +638,7 @@ export default class Exchange {
|
|
|
636
638
|
filterByLimit(array: object[], limit?: Int, key?: IndexType, fromStart?: boolean): any;
|
|
637
639
|
filterBySinceLimit(array: object[], since?: Int, limit?: Int, key?: IndexType, tail?: boolean): any;
|
|
638
640
|
filterByValueSinceLimit(array: object[], field: IndexType, value?: any, since?: Int, limit?: Int, key?: string, tail?: boolean): any;
|
|
639
|
-
setSandboxMode(enabled:
|
|
641
|
+
setSandboxMode(enabled: boolean): void;
|
|
640
642
|
sign(path: any, api?: any, method?: string, params?: {}, headers?: any, body?: any): {};
|
|
641
643
|
fetchAccounts(params?: {}): Promise<{}>;
|
|
642
644
|
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
@@ -649,7 +651,8 @@ export default class Exchange {
|
|
|
649
651
|
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
650
652
|
fetchDepositAddresses(codes?: string[], params?: {}): Promise<{}>;
|
|
651
653
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
652
|
-
fetchMarginMode(symbol
|
|
654
|
+
fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
|
|
655
|
+
fetchMarginModes(symbols?: string[], params?: {}): Promise<MarginModes>;
|
|
653
656
|
fetchRestOrderBookSafe(symbol: any, limit?: any, params?: {}): Promise<OrderBook>;
|
|
654
657
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
655
658
|
fetchTime(params?: {}): Promise<Int>;
|
|
@@ -681,6 +684,7 @@ export default class Exchange {
|
|
|
681
684
|
createDepositAddress(code: string, params?: {}): Promise<DepositAddressResponse>;
|
|
682
685
|
setLeverage(leverage: Int, symbol?: string, params?: {}): Promise<{}>;
|
|
683
686
|
fetchLeverage(symbol: string, params?: {}): Promise<{}>;
|
|
687
|
+
fetchLeverages(symbols?: string[], params?: {}): Promise<{}>;
|
|
684
688
|
setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<{}>;
|
|
685
689
|
addMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
|
|
686
690
|
reduceMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
|
|
@@ -988,5 +992,7 @@ export default class Exchange {
|
|
|
988
992
|
parseLiquidation(liquidation: any, market?: Market): Liquidation;
|
|
989
993
|
parseLiquidations(liquidations: any, market?: any, since?: Int, limit?: Int): Liquidation[];
|
|
990
994
|
parseGreeks(greeks: any, market?: Market): Greeks;
|
|
995
|
+
parseMarginModes(response: object[], symbols?: string[], symbolKey?: string, marketType?: MarketType): MarginModes;
|
|
996
|
+
parseMarginMode(marginMode: any, market?: Market): MarginMode;
|
|
991
997
|
}
|
|
992
998
|
export { Exchange, };
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -430,9 +430,11 @@ export default class Exchange {
|
|
|
430
430
|
'fetchLedger': undefined,
|
|
431
431
|
'fetchLedgerEntry': undefined,
|
|
432
432
|
'fetchLeverage': undefined,
|
|
433
|
+
'fetchLeverages': undefined,
|
|
433
434
|
'fetchLeverageTiers': undefined,
|
|
434
435
|
'fetchLiquidations': undefined,
|
|
435
436
|
'fetchMarginMode': undefined,
|
|
437
|
+
'fetchMarginModes': undefined,
|
|
436
438
|
'fetchMarketLeverageTiers': undefined,
|
|
437
439
|
'fetchMarkets': true,
|
|
438
440
|
'fetchMarketsWs': undefined,
|
|
@@ -1863,8 +1865,17 @@ export default class Exchange {
|
|
|
1863
1865
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
1864
1866
|
throw new NotSupported(this.id + ' fetchOrderBook() is not supported yet');
|
|
1865
1867
|
}
|
|
1866
|
-
async fetchMarginMode(symbol
|
|
1867
|
-
|
|
1868
|
+
async fetchMarginMode(symbol, params = {}) {
|
|
1869
|
+
if (this.has['fetchMarginModes']) {
|
|
1870
|
+
const marginModes = await this.fetchMarginModes([symbol], params);
|
|
1871
|
+
return this.safeDict(marginModes, symbol);
|
|
1872
|
+
}
|
|
1873
|
+
else {
|
|
1874
|
+
throw new NotSupported(this.id + ' fetchMarginMode() is not supported yet');
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
async fetchMarginModes(symbols = undefined, params = {}) {
|
|
1878
|
+
throw new NotSupported(this.id + ' fetchMarginModes () is not supported yet');
|
|
1868
1879
|
}
|
|
1869
1880
|
async fetchRestOrderBookSafe(symbol, limit = undefined, params = {}) {
|
|
1870
1881
|
const fetchSnapshotMaxRetries = this.handleOption('watchOrderBook', 'maxRetries', 3);
|
|
@@ -1975,6 +1986,9 @@ export default class Exchange {
|
|
|
1975
1986
|
async fetchLeverage(symbol, params = {}) {
|
|
1976
1987
|
throw new NotSupported(this.id + ' fetchLeverage() is not supported yet');
|
|
1977
1988
|
}
|
|
1989
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
1990
|
+
throw new NotSupported(this.id + ' fetchLeverages() is not supported yet');
|
|
1991
|
+
}
|
|
1978
1992
|
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
1979
1993
|
throw new NotSupported(this.id + ' setPositionMode() is not supported yet');
|
|
1980
1994
|
}
|
|
@@ -5554,5 +5568,20 @@ export default class Exchange {
|
|
|
5554
5568
|
parseGreeks(greeks, market = undefined) {
|
|
5555
5569
|
throw new NotSupported(this.id + ' parseGreeks () is not supported yet');
|
|
5556
5570
|
}
|
|
5571
|
+
parseMarginModes(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
|
|
5572
|
+
const marginModeStructures = {};
|
|
5573
|
+
for (let i = 0; i < response.length; i++) {
|
|
5574
|
+
const info = response[i];
|
|
5575
|
+
const marketId = this.safeString(info, symbolKey);
|
|
5576
|
+
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
5577
|
+
if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
|
|
5578
|
+
marginModeStructures[market['symbol']] = this.parseMarginMode(info, market);
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5581
|
+
return marginModeStructures;
|
|
5582
|
+
}
|
|
5583
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
5584
|
+
throw new NotSupported(this.id + ' parseMarginMode () is not supported yet');
|
|
5585
|
+
}
|
|
5557
5586
|
}
|
|
5558
5587
|
export { Exchange, };
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export declare type SubType = 'linear' | 'inverse' | undefined;
|
|
|
11
11
|
export interface Dictionary<T> {
|
|
12
12
|
[key: string]: T;
|
|
13
13
|
}
|
|
14
|
-
export declare type Dict = Dictionary<any
|
|
15
|
-
export declare type List = Array<any
|
|
14
|
+
export declare type Dict = Dictionary<any> | undefined;
|
|
15
|
+
export declare type List = Array<any> | undefined;
|
|
16
16
|
/** Request parameters */
|
|
17
17
|
export interface MinMax {
|
|
18
18
|
min: Num;
|
|
@@ -365,7 +365,7 @@ export interface FundingHistory {
|
|
|
365
365
|
amount: number;
|
|
366
366
|
}
|
|
367
367
|
export interface MarginMode {
|
|
368
|
-
|
|
368
|
+
info: any;
|
|
369
369
|
symbol: string;
|
|
370
370
|
marginMode: 'isolated' | 'cross' | string;
|
|
371
371
|
}
|
|
@@ -390,6 +390,8 @@ export interface Greeks {
|
|
|
390
390
|
underlyingPrice: number;
|
|
391
391
|
info: any;
|
|
392
392
|
}
|
|
393
|
+
export interface MarginModes extends Dictionary<MarginMode> {
|
|
394
|
+
}
|
|
393
395
|
/** [ timestamp, open, high, low, close, volume ] */
|
|
394
396
|
export declare type OHLCV = [Num, Num, Num, Num, Num, Num];
|
|
395
397
|
/** [ timestamp, open, high, low, close, volume, count ] */
|
package/js/src/binance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/binance.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class binance
|
|
5
5
|
* @augments Exchange
|
|
@@ -433,4 +433,6 @@ export default class binance extends Exchange {
|
|
|
433
433
|
info: any;
|
|
434
434
|
hedged: boolean;
|
|
435
435
|
}>;
|
|
436
|
+
fetchMarginModes(symbols?: string[], params?: {}): Promise<MarginModes>;
|
|
437
|
+
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
436
438
|
}
|
package/js/src/binance.js
CHANGED
|
@@ -100,6 +100,8 @@ export default class binance extends Exchange {
|
|
|
100
100
|
'fetchLeverage': true,
|
|
101
101
|
'fetchLeverageTiers': true,
|
|
102
102
|
'fetchLiquidations': false,
|
|
103
|
+
'fetchMarginMode': 'emulated',
|
|
104
|
+
'fetchMarginModes': true,
|
|
103
105
|
'fetchMarketLeverageTiers': 'emulated',
|
|
104
106
|
'fetchMarkets': true,
|
|
105
107
|
'fetchMarkOHLCV': true,
|
|
@@ -12161,4 +12163,157 @@ export default class binance extends Exchange {
|
|
|
12161
12163
|
'hedged': dualSidePosition,
|
|
12162
12164
|
};
|
|
12163
12165
|
}
|
|
12166
|
+
async fetchMarginModes(symbols = undefined, params = {}) {
|
|
12167
|
+
/**
|
|
12168
|
+
* @method
|
|
12169
|
+
* @name binance#fetchMarginMode
|
|
12170
|
+
* @description fetches margin modes ("isolated" or "cross") that the market for the symbol in in, with symbol=undefined all markets for a subType (linear/inverse) are returned
|
|
12171
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
12172
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
12173
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
12174
|
+
* @returns {object} struct of marginMode
|
|
12175
|
+
*/
|
|
12176
|
+
await this.loadMarkets();
|
|
12177
|
+
let market = undefined;
|
|
12178
|
+
if (symbols !== undefined) {
|
|
12179
|
+
symbols = this.marketSymbols(symbols);
|
|
12180
|
+
market = this.market(symbols[0]);
|
|
12181
|
+
}
|
|
12182
|
+
let subType = undefined;
|
|
12183
|
+
[subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
|
|
12184
|
+
let response = undefined;
|
|
12185
|
+
if (subType === 'linear') {
|
|
12186
|
+
response = await this.fapiPrivateV2GetAccount(params);
|
|
12187
|
+
//
|
|
12188
|
+
// {
|
|
12189
|
+
// feeTier: '0',
|
|
12190
|
+
// canTrade: true,
|
|
12191
|
+
// canDeposit: true,
|
|
12192
|
+
// canWithdraw: true,
|
|
12193
|
+
// tradeGroupId: '-1',
|
|
12194
|
+
// updateTime: '0',
|
|
12195
|
+
// multiAssetsMargin: true,
|
|
12196
|
+
// totalInitialMargin: '438.31134352',
|
|
12197
|
+
// totalMaintMargin: '5.90847101',
|
|
12198
|
+
// totalWalletBalance: '4345.15626338',
|
|
12199
|
+
// totalUnrealizedProfit: '376.45220224',
|
|
12200
|
+
// totalMarginBalance: '4721.60846562',
|
|
12201
|
+
// totalPositionInitialMargin: '425.45252687',
|
|
12202
|
+
// totalOpenOrderInitialMargin: '12.85881664',
|
|
12203
|
+
// totalCrossWalletBalance: '4345.15626338',
|
|
12204
|
+
// totalCrossUnPnl: '376.45220224',
|
|
12205
|
+
// availableBalance: '4281.84764041',
|
|
12206
|
+
// maxWithdrawAmount: '4281.84764041',
|
|
12207
|
+
// assets: [
|
|
12208
|
+
// {
|
|
12209
|
+
// asset: 'ETH',
|
|
12210
|
+
// walletBalance: '0.00000000',
|
|
12211
|
+
// unrealizedProfit: '0.00000000',
|
|
12212
|
+
// marginBalance: '0.00000000',
|
|
12213
|
+
// maintMargin: '0.00000000',
|
|
12214
|
+
// initialMargin: '0.00000000',
|
|
12215
|
+
// positionInitialMargin: '0.00000000',
|
|
12216
|
+
// openOrderInitialMargin: '0.00000000',
|
|
12217
|
+
// maxWithdrawAmount: '0.00000000',
|
|
12218
|
+
// crossWalletBalance: '0.00000000',
|
|
12219
|
+
// crossUnPnl: '0.00000000',
|
|
12220
|
+
// availableBalance: '1.26075574',
|
|
12221
|
+
// marginAvailable: true,
|
|
12222
|
+
// updateTime: '0'
|
|
12223
|
+
// },
|
|
12224
|
+
// ...
|
|
12225
|
+
// ],
|
|
12226
|
+
// positions: [
|
|
12227
|
+
// {
|
|
12228
|
+
// symbol: 'SNTUSDT',
|
|
12229
|
+
// initialMargin: '0',
|
|
12230
|
+
// maintMargin: '0',
|
|
12231
|
+
// unrealizedProfit: '0.00000000',
|
|
12232
|
+
// positionInitialMargin: '0',
|
|
12233
|
+
// openOrderInitialMargin: '0',
|
|
12234
|
+
// leverage: '20',
|
|
12235
|
+
// isolated: false,
|
|
12236
|
+
// entryPrice: '0.0',
|
|
12237
|
+
// breakEvenPrice: '0.0',
|
|
12238
|
+
// maxNotional: '25000',
|
|
12239
|
+
// positionSide: 'BOTH',
|
|
12240
|
+
// positionAmt: '0',
|
|
12241
|
+
// notional: '0',
|
|
12242
|
+
// isolatedWallet: '0',
|
|
12243
|
+
// updateTime: '0',
|
|
12244
|
+
// bidNotional: '0',
|
|
12245
|
+
// askNotional: '0'
|
|
12246
|
+
// },
|
|
12247
|
+
// ...
|
|
12248
|
+
// ]
|
|
12249
|
+
// }
|
|
12250
|
+
//
|
|
12251
|
+
}
|
|
12252
|
+
else if (subType === 'inverse') {
|
|
12253
|
+
response = await this.dapiPrivateGetAccount(params);
|
|
12254
|
+
//
|
|
12255
|
+
// {
|
|
12256
|
+
// feeTier: '0',
|
|
12257
|
+
// canTrade: true,
|
|
12258
|
+
// canDeposit: true,
|
|
12259
|
+
// canWithdraw: true,
|
|
12260
|
+
// updateTime: '0',
|
|
12261
|
+
// assets: [
|
|
12262
|
+
// {
|
|
12263
|
+
// asset: 'APT',
|
|
12264
|
+
// walletBalance: '0.00000000',
|
|
12265
|
+
// unrealizedProfit: '0.00000000',
|
|
12266
|
+
// marginBalance: '0.00000000',
|
|
12267
|
+
// maintMargin: '0.00000000',
|
|
12268
|
+
// initialMargin: '0.00000000',
|
|
12269
|
+
// positionInitialMargin: '0.00000000',
|
|
12270
|
+
// openOrderInitialMargin: '0.00000000',
|
|
12271
|
+
// maxWithdrawAmount: '0.00000000',
|
|
12272
|
+
// crossWalletBalance: '0.00000000',
|
|
12273
|
+
// crossUnPnl: '0.00000000',
|
|
12274
|
+
// availableBalance: '0.00000000',
|
|
12275
|
+
// updateTime: '0'
|
|
12276
|
+
// },
|
|
12277
|
+
// ...
|
|
12278
|
+
// ],
|
|
12279
|
+
// positions: [
|
|
12280
|
+
// {
|
|
12281
|
+
// symbol: 'BCHUSD_240329',
|
|
12282
|
+
// initialMargin: '0',
|
|
12283
|
+
// maintMargin: '0',
|
|
12284
|
+
// unrealizedProfit: '0.00000000',
|
|
12285
|
+
// positionInitialMargin: '0',
|
|
12286
|
+
// openOrderInitialMargin: '0',
|
|
12287
|
+
// leverage: '20',
|
|
12288
|
+
// isolated: false,
|
|
12289
|
+
// positionSide: 'BOTH',
|
|
12290
|
+
// entryPrice: '0.00000000',
|
|
12291
|
+
// maxQty: '1000',
|
|
12292
|
+
// notionalValue: '0',
|
|
12293
|
+
// isolatedWallet: '0',
|
|
12294
|
+
// updateTime: '0',
|
|
12295
|
+
// positionAmt: '0',
|
|
12296
|
+
// breakEvenPrice: '0.00000000'
|
|
12297
|
+
// },
|
|
12298
|
+
// ...
|
|
12299
|
+
// ]
|
|
12300
|
+
// }
|
|
12301
|
+
//
|
|
12302
|
+
}
|
|
12303
|
+
else {
|
|
12304
|
+
throw new BadRequest(this.id + ' fetchMarginModes () supports linear and inverse subTypes only');
|
|
12305
|
+
}
|
|
12306
|
+
const assets = this.safeValue(response, 'positions', []);
|
|
12307
|
+
return this.parseMarginModes(assets, symbols, 'symbol', 'swap');
|
|
12308
|
+
}
|
|
12309
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
12310
|
+
const marketId = this.safeString(marginMode, 'symbol');
|
|
12311
|
+
market = this.safeMarket(marketId, market);
|
|
12312
|
+
const isIsolated = this.safeBool(marginMode, 'isolated');
|
|
12313
|
+
return {
|
|
12314
|
+
'info': marginMode,
|
|
12315
|
+
'symbol': market['symbol'],
|
|
12316
|
+
'marginMode': isIsolated ? 'isolated' : 'cross',
|
|
12317
|
+
};
|
|
12318
|
+
}
|
|
12164
12319
|
}
|
package/js/src/bingx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bingx.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Dict } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bingx
|
|
5
5
|
* @augments Exchange
|
|
@@ -61,7 +61,7 @@ export default class bingx extends Exchange {
|
|
|
61
61
|
parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
|
|
62
62
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
63
63
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
64
|
-
parseTicker(ticker:
|
|
64
|
+
parseTicker(ticker: Dict, market?: Market): Ticker;
|
|
65
65
|
fetchBalance(params?: {}): Promise<Balances>;
|
|
66
66
|
parseBalance(response: any): Balances;
|
|
67
67
|
fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
|
|
@@ -107,7 +107,7 @@ export default class bingx extends Exchange {
|
|
|
107
107
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
108
108
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
109
109
|
parseTransaction(transaction: any, currency?: Currency): Transaction;
|
|
110
|
-
parseTransactionStatus(status:
|
|
110
|
+
parseTransactionStatus(status: string): string;
|
|
111
111
|
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
|
|
112
112
|
setMargin(symbol: string, amount: number, params?: {}): Promise<any>;
|
|
113
113
|
fetchLeverage(symbol: string, params?: {}): Promise<any>;
|
|
@@ -145,6 +145,6 @@ export default class bingx extends Exchange {
|
|
|
145
145
|
headers: any;
|
|
146
146
|
};
|
|
147
147
|
nonce(): number;
|
|
148
|
-
setSandboxMode(enable:
|
|
148
|
+
setSandboxMode(enable: boolean): void;
|
|
149
149
|
handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
150
150
|
}
|
package/js/src/bingx.js
CHANGED
|
@@ -1402,7 +1402,9 @@ export default class bingx extends Exchange {
|
|
|
1402
1402
|
if (symbols !== undefined) {
|
|
1403
1403
|
symbols = this.marketSymbols(symbols);
|
|
1404
1404
|
const firstSymbol = this.safeString(symbols, 0);
|
|
1405
|
-
|
|
1405
|
+
if (firstSymbol !== undefined) {
|
|
1406
|
+
market = this.market(firstSymbol);
|
|
1407
|
+
}
|
|
1406
1408
|
}
|
|
1407
1409
|
let type = undefined;
|
|
1408
1410
|
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
package/js/src/bitmex.d.ts
CHANGED
|
@@ -62,6 +62,8 @@ export default class bitmex extends Exchange {
|
|
|
62
62
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
63
63
|
cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
|
|
64
64
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
|
|
65
|
+
fetchLeverages(symbols?: string[], params?: {}): Promise<any[]>;
|
|
66
|
+
fetchLeverage(symbol: string, params?: {}): Promise<any[]>;
|
|
65
67
|
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
66
68
|
parsePosition(position: any, market?: Market): import("./base/types.js").Position;
|
|
67
69
|
withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
|
package/js/src/bitmex.js
CHANGED
|
@@ -62,7 +62,8 @@ export default class bitmex extends Exchange {
|
|
|
62
62
|
'fetchFundingRates': true,
|
|
63
63
|
'fetchIndexOHLCV': false,
|
|
64
64
|
'fetchLedger': true,
|
|
65
|
-
'fetchLeverage':
|
|
65
|
+
'fetchLeverage': true,
|
|
66
|
+
'fetchLeverages': true,
|
|
66
67
|
'fetchLeverageTiers': false,
|
|
67
68
|
'fetchLiquidations': true,
|
|
68
69
|
'fetchMarketLeverageTiers': false,
|
|
@@ -2117,6 +2118,46 @@ export default class bitmex extends Exchange {
|
|
|
2117
2118
|
//
|
|
2118
2119
|
return this.parseOrders(response, market);
|
|
2119
2120
|
}
|
|
2121
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
2122
|
+
/**
|
|
2123
|
+
* @method
|
|
2124
|
+
* @name bitmex#fetchLeverages
|
|
2125
|
+
* @description fetch the set leverage for all contract markets
|
|
2126
|
+
* @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
|
|
2127
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
2128
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2129
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
2130
|
+
*/
|
|
2131
|
+
await this.loadMarkets();
|
|
2132
|
+
const positions = await this.fetchPositions(symbols, params);
|
|
2133
|
+
const result = [];
|
|
2134
|
+
for (let i = 0; i < positions.length; i++) {
|
|
2135
|
+
const entry = positions[i];
|
|
2136
|
+
const marketId = this.safeString(entry, 'symbol');
|
|
2137
|
+
const market = this.safeMarket(marketId, undefined, undefined, 'contract');
|
|
2138
|
+
result.push({
|
|
2139
|
+
'info': entry,
|
|
2140
|
+
'symbol': market['symbol'],
|
|
2141
|
+
'leverage': this.safeInteger(entry, 'leverage'),
|
|
2142
|
+
'marginMode': this.safeString(entry, 'marginMode'),
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
return result;
|
|
2146
|
+
}
|
|
2147
|
+
async fetchLeverage(symbol, params = {}) {
|
|
2148
|
+
/**
|
|
2149
|
+
* @method
|
|
2150
|
+
* @name bitmex#fetchLeverage
|
|
2151
|
+
* @description fetch the set leverage for a market
|
|
2152
|
+
* @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
|
|
2153
|
+
* @param {string} symbol unified market symbol
|
|
2154
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2155
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
2156
|
+
*/
|
|
2157
|
+
await this.loadMarkets();
|
|
2158
|
+
const leverage = await this.fetchLeverages([symbol], params);
|
|
2159
|
+
return leverage;
|
|
2160
|
+
}
|
|
2120
2161
|
async fetchPositions(symbols = undefined, params = {}) {
|
|
2121
2162
|
/**
|
|
2122
2163
|
* @method
|
package/js/src/hitbtc.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/hitbtc.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, OrderType, FundingRateHistory, OHLCV, Ticker, Order, OrderBook, Dictionary, Position, Str, Trade, Balances, Transaction, MarginMode, Tickers, Strings, Market, Currency } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, OrderType, FundingRateHistory, OHLCV, Ticker, Order, OrderBook, Dictionary, Position, Str, Trade, Balances, Transaction, MarginMode, Tickers, Strings, Market, Currency, MarginModes } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class hitbtc
|
|
5
5
|
* @augments Exchange
|
|
@@ -69,7 +69,8 @@ export default class hitbtc extends Exchange {
|
|
|
69
69
|
createOrderRequest(market: object, marketType: string, type: OrderType, side: OrderSide, amount: any, price?: any, marginMode?: Str, params?: {}): {}[];
|
|
70
70
|
parseOrderStatus(status: any): string;
|
|
71
71
|
parseOrder(order: any, market?: Market): Order;
|
|
72
|
-
|
|
72
|
+
fetchMarginModes(symbols?: Str[], params?: {}): Promise<MarginModes>;
|
|
73
|
+
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
73
74
|
transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
|
|
74
75
|
parseTransfer(transfer: any, currency?: Currency): {
|
|
75
76
|
id: string;
|
package/js/src/hitbtc.js
CHANGED
|
@@ -66,7 +66,8 @@ export default class hitbtc extends Exchange {
|
|
|
66
66
|
'fetchLeverage': true,
|
|
67
67
|
'fetchLeverageTiers': undefined,
|
|
68
68
|
'fetchLiquidations': false,
|
|
69
|
-
'fetchMarginMode':
|
|
69
|
+
'fetchMarginMode': 'emulated',
|
|
70
|
+
'fetchMarginModes': true,
|
|
70
71
|
'fetchMarketLeverageTiers': false,
|
|
71
72
|
'fetchMarkets': true,
|
|
72
73
|
'fetchMarkOHLCV': true,
|
|
@@ -2510,7 +2511,7 @@ export default class hitbtc extends Exchange {
|
|
|
2510
2511
|
'stopLossPrice': undefined,
|
|
2511
2512
|
}, market);
|
|
2512
2513
|
}
|
|
2513
|
-
async
|
|
2514
|
+
async fetchMarginModes(symbols = undefined, params = {}) {
|
|
2514
2515
|
/**
|
|
2515
2516
|
* @method
|
|
2516
2517
|
* @name hitbtc#fetchMarginMode
|
|
@@ -2523,70 +2524,66 @@ export default class hitbtc extends Exchange {
|
|
|
2523
2524
|
*/
|
|
2524
2525
|
await this.loadMarkets();
|
|
2525
2526
|
let market = undefined;
|
|
2526
|
-
if (
|
|
2527
|
-
|
|
2527
|
+
if (symbols !== undefined) {
|
|
2528
|
+
symbols = this.marketSymbols(symbols);
|
|
2529
|
+
market = this.market(symbols[0]);
|
|
2528
2530
|
}
|
|
2529
2531
|
let marketType = undefined;
|
|
2530
2532
|
[marketType, params] = this.handleMarketTypeAndParams('fetchMarginMode', market, params);
|
|
2531
2533
|
let response = undefined;
|
|
2532
2534
|
if (marketType === 'margin') {
|
|
2533
2535
|
response = await this.privateGetMarginConfig(params);
|
|
2536
|
+
//
|
|
2537
|
+
// {
|
|
2538
|
+
// "config": [{
|
|
2539
|
+
// "symbol": "BTCUSD",
|
|
2540
|
+
// "margin_call_leverage_mul": "1.50",
|
|
2541
|
+
// "liquidation_leverage_mul": "2.00",
|
|
2542
|
+
// "max_initial_leverage": "10.00",
|
|
2543
|
+
// "margin_mode": "Isolated",
|
|
2544
|
+
// "force_close_fee": "0.05",
|
|
2545
|
+
// "enabled": true,
|
|
2546
|
+
// "active": true,
|
|
2547
|
+
// "limit_base": "50000.00",
|
|
2548
|
+
// "limit_power": "2.2",
|
|
2549
|
+
// "unlimited_threshold": "10.0"
|
|
2550
|
+
// }]
|
|
2551
|
+
// }
|
|
2552
|
+
//
|
|
2534
2553
|
}
|
|
2535
2554
|
else if (marketType === 'swap') {
|
|
2536
2555
|
response = await this.privateGetFuturesConfig(params);
|
|
2556
|
+
//
|
|
2557
|
+
// {
|
|
2558
|
+
// "config": [{
|
|
2559
|
+
// "symbol": "BTCUSD_PERP",
|
|
2560
|
+
// "margin_call_leverage_mul": "1.20",
|
|
2561
|
+
// "liquidation_leverage_mul": "2.00",
|
|
2562
|
+
// "max_initial_leverage": "100.00",
|
|
2563
|
+
// "margin_mode": "Isolated",
|
|
2564
|
+
// "force_close_fee": "0.001",
|
|
2565
|
+
// "enabled": true,
|
|
2566
|
+
// "active": false,
|
|
2567
|
+
// "limit_base": "5000000.000000000000",
|
|
2568
|
+
// "limit_power": "1.25",
|
|
2569
|
+
// "unlimited_threshold": "2.00"
|
|
2570
|
+
// }]
|
|
2571
|
+
// }
|
|
2572
|
+
//
|
|
2537
2573
|
}
|
|
2538
2574
|
else {
|
|
2539
|
-
throw new BadSymbol(this.id + '
|
|
2540
|
-
}
|
|
2541
|
-
//
|
|
2542
|
-
// margin
|
|
2543
|
-
// {
|
|
2544
|
-
// "config": [{
|
|
2545
|
-
// "symbol": "BTCUSD",
|
|
2546
|
-
// "margin_call_leverage_mul": "1.50",
|
|
2547
|
-
// "liquidation_leverage_mul": "2.00",
|
|
2548
|
-
// "max_initial_leverage": "10.00",
|
|
2549
|
-
// "margin_mode": "Isolated",
|
|
2550
|
-
// "force_close_fee": "0.05",
|
|
2551
|
-
// "enabled": true,
|
|
2552
|
-
// "active": true,
|
|
2553
|
-
// "limit_base": "50000.00",
|
|
2554
|
-
// "limit_power": "2.2",
|
|
2555
|
-
// "unlimited_threshold": "10.0"
|
|
2556
|
-
// }]
|
|
2557
|
-
// }
|
|
2558
|
-
//
|
|
2559
|
-
// swap
|
|
2560
|
-
// {
|
|
2561
|
-
// "config": [{
|
|
2562
|
-
// "symbol": "BTCUSD_PERP",
|
|
2563
|
-
// "margin_call_leverage_mul": "1.20",
|
|
2564
|
-
// "liquidation_leverage_mul": "2.00",
|
|
2565
|
-
// "max_initial_leverage": "100.00",
|
|
2566
|
-
// "margin_mode": "Isolated",
|
|
2567
|
-
// "force_close_fee": "0.001",
|
|
2568
|
-
// "enabled": true,
|
|
2569
|
-
// "active": false,
|
|
2570
|
-
// "limit_base": "5000000.000000000000",
|
|
2571
|
-
// "limit_power": "1.25",
|
|
2572
|
-
// "unlimited_threshold": "2.00"
|
|
2573
|
-
// }]
|
|
2574
|
-
// }
|
|
2575
|
-
//
|
|
2576
|
-
const config = this.safeValue(response, 'config', []);
|
|
2577
|
-
const marginModes = [];
|
|
2578
|
-
for (let i = 0; i < config.length; i++) {
|
|
2579
|
-
const data = this.safeValue(config, i);
|
|
2580
|
-
const marketId = this.safeString(data, 'symbol');
|
|
2581
|
-
const marketInner = this.safeMarket(marketId);
|
|
2582
|
-
marginModes.push({
|
|
2583
|
-
'info': data,
|
|
2584
|
-
'symbol': this.safeString(marketInner, 'symbol'),
|
|
2585
|
-
'marginMode': this.safeStringLower(data, 'margin_mode'),
|
|
2586
|
-
});
|
|
2575
|
+
throw new BadSymbol(this.id + ' fetchMarginModes () supports swap contracts and margin only');
|
|
2587
2576
|
}
|
|
2588
|
-
const
|
|
2589
|
-
return this.
|
|
2577
|
+
const config = this.safeList(response, 'config', []);
|
|
2578
|
+
return this.parseMarginModes(config, symbols, 'symbol');
|
|
2579
|
+
}
|
|
2580
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
2581
|
+
const marketId = this.safeString(marginMode, 'symbol');
|
|
2582
|
+
return {
|
|
2583
|
+
'info': marginMode,
|
|
2584
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
2585
|
+
'marginMode': this.safeStringLower(marginMode, 'margin_mode'),
|
|
2586
|
+
};
|
|
2590
2587
|
}
|
|
2591
2588
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
2592
2589
|
/**
|
package/js/src/mexc.d.ts
CHANGED
|
@@ -172,6 +172,18 @@ export default class mexc extends Exchange {
|
|
|
172
172
|
parseTransactionFee(transaction: any, currency?: Currency): {};
|
|
173
173
|
fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
|
|
174
174
|
parseDepositWithdrawFee(fee: any, currency?: Currency): any;
|
|
175
|
+
fetchLeverage(symbol: string, params?: {}): Promise<{
|
|
176
|
+
info: any;
|
|
177
|
+
symbol: string;
|
|
178
|
+
leverage: number;
|
|
179
|
+
marginMode: any;
|
|
180
|
+
}>;
|
|
181
|
+
parseLeverage(leverage: any, market?: Market): {
|
|
182
|
+
info: any;
|
|
183
|
+
symbol: string;
|
|
184
|
+
leverage: number;
|
|
185
|
+
marginMode: any;
|
|
186
|
+
};
|
|
175
187
|
handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
|
|
176
188
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
177
189
|
url: any;
|