ccxt 4.2.57 → 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 -5
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +462 -280
- 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 +22 -1
- package/dist/cjs/src/binance.js +41 -28
- package/dist/cjs/src/bingx.js +12 -1
- package/dist/cjs/src/bitget.js +71 -56
- package/dist/cjs/src/bitmex.js +12 -28
- 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 +12 -1
- package/dist/cjs/src/krakenfutures.js +22 -7
- package/dist/cjs/src/kuna.js +14 -11
- package/dist/cjs/src/mexc.js +19 -19
- package/dist/cjs/src/okx.js +31 -1
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/whitebit.js +4 -6
- 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 +6 -4
- package/js/src/base/Exchange.js +22 -1
- package/js/src/base/types.d.ts +9 -0
- package/js/src/binance.d.ts +3 -2
- package/js/src/binance.js +41 -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 -3
- package/js/src/bitmex.js +12 -28
- 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 +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/mexc.d.ts +3 -13
- package/js/src/mexc.js +19 -19
- 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/whitebit.js +4 -6
- 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 +6 -1
|
@@ -2456,7 +2456,7 @@ class krakenfutures extends krakenfutures$1 {
|
|
|
2456
2456
|
//
|
|
2457
2457
|
return await this.privatePutLeveragepreferences(this.extend(request, params));
|
|
2458
2458
|
}
|
|
2459
|
-
async fetchLeverage(symbol
|
|
2459
|
+
async fetchLeverage(symbol, params = {}) {
|
|
2460
2460
|
/**
|
|
2461
2461
|
* @method
|
|
2462
2462
|
* @name krakenfutures#fetchLeverage
|
|
@@ -2470,17 +2470,32 @@ class krakenfutures extends krakenfutures$1 {
|
|
|
2470
2470
|
throw new errors.ArgumentsRequired(this.id + ' fetchLeverage() requires a symbol argument');
|
|
2471
2471
|
}
|
|
2472
2472
|
await this.loadMarkets();
|
|
2473
|
+
const market = this.market(symbol);
|
|
2473
2474
|
const request = {
|
|
2474
2475
|
'symbol': this.marketId(symbol).toUpperCase(),
|
|
2475
2476
|
};
|
|
2477
|
+
const response = await this.privateGetLeveragepreferences(this.extend(request, params));
|
|
2476
2478
|
//
|
|
2477
|
-
//
|
|
2478
|
-
//
|
|
2479
|
-
//
|
|
2480
|
-
//
|
|
2481
|
-
//
|
|
2479
|
+
// {
|
|
2480
|
+
// "result": "success",
|
|
2481
|
+
// "serverTime": "2023-08-01T09:54:08.900Z",
|
|
2482
|
+
// "leveragePreferences": [ { symbol: "PF_LTCUSD", maxLeverage: "5.00" } ]
|
|
2483
|
+
// }
|
|
2482
2484
|
//
|
|
2483
|
-
|
|
2485
|
+
const leveragePreferences = this.safeList(response, 'leveragePreferences', []);
|
|
2486
|
+
const data = this.safeDict(leveragePreferences, 0, {});
|
|
2487
|
+
return this.parseLeverage(data, market);
|
|
2488
|
+
}
|
|
2489
|
+
parseLeverage(leverage, market = undefined) {
|
|
2490
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
2491
|
+
const leverageValue = this.safeInteger(leverage, 'maxLeverage');
|
|
2492
|
+
return {
|
|
2493
|
+
'info': leverage,
|
|
2494
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
2495
|
+
'marginMode': undefined,
|
|
2496
|
+
'longLeverage': leverageValue,
|
|
2497
|
+
'shortLeverage': leverageValue,
|
|
2498
|
+
};
|
|
2484
2499
|
}
|
|
2485
2500
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2486
2501
|
if (response === undefined) {
|
package/dist/cjs/src/kuna.js
CHANGED
|
@@ -806,7 +806,7 @@ class kuna extends kuna$1 {
|
|
|
806
806
|
await this.loadMarkets();
|
|
807
807
|
const market = this.market(symbol);
|
|
808
808
|
const request = {
|
|
809
|
-
'
|
|
809
|
+
'pairs': market['id'],
|
|
810
810
|
};
|
|
811
811
|
if (limit !== undefined) {
|
|
812
812
|
request['limit'] = limit;
|
|
@@ -814,18 +814,21 @@ class kuna extends kuna$1 {
|
|
|
814
814
|
const response = await this.v4PublicGetTradePublicBookPairs(this.extend(request, params));
|
|
815
815
|
//
|
|
816
816
|
// {
|
|
817
|
-
//
|
|
818
|
-
//
|
|
819
|
-
//
|
|
820
|
-
//
|
|
821
|
-
//
|
|
822
|
-
//
|
|
823
|
-
//
|
|
824
|
-
//
|
|
825
|
-
//
|
|
817
|
+
// 'data': [
|
|
818
|
+
// {
|
|
819
|
+
// 'createdAt': '2024-03-02T00:10:49.385Z',
|
|
820
|
+
// 'id': '3b42878a-3688-4bc1-891e-5cc2fc902142',
|
|
821
|
+
// 'matchPrice': '62181.31',
|
|
822
|
+
// 'matchQuantity': '0.00568',
|
|
823
|
+
// 'pair': 'BTC_USDT',
|
|
824
|
+
// 'quoteQuantity': '353.1898408',
|
|
825
|
+
// 'side': 'Bid'
|
|
826
|
+
// },
|
|
827
|
+
// ...
|
|
828
|
+
// ]
|
|
826
829
|
// }
|
|
827
830
|
//
|
|
828
|
-
const data = this.
|
|
831
|
+
const data = this.safeList(response, 'data', []);
|
|
829
832
|
return this.parseTrades(data, market, since, limit);
|
|
830
833
|
}
|
|
831
834
|
parseTrade(trade, market = undefined) {
|
package/dist/cjs/src/mexc.js
CHANGED
|
@@ -5422,30 +5422,30 @@ class mexc extends mexc$1 {
|
|
|
5422
5422
|
// }
|
|
5423
5423
|
//
|
|
5424
5424
|
const data = this.safeList(response, 'data', []);
|
|
5425
|
-
|
|
5426
|
-
return this.parseLeverage(longLeverage, market);
|
|
5425
|
+
return this.parseLeverage(data, market);
|
|
5427
5426
|
}
|
|
5428
5427
|
parseLeverage(leverage, market = undefined) {
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5428
|
+
let marginMode = undefined;
|
|
5429
|
+
let longLeverage = undefined;
|
|
5430
|
+
let shortLeverage = undefined;
|
|
5431
|
+
for (let i = 0; i < leverage.length; i++) {
|
|
5432
|
+
const entry = leverage[i];
|
|
5433
|
+
const openType = this.safeInteger(entry, 'openType');
|
|
5434
|
+
const positionType = this.safeInteger(entry, 'positionType');
|
|
5435
|
+
if (positionType === 1) {
|
|
5436
|
+
longLeverage = this.safeInteger(entry, 'leverage');
|
|
5437
|
+
}
|
|
5438
|
+
else if (positionType === 2) {
|
|
5439
|
+
shortLeverage = this.safeInteger(entry, 'leverage');
|
|
5440
|
+
}
|
|
5441
|
+
marginMode = (openType === 1) ? 'isolated' : 'cross';
|
|
5442
|
+
}
|
|
5444
5443
|
return {
|
|
5445
5444
|
'info': leverage,
|
|
5446
5445
|
'symbol': market['symbol'],
|
|
5447
|
-
'
|
|
5448
|
-
'
|
|
5446
|
+
'marginMode': marginMode,
|
|
5447
|
+
'longLeverage': longLeverage,
|
|
5448
|
+
'shortLeverage': shortLeverage,
|
|
5449
5449
|
};
|
|
5450
5450
|
}
|
|
5451
5451
|
handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -5161,7 +5161,37 @@ class okx extends okx$1 {
|
|
|
5161
5161
|
// "msg": ""
|
|
5162
5162
|
// }
|
|
5163
5163
|
//
|
|
5164
|
-
|
|
5164
|
+
const data = this.safeList(response, 'data', []);
|
|
5165
|
+
return this.parseLeverage(data, market);
|
|
5166
|
+
}
|
|
5167
|
+
parseLeverage(leverage, market = undefined) {
|
|
5168
|
+
let marketId = undefined;
|
|
5169
|
+
let marginMode = undefined;
|
|
5170
|
+
let longLeverage = undefined;
|
|
5171
|
+
let shortLeverage = undefined;
|
|
5172
|
+
for (let i = 0; i < leverage.length; i++) {
|
|
5173
|
+
const entry = leverage[i];
|
|
5174
|
+
marginMode = this.safeStringLower(entry, 'mgnMode');
|
|
5175
|
+
marketId = this.safeString(entry, 'instId');
|
|
5176
|
+
const positionSide = this.safeStringLower(entry, 'posSide');
|
|
5177
|
+
if (positionSide === 'long') {
|
|
5178
|
+
longLeverage = this.safeInteger(entry, 'lever');
|
|
5179
|
+
}
|
|
5180
|
+
else if (positionSide === 'short') {
|
|
5181
|
+
shortLeverage = this.safeInteger(entry, 'lever');
|
|
5182
|
+
}
|
|
5183
|
+
else {
|
|
5184
|
+
longLeverage = this.safeInteger(entry, 'lever');
|
|
5185
|
+
shortLeverage = this.safeInteger(entry, 'lever');
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
5188
|
+
return {
|
|
5189
|
+
'info': leverage,
|
|
5190
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
5191
|
+
'marginMode': marginMode,
|
|
5192
|
+
'longLeverage': longLeverage,
|
|
5193
|
+
'shortLeverage': shortLeverage,
|
|
5194
|
+
};
|
|
5165
5195
|
}
|
|
5166
5196
|
async fetchPosition(symbol, params = {}) {
|
|
5167
5197
|
/**
|
|
@@ -610,7 +610,7 @@ class alpaca extends alpaca$1 {
|
|
|
610
610
|
for (let i = 0; i < message.length; i++) {
|
|
611
611
|
const data = message[i];
|
|
612
612
|
const T = this.safeString(data, 'T');
|
|
613
|
-
const msg = this.
|
|
613
|
+
const msg = this.safeString(data, 'msg');
|
|
614
614
|
if (T === 'subscription') {
|
|
615
615
|
this.handleSubscription(client, data);
|
|
616
616
|
return;
|
|
@@ -868,12 +868,10 @@ class whitebit extends whitebit$1 {
|
|
|
868
868
|
if (!this.handleErrorMessage(client, message)) {
|
|
869
869
|
return;
|
|
870
870
|
}
|
|
871
|
-
const result = this.
|
|
872
|
-
if (result
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
871
|
+
const result = this.safeString(message, 'result');
|
|
872
|
+
if (result === 'pong') {
|
|
873
|
+
this.handlePong(client, message);
|
|
874
|
+
return;
|
|
877
875
|
}
|
|
878
876
|
const id = this.safeInteger(message, 'id');
|
|
879
877
|
if (id !== undefined) {
|
package/dist/cjs/src/probit.js
CHANGED
|
@@ -1553,7 +1553,7 @@ class probit extends probit$1 {
|
|
|
1553
1553
|
// ]
|
|
1554
1554
|
// }
|
|
1555
1555
|
//
|
|
1556
|
-
const data = this.
|
|
1556
|
+
const data = this.safeList(response, 'data', []);
|
|
1557
1557
|
return this.parseTransactions(data, currency, since, limit);
|
|
1558
1558
|
}
|
|
1559
1559
|
parseTransaction(transaction, currency = undefined) {
|
|
@@ -1378,7 +1378,7 @@ class wavesexchange extends wavesexchange$1 {
|
|
|
1378
1378
|
'amountAsset': amountAsset,
|
|
1379
1379
|
'priceAsset': priceAsset,
|
|
1380
1380
|
};
|
|
1381
|
-
const sandboxMode = this.
|
|
1381
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
1382
1382
|
const chainId = (sandboxMode) ? 84 : 87;
|
|
1383
1383
|
const body = {
|
|
1384
1384
|
'senderPublicKey': this.apiKey,
|
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,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');
|
|
@@ -5583,5 +5589,20 @@ export default class Exchange {
|
|
|
5583
5589
|
parseMarginMode(marginMode, market = undefined) {
|
|
5584
5590
|
throw new NotSupported(this.id + ' parseMarginMode () is not supported yet');
|
|
5585
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
|
+
}
|
|
5586
5607
|
}
|
|
5587
5608
|
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): {
|