ccxt 4.2.56 → 4.2.58
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 -4
- package/dist/ccxt.browser.js +818 -335
- 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 +53 -3
- package/dist/cjs/src/binance.js +196 -28
- package/dist/cjs/src/bingx.js +12 -1
- package/dist/cjs/src/bitget.js +71 -56
- package/dist/cjs/src/bitmex.js +26 -1
- package/dist/cjs/src/bitrue.js +24 -15
- package/dist/cjs/src/blofin.js +24 -1
- package/dist/cjs/src/bybit.js +11 -3
- 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 +63 -55
- package/dist/cjs/src/krakenfutures.js +22 -7
- package/dist/cjs/src/kuna.js +14 -11
- package/dist/cjs/src/mexc.js +75 -0
- package/dist/cjs/src/okx.js +31 -1
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/bitmex.js +23 -32
- package/dist/cjs/src/pro/cex.js +6 -2
- package/dist/cjs/src/pro/coinex.js +6 -3
- package/dist/cjs/src/pro/mexc.js +2 -2
- package/dist/cjs/src/pro/whitebit.js +15 -13
- package/dist/cjs/src/probit.js +1 -1
- package/dist/cjs/src/wavesexchange.js +1 -1
- package/dist/cjs/src/woo.js +20 -4
- 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 +14 -6
- package/js/src/base/Exchange.js +53 -3
- package/js/src/base/types.d.ts +12 -1
- package/js/src/binance.d.ts +5 -2
- package/js/src/binance.js +196 -28
- package/js/src/bingx.d.ts +3 -2
- package/js/src/bingx.js +12 -1
- package/js/src/bitget.d.ts +3 -2
- package/js/src/bitget.js +71 -56
- package/js/src/bitmex.d.ts +3 -1
- package/js/src/bitmex.js +26 -1
- package/js/src/bitrue.js +24 -15
- package/js/src/blofin.d.ts +3 -2
- package/js/src/blofin.js +24 -1
- package/js/src/bybit.d.ts +3 -6
- package/js/src/bybit.js +11 -3
- 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 +5 -3
- package/js/src/hitbtc.js +63 -55
- 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/mexc.d.ts +3 -1
- package/js/src/mexc.js +75 -0
- package/js/src/okx.d.ts +3 -2
- package/js/src/okx.js +31 -1
- package/js/src/pro/alpaca.js +1 -1
- package/js/src/pro/bitmex.js +24 -31
- package/js/src/pro/cex.js +6 -2
- package/js/src/pro/coinex.js +6 -3
- package/js/src/pro/mexc.js +2 -2
- package/js/src/pro/whitebit.js +15 -13
- 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 +20 -4
- package/package.json +1 -1
- package/skip-tests.json +26 -8
package/dist/cjs/src/woo.js
CHANGED
|
@@ -2653,7 +2653,17 @@ class woo extends woo$1 {
|
|
|
2653
2653
|
return response;
|
|
2654
2654
|
}
|
|
2655
2655
|
async fetchLeverage(symbol, params = {}) {
|
|
2656
|
+
/**
|
|
2657
|
+
* @method
|
|
2658
|
+
* @name woo#fetchLeverage
|
|
2659
|
+
* @description fetch the set leverage for a market
|
|
2660
|
+
* @see https://docs.woo.org/#get-account-information-new
|
|
2661
|
+
* @param {string} symbol unified market symbol
|
|
2662
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2663
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
2664
|
+
*/
|
|
2656
2665
|
await this.loadMarkets();
|
|
2666
|
+
const market = this.market(symbol);
|
|
2657
2667
|
const response = await this.v3PrivateGetAccountinfo(params);
|
|
2658
2668
|
//
|
|
2659
2669
|
// {
|
|
@@ -2683,11 +2693,17 @@ class woo extends woo$1 {
|
|
|
2683
2693
|
// "timestamp": 1673323685109
|
|
2684
2694
|
// }
|
|
2685
2695
|
//
|
|
2686
|
-
const
|
|
2687
|
-
|
|
2696
|
+
const data = this.safeDict(response, 'data', {});
|
|
2697
|
+
return this.parseLeverage(data, market);
|
|
2698
|
+
}
|
|
2699
|
+
parseLeverage(leverage, market = undefined) {
|
|
2700
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
2688
2701
|
return {
|
|
2689
|
-
'info':
|
|
2690
|
-
'
|
|
2702
|
+
'info': leverage,
|
|
2703
|
+
'symbol': market['symbol'],
|
|
2704
|
+
'marginMode': undefined,
|
|
2705
|
+
'longLeverage': leverageValue,
|
|
2706
|
+
'shortLeverage': leverageValue,
|
|
2691
2707
|
};
|
|
2692
2708
|
}
|
|
2693
2709
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
package/js/ccxt.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
|
|
|
2
2
|
import { Precise } from './src/base/Precise.js';
|
|
3
3
|
import * as functions from './src/base/functions.js';
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
|
-
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
|
|
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.57";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
|
@@ -501,5 +501,5 @@ declare const ccxt: {
|
|
|
501
501
|
zaif: typeof zaif;
|
|
502
502
|
zonda: typeof zonda;
|
|
503
503
|
} & typeof functions & typeof errors;
|
|
504
|
-
export { version, Exchange, exchanges, pro, Precise, functions, errors, 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, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbasepro, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
504
|
+
export { version, Exchange, exchanges, pro, Precise, functions, errors, 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, 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, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbasepro, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
505
505
|
export default ccxt;
|
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.58';
|
|
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,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';
|
|
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';
|
|
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
|
+
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;
|
|
@@ -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>;
|
|
@@ -680,7 +683,8 @@ export default class Exchange {
|
|
|
680
683
|
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
681
684
|
createDepositAddress(code: string, params?: {}): Promise<DepositAddressResponse>;
|
|
682
685
|
setLeverage(leverage: Int, symbol?: string, params?: {}): Promise<{}>;
|
|
683
|
-
fetchLeverage(symbol: string, params?: {}): Promise<
|
|
686
|
+
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
687
|
+
fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
|
|
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,9 @@ 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;
|
|
997
|
+
parseLeverages(response: object[], symbols?: string[], symbolKey?: string, marketType?: MarketType): Leverages;
|
|
998
|
+
parseLeverage(leverage: any, market?: Market): Leverage;
|
|
991
999
|
}
|
|
992
1000
|
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);
|
|
@@ -1973,7 +1984,16 @@ export default class Exchange {
|
|
|
1973
1984
|
throw new NotSupported(this.id + ' setLeverage() is not supported yet');
|
|
1974
1985
|
}
|
|
1975
1986
|
async fetchLeverage(symbol, params = {}) {
|
|
1976
|
-
|
|
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
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
1996
|
+
throw new NotSupported(this.id + ' fetchLeverages() is not supported yet');
|
|
1977
1997
|
}
|
|
1978
1998
|
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
1979
1999
|
throw new NotSupported(this.id + ' setPositionMode() is not supported yet');
|
|
@@ -5554,5 +5574,35 @@ export default class Exchange {
|
|
|
5554
5574
|
parseGreeks(greeks, market = undefined) {
|
|
5555
5575
|
throw new NotSupported(this.id + ' parseGreeks () is not supported yet');
|
|
5556
5576
|
}
|
|
5577
|
+
parseMarginModes(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
|
|
5578
|
+
const marginModeStructures = {};
|
|
5579
|
+
for (let i = 0; i < response.length; i++) {
|
|
5580
|
+
const info = response[i];
|
|
5581
|
+
const marketId = this.safeString(info, symbolKey);
|
|
5582
|
+
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
5583
|
+
if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
|
|
5584
|
+
marginModeStructures[market['symbol']] = this.parseMarginMode(info, market);
|
|
5585
|
+
}
|
|
5586
|
+
}
|
|
5587
|
+
return marginModeStructures;
|
|
5588
|
+
}
|
|
5589
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
5590
|
+
throw new NotSupported(this.id + ' parseMarginMode () is not supported yet');
|
|
5591
|
+
}
|
|
5592
|
+
parseLeverages(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
|
|
5593
|
+
const leverageStructures = {};
|
|
5594
|
+
for (let i = 0; i < response.length; i++) {
|
|
5595
|
+
const info = response[i];
|
|
5596
|
+
const marketId = this.safeString(info, symbolKey);
|
|
5597
|
+
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
5598
|
+
if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
|
|
5599
|
+
leverageStructures[market['symbol']] = this.parseLeverage(info, market);
|
|
5600
|
+
}
|
|
5601
|
+
}
|
|
5602
|
+
return leverageStructures;
|
|
5603
|
+
}
|
|
5604
|
+
parseLeverage(leverage, market = undefined) {
|
|
5605
|
+
throw new NotSupported(this.id + ' parseLeverage() is not supported yet');
|
|
5606
|
+
}
|
|
5557
5607
|
}
|
|
5558
5608
|
export { Exchange, };
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -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,17 @@ 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
|
+
}
|
|
402
|
+
export interface MarginModes extends Dictionary<MarginMode> {
|
|
403
|
+
}
|
|
393
404
|
/** [ timestamp, open, high, low, close, volume ] */
|
|
394
405
|
export declare type OHLCV = [Num, Num, Num, Num, Num, Num];
|
|
395
406
|
/** [ 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, 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): {
|
|
@@ -433,4 +434,6 @@ export default class binance extends Exchange {
|
|
|
433
434
|
info: any;
|
|
434
435
|
hedged: boolean;
|
|
435
436
|
}>;
|
|
437
|
+
fetchMarginModes(symbols?: string[], params?: {}): Promise<MarginModes>;
|
|
438
|
+
parseMarginMode(marginMode: any, market?: any): MarginMode;
|
|
436
439
|
}
|