ccxt 4.3.96 → 4.3.98
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 +3 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +3 -0
- package/dist/cjs/src/bitget.js +2 -0
- package/dist/cjs/src/coinex.js +16 -3
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/pro/gate.js +179 -0
- package/dist/cjs/src/pro/kraken.js +14 -10
- package/dist/cjs/src/pro/kucoin.js +191 -0
- package/dist/cjs/src/whitebit.js +7 -8
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/binance.js +3 -0
- package/js/src/bitget.js +2 -0
- package/js/src/coinex.js +16 -3
- package/js/src/gate.js +1 -1
- package/js/src/kucoin.js +1 -1
- package/js/src/pro/gate.d.ts +7 -1
- package/js/src/pro/gate.js +180 -1
- package/js/src/pro/kraken.js +14 -10
- package/js/src/pro/kucoin.d.ts +7 -1
- package/js/src/pro/kucoin.js +192 -1
- package/js/src/whitebit.js +7 -8
- package/package.json +1 -1
package/dist/cjs/src/whitebit.js
CHANGED
|
@@ -1623,20 +1623,19 @@ class whitebit extends whitebit$1 {
|
|
|
1623
1623
|
* @name whitebit#fetchOpenOrders
|
|
1624
1624
|
* @description fetch all unfilled currently open orders
|
|
1625
1625
|
* @see https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
|
|
1626
|
-
* @param {string} symbol unified market symbol
|
|
1626
|
+
* @param {string} [symbol] unified market symbol
|
|
1627
1627
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1628
1628
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
1629
1629
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1630
1630
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1631
1631
|
*/
|
|
1632
|
-
if (symbol === undefined) {
|
|
1633
|
-
throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
|
|
1634
|
-
}
|
|
1635
1632
|
await this.loadMarkets();
|
|
1636
|
-
|
|
1637
|
-
const request = {
|
|
1638
|
-
|
|
1639
|
-
|
|
1633
|
+
let market = undefined;
|
|
1634
|
+
const request = {};
|
|
1635
|
+
if (symbol !== undefined) {
|
|
1636
|
+
market = this.market(symbol);
|
|
1637
|
+
request['market'] = market['id'];
|
|
1638
|
+
}
|
|
1640
1639
|
if (limit !== undefined) {
|
|
1641
1640
|
request['limit'] = Math.min(limit, 100);
|
|
1642
1641
|
}
|
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 { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.3.
|
|
7
|
+
declare const version = "4.3.97";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.3.
|
|
41
|
+
const version = '4.3.98';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/binance.js
CHANGED
|
@@ -4252,6 +4252,9 @@ export default class binance extends Exchange {
|
|
|
4252
4252
|
const price = this.safeString(params, 'price');
|
|
4253
4253
|
const until = this.safeInteger(params, 'until');
|
|
4254
4254
|
params = this.omit(params, ['price', 'until']);
|
|
4255
|
+
if (since !== undefined && until !== undefined && limit === undefined) {
|
|
4256
|
+
limit = maxLimit;
|
|
4257
|
+
}
|
|
4255
4258
|
limit = (limit === undefined) ? defaultLimit : Math.min(limit, maxLimit);
|
|
4256
4259
|
const request = {
|
|
4257
4260
|
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
package/js/src/bitget.js
CHANGED
|
@@ -1233,6 +1233,8 @@ export default class bitget extends Exchange {
|
|
|
1233
1233
|
'40714': ExchangeError,
|
|
1234
1234
|
'40762': InsufficientFunds,
|
|
1235
1235
|
'40768': OrderNotFound,
|
|
1236
|
+
'40808': InvalidOrder,
|
|
1237
|
+
'41103': InvalidOrder,
|
|
1236
1238
|
'41114': OnMaintenance,
|
|
1237
1239
|
'43011': InvalidOrder,
|
|
1238
1240
|
'43012': InsufficientFunds,
|
package/js/src/coinex.js
CHANGED
|
@@ -1213,7 +1213,10 @@ export default class coinex extends Exchange {
|
|
|
1213
1213
|
// "side": "buy",
|
|
1214
1214
|
// "order_id": 136915589622,
|
|
1215
1215
|
// "price": "64376",
|
|
1216
|
-
// "amount": "0.0001"
|
|
1216
|
+
// "amount": "0.0001",
|
|
1217
|
+
// "role": "taker",
|
|
1218
|
+
// "fee": "0.0299",
|
|
1219
|
+
// "fee_ccy": "USDT"
|
|
1217
1220
|
// }
|
|
1218
1221
|
//
|
|
1219
1222
|
const timestamp = this.safeInteger(trade, 'created_at');
|
|
@@ -1223,6 +1226,16 @@ export default class coinex extends Exchange {
|
|
|
1223
1226
|
}
|
|
1224
1227
|
const marketId = this.safeString(trade, 'market');
|
|
1225
1228
|
market = this.safeMarket(marketId, market, undefined, defaultType);
|
|
1229
|
+
const feeCostString = this.safeString(trade, 'fee');
|
|
1230
|
+
let fee = undefined;
|
|
1231
|
+
if (feeCostString !== undefined) {
|
|
1232
|
+
const feeCurrencyId = this.safeString(trade, 'fee_ccy');
|
|
1233
|
+
const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
1234
|
+
fee = {
|
|
1235
|
+
'cost': feeCostString,
|
|
1236
|
+
'currency': feeCurrencyCode,
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1226
1239
|
return this.safeTrade({
|
|
1227
1240
|
'info': trade,
|
|
1228
1241
|
'timestamp': timestamp,
|
|
@@ -1232,11 +1245,11 @@ export default class coinex extends Exchange {
|
|
|
1232
1245
|
'order': this.safeString(trade, 'order_id'),
|
|
1233
1246
|
'type': undefined,
|
|
1234
1247
|
'side': this.safeString(trade, 'side'),
|
|
1235
|
-
'takerOrMaker':
|
|
1248
|
+
'takerOrMaker': this.safeString(trade, 'role'),
|
|
1236
1249
|
'price': this.safeString(trade, 'price'),
|
|
1237
1250
|
'amount': this.safeString(trade, 'amount'),
|
|
1238
1251
|
'cost': this.safeString(trade, 'deal_money'),
|
|
1239
|
-
'fee':
|
|
1252
|
+
'fee': fee,
|
|
1240
1253
|
}, market);
|
|
1241
1254
|
}
|
|
1242
1255
|
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
package/js/src/gate.js
CHANGED
|
@@ -4020,7 +4020,7 @@ export default class gate extends Exchange {
|
|
|
4020
4020
|
request['settle'] = market['settleId']; // filled in prepareRequest above
|
|
4021
4021
|
}
|
|
4022
4022
|
if (isMarketOrder) {
|
|
4023
|
-
request['price'] =
|
|
4023
|
+
request['price'] = '0'; // set to 0 for market orders
|
|
4024
4024
|
}
|
|
4025
4025
|
else {
|
|
4026
4026
|
request['price'] = (price === 0) ? '0' : this.priceToPrecision(symbol, price);
|
package/js/src/kucoin.js
CHANGED
|
@@ -3831,7 +3831,7 @@ export default class kucoin extends Exchange {
|
|
|
3831
3831
|
params = this.omit(params, 'type');
|
|
3832
3832
|
let hf = undefined;
|
|
3833
3833
|
[hf, params] = this.handleHfAndParams(params);
|
|
3834
|
-
if (hf) {
|
|
3834
|
+
if (hf && (type !== 'main')) {
|
|
3835
3835
|
type = 'trade_hf';
|
|
3836
3836
|
}
|
|
3837
3837
|
const [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
|
package/js/src/pro/gate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import gateRest from '../gate.js';
|
|
2
|
-
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Position, Balances, Liquidation, OrderType, OrderSide, Num, Market, MarketType, OrderRequest } from '../base/types.js';
|
|
2
|
+
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Position, Balances, Dict, Liquidation, OrderType, OrderSide, Num, Market, MarketType, OrderRequest } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class gate extends gateRest {
|
|
5
5
|
describe(): any;
|
|
@@ -13,6 +13,7 @@ export default class gate extends gateRest {
|
|
|
13
13
|
fetchClosedOrdersWs(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
14
14
|
fetchOrdersByStatusWs(status: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
15
15
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
16
|
+
unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
|
|
16
17
|
handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
|
|
17
18
|
handleOrderBook(client: Client, message: any): void;
|
|
18
19
|
getCacheIndex(orderBook: any, cache: any): any;
|
|
@@ -27,6 +28,8 @@ export default class gate extends gateRest {
|
|
|
27
28
|
handleTickerAndBidAsk(objectName: string, client: Client, message: any): void;
|
|
28
29
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
29
30
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
31
|
+
unWatchTradesForSymbols(symbols: string[], params?: {}): Promise<any>;
|
|
32
|
+
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|
|
30
33
|
handleTrades(client: Client, message: any): void;
|
|
31
34
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
32
35
|
handleOHLCV(client: Client, message: any): void;
|
|
@@ -47,6 +50,8 @@ export default class gate extends gateRest {
|
|
|
47
50
|
handleErrorMessage(client: Client, message: any): boolean;
|
|
48
51
|
handleBalanceSubscription(client: Client, message: any, subscription?: any): void;
|
|
49
52
|
handleSubscriptionStatus(client: Client, message: any): void;
|
|
53
|
+
handleUnSubscribe(client: Client, message: any): void;
|
|
54
|
+
cleanCache(subscription: Dict): void;
|
|
50
55
|
handleMessage(client: Client, message: any): void;
|
|
51
56
|
getUrlByMarket(market: any): any;
|
|
52
57
|
getTypeByMarket(market: Market): "spot" | "futures" | "options";
|
|
@@ -55,6 +60,7 @@ export default class gate extends gateRest {
|
|
|
55
60
|
requestId(): any;
|
|
56
61
|
subscribePublic(url: any, messageHash: any, payload: any, channel: any, params?: {}, subscription?: any): Promise<any>;
|
|
57
62
|
subscribePublicMultiple(url: any, messageHashes: any, payload: any, channel: any, params?: {}): Promise<any>;
|
|
63
|
+
unSubscribePublicMultiple(url: any, topic: any, symbols: any, messageHashes: any, subMessageHashes: any, payload: any, channel: any, params?: {}): Promise<any>;
|
|
58
64
|
authenticate(url: any, messageType: any): Promise<any>;
|
|
59
65
|
handleAuthenticationMessage(client: Client, message: any): void;
|
|
60
66
|
requestPrivate(url: any, reqParams: any, channel: any, requestId?: Str): Promise<any>;
|
package/js/src/pro/gate.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import gateRest from '../gate.js';
|
|
9
|
-
import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported } from '../base/errors.js';
|
|
9
|
+
import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported, UnsubscribeError } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha512 } from '../static_dependencies/noble-hashes/sha512.js';
|
|
12
12
|
import Precise from '../base/Precise.js';
|
|
@@ -388,6 +388,34 @@ export default class gate extends gateRest {
|
|
|
388
388
|
const orderbook = await this.subscribePublic(url, messageHash, payload, channel, query, subscription);
|
|
389
389
|
return orderbook.limit();
|
|
390
390
|
}
|
|
391
|
+
async unWatchOrderBook(symbol, params = {}) {
|
|
392
|
+
/**
|
|
393
|
+
* @method
|
|
394
|
+
* @name gate#unWatchOrderBook
|
|
395
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
396
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
397
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
398
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
399
|
+
*/
|
|
400
|
+
await this.loadMarkets();
|
|
401
|
+
const market = this.market(symbol);
|
|
402
|
+
symbol = market['symbol'];
|
|
403
|
+
const marketId = market['id'];
|
|
404
|
+
let interval = '100ms';
|
|
405
|
+
[interval, params] = this.handleOptionAndParams(params, 'watchOrderBook', 'interval', interval);
|
|
406
|
+
const messageType = this.getTypeByMarket(market);
|
|
407
|
+
const channel = messageType + '.order_book_update';
|
|
408
|
+
const subMessageHash = 'orderbook' + ':' + symbol;
|
|
409
|
+
const messageHash = 'unsubscribe:orderbook' + ':' + symbol;
|
|
410
|
+
const url = this.getUrlByMarket(market);
|
|
411
|
+
const payload = [marketId, interval];
|
|
412
|
+
const limit = this.safeInteger(params, 'limit', 100);
|
|
413
|
+
if (market['contract']) {
|
|
414
|
+
const stringLimit = limit.toString();
|
|
415
|
+
payload.push(stringLimit);
|
|
416
|
+
}
|
|
417
|
+
return await this.unSubscribePublicMultiple(url, 'orderbook', [symbol], [messageHash], [subMessageHash], payload, channel, params);
|
|
418
|
+
}
|
|
391
419
|
handleOrderBookSubscription(client, message, subscription) {
|
|
392
420
|
const symbol = this.safeString(subscription, 'symbol');
|
|
393
421
|
const limit = this.safeInteger(subscription, 'limit');
|
|
@@ -720,6 +748,42 @@ export default class gate extends gateRest {
|
|
|
720
748
|
}
|
|
721
749
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
722
750
|
}
|
|
751
|
+
async unWatchTradesForSymbols(symbols, params = {}) {
|
|
752
|
+
/**
|
|
753
|
+
* @method
|
|
754
|
+
* @name gate#unWatchTradesForSymbols
|
|
755
|
+
* @description get the list of most recent trades for a particular symbol
|
|
756
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
757
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
758
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
759
|
+
*/
|
|
760
|
+
await this.loadMarkets();
|
|
761
|
+
symbols = this.marketSymbols(symbols);
|
|
762
|
+
const marketIds = this.marketIds(symbols);
|
|
763
|
+
const market = this.market(symbols[0]);
|
|
764
|
+
const messageType = this.getTypeByMarket(market);
|
|
765
|
+
const channel = messageType + '.trades';
|
|
766
|
+
const subMessageHashes = [];
|
|
767
|
+
const messageHashes = [];
|
|
768
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
769
|
+
const symbol = symbols[i];
|
|
770
|
+
subMessageHashes.push('trades:' + symbol);
|
|
771
|
+
messageHashes.push('unsubscribe:trades:' + symbol);
|
|
772
|
+
}
|
|
773
|
+
const url = this.getUrlByMarket(market);
|
|
774
|
+
return await this.unSubscribePublicMultiple(url, 'trades', symbols, messageHashes, subMessageHashes, marketIds, channel, params);
|
|
775
|
+
}
|
|
776
|
+
async unWatchTrades(symbol, params = {}) {
|
|
777
|
+
/**
|
|
778
|
+
* @method
|
|
779
|
+
* @name gate#unWatchTrades
|
|
780
|
+
* @description get the list of most recent trades for a particular symbol
|
|
781
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
782
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
783
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
784
|
+
*/
|
|
785
|
+
return await this.unWatchTradesForSymbols([symbol], params);
|
|
786
|
+
}
|
|
723
787
|
handleTrades(client, message) {
|
|
724
788
|
//
|
|
725
789
|
// {
|
|
@@ -1561,6 +1625,96 @@ export default class gate extends gateRest {
|
|
|
1561
1625
|
delete client.subscriptions[id];
|
|
1562
1626
|
}
|
|
1563
1627
|
}
|
|
1628
|
+
handleUnSubscribe(client, message) {
|
|
1629
|
+
//
|
|
1630
|
+
// {
|
|
1631
|
+
// "time":1725534679,
|
|
1632
|
+
// "time_ms":1725534679786,
|
|
1633
|
+
// "id":2,
|
|
1634
|
+
// "conn_id":"fac539b443fd7002",
|
|
1635
|
+
// "trace_id":"efe1d282b630b4aa266b84bee177791a",
|
|
1636
|
+
// "channel":"spot.trades",
|
|
1637
|
+
// "event":"unsubscribe",
|
|
1638
|
+
// "payload":[
|
|
1639
|
+
// "LTC_USDT"
|
|
1640
|
+
// ],
|
|
1641
|
+
// "result":{
|
|
1642
|
+
// "status":"success"
|
|
1643
|
+
// },
|
|
1644
|
+
// "requestId":"efe1d282b630b4aa266b84bee177791a"
|
|
1645
|
+
// }
|
|
1646
|
+
//
|
|
1647
|
+
const id = this.safeString(message, 'id');
|
|
1648
|
+
const keys = Object.keys(client.subscriptions);
|
|
1649
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1650
|
+
const messageHash = keys[i];
|
|
1651
|
+
if (!(messageHash in client.subscriptions)) {
|
|
1652
|
+
continue;
|
|
1653
|
+
// the previous iteration can have deleted the messageHash from the subscriptions
|
|
1654
|
+
}
|
|
1655
|
+
if (messageHash.startsWith('unsubscribe')) {
|
|
1656
|
+
const subscription = client.subscriptions[messageHash];
|
|
1657
|
+
const subId = this.safeString(subscription, 'id');
|
|
1658
|
+
if (id !== subId) {
|
|
1659
|
+
continue;
|
|
1660
|
+
}
|
|
1661
|
+
const messageHashes = this.safeList(subscription, 'messageHashes', []);
|
|
1662
|
+
const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
|
|
1663
|
+
for (let j = 0; j < messageHashes.length; j++) {
|
|
1664
|
+
const unsubHash = messageHashes[j];
|
|
1665
|
+
const subHash = subMessageHashes[j];
|
|
1666
|
+
if (unsubHash in client.subscriptions) {
|
|
1667
|
+
delete client.subscriptions[unsubHash];
|
|
1668
|
+
}
|
|
1669
|
+
if (subHash in client.subscriptions) {
|
|
1670
|
+
delete client.subscriptions[subHash];
|
|
1671
|
+
}
|
|
1672
|
+
const error = new UnsubscribeError(this.id + ' ' + messageHash);
|
|
1673
|
+
client.reject(error, subHash);
|
|
1674
|
+
client.resolve(true, unsubHash);
|
|
1675
|
+
}
|
|
1676
|
+
this.cleanCache(subscription);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
cleanCache(subscription) {
|
|
1681
|
+
const topic = this.safeString(subscription, 'topic', '');
|
|
1682
|
+
const symbols = this.safeList(subscription, 'symbols', []);
|
|
1683
|
+
const symbolsLength = symbols.length;
|
|
1684
|
+
if (topic === 'ohlcv') {
|
|
1685
|
+
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
1686
|
+
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
1687
|
+
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
1688
|
+
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
1689
|
+
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
1690
|
+
delete this.ohlcvs[symbol][timeframe];
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
else if (symbolsLength > 0) {
|
|
1694
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
1695
|
+
const symbol = symbols[i];
|
|
1696
|
+
if (topic.endsWith('trades')) {
|
|
1697
|
+
delete this.trades[symbol];
|
|
1698
|
+
}
|
|
1699
|
+
else if (topic === 'orderbook') {
|
|
1700
|
+
delete this.orderbooks[symbol];
|
|
1701
|
+
}
|
|
1702
|
+
else if (topic === 'ticker') {
|
|
1703
|
+
delete this.tickers[symbol];
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
else {
|
|
1708
|
+
if (topic.endsWith('trades')) {
|
|
1709
|
+
// don't reset this.myTrades directly here
|
|
1710
|
+
// because in c# we need to use a different object
|
|
1711
|
+
const keys = Object.keys(this.trades);
|
|
1712
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1713
|
+
delete this.trades[keys[i]];
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1564
1718
|
handleMessage(client, message) {
|
|
1565
1719
|
//
|
|
1566
1720
|
// subscribe
|
|
@@ -1659,6 +1813,10 @@ export default class gate extends gateRest {
|
|
|
1659
1813
|
this.handleSubscriptionStatus(client, message);
|
|
1660
1814
|
return;
|
|
1661
1815
|
}
|
|
1816
|
+
if (event === 'unsubscribe') {
|
|
1817
|
+
this.handleUnSubscribe(client, message);
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1662
1820
|
const channel = this.safeString(message, 'channel', '');
|
|
1663
1821
|
const channelParts = channel.split('.');
|
|
1664
1822
|
const channelType = this.safeValue(channelParts, 1);
|
|
@@ -1778,6 +1936,27 @@ export default class gate extends gateRest {
|
|
|
1778
1936
|
const message = this.extend(request, params);
|
|
1779
1937
|
return await this.watchMultiple(url, messageHashes, message, messageHashes);
|
|
1780
1938
|
}
|
|
1939
|
+
async unSubscribePublicMultiple(url, topic, symbols, messageHashes, subMessageHashes, payload, channel, params = {}) {
|
|
1940
|
+
const requestId = this.requestId();
|
|
1941
|
+
const time = this.seconds();
|
|
1942
|
+
const request = {
|
|
1943
|
+
'id': requestId,
|
|
1944
|
+
'time': time,
|
|
1945
|
+
'channel': channel,
|
|
1946
|
+
'event': 'unsubscribe',
|
|
1947
|
+
'payload': payload,
|
|
1948
|
+
};
|
|
1949
|
+
const sub = {
|
|
1950
|
+
'id': requestId.toString(),
|
|
1951
|
+
'topic': topic,
|
|
1952
|
+
'unsubscribe': true,
|
|
1953
|
+
'messageHashes': messageHashes,
|
|
1954
|
+
'subMessageHashes': subMessageHashes,
|
|
1955
|
+
'symbols': symbols,
|
|
1956
|
+
};
|
|
1957
|
+
const message = this.extend(request, params);
|
|
1958
|
+
return await this.watchMultiple(url, messageHashes, message, messageHashes, sub);
|
|
1959
|
+
}
|
|
1781
1960
|
async authenticate(url, messageType) {
|
|
1782
1961
|
const channel = messageType + '.login';
|
|
1783
1962
|
const client = this.client(url);
|
package/js/src/pro/kraken.js
CHANGED
|
@@ -115,7 +115,7 @@ export default class kraken extends krakenRest {
|
|
|
115
115
|
/**
|
|
116
116
|
* @method
|
|
117
117
|
* @name kraken#createOrderWs
|
|
118
|
-
* @see https://docs.kraken.com/
|
|
118
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/addorder
|
|
119
119
|
* @description create a trade order
|
|
120
120
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
121
121
|
* @param {string} type 'market' or 'limit'
|
|
@@ -172,7 +172,7 @@ export default class kraken extends krakenRest {
|
|
|
172
172
|
* @method
|
|
173
173
|
* @name kraken#editOrderWs
|
|
174
174
|
* @description edit a trade order
|
|
175
|
-
* @see https://docs.kraken.com/
|
|
175
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/editorder
|
|
176
176
|
* @param {string} id order id
|
|
177
177
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
178
178
|
* @param {string} type 'market' or 'limit'
|
|
@@ -205,7 +205,7 @@ export default class kraken extends krakenRest {
|
|
|
205
205
|
/**
|
|
206
206
|
* @method
|
|
207
207
|
* @name kraken#cancelOrdersWs
|
|
208
|
-
* @see https://docs.kraken.com/
|
|
208
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/cancelorder
|
|
209
209
|
* @description cancel multiple orders
|
|
210
210
|
* @param {string[]} ids order ids
|
|
211
211
|
* @param {string} symbol unified market symbol, default is undefined
|
|
@@ -229,7 +229,7 @@ export default class kraken extends krakenRest {
|
|
|
229
229
|
/**
|
|
230
230
|
* @method
|
|
231
231
|
* @name kraken#cancelOrderWs
|
|
232
|
-
* @see https://docs.kraken.com/
|
|
232
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/cancelorder
|
|
233
233
|
* @description cancels an open order
|
|
234
234
|
* @param {string} id order id
|
|
235
235
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
@@ -267,7 +267,7 @@ export default class kraken extends krakenRest {
|
|
|
267
267
|
/**
|
|
268
268
|
* @method
|
|
269
269
|
* @name kraken#cancelAllOrdersWs
|
|
270
|
-
* @see https://docs.kraken.com/
|
|
270
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/cancelall
|
|
271
271
|
* @description cancel all open orders
|
|
272
272
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
273
273
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -469,6 +469,7 @@ export default class kraken extends krakenRest {
|
|
|
469
469
|
* @method
|
|
470
470
|
* @name kraken#watchTicker
|
|
471
471
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
472
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/ticker
|
|
472
473
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
473
474
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
474
475
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -483,6 +484,7 @@ export default class kraken extends krakenRest {
|
|
|
483
484
|
* @method
|
|
484
485
|
* @name kraken#watchTickers
|
|
485
486
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
487
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/ticker
|
|
486
488
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
487
489
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
488
490
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -502,7 +504,7 @@ export default class kraken extends krakenRest {
|
|
|
502
504
|
* @method
|
|
503
505
|
* @name kraken#watchTrades
|
|
504
506
|
* @description get the list of most recent trades for a particular symbol
|
|
505
|
-
* @see https://docs.kraken.com/
|
|
507
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/trade
|
|
506
508
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
507
509
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
508
510
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -515,7 +517,7 @@ export default class kraken extends krakenRest {
|
|
|
515
517
|
/**
|
|
516
518
|
* @method
|
|
517
519
|
* @name kraken#watchTradesForSymbols
|
|
518
|
-
* @see https://docs.kraken.com/
|
|
520
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/trade
|
|
519
521
|
* @description get the list of most recent trades for a list of symbols
|
|
520
522
|
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
521
523
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
@@ -536,7 +538,7 @@ export default class kraken extends krakenRest {
|
|
|
536
538
|
* @method
|
|
537
539
|
* @name kraken#watchOrderBook
|
|
538
540
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
539
|
-
* @see https://docs.kraken.com/
|
|
541
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/book
|
|
540
542
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
541
543
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
542
544
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -549,7 +551,7 @@ export default class kraken extends krakenRest {
|
|
|
549
551
|
* @method
|
|
550
552
|
* @name kraken#watchOrderBookForSymbols
|
|
551
553
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
552
|
-
* @see https://docs.kraken.com/
|
|
554
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/book
|
|
553
555
|
* @param {string[]} symbols unified array of symbols
|
|
554
556
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
555
557
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -574,6 +576,7 @@ export default class kraken extends krakenRest {
|
|
|
574
576
|
* @method
|
|
575
577
|
* @name kraken#watchOHLCV
|
|
576
578
|
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
579
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/ohlc
|
|
577
580
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
578
581
|
* @param {string} timeframe the length of time each candle represents
|
|
579
582
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -883,6 +886,7 @@ export default class kraken extends krakenRest {
|
|
|
883
886
|
* @method
|
|
884
887
|
* @name kraken#watchMyTrades
|
|
885
888
|
* @description watches information on multiple trades made by the user
|
|
889
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/owntrades
|
|
886
890
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
887
891
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
888
892
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
@@ -1043,7 +1047,7 @@ export default class kraken extends krakenRest {
|
|
|
1043
1047
|
/**
|
|
1044
1048
|
* @method
|
|
1045
1049
|
* @name kraken#watchOrders
|
|
1046
|
-
* @see https://docs.kraken.com/
|
|
1050
|
+
* @see https://docs.kraken.com/api/docs/websocket-v1/openorders
|
|
1047
1051
|
* @description watches information on multiple orders made by the user
|
|
1048
1052
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1049
1053
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
package/js/src/pro/kucoin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import kucoinRest from '../kucoin.js';
|
|
2
|
-
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Balances } from '../base/types.js';
|
|
2
|
+
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Balances, Dict } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class kucoin extends kucoinRest {
|
|
5
5
|
describe(): any;
|
|
@@ -8,6 +8,7 @@ export default class kucoin extends kucoinRest {
|
|
|
8
8
|
requestId(): any;
|
|
9
9
|
subscribe(url: any, messageHash: any, subscriptionHash: any, params?: {}, subscription?: any): Promise<any>;
|
|
10
10
|
subscribeMultiple(url: any, messageHashes: any, topic: any, subscriptionHashes: any, params?: {}, subscription?: any): Promise<any>;
|
|
11
|
+
unSubscribeMultiple(url: any, messageHashes: any, topic: any, subscriptionHashes: any, params?: {}, subscription?: Dict): Promise<any>;
|
|
11
12
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
12
13
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
13
14
|
handleTicker(client: Client, message: any): void;
|
|
@@ -19,15 +20,20 @@ export default class kucoin extends kucoinRest {
|
|
|
19
20
|
handleOHLCV(client: Client, message: any): void;
|
|
20
21
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
21
22
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
23
|
+
unWatchTradesForSymbols(symbols: string[], params?: {}): Promise<any>;
|
|
24
|
+
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|
|
22
25
|
handleTrade(client: Client, message: any): void;
|
|
23
26
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
27
|
+
unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
|
|
24
28
|
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
29
|
+
unWatchOrderBookForSymbols(symbols: string[], params?: {}): Promise<any>;
|
|
25
30
|
handleOrderBook(client: Client, message: any): void;
|
|
26
31
|
getCacheIndex(orderbook: any, cache: any): any;
|
|
27
32
|
handleDelta(orderbook: any, delta: any): void;
|
|
28
33
|
handleBidAsks(bookSide: any, bidAsks: any): void;
|
|
29
34
|
handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
|
|
30
35
|
handleSubscriptionStatus(client: Client, message: any): void;
|
|
36
|
+
cleanCache(subscription: Dict): void;
|
|
31
37
|
handleSystemStatus(client: Client, message: any): any;
|
|
32
38
|
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
33
39
|
parseWsOrderStatus(status: any): string;
|