ccxt 4.1.87 → 4.1.89
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 +8309 -5710
- package/README.md +10 -9
- package/changelog.js +101 -0
- package/dist/ccxt.browser.js +8628 -4849
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/base/Exchange.js +95 -27
- package/dist/cjs/src/base/ws/Client.js +3 -3
- package/dist/cjs/src/base/ws/Future.js +9 -2
- package/dist/cjs/src/base/ws/WsClient.js +1 -1
- package/dist/cjs/src/bigone.js +8 -1
- package/dist/cjs/src/binance.js +4 -105
- package/dist/cjs/src/bit2c.js +8 -2
- package/dist/cjs/src/bitget.js +3455 -2480
- package/dist/cjs/src/bitmart.js +35 -9
- package/dist/cjs/src/coinbase.js +2 -0
- package/dist/cjs/src/coinbasepro.js +0 -43
- package/dist/cjs/src/coinex.js +14 -1
- package/dist/cjs/src/coinsph.js +0 -29
- package/dist/cjs/src/cryptocom.js +22 -10
- package/dist/cjs/src/gate.js +37 -39
- package/dist/cjs/src/gemini.js +1 -0
- package/dist/cjs/src/novadax.js +28 -16
- package/dist/cjs/src/okcoin.js +80 -21
- package/dist/cjs/src/phemex.js +105 -29
- package/dist/cjs/src/pro/binance.js +18 -215
- package/dist/cjs/src/pro/bitget.js +780 -736
- package/dist/cjs/src/pro/bitmart.js +8 -10
- package/dist/cjs/src/pro/bitmex.js +9 -34
- package/dist/cjs/src/pro/bitpanda.js +4 -4
- package/dist/cjs/src/pro/bybit.js +21 -97
- package/dist/cjs/src/pro/coinbasepro.js +36 -40
- package/dist/cjs/src/pro/cryptocom.js +10 -26
- package/dist/cjs/src/pro/gate.js +20 -17
- package/dist/cjs/src/pro/kucoin.js +39 -39
- package/dist/cjs/src/pro/kucoinfutures.js +40 -36
- package/dist/cjs/src/pro/okx.js +16 -29
- package/dist/cjs/src/tokocrypto.js +28 -14
- package/dist/cjs/src/woo.js +41 -14
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/bitget.d.ts +1 -1
- package/js/src/abstract/coinbasepro.d.ts +69 -0
- package/js/src/abstract/coinbasepro.js +11 -0
- package/js/src/abstract/phemex.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +2 -3
- package/js/src/base/Exchange.js +96 -28
- package/js/src/base/ws/Client.d.ts +2 -2
- package/js/src/base/ws/Client.js +4 -4
- package/js/src/base/ws/Future.d.ts +5 -2
- package/js/src/base/ws/Future.js +8 -2
- package/js/src/base/ws/WsClient.d.ts +1 -1
- package/js/src/base/ws/WsClient.js +2 -2
- package/js/src/bigone.js +9 -2
- package/js/src/binance.d.ts +0 -9
- package/js/src/binance.js +4 -105
- package/js/src/bit2c.js +8 -2
- package/js/src/bitget.d.ts +13 -11
- package/js/src/bitget.js +3455 -2480
- package/js/src/bitmart.js +35 -9
- package/js/src/coinbase.js +2 -0
- package/js/src/coinbasepro.d.ts +0 -4
- package/js/src/coinbasepro.js +1 -44
- package/js/src/coinex.js +14 -1
- package/js/src/coinsph.d.ts +0 -1
- package/js/src/coinsph.js +0 -29
- package/js/src/cryptocom.js +22 -10
- package/js/src/gate.js +37 -39
- package/js/src/gemini.js +1 -0
- package/js/src/novadax.js +28 -16
- package/js/src/okcoin.d.ts +1 -0
- package/js/src/okcoin.js +81 -22
- package/js/src/phemex.d.ts +2 -108
- package/js/src/phemex.js +105 -29
- package/js/src/pro/binance.d.ts +0 -2
- package/js/src/pro/binance.js +19 -216
- package/js/src/pro/bitget.d.ts +3 -5
- package/js/src/pro/bitget.js +780 -736
- package/js/src/pro/bitmart.js +8 -10
- package/js/src/pro/bitmex.js +9 -34
- package/js/src/pro/bitpanda.d.ts +1 -1
- package/js/src/pro/bitpanda.js +4 -4
- package/js/src/pro/bybit.d.ts +1 -2
- package/js/src/pro/bybit.js +21 -97
- package/js/src/pro/coinbasepro.d.ts +2 -2
- package/js/src/pro/coinbasepro.js +36 -40
- package/js/src/pro/cryptocom.d.ts +1 -1
- package/js/src/pro/cryptocom.js +10 -26
- package/js/src/pro/gate.d.ts +1 -0
- package/js/src/pro/gate.js +20 -17
- package/js/src/pro/kucoin.d.ts +1 -0
- package/js/src/pro/kucoin.js +39 -39
- package/js/src/pro/kucoinfutures.d.ts +2 -1
- package/js/src/pro/kucoinfutures.js +40 -36
- package/js/src/pro/okx.d.ts +1 -1
- package/js/src/pro/okx.js +16 -29
- package/js/src/tokocrypto.js +28 -14
- package/js/src/woo.d.ts +1 -0
- package/js/src/woo.js +42 -15
- package/package.json +2 -2
- package/skip-tests.json +3 -14
package/dist/cjs/src/woo.js
CHANGED
|
@@ -37,7 +37,10 @@ class woo extends woo$1 {
|
|
|
37
37
|
'closeAllPositions': false,
|
|
38
38
|
'closePosition': false,
|
|
39
39
|
'createDepositAddress': false,
|
|
40
|
+
'createMarketBuyOrderWithCost': true,
|
|
40
41
|
'createMarketOrder': false,
|
|
42
|
+
'createMarketOrderWithCost': false,
|
|
43
|
+
'createMarketSellOrderWithCost': false,
|
|
41
44
|
'createOrder': true,
|
|
42
45
|
'createReduceOnlyOrder': true,
|
|
43
46
|
'createStopLimitOrder': false,
|
|
@@ -739,6 +742,25 @@ class woo extends woo$1 {
|
|
|
739
742
|
}
|
|
740
743
|
return result;
|
|
741
744
|
}
|
|
745
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
746
|
+
/**
|
|
747
|
+
* @method
|
|
748
|
+
* @name woo#createMarketBuyOrderWithCost
|
|
749
|
+
* @description create a market buy order by providing the symbol and cost
|
|
750
|
+
* @see https://docs.woo.org/#send-order
|
|
751
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
752
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
753
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
754
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
755
|
+
*/
|
|
756
|
+
await this.loadMarkets();
|
|
757
|
+
const market = this.market(symbol);
|
|
758
|
+
if (!market['spot']) {
|
|
759
|
+
throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
760
|
+
}
|
|
761
|
+
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
762
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
763
|
+
}
|
|
742
764
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
743
765
|
/**
|
|
744
766
|
* @method
|
|
@@ -758,9 +780,11 @@ class woo extends woo$1 {
|
|
|
758
780
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
|
|
759
781
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
760
782
|
* @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
|
|
783
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
761
784
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
762
785
|
*/
|
|
763
786
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
|
|
787
|
+
params = this.omit(params, ['reduceOnly', 'reduce_only']);
|
|
764
788
|
const orderType = type.toUpperCase();
|
|
765
789
|
await this.loadMarkets();
|
|
766
790
|
const market = this.market(symbol);
|
|
@@ -803,26 +827,29 @@ class woo extends woo$1 {
|
|
|
803
827
|
if (isMarket && !isStop) {
|
|
804
828
|
// for market buy it requires the amount of quote currency to spend
|
|
805
829
|
if (market['spot'] && orderSide === 'BUY') {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
830
|
+
let quoteAmount = undefined;
|
|
831
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
832
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
833
|
+
const cost = this.safeNumber2(params, 'cost', 'order_amount');
|
|
834
|
+
params = this.omit(params, ['cost', 'order_amount']);
|
|
835
|
+
if (cost !== undefined) {
|
|
836
|
+
quoteAmount = this.costToPrecision(symbol, cost);
|
|
837
|
+
}
|
|
838
|
+
else if (createMarketBuyOrderRequiresPrice) {
|
|
839
|
+
if (price === undefined) {
|
|
840
|
+
throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
|
|
818
841
|
}
|
|
819
842
|
else {
|
|
820
|
-
|
|
843
|
+
const amountString = this.numberToString(amount);
|
|
844
|
+
const priceString = this.numberToString(price);
|
|
845
|
+
const costRequest = Precise["default"].stringMul(amountString, priceString);
|
|
846
|
+
quoteAmount = this.costToPrecision(symbol, costRequest);
|
|
821
847
|
}
|
|
822
848
|
}
|
|
823
849
|
else {
|
|
824
|
-
|
|
850
|
+
quoteAmount = this.costToPrecision(symbol, amount);
|
|
825
851
|
}
|
|
852
|
+
request['order_amount'] = quoteAmount;
|
|
826
853
|
}
|
|
827
854
|
else {
|
|
828
855
|
request['order_quantity'] = this.amountToPrecision(symbol, amount);
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } 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.1.
|
|
7
|
+
declare const version = "4.1.88";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
|
@@ -43,6 +43,7 @@ import btcturk from './src/btcturk.js';
|
|
|
43
43
|
import bybit from './src/bybit.js';
|
|
44
44
|
import cex from './src/cex.js';
|
|
45
45
|
import coinbase from './src/coinbase.js';
|
|
46
|
+
import coinbasepro from './src/coinbasepro.js';
|
|
46
47
|
import coincheck from './src/coincheck.js';
|
|
47
48
|
import coinex from './src/coinex.js';
|
|
48
49
|
import coinlist from './src/coinlist.js';
|
|
@@ -124,6 +125,7 @@ import blockchaincomPro from './src/pro/blockchaincom.js';
|
|
|
124
125
|
import bybitPro from './src/pro/bybit.js';
|
|
125
126
|
import cexPro from './src/pro/cex.js';
|
|
126
127
|
import coinbasePro from './src/pro/coinbase.js';
|
|
128
|
+
import coinbaseproPro from './src/pro/coinbasepro.js';
|
|
127
129
|
import coinexPro from './src/pro/coinex.js';
|
|
128
130
|
import cryptocomPro from './src/pro/cryptocom.js';
|
|
129
131
|
import currencycomPro from './src/pro/currencycom.js';
|
|
@@ -195,6 +197,7 @@ declare const exchanges: {
|
|
|
195
197
|
bybit: typeof bybit;
|
|
196
198
|
cex: typeof cex;
|
|
197
199
|
coinbase: typeof coinbase;
|
|
200
|
+
coinbasepro: typeof coinbasepro;
|
|
198
201
|
coincheck: typeof coincheck;
|
|
199
202
|
coinex: typeof coinex;
|
|
200
203
|
coinlist: typeof coinlist;
|
|
@@ -278,6 +281,7 @@ declare const pro: {
|
|
|
278
281
|
bybit: typeof bybitPro;
|
|
279
282
|
cex: typeof cexPro;
|
|
280
283
|
coinbase: typeof coinbasePro;
|
|
284
|
+
coinbasepro: typeof coinbaseproPro;
|
|
281
285
|
coinex: typeof coinexPro;
|
|
282
286
|
cryptocom: typeof cryptocomPro;
|
|
283
287
|
currencycom: typeof currencycomPro;
|
|
@@ -340,6 +344,7 @@ declare const ccxt: {
|
|
|
340
344
|
bybit: typeof bybitPro;
|
|
341
345
|
cex: typeof cexPro;
|
|
342
346
|
coinbase: typeof coinbasePro;
|
|
347
|
+
coinbasepro: typeof coinbaseproPro;
|
|
343
348
|
coinex: typeof coinexPro;
|
|
344
349
|
cryptocom: typeof cryptocomPro;
|
|
345
350
|
currencycom: typeof currencycomPro;
|
|
@@ -412,6 +417,7 @@ declare const ccxt: {
|
|
|
412
417
|
bybit: typeof bybit;
|
|
413
418
|
cex: typeof cex;
|
|
414
419
|
coinbase: typeof coinbase;
|
|
420
|
+
coinbasepro: typeof coinbasepro;
|
|
415
421
|
coincheck: typeof coincheck;
|
|
416
422
|
coinex: typeof coinex;
|
|
417
423
|
coinlist: typeof coinlist;
|
|
@@ -471,5 +477,5 @@ declare const ccxt: {
|
|
|
471
477
|
zaif: typeof zaif;
|
|
472
478
|
zonda: typeof zonda;
|
|
473
479
|
} & typeof functions & typeof errors;
|
|
474
|
-
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, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coincheck, coinex, coinlist, coinmate, 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, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
480
|
+
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, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbasepro, coincheck, coinex, coinlist, coinmate, 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, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
475
481
|
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.1.
|
|
41
|
+
const version = '4.1.89';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -79,6 +79,7 @@ import btcturk from './src/btcturk.js';
|
|
|
79
79
|
import bybit from './src/bybit.js';
|
|
80
80
|
import cex from './src/cex.js';
|
|
81
81
|
import coinbase from './src/coinbase.js';
|
|
82
|
+
import coinbasepro from './src/coinbasepro.js';
|
|
82
83
|
import coincheck from './src/coincheck.js';
|
|
83
84
|
import coinex from './src/coinex.js';
|
|
84
85
|
import coinlist from './src/coinlist.js';
|
|
@@ -161,6 +162,7 @@ import blockchaincomPro from './src/pro/blockchaincom.js';
|
|
|
161
162
|
import bybitPro from './src/pro/bybit.js';
|
|
162
163
|
import cexPro from './src/pro/cex.js';
|
|
163
164
|
import coinbasePro from './src/pro/coinbase.js';
|
|
165
|
+
import coinbaseproPro from './src/pro/coinbasepro.js';
|
|
164
166
|
import coinexPro from './src/pro/coinex.js';
|
|
165
167
|
import cryptocomPro from './src/pro/cryptocom.js';
|
|
166
168
|
import currencycomPro from './src/pro/currencycom.js';
|
|
@@ -232,6 +234,7 @@ const exchanges = {
|
|
|
232
234
|
'bybit': bybit,
|
|
233
235
|
'cex': cex,
|
|
234
236
|
'coinbase': coinbase,
|
|
237
|
+
'coinbasepro': coinbasepro,
|
|
235
238
|
'coincheck': coincheck,
|
|
236
239
|
'coinex': coinex,
|
|
237
240
|
'coinlist': coinlist,
|
|
@@ -315,6 +318,7 @@ const pro = {
|
|
|
315
318
|
'bybit': bybitPro,
|
|
316
319
|
'cex': cexPro,
|
|
317
320
|
'coinbase': coinbasePro,
|
|
321
|
+
'coinbasepro': coinbaseproPro,
|
|
318
322
|
'coinex': coinexPro,
|
|
319
323
|
'cryptocom': cryptocomPro,
|
|
320
324
|
'currencycom': currencycomPro,
|
|
@@ -360,6 +364,6 @@ pro.exchanges = Object.keys(pro);
|
|
|
360
364
|
pro['Exchange'] = Exchange; // now the same for rest and ts
|
|
361
365
|
//-----------------------------------------------------------------------------
|
|
362
366
|
const ccxt = Object.assign({ version, Exchange, Precise, 'exchanges': Object.keys(exchanges), 'pro': pro }, exchanges, functions, errors);
|
|
363
|
-
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, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coincheck, coinex, coinlist, coinmate, 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, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
367
|
+
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, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbasepro, coincheck, coinex, coinlist, coinmate, 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, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
364
368
|
export default ccxt;
|
|
365
369
|
//-----------------------------------------------------------------------------
|
|
@@ -3,7 +3,6 @@ import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
|
3
3
|
interface Exchange {
|
|
4
4
|
publicCommonGetV2PublicAnnoucements(params?: {}): Promise<implicitReturnType>;
|
|
5
5
|
publicCommonGetV2PublicTime(params?: {}): Promise<implicitReturnType>;
|
|
6
|
-
publicCommonGetV2CommonTradeRate(params?: {}): Promise<implicitReturnType>;
|
|
7
6
|
publicSpotGetSpotV1NoticeQueryAllNotices(params?: {}): Promise<implicitReturnType>;
|
|
8
7
|
publicSpotGetSpotV1PublicTime(params?: {}): Promise<implicitReturnType>;
|
|
9
8
|
publicSpotGetSpotV1PublicCurrencies(params?: {}): Promise<implicitReturnType>;
|
|
@@ -496,6 +495,7 @@ interface Exchange {
|
|
|
496
495
|
privateEarnPostV2EarnLoanBorrow(params?: {}): Promise<implicitReturnType>;
|
|
497
496
|
privateEarnPostV2EarnLoanRepay(params?: {}): Promise<implicitReturnType>;
|
|
498
497
|
privateEarnPostV2EarnLoanRevisePledge(params?: {}): Promise<implicitReturnType>;
|
|
498
|
+
privateCommonGetV2CommonTradeRate(params?: {}): Promise<implicitReturnType>;
|
|
499
499
|
}
|
|
500
500
|
declare abstract class Exchange extends _Exchange {
|
|
501
501
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { implicitReturnType } from '../base/types.js';
|
|
2
|
+
import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
3
|
+
interface Exchange {
|
|
4
|
+
publicGetCurrencies(params?: {}): Promise<implicitReturnType>;
|
|
5
|
+
publicGetProducts(params?: {}): Promise<implicitReturnType>;
|
|
6
|
+
publicGetProductsId(params?: {}): Promise<implicitReturnType>;
|
|
7
|
+
publicGetProductsIdBook(params?: {}): Promise<implicitReturnType>;
|
|
8
|
+
publicGetProductsIdCandles(params?: {}): Promise<implicitReturnType>;
|
|
9
|
+
publicGetProductsIdStats(params?: {}): Promise<implicitReturnType>;
|
|
10
|
+
publicGetProductsIdTicker(params?: {}): Promise<implicitReturnType>;
|
|
11
|
+
publicGetProductsIdTrades(params?: {}): Promise<implicitReturnType>;
|
|
12
|
+
publicGetTime(params?: {}): Promise<implicitReturnType>;
|
|
13
|
+
publicGetProductsSparkLines(params?: {}): Promise<implicitReturnType>;
|
|
14
|
+
privateGetAddressBook(params?: {}): Promise<implicitReturnType>;
|
|
15
|
+
privateGetAccounts(params?: {}): Promise<implicitReturnType>;
|
|
16
|
+
privateGetAccountsId(params?: {}): Promise<implicitReturnType>;
|
|
17
|
+
privateGetAccountsIdHolds(params?: {}): Promise<implicitReturnType>;
|
|
18
|
+
privateGetAccountsIdLedger(params?: {}): Promise<implicitReturnType>;
|
|
19
|
+
privateGetAccountsIdTransfers(params?: {}): Promise<implicitReturnType>;
|
|
20
|
+
privateGetCoinbaseAccounts(params?: {}): Promise<implicitReturnType>;
|
|
21
|
+
privateGetFills(params?: {}): Promise<implicitReturnType>;
|
|
22
|
+
privateGetFunding(params?: {}): Promise<implicitReturnType>;
|
|
23
|
+
privateGetFees(params?: {}): Promise<implicitReturnType>;
|
|
24
|
+
privateGetMarginProfileInformation(params?: {}): Promise<implicitReturnType>;
|
|
25
|
+
privateGetMarginBuyingPower(params?: {}): Promise<implicitReturnType>;
|
|
26
|
+
privateGetMarginWithdrawalPower(params?: {}): Promise<implicitReturnType>;
|
|
27
|
+
privateGetMarginWithdrawalPowerAll(params?: {}): Promise<implicitReturnType>;
|
|
28
|
+
privateGetMarginExitPlan(params?: {}): Promise<implicitReturnType>;
|
|
29
|
+
privateGetMarginLiquidationHistory(params?: {}): Promise<implicitReturnType>;
|
|
30
|
+
privateGetMarginPositionRefreshAmounts(params?: {}): Promise<implicitReturnType>;
|
|
31
|
+
privateGetMarginStatus(params?: {}): Promise<implicitReturnType>;
|
|
32
|
+
privateGetOracle(params?: {}): Promise<implicitReturnType>;
|
|
33
|
+
privateGetOrders(params?: {}): Promise<implicitReturnType>;
|
|
34
|
+
privateGetOrdersId(params?: {}): Promise<implicitReturnType>;
|
|
35
|
+
privateGetOrdersClientClientOid(params?: {}): Promise<implicitReturnType>;
|
|
36
|
+
privateGetOtcOrders(params?: {}): Promise<implicitReturnType>;
|
|
37
|
+
privateGetPaymentMethods(params?: {}): Promise<implicitReturnType>;
|
|
38
|
+
privateGetPosition(params?: {}): Promise<implicitReturnType>;
|
|
39
|
+
privateGetProfiles(params?: {}): Promise<implicitReturnType>;
|
|
40
|
+
privateGetProfilesId(params?: {}): Promise<implicitReturnType>;
|
|
41
|
+
privateGetReportsReportId(params?: {}): Promise<implicitReturnType>;
|
|
42
|
+
privateGetTransfers(params?: {}): Promise<implicitReturnType>;
|
|
43
|
+
privateGetTransfersTransferId(params?: {}): Promise<implicitReturnType>;
|
|
44
|
+
privateGetUsersSelfExchangeLimits(params?: {}): Promise<implicitReturnType>;
|
|
45
|
+
privateGetUsersSelfHoldBalances(params?: {}): Promise<implicitReturnType>;
|
|
46
|
+
privateGetUsersSelfTrailingVolume(params?: {}): Promise<implicitReturnType>;
|
|
47
|
+
privateGetWithdrawalsFeeEstimate(params?: {}): Promise<implicitReturnType>;
|
|
48
|
+
privateGetConversionsConversionId(params?: {}): Promise<implicitReturnType>;
|
|
49
|
+
privatePostConversions(params?: {}): Promise<implicitReturnType>;
|
|
50
|
+
privatePostDepositsCoinbaseAccount(params?: {}): Promise<implicitReturnType>;
|
|
51
|
+
privatePostDepositsPaymentMethod(params?: {}): Promise<implicitReturnType>;
|
|
52
|
+
privatePostCoinbaseAccountsIdAddresses(params?: {}): Promise<implicitReturnType>;
|
|
53
|
+
privatePostFundingRepay(params?: {}): Promise<implicitReturnType>;
|
|
54
|
+
privatePostOrders(params?: {}): Promise<implicitReturnType>;
|
|
55
|
+
privatePostPositionClose(params?: {}): Promise<implicitReturnType>;
|
|
56
|
+
privatePostProfilesMarginTransfer(params?: {}): Promise<implicitReturnType>;
|
|
57
|
+
privatePostProfilesTransfer(params?: {}): Promise<implicitReturnType>;
|
|
58
|
+
privatePostReports(params?: {}): Promise<implicitReturnType>;
|
|
59
|
+
privatePostWithdrawalsCoinbase(params?: {}): Promise<implicitReturnType>;
|
|
60
|
+
privatePostWithdrawalsCoinbaseAccount(params?: {}): Promise<implicitReturnType>;
|
|
61
|
+
privatePostWithdrawalsCrypto(params?: {}): Promise<implicitReturnType>;
|
|
62
|
+
privatePostWithdrawalsPaymentMethod(params?: {}): Promise<implicitReturnType>;
|
|
63
|
+
privateDeleteOrders(params?: {}): Promise<implicitReturnType>;
|
|
64
|
+
privateDeleteOrdersClientClientOid(params?: {}): Promise<implicitReturnType>;
|
|
65
|
+
privateDeleteOrdersId(params?: {}): Promise<implicitReturnType>;
|
|
66
|
+
}
|
|
67
|
+
declare abstract class Exchange extends _Exchange {
|
|
68
|
+
}
|
|
69
|
+
export default Exchange;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
// -------------------------------------------------------------------------------
|
|
8
|
+
import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
9
|
+
class Exchange extends _Exchange {
|
|
10
|
+
}
|
|
11
|
+
export default Exchange;
|
|
@@ -22,6 +22,7 @@ interface Exchange {
|
|
|
22
22
|
v1GetMdSpotTicker24hrAll(params?: {}): Promise<implicitReturnType>;
|
|
23
23
|
v1GetExchangePublicProducts(params?: {}): Promise<implicitReturnType>;
|
|
24
24
|
v1GetApiDataPublicDataFundingRateHistory(params?: {}): Promise<implicitReturnType>;
|
|
25
|
+
v2GetPublicProducts(params?: {}): Promise<implicitReturnType>;
|
|
25
26
|
v2GetMdV2Orderbook(params?: {}): Promise<implicitReturnType>;
|
|
26
27
|
v2GetMdV2Trade(params?: {}): Promise<implicitReturnType>;
|
|
27
28
|
v2GetMdV2Ticker24hr(params?: {}): Promise<implicitReturnType>;
|
|
@@ -532,13 +532,14 @@ export default class Exchange {
|
|
|
532
532
|
checkOrderArguments(market: any, type: any, side: any, amount: any, price: any, params: any): void;
|
|
533
533
|
handleHttpStatusCode(code: any, reason: any, url: any, method: any, body: any): void;
|
|
534
534
|
remove0xPrefix(hexData: any): any;
|
|
535
|
-
spawn(method: any, ...args: any[]): Future
|
|
535
|
+
spawn(method: any, ...args: any[]): ReturnType<typeof Future>;
|
|
536
536
|
delay(timeout: any, method: any, ...args: any[]): void;
|
|
537
537
|
orderBook(snapshot?: {}, depth?: number): WsOrderBook;
|
|
538
538
|
indexedOrderBook(snapshot?: {}, depth?: number): IndexedOrderBook;
|
|
539
539
|
countedOrderBook(snapshot?: {}, depth?: number): CountedOrderBook;
|
|
540
540
|
handleMessage(client: any, message: any): void;
|
|
541
541
|
client(url: any): WsClient;
|
|
542
|
+
watchMultiple(url: any, messageHashes: any, message?: any, subscribeHashes?: any, subscription?: any): import("./ws/Future.js").FutureInterface;
|
|
542
543
|
watch(url: any, messageHash: any, message?: any, subscribeHash?: any, subscription?: any): any;
|
|
543
544
|
onConnected(client: any, message?: any): void;
|
|
544
545
|
onError(client: any, error: any): void;
|
|
@@ -871,8 +872,6 @@ export default class Exchange {
|
|
|
871
872
|
fetchTransactions(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
872
873
|
filterByArrayPositions(objects: any, key: IndexType, values?: any, indexed?: boolean): Position[];
|
|
873
874
|
filterByArrayTickers(objects: any, key: IndexType, values?: any, indexed?: boolean): Dictionary<Ticker>;
|
|
874
|
-
resolvePromiseIfMessagehashMatches(client: any, prefix: string, symbol: string, data: any): void;
|
|
875
|
-
resolveMultipleOHLCV(client: any, prefix: string, symbol: string, timeframe: string, data: any): void;
|
|
876
875
|
createOHLCVObject(symbol: string, timeframe: string, data: any): Dictionary<Dictionary<OHLCV[]>>;
|
|
877
876
|
handleMaxEntriesPerRequestAndParams(method: string, maxEntriesPerRequest?: Int, params?: {}): [Int, any];
|
|
878
877
|
fetchPaginatedCallDynamic(method: string, symbol?: string, since?: Int, limit?: Int, params?: {}, maxEntriesPerRequest?: Int): Promise<any>;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -15,7 +15,7 @@ ExchangeError, BadSymbol, NullResponse, InvalidAddress, InvalidOrder, NotSupport
|
|
|
15
15
|
import { Precise } from './Precise.js';
|
|
16
16
|
//-----------------------------------------------------------------------------
|
|
17
17
|
import WsClient from './ws/WsClient.js';
|
|
18
|
-
import {
|
|
18
|
+
import { Future } from './ws/Future.js';
|
|
19
19
|
import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
|
|
20
20
|
// ----------------------------------------------------------------------------
|
|
21
21
|
//
|
|
@@ -970,7 +970,7 @@ export default class Exchange {
|
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
972
|
spawn(method, ...args) {
|
|
973
|
-
const future =
|
|
973
|
+
const future = Future();
|
|
974
974
|
method.apply(this, args).then(future.resolve).catch(future.reject);
|
|
975
975
|
return future;
|
|
976
976
|
}
|
|
@@ -1023,6 +1023,99 @@ export default class Exchange {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
return this.clients[url];
|
|
1025
1025
|
}
|
|
1026
|
+
watchMultiple(url, messageHashes, message = undefined, subscribeHashes = undefined, subscription = undefined) {
|
|
1027
|
+
//
|
|
1028
|
+
// Without comments the code of this method is short and easy:
|
|
1029
|
+
//
|
|
1030
|
+
// const client = this.client (url)
|
|
1031
|
+
// const backoffDelay = 0
|
|
1032
|
+
// const future = client.future (messageHash)
|
|
1033
|
+
// const connected = client.connect (backoffDelay)
|
|
1034
|
+
// connected.then (() => {
|
|
1035
|
+
// if (message && !client.subscriptions[subscribeHash]) {
|
|
1036
|
+
// client.subscriptions[subscribeHash] = true
|
|
1037
|
+
// client.send (message)
|
|
1038
|
+
// }
|
|
1039
|
+
// }).catch ((error) => {})
|
|
1040
|
+
// return future
|
|
1041
|
+
//
|
|
1042
|
+
// The following is a longer version of this method with comments
|
|
1043
|
+
//
|
|
1044
|
+
const client = this.client(url);
|
|
1045
|
+
// todo: calculate the backoff using the clients cache
|
|
1046
|
+
const backoffDelay = 0;
|
|
1047
|
+
//
|
|
1048
|
+
// watchOrderBook ---- future ----+---------------+----→ user
|
|
1049
|
+
// | |
|
|
1050
|
+
// ↓ ↑
|
|
1051
|
+
// | |
|
|
1052
|
+
// connect ......→ resolve
|
|
1053
|
+
// | |
|
|
1054
|
+
// ↓ ↑
|
|
1055
|
+
// | |
|
|
1056
|
+
// subscribe -----→ receive
|
|
1057
|
+
//
|
|
1058
|
+
const future = Future.race(messageHashes.map(messageHash => client.future(messageHash)));
|
|
1059
|
+
// read and write subscription, this is done before connecting the client
|
|
1060
|
+
// to avoid race conditions when other parts of the code read or write to the client.subscriptions
|
|
1061
|
+
let missingSubscriptions = [];
|
|
1062
|
+
if (subscribeHashes !== undefined) {
|
|
1063
|
+
for (let i = 0; i < subscribeHashes.length; i++) {
|
|
1064
|
+
const subscribeHash = subscribeHashes[i];
|
|
1065
|
+
if (!client.subscriptions[subscribeHash]) {
|
|
1066
|
+
missingSubscriptions.push(subscribeHash);
|
|
1067
|
+
client.subscriptions[subscribeHash] = subscription || true;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
// we intentionally do not use await here to avoid unhandled exceptions
|
|
1072
|
+
// the policy is to make sure that 100% of promises are resolved or rejected
|
|
1073
|
+
// either with a call to client.resolve or client.reject with
|
|
1074
|
+
// a proper exception class instance
|
|
1075
|
+
const connected = client.connect(backoffDelay);
|
|
1076
|
+
// the following is executed only if the catch-clause does not
|
|
1077
|
+
// catch any connection-level exceptions from the client
|
|
1078
|
+
// (connection established successfully)
|
|
1079
|
+
if ((subscribeHashes === undefined) || missingSubscriptions.length) {
|
|
1080
|
+
connected.then(() => {
|
|
1081
|
+
const options = this.safeValue(this.options, 'ws');
|
|
1082
|
+
const cost = this.safeValue(options, 'cost', 1);
|
|
1083
|
+
if (message) {
|
|
1084
|
+
if (this.enableRateLimit && client.throttle) {
|
|
1085
|
+
// add cost here |
|
|
1086
|
+
// |
|
|
1087
|
+
// V
|
|
1088
|
+
client.throttle(cost).then(() => {
|
|
1089
|
+
client.send(message);
|
|
1090
|
+
}).catch((e) => {
|
|
1091
|
+
for (let i = 0; i < missingSubscriptions.length; i++) {
|
|
1092
|
+
const subscribeHash = missingSubscriptions[i];
|
|
1093
|
+
delete client.subscriptions[subscribeHash];
|
|
1094
|
+
}
|
|
1095
|
+
future.reject(e);
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
else {
|
|
1099
|
+
client.send(message)
|
|
1100
|
+
.catch((e) => {
|
|
1101
|
+
for (let i = 0; i < missingSubscriptions.length; i++) {
|
|
1102
|
+
const subscribeHash = missingSubscriptions[i];
|
|
1103
|
+
delete client.subscriptions[subscribeHash];
|
|
1104
|
+
}
|
|
1105
|
+
future.reject(e);
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
}).catch((e) => {
|
|
1110
|
+
for (let i = 0; i < missingSubscriptions.length; i++) {
|
|
1111
|
+
const subscribeHash = missingSubscriptions[i];
|
|
1112
|
+
delete client.subscriptions[subscribeHash];
|
|
1113
|
+
}
|
|
1114
|
+
future.reject(e);
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
return future;
|
|
1118
|
+
}
|
|
1026
1119
|
watch(url, messageHash, message = undefined, subscribeHash = undefined, subscription = undefined) {
|
|
1027
1120
|
//
|
|
1028
1121
|
// Without comments the code of this method is short and easy:
|
|
@@ -1389,7 +1482,7 @@ export default class Exchange {
|
|
|
1389
1482
|
const length = usedProxies.length;
|
|
1390
1483
|
if (length > 1) {
|
|
1391
1484
|
const joinedProxyNames = usedProxies.join(',');
|
|
1392
|
-
throw new ExchangeError(this.id + ' you have multiple conflicting settings (' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy,
|
|
1485
|
+
throw new ExchangeError(this.id + ' you have multiple conflicting settings (' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy, wsSocksProxy');
|
|
1393
1486
|
}
|
|
1394
1487
|
return [wsProxy, wssProxy, wsSocksProxy];
|
|
1395
1488
|
}
|
|
@@ -4514,31 +4607,6 @@ export default class Exchange {
|
|
|
4514
4607
|
*/
|
|
4515
4608
|
return this.filterByArray(objects, key, values, indexed);
|
|
4516
4609
|
}
|
|
4517
|
-
resolvePromiseIfMessagehashMatches(client, prefix, symbol, data) {
|
|
4518
|
-
const messageHashes = this.findMessageHashes(client, prefix);
|
|
4519
|
-
for (let i = 0; i < messageHashes.length; i++) {
|
|
4520
|
-
const messageHash = messageHashes[i];
|
|
4521
|
-
const parts = messageHash.split('::');
|
|
4522
|
-
const symbolsString = parts[1];
|
|
4523
|
-
const symbols = symbolsString.split(',');
|
|
4524
|
-
if (this.inArray(symbol, symbols)) {
|
|
4525
|
-
client.resolve(data, messageHash);
|
|
4526
|
-
}
|
|
4527
|
-
}
|
|
4528
|
-
}
|
|
4529
|
-
resolveMultipleOHLCV(client, prefix, symbol, timeframe, data) {
|
|
4530
|
-
const messageHashes = this.findMessageHashes(client, 'multipleOHLCV::');
|
|
4531
|
-
for (let i = 0; i < messageHashes.length; i++) {
|
|
4532
|
-
const messageHash = messageHashes[i];
|
|
4533
|
-
const parts = messageHash.split('::');
|
|
4534
|
-
const symbolsAndTimeframes = parts[1];
|
|
4535
|
-
const splitted = symbolsAndTimeframes.split(',');
|
|
4536
|
-
const id = symbol + '#' + timeframe;
|
|
4537
|
-
if (this.inArray(id, splitted)) {
|
|
4538
|
-
client.resolve([symbol, timeframe, data], messageHash);
|
|
4539
|
-
}
|
|
4540
|
-
}
|
|
4541
|
-
}
|
|
4542
4610
|
createOHLCVObject(symbol, timeframe, data) {
|
|
4543
4611
|
const res = {};
|
|
4544
4612
|
res[symbol] = {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Future } from './Future.js';
|
|
2
2
|
export default class Client {
|
|
3
3
|
connected: Promise<any>;
|
|
4
|
-
disconnected: Future
|
|
4
|
+
disconnected: ReturnType<typeof Future>;
|
|
5
5
|
futures: {};
|
|
6
6
|
rejections: {};
|
|
7
7
|
keepAlive: number;
|
|
@@ -45,7 +45,7 @@ export default class Client {
|
|
|
45
45
|
onError(error: any): void;
|
|
46
46
|
onClose(event: any): void;
|
|
47
47
|
onUpgrade(message: any): void;
|
|
48
|
-
send(message: any): Promise<
|
|
48
|
+
send(message: any): Promise<any>;
|
|
49
49
|
close(): void;
|
|
50
50
|
onMessage(messageEvent: any): void;
|
|
51
51
|
}
|
package/js/src/base/ws/Client.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { RequestTimeout, NetworkError, NotSupported, BaseError } from '../../base/errors.js';
|
|
8
8
|
import { inflateSync, gunzipSync } from '../../static_dependencies/fflake/browser.js';
|
|
9
|
-
import {
|
|
9
|
+
import { Future } from './Future.js';
|
|
10
10
|
import { isNode, isJsonEncodedObject, deepExtend, milliseconds, } from '../../base/functions.js';
|
|
11
11
|
import { utf8 } from '../../static_dependencies/scure-base/index.js';
|
|
12
12
|
export default class Client {
|
|
@@ -43,11 +43,11 @@ export default class Client {
|
|
|
43
43
|
};
|
|
44
44
|
Object.assign(this, deepExtend(defaults, config));
|
|
45
45
|
// connection-related Future
|
|
46
|
-
this.connected =
|
|
46
|
+
this.connected = Future();
|
|
47
47
|
}
|
|
48
48
|
future(messageHash) {
|
|
49
49
|
if (!(messageHash in this.futures)) {
|
|
50
|
-
this.futures[messageHash] =
|
|
50
|
+
this.futures[messageHash] = Future();
|
|
51
51
|
}
|
|
52
52
|
const future = this.futures[messageHash];
|
|
53
53
|
if (messageHash in this.rejections) {
|
|
@@ -225,7 +225,7 @@ export default class Client {
|
|
|
225
225
|
this.log(new Date(), 'sending', message);
|
|
226
226
|
}
|
|
227
227
|
message = (typeof message === 'string') ? message : JSON.stringify(message);
|
|
228
|
-
const future =
|
|
228
|
+
const future = Future();
|
|
229
229
|
if (isNode) {
|
|
230
230
|
/* eslint-disable no-inner-declarations */
|
|
231
231
|
function onSendComplete(error) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface FutureInterface extends Promise<any> {
|
|
2
2
|
resolve(value: unknown): void;
|
|
3
3
|
reject(reason?: any): void;
|
|
4
4
|
}
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function Future(): FutureInterface;
|
|
6
|
+
export declare namespace Future {
|
|
7
|
+
var race: (futures: any) => FutureInterface;
|
|
8
|
+
}
|
package/js/src/base/ws/Future.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
6
|
|
|
7
7
|
// @ts-nocheck
|
|
8
|
-
export function
|
|
8
|
+
export function Future() {
|
|
9
9
|
let resolve = undefined, reject = undefined;
|
|
10
10
|
const p = new Promise((resolve_, reject_) => {
|
|
11
11
|
resolve = resolve_;
|
|
@@ -25,4 +25,10 @@ export function createFuture() {
|
|
|
25
25
|
};
|
|
26
26
|
return p;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
function wrapFuture(aggregatePromise) {
|
|
29
|
+
const p = Future();
|
|
30
|
+
// wrap the promises as a future
|
|
31
|
+
aggregatePromise.then(p.resolve, p.reject);
|
|
32
|
+
return p;
|
|
33
|
+
}
|
|
34
|
+
Future.race = (futures) => wrapFuture(Promise.race(futures));
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import Client from './Client.js';
|
|
8
8
|
import { sleep, isNode, milliseconds, } from '../../base/functions.js';
|
|
9
9
|
import WebSocket from 'ws';
|
|
10
|
-
import {
|
|
10
|
+
import { Future } from './Future.js';
|
|
11
11
|
const WebSocketPlatform = isNode ? WebSocket : self.WebSocket;
|
|
12
12
|
export default class WsClient extends Client {
|
|
13
13
|
createConnection() {
|
|
@@ -54,7 +54,7 @@ export default class WsClient extends Client {
|
|
|
54
54
|
close() {
|
|
55
55
|
if (this.connection instanceof WebSocketPlatform) {
|
|
56
56
|
if (this.disconnected === undefined) {
|
|
57
|
-
this.disconnected =
|
|
57
|
+
this.disconnected = Future();
|
|
58
58
|
}
|
|
59
59
|
this.connection.close();
|
|
60
60
|
}
|