ccxt 4.2.57 → 4.2.59
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/CHANGELOG.md +83 -0
- package/README.md +4 -5
- package/build.sh +1 -1
- package/cleanup.sh +3 -0
- package/dist/ccxt.browser.js +772 -497
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +90 -88
- package/dist/cjs/src/base/Exchange.js +24 -1
- package/dist/cjs/src/binance.js +43 -30
- package/dist/cjs/src/bingx.js +15 -4
- package/dist/cjs/src/bitget.js +72 -57
- package/dist/cjs/src/bitmex.js +13 -29
- package/dist/cjs/src/bitrue.js +24 -15
- package/dist/cjs/src/blofin.js +25 -2
- package/dist/cjs/src/bybit.js +11 -3
- package/dist/cjs/src/coinbase.js +24 -14
- package/dist/cjs/src/currencycom.js +15 -5
- package/dist/cjs/src/delta.js +14 -1
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/hitbtc.js +12 -1
- package/dist/cjs/src/krakenfutures.js +22 -7
- package/dist/cjs/src/kuna.js +14 -11
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/mexc.js +20 -20
- package/dist/cjs/src/okx.js +32 -2
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/bitfinex2.js +1 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +51 -89
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/coinex.js +1 -1
- package/dist/cjs/src/pro/cryptocom.js +1 -1
- package/dist/cjs/src/pro/deribit.js +201 -84
- package/dist/cjs/src/pro/gate.js +1 -1
- package/dist/cjs/src/pro/independentreserve.js +1 -1
- package/dist/cjs/src/pro/kraken.js +1 -1
- package/dist/cjs/src/pro/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/mexc.js +5 -3
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/whitebit.js +4 -6
- package/dist/cjs/src/pro/woo.js +1 -1
- package/dist/cjs/src/probit.js +1 -1
- package/dist/cjs/src/wavesexchange.js +1 -1
- package/dist/cjs/src/woo.js +22 -6
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/alpaca.js +90 -88
- package/js/src/base/Exchange.d.ts +6 -4
- package/js/src/base/Exchange.js +24 -1
- package/js/src/base/types.d.ts +9 -0
- package/js/src/binance.d.ts +3 -2
- package/js/src/binance.js +43 -30
- package/js/src/bingx.d.ts +3 -2
- package/js/src/bingx.js +15 -4
- package/js/src/bitget.d.ts +3 -2
- package/js/src/bitget.js +72 -57
- package/js/src/bitmex.d.ts +3 -3
- package/js/src/bitmex.js +13 -29
- package/js/src/bitrue.js +24 -15
- package/js/src/blofin.d.ts +3 -2
- package/js/src/blofin.js +25 -2
- package/js/src/bybit.d.ts +3 -6
- package/js/src/bybit.js +11 -3
- package/js/src/coinbase.js +24 -14
- package/js/src/currencycom.d.ts +3 -2
- package/js/src/currencycom.js +15 -5
- package/js/src/delta.d.ts +3 -2
- package/js/src/delta.js +14 -1
- package/js/src/gate.js +1 -1
- package/js/src/hitbtc.d.ts +3 -2
- package/js/src/hitbtc.js +12 -1
- package/js/src/krakenfutures.d.ts +3 -2
- package/js/src/krakenfutures.js +22 -7
- package/js/src/kuna.js +14 -11
- package/js/src/lbank.js +1 -1
- package/js/src/mexc.d.ts +3 -13
- package/js/src/mexc.js +20 -20
- package/js/src/okx.d.ts +3 -2
- package/js/src/okx.js +32 -2
- package/js/src/phemex.js +1 -1
- package/js/src/pro/alpaca.js +1 -1
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/bitfinex2.js +1 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.d.ts +2 -2
- package/js/src/pro/bitmart.js +51 -89
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/pro/coinex.js +1 -1
- package/js/src/pro/cryptocom.js +1 -1
- package/js/src/pro/deribit.d.ts +5 -0
- package/js/src/pro/deribit.js +202 -85
- package/js/src/pro/gate.js +1 -1
- package/js/src/pro/independentreserve.js +1 -1
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/kucoinfutures.js +1 -1
- package/js/src/pro/mexc.js +6 -4
- package/js/src/pro/okx.js +1 -1
- package/js/src/pro/whitebit.js +4 -6
- package/js/src/pro/woo.js +1 -1
- package/js/src/probit.js +1 -1
- package/js/src/wavesexchange.js +1 -1
- package/js/src/woo.d.ts +3 -5
- package/js/src/woo.js +22 -6
- package/package.json +1 -1
- package/skip-tests.json +8 -3
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.59';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/alpaca.js
CHANGED
|
@@ -443,7 +443,7 @@ export default class alpaca extends Exchange {
|
|
|
443
443
|
'loc': loc,
|
|
444
444
|
};
|
|
445
445
|
params = this.omit(params, ['loc', 'method']);
|
|
446
|
-
let
|
|
446
|
+
let symbolTrades = undefined;
|
|
447
447
|
if (method === 'marketPublicGetV1beta3CryptoLocTrades') {
|
|
448
448
|
if (since !== undefined) {
|
|
449
449
|
request['start'] = this.iso8601(since);
|
|
@@ -451,47 +451,48 @@ export default class alpaca extends Exchange {
|
|
|
451
451
|
if (limit !== undefined) {
|
|
452
452
|
request['limit'] = limit;
|
|
453
453
|
}
|
|
454
|
-
response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
|
|
454
|
+
const response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
|
|
455
|
+
//
|
|
456
|
+
// {
|
|
457
|
+
// "next_page_token": null,
|
|
458
|
+
// "trades": {
|
|
459
|
+
// "BTC/USD": [
|
|
460
|
+
// {
|
|
461
|
+
// "i": 36440704,
|
|
462
|
+
// "p": 22625,
|
|
463
|
+
// "s": 0.0001,
|
|
464
|
+
// "t": "2022-07-21T11:47:31.073391Z",
|
|
465
|
+
// "tks": "B"
|
|
466
|
+
// }
|
|
467
|
+
// ]
|
|
468
|
+
// }
|
|
469
|
+
// }
|
|
470
|
+
//
|
|
471
|
+
const trades = this.safeDict(response, 'trades', {});
|
|
472
|
+
symbolTrades = this.safeList(trades, marketId, []);
|
|
455
473
|
}
|
|
456
474
|
else if (method === 'marketPublicGetV1beta3CryptoLocLatestTrades') {
|
|
457
|
-
response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
|
|
475
|
+
const response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
|
|
476
|
+
//
|
|
477
|
+
// {
|
|
478
|
+
// "trades": {
|
|
479
|
+
// "BTC/USD": {
|
|
480
|
+
// "i": 36440704,
|
|
481
|
+
// "p": 22625,
|
|
482
|
+
// "s": 0.0001,
|
|
483
|
+
// "t": "2022-07-21T11:47:31.073391Z",
|
|
484
|
+
// "tks": "B"
|
|
485
|
+
// }
|
|
486
|
+
// }
|
|
487
|
+
// }
|
|
488
|
+
//
|
|
489
|
+
const trades = this.safeDict(response, 'trades', {});
|
|
490
|
+
symbolTrades = this.safeDict(trades, marketId, {});
|
|
491
|
+
symbolTrades = [symbolTrades];
|
|
458
492
|
}
|
|
459
493
|
else {
|
|
460
494
|
throw new NotSupported(this.id + ' fetchTrades() does not support ' + method + ', marketPublicGetV1beta3CryptoLocTrades and marketPublicGetV1beta3CryptoLocLatestTrades are supported');
|
|
461
495
|
}
|
|
462
|
-
//
|
|
463
|
-
// {
|
|
464
|
-
// "next_page_token":null,
|
|
465
|
-
// "trades":{
|
|
466
|
-
// "BTC/USD":[
|
|
467
|
-
// {
|
|
468
|
-
// "i":36440704,
|
|
469
|
-
// "p":22625,
|
|
470
|
-
// "s":0.0001,
|
|
471
|
-
// "t":"2022-07-21T11:47:31.073391Z",
|
|
472
|
-
// "tks":"B"
|
|
473
|
-
// }
|
|
474
|
-
// ]
|
|
475
|
-
// }
|
|
476
|
-
// }
|
|
477
|
-
//
|
|
478
|
-
// {
|
|
479
|
-
// "trades":{
|
|
480
|
-
// "BTC/USD":{
|
|
481
|
-
// "i":36440704,
|
|
482
|
-
// "p":22625,
|
|
483
|
-
// "s":0.0001,
|
|
484
|
-
// "t":"2022-07-21T11:47:31.073391Z",
|
|
485
|
-
// "tks":"B"
|
|
486
|
-
// }
|
|
487
|
-
// }
|
|
488
|
-
// }
|
|
489
|
-
//
|
|
490
|
-
const trades = this.safeValue(response, 'trades', {});
|
|
491
|
-
let symbolTrades = this.safeValue(trades, marketId, {});
|
|
492
|
-
if (!Array.isArray(symbolTrades)) {
|
|
493
|
-
symbolTrades = [symbolTrades];
|
|
494
|
-
}
|
|
495
496
|
return this.parseTrades(symbolTrades, market, since, limit);
|
|
496
497
|
}
|
|
497
498
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
@@ -583,7 +584,7 @@ export default class alpaca extends Exchange {
|
|
|
583
584
|
'loc': loc,
|
|
584
585
|
};
|
|
585
586
|
params = this.omit(params, ['loc', 'method']);
|
|
586
|
-
let
|
|
587
|
+
let ohlcvs = undefined;
|
|
587
588
|
if (method === 'marketPublicGetV1beta3CryptoLocBars') {
|
|
588
589
|
if (limit !== undefined) {
|
|
589
590
|
request['limit'] = limit;
|
|
@@ -592,63 +593,64 @@ export default class alpaca extends Exchange {
|
|
|
592
593
|
request['start'] = this.yyyymmdd(since);
|
|
593
594
|
}
|
|
594
595
|
request['timeframe'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
595
|
-
response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
|
|
596
|
+
const response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
|
|
597
|
+
//
|
|
598
|
+
// {
|
|
599
|
+
// "bars": {
|
|
600
|
+
// "BTC/USD": [
|
|
601
|
+
// {
|
|
602
|
+
// "c": 22887,
|
|
603
|
+
// "h": 22888,
|
|
604
|
+
// "l": 22873,
|
|
605
|
+
// "n": 11,
|
|
606
|
+
// "o": 22883,
|
|
607
|
+
// "t": "2022-07-21T05:00:00Z",
|
|
608
|
+
// "v": 1.1138,
|
|
609
|
+
// "vw": 22883.0155324116
|
|
610
|
+
// },
|
|
611
|
+
// {
|
|
612
|
+
// "c": 22895,
|
|
613
|
+
// "h": 22895,
|
|
614
|
+
// "l": 22884,
|
|
615
|
+
// "n": 6,
|
|
616
|
+
// "o": 22884,
|
|
617
|
+
// "t": "2022-07-21T05:01:00Z",
|
|
618
|
+
// "v": 0.001,
|
|
619
|
+
// "vw": 22889.5
|
|
620
|
+
// }
|
|
621
|
+
// ]
|
|
622
|
+
// },
|
|
623
|
+
// "next_page_token": "QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
|
|
624
|
+
// }
|
|
625
|
+
//
|
|
626
|
+
const bars = this.safeDict(response, 'bars', {});
|
|
627
|
+
ohlcvs = this.safeList(bars, marketId, []);
|
|
596
628
|
}
|
|
597
629
|
else if (method === 'marketPublicGetV1beta3CryptoLocLatestBars') {
|
|
598
|
-
response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
|
|
630
|
+
const response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
|
|
631
|
+
//
|
|
632
|
+
// {
|
|
633
|
+
// "bars": {
|
|
634
|
+
// "BTC/USD": {
|
|
635
|
+
// "c": 22887,
|
|
636
|
+
// "h": 22888,
|
|
637
|
+
// "l": 22873,
|
|
638
|
+
// "n": 11,
|
|
639
|
+
// "o": 22883,
|
|
640
|
+
// "t": "2022-07-21T05:00:00Z",
|
|
641
|
+
// "v": 1.1138,
|
|
642
|
+
// "vw": 22883.0155324116
|
|
643
|
+
// }
|
|
644
|
+
// }
|
|
645
|
+
// }
|
|
646
|
+
//
|
|
647
|
+
const bars = this.safeDict(response, 'bars', {});
|
|
648
|
+
ohlcvs = this.safeDict(bars, marketId, {});
|
|
649
|
+
ohlcvs = [ohlcvs];
|
|
599
650
|
}
|
|
600
651
|
else {
|
|
601
652
|
throw new NotSupported(this.id + ' fetchOHLCV() does not support ' + method + ', marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported');
|
|
602
653
|
}
|
|
603
|
-
//
|
|
604
|
-
// {
|
|
605
|
-
// "bars":{
|
|
606
|
-
// "BTC/USD":[
|
|
607
|
-
// {
|
|
608
|
-
// "c":22887,
|
|
609
|
-
// "h":22888,
|
|
610
|
-
// "l":22873,
|
|
611
|
-
// "n":11,
|
|
612
|
-
// "o":22883,
|
|
613
|
-
// "t":"2022-07-21T05:00:00Z",
|
|
614
|
-
// "v":1.1138,
|
|
615
|
-
// "vw":22883.0155324116
|
|
616
|
-
// },
|
|
617
|
-
// {
|
|
618
|
-
// "c":22895,
|
|
619
|
-
// "h":22895,
|
|
620
|
-
// "l":22884,
|
|
621
|
-
// "n":6,
|
|
622
|
-
// "o":22884,
|
|
623
|
-
// "t":"2022-07-21T05:01:00Z",
|
|
624
|
-
// "v":0.001,
|
|
625
|
-
// "vw":22889.5
|
|
626
|
-
// }
|
|
627
|
-
// ]
|
|
628
|
-
// },
|
|
629
|
-
// "next_page_token":"QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
|
|
630
|
-
// }
|
|
631
|
-
//
|
|
632
|
-
// {
|
|
633
|
-
// "bars":{
|
|
634
|
-
// "BTC/USD":{
|
|
635
|
-
// "c":22887,
|
|
636
|
-
// "h":22888,
|
|
637
|
-
// "l":22873,
|
|
638
|
-
// "n":11,
|
|
639
|
-
// "o":22883,
|
|
640
|
-
// "t":"2022-07-21T05:00:00Z",
|
|
641
|
-
// "v":1.1138,
|
|
642
|
-
// "vw":22883.0155324116
|
|
643
|
-
// }
|
|
644
|
-
// }
|
|
645
|
-
// }
|
|
646
|
-
//
|
|
647
|
-
const bars = this.safeValue(response, 'bars', {});
|
|
648
|
-
let ohlcvs = this.safeValue(bars, marketId, {});
|
|
649
|
-
if (!Array.isArray(ohlcvs)) {
|
|
650
|
-
ohlcvs = [ohlcvs];
|
|
651
|
-
}
|
|
652
654
|
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
653
655
|
}
|
|
654
656
|
parseOHLCV(ohlcv, market = undefined) {
|
|
@@ -3,8 +3,8 @@ 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, MarginModes, MarketType } from './types.js';
|
|
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';
|
|
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, Leverage, Leverages } from './types.js';
|
|
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, Leverage, Leverages } from './types.js';
|
|
8
8
|
import { ArrayCache, ArrayCacheByTimestamp } from './ws/Cache.js';
|
|
9
9
|
import { OrderBook as Ob } from './ws/OrderBook.js';
|
|
10
10
|
/**
|
|
@@ -683,8 +683,8 @@ export default class Exchange {
|
|
|
683
683
|
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
684
684
|
createDepositAddress(code: string, params?: {}): Promise<DepositAddressResponse>;
|
|
685
685
|
setLeverage(leverage: Int, symbol?: string, params?: {}): Promise<{}>;
|
|
686
|
-
fetchLeverage(symbol: string, params?: {}): Promise<
|
|
687
|
-
fetchLeverages(symbols?: string[], params?: {}): Promise<
|
|
686
|
+
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
687
|
+
fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
|
|
688
688
|
setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<{}>;
|
|
689
689
|
addMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
|
|
690
690
|
reduceMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
|
|
@@ -994,5 +994,7 @@ export default class Exchange {
|
|
|
994
994
|
parseGreeks(greeks: any, market?: Market): Greeks;
|
|
995
995
|
parseMarginModes(response: object[], symbols?: string[], symbolKey?: string, marketType?: MarketType): MarginModes;
|
|
996
996
|
parseMarginMode(marginMode: any, market?: Market): MarginMode;
|
|
997
|
+
parseLeverages(response: object[], symbols?: string[], symbolKey?: string, marketType?: MarketType): Leverages;
|
|
998
|
+
parseLeverage(leverage: any, market?: Market): Leverage;
|
|
997
999
|
}
|
|
998
1000
|
export { Exchange, };
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -1984,7 +1984,13 @@ export default class Exchange {
|
|
|
1984
1984
|
throw new NotSupported(this.id + ' setLeverage() is not supported yet');
|
|
1985
1985
|
}
|
|
1986
1986
|
async fetchLeverage(symbol, params = {}) {
|
|
1987
|
-
|
|
1987
|
+
if (this.has['fetchLeverages']) {
|
|
1988
|
+
const leverages = await this.fetchLeverages([symbol], params);
|
|
1989
|
+
return this.safeDict(leverages, symbol);
|
|
1990
|
+
}
|
|
1991
|
+
else {
|
|
1992
|
+
throw new NotSupported(this.id + ' fetchLeverage() is not supported yet');
|
|
1993
|
+
}
|
|
1988
1994
|
}
|
|
1989
1995
|
async fetchLeverages(symbols = undefined, params = {}) {
|
|
1990
1996
|
throw new NotSupported(this.id + ' fetchLeverages() is not supported yet');
|
|
@@ -3885,6 +3891,8 @@ export default class Exchange {
|
|
|
3885
3891
|
params = this.omit(params, [optionName, defaultOptionName]);
|
|
3886
3892
|
}
|
|
3887
3893
|
else {
|
|
3894
|
+
// handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
|
|
3895
|
+
[methodName, params] = this.handleParamString(params, 'callerMethodName', methodName);
|
|
3888
3896
|
// check if exchange has properties for this method
|
|
3889
3897
|
const exchangeWideMethodOptions = this.safeValue(this.options, methodName);
|
|
3890
3898
|
if (exchangeWideMethodOptions !== undefined) {
|
|
@@ -5583,5 +5591,20 @@ export default class Exchange {
|
|
|
5583
5591
|
parseMarginMode(marginMode, market = undefined) {
|
|
5584
5592
|
throw new NotSupported(this.id + ' parseMarginMode () is not supported yet');
|
|
5585
5593
|
}
|
|
5594
|
+
parseLeverages(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
|
|
5595
|
+
const leverageStructures = {};
|
|
5596
|
+
for (let i = 0; i < response.length; i++) {
|
|
5597
|
+
const info = response[i];
|
|
5598
|
+
const marketId = this.safeString(info, symbolKey);
|
|
5599
|
+
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
5600
|
+
if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
|
|
5601
|
+
leverageStructures[market['symbol']] = this.parseLeverage(info, market);
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
return leverageStructures;
|
|
5605
|
+
}
|
|
5606
|
+
parseLeverage(leverage, market = undefined) {
|
|
5607
|
+
throw new NotSupported(this.id + ' parseLeverage() is not supported yet');
|
|
5608
|
+
}
|
|
5586
5609
|
}
|
|
5587
5610
|
export { Exchange, };
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -390,6 +390,15 @@ export interface Greeks {
|
|
|
390
390
|
underlyingPrice: number;
|
|
391
391
|
info: any;
|
|
392
392
|
}
|
|
393
|
+
export interface Leverage {
|
|
394
|
+
info: any;
|
|
395
|
+
symbol: string;
|
|
396
|
+
marginMode: 'isolated' | 'cross' | string;
|
|
397
|
+
longLeverage: number;
|
|
398
|
+
shortLeverage: number;
|
|
399
|
+
}
|
|
400
|
+
export interface Leverages extends Dictionary<Leverage> {
|
|
401
|
+
}
|
|
393
402
|
export interface MarginModes extends Dictionary<MarginMode> {
|
|
394
403
|
}
|
|
395
404
|
/** [ timestamp, open, high, low, close, volume ] */
|
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, MarginMode, MarginModes } 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, Leverage, Leverages } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class binance
|
|
5
5
|
* @augments Exchange
|
|
@@ -264,7 +264,8 @@ export default class binance extends Exchange {
|
|
|
264
264
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
265
265
|
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
|
|
266
266
|
setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<any>;
|
|
267
|
-
|
|
267
|
+
fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
|
|
268
|
+
parseLeverage(leverage: any, market?: any): Leverage;
|
|
268
269
|
fetchSettlementHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
269
270
|
fetchMySettlementHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
270
271
|
parseSettlement(settlement: any, market: any): {
|
package/js/src/binance.js
CHANGED
|
@@ -97,7 +97,8 @@ export default class binance extends Exchange {
|
|
|
97
97
|
'fetchLastPrices': true,
|
|
98
98
|
'fetchLedger': true,
|
|
99
99
|
'fetchLedgerEntry': true,
|
|
100
|
-
'fetchLeverage':
|
|
100
|
+
'fetchLeverage': 'emulated',
|
|
101
|
+
'fetchLeverages': true,
|
|
101
102
|
'fetchLeverageTiers': true,
|
|
102
103
|
'fetchLiquidations': false,
|
|
103
104
|
'fetchMarginMode': 'emulated',
|
|
@@ -4812,7 +4813,7 @@ export default class binance extends Exchange {
|
|
|
4812
4813
|
let stopPriceIsRequired = false;
|
|
4813
4814
|
let quantityIsRequired = false;
|
|
4814
4815
|
if (uppercaseType === 'MARKET') {
|
|
4815
|
-
const quoteOrderQty = this.
|
|
4816
|
+
const quoteOrderQty = this.safeBool(this.options, 'quoteOrderQty', true);
|
|
4816
4817
|
if (quoteOrderQty) {
|
|
4817
4818
|
const quoteOrderQtyNew = this.safeValue2(params, 'quoteOrderQty', 'cost');
|
|
4818
4819
|
const precision = market['precision']['price'];
|
|
@@ -10320,7 +10321,7 @@ export default class binance extends Exchange {
|
|
|
10320
10321
|
// POST https://fapi.binance.com/fapi/v1/marginType 400 Bad Request
|
|
10321
10322
|
// binanceusdm
|
|
10322
10323
|
if (e instanceof MarginModeAlreadySet) {
|
|
10323
|
-
const throwMarginModeAlreadySet = this.
|
|
10324
|
+
const throwMarginModeAlreadySet = this.safeBool(this.options, 'throwMarginModeAlreadySet', false);
|
|
10324
10325
|
if (throwMarginModeAlreadySet) {
|
|
10325
10326
|
throw e;
|
|
10326
10327
|
}
|
|
@@ -10391,31 +10392,27 @@ export default class binance extends Exchange {
|
|
|
10391
10392
|
//
|
|
10392
10393
|
return response;
|
|
10393
10394
|
}
|
|
10394
|
-
async
|
|
10395
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
10395
10396
|
/**
|
|
10396
10397
|
* @method
|
|
10397
|
-
* @name binance#
|
|
10398
|
-
* @description fetch the set leverage for
|
|
10398
|
+
* @name binance#fetchLeverages
|
|
10399
|
+
* @description fetch the set leverage for all markets
|
|
10399
10400
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
10400
10401
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
10401
10402
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
|
|
10402
10403
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
|
10403
|
-
* @param {string}
|
|
10404
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
10404
10405
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
10405
|
-
* @returns {object} a [leverage
|
|
10406
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
10406
10407
|
*/
|
|
10407
10408
|
await this.loadMarkets();
|
|
10408
10409
|
await this.loadLeverageBrackets(false, params);
|
|
10409
|
-
const market = this.market(symbol);
|
|
10410
|
-
if (!market['contract']) {
|
|
10411
|
-
throw new NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
|
|
10412
|
-
}
|
|
10413
10410
|
let type = undefined;
|
|
10414
|
-
[type, params] = this.handleMarketTypeAndParams('
|
|
10411
|
+
[type, params] = this.handleMarketTypeAndParams('fetchLeverages', undefined, params);
|
|
10415
10412
|
let subType = undefined;
|
|
10416
|
-
[subType, params] = this.handleSubTypeAndParams('
|
|
10413
|
+
[subType, params] = this.handleSubTypeAndParams('fetchLeverages', undefined, params, 'linear');
|
|
10417
10414
|
let isPortfolioMargin = undefined;
|
|
10418
|
-
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, '
|
|
10415
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverages', 'papi', 'portfolioMargin', false);
|
|
10419
10416
|
let response = undefined;
|
|
10420
10417
|
if (this.isLinear(type, subType)) {
|
|
10421
10418
|
if (isPortfolioMargin) {
|
|
@@ -10434,23 +10431,39 @@ export default class binance extends Exchange {
|
|
|
10434
10431
|
}
|
|
10435
10432
|
}
|
|
10436
10433
|
else {
|
|
10437
|
-
throw new NotSupported(this.id + '
|
|
10434
|
+
throw new NotSupported(this.id + ' fetchLeverages() supports linear and inverse contracts only');
|
|
10438
10435
|
}
|
|
10439
|
-
const
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
'marginMode': marginMode,
|
|
10449
|
-
'leverage': this.safeInteger(position, 'leverage'),
|
|
10450
|
-
};
|
|
10451
|
-
}
|
|
10436
|
+
const leverages = this.safeList(response, 'positions', []);
|
|
10437
|
+
return this.parseLeverages(leverages, symbols, 'symbol');
|
|
10438
|
+
}
|
|
10439
|
+
parseLeverage(leverage, market = undefined) {
|
|
10440
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
10441
|
+
const marginModeRaw = this.safeBool(leverage, 'isolated');
|
|
10442
|
+
let marginMode = undefined;
|
|
10443
|
+
if (marginModeRaw !== undefined) {
|
|
10444
|
+
marginMode = marginModeRaw ? 'isolated' : 'cross';
|
|
10452
10445
|
}
|
|
10453
|
-
|
|
10446
|
+
const side = this.safeStringLower(leverage, 'positionSide');
|
|
10447
|
+
let longLeverage = undefined;
|
|
10448
|
+
let shortLeverage = undefined;
|
|
10449
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
10450
|
+
if (side === 'both') {
|
|
10451
|
+
longLeverage = leverageValue;
|
|
10452
|
+
shortLeverage = leverageValue;
|
|
10453
|
+
}
|
|
10454
|
+
else if (side === 'long') {
|
|
10455
|
+
longLeverage = leverageValue;
|
|
10456
|
+
}
|
|
10457
|
+
else if (side === 'short') {
|
|
10458
|
+
shortLeverage = leverageValue;
|
|
10459
|
+
}
|
|
10460
|
+
return {
|
|
10461
|
+
'info': leverage,
|
|
10462
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
10463
|
+
'marginMode': marginMode,
|
|
10464
|
+
'longLeverage': longLeverage,
|
|
10465
|
+
'shortLeverage': shortLeverage,
|
|
10466
|
+
};
|
|
10454
10467
|
}
|
|
10455
10468
|
async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
10456
10469
|
/**
|
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, Dict } 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, Leverage } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bingx
|
|
5
5
|
* @augments Exchange
|
|
@@ -110,7 +110,8 @@ export default class bingx extends Exchange {
|
|
|
110
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
|
-
fetchLeverage(symbol: string, params?: {}): Promise<
|
|
113
|
+
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
114
|
+
parseLeverage(leverage: any, market?: any): Leverage;
|
|
114
115
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
115
116
|
fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
116
117
|
parseDepositWithdrawFee(fee: any, currency?: Currency): {
|
package/js/src/bingx.js
CHANGED
|
@@ -452,7 +452,7 @@ export default class bingx extends Exchange {
|
|
|
452
452
|
if (!this.checkRequiredCredentials(false)) {
|
|
453
453
|
return undefined;
|
|
454
454
|
}
|
|
455
|
-
const isSandbox = this.
|
|
455
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
456
456
|
if (isSandbox) {
|
|
457
457
|
return undefined;
|
|
458
458
|
}
|
|
@@ -696,7 +696,7 @@ export default class bingx extends Exchange {
|
|
|
696
696
|
* @returns {object[]} an array of objects representing market data
|
|
697
697
|
*/
|
|
698
698
|
const requests = [this.fetchSwapMarkets(params)];
|
|
699
|
-
const isSandbox = this.
|
|
699
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
700
700
|
if (!isSandbox) {
|
|
701
701
|
requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
|
|
702
702
|
}
|
|
@@ -3499,7 +3499,18 @@ export default class bingx extends Exchange {
|
|
|
3499
3499
|
// }
|
|
3500
3500
|
// }
|
|
3501
3501
|
//
|
|
3502
|
-
|
|
3502
|
+
const data = this.safeDict(response, 'data', {});
|
|
3503
|
+
return this.parseLeverage(data, market);
|
|
3504
|
+
}
|
|
3505
|
+
parseLeverage(leverage, market = undefined) {
|
|
3506
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
3507
|
+
return {
|
|
3508
|
+
'info': leverage,
|
|
3509
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3510
|
+
'marginMode': undefined,
|
|
3511
|
+
'longLeverage': this.safeInteger(leverage, 'longLeverage'),
|
|
3512
|
+
'shortLeverage': this.safeInteger(leverage, 'shortLeverage'),
|
|
3513
|
+
};
|
|
3503
3514
|
}
|
|
3504
3515
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
3505
3516
|
/**
|
|
@@ -4162,7 +4173,7 @@ export default class bingx extends Exchange {
|
|
|
4162
4173
|
const type = section[0];
|
|
4163
4174
|
const version = section[1];
|
|
4164
4175
|
const access = section[2];
|
|
4165
|
-
const isSandbox = this.
|
|
4176
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
4166
4177
|
if (isSandbox && (type !== 'swap')) {
|
|
4167
4178
|
throw new NotSupported(this.id + ' does not have a testnet/sandbox URL for ' + type + ' endpoints');
|
|
4168
4179
|
}
|
package/js/src/bitget.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bitget.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bitget
|
|
5
5
|
* @augments Exchange
|
|
@@ -157,7 +157,8 @@ export default class bitget extends Exchange {
|
|
|
157
157
|
};
|
|
158
158
|
reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
159
159
|
addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
|
|
160
|
-
fetchLeverage(symbol: string, params?: {}): Promise<
|
|
160
|
+
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
161
|
+
parseLeverage(leverage: any, market?: any): Leverage;
|
|
161
162
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
162
163
|
setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
|
|
163
164
|
setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<any>;
|