ccxt 4.3.85 → 4.3.87
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 +8 -5
- package/dist/ccxt.browser.min.js +15 -15
- package/dist/cjs/ccxt.js +7 -1
- package/dist/cjs/src/abstract/hashkey.js +9 -0
- package/dist/cjs/src/base/Exchange.js +1 -1
- package/dist/cjs/src/base/errors.js +8 -1
- package/dist/cjs/src/binance.js +4 -2
- package/dist/cjs/src/bingx.js +7 -1
- package/dist/cjs/src/bitfinex.js +2 -2
- package/dist/cjs/src/hashkey.js +4327 -0
- package/dist/cjs/src/hyperliquid.js +85 -65
- package/dist/cjs/src/indodax.js +37 -9
- package/dist/cjs/src/kraken.js +37 -6
- package/dist/cjs/src/krakenfutures.js +12 -10
- package/dist/cjs/src/pro/ascendex.js +45 -5
- package/dist/cjs/src/pro/bingx.js +13 -12
- package/dist/cjs/src/pro/bitget.js +164 -19
- package/dist/cjs/src/pro/hashkey.js +839 -0
- package/dist/cjs/src/pro/hyperliquid.js +123 -0
- package/dist/cjs/src/pro/mexc.js +13 -7
- package/dist/cjs/src/pro/p2b.js +34 -7
- package/dist/cjs/src/pro/poloniex.js +36 -3
- package/dist/cjs/src/pro/poloniexfutures.js +1 -0
- package/dist/cjs/src/pro/probit.js +2 -0
- package/dist/cjs/src/pro/upbit.js +48 -3
- package/dist/cjs/src/pro/vertex.js +1 -0
- package/dist/cjs/src/pro/wazirx.js +3 -0
- package/dist/cjs/src/pro/whitebit.js +9 -0
- package/dist/cjs/src/pro/woo.js +1 -0
- package/dist/cjs/src/pro/woofipro.js +1 -0
- package/dist/cjs/src/pro/xt.js +1 -0
- package/dist/cjs/src/upbit.js +1 -1
- package/js/ccxt.d.ts +9 -3
- package/js/ccxt.js +7 -3
- package/js/src/abstract/hashkey.d.ts +70 -0
- package/js/src/abstract/hashkey.js +11 -0
- package/js/src/base/Exchange.js +1 -1
- package/js/src/base/errorHierarchy.d.ts +1 -0
- package/js/src/base/errorHierarchy.js +1 -0
- package/js/src/base/errors.d.ts +5 -1
- package/js/src/base/errors.js +8 -2
- package/js/src/binance.js +4 -2
- package/js/src/bingx.js +7 -1
- package/js/src/bitfinex.js +2 -2
- package/js/src/hashkey.d.ts +178 -0
- package/js/src/hashkey.js +4328 -0
- package/js/src/hyperliquid.d.ts +3 -0
- package/js/src/hyperliquid.js +85 -65
- package/js/src/indodax.js +37 -9
- package/js/src/kraken.js +37 -6
- package/js/src/krakenfutures.js +12 -10
- package/js/src/pro/ascendex.d.ts +2 -0
- package/js/src/pro/ascendex.js +45 -5
- package/js/src/pro/bingx.js +13 -12
- package/js/src/pro/bitget.d.ts +8 -0
- package/js/src/pro/bitget.js +165 -20
- package/js/src/pro/hashkey.d.ts +34 -0
- package/js/src/pro/hashkey.js +840 -0
- package/js/src/pro/hyperliquid.d.ts +7 -1
- package/js/src/pro/hyperliquid.js +123 -0
- package/js/src/pro/mexc.js +13 -7
- package/js/src/pro/p2b.d.ts +1 -0
- package/js/src/pro/p2b.js +34 -7
- package/js/src/pro/poloniex.d.ts +1 -0
- package/js/src/pro/poloniex.js +36 -3
- package/js/src/pro/poloniexfutures.js +1 -0
- package/js/src/pro/probit.js +2 -0
- package/js/src/pro/upbit.d.ts +1 -0
- package/js/src/pro/upbit.js +48 -3
- package/js/src/pro/vertex.js +1 -0
- package/js/src/pro/wazirx.js +3 -0
- package/js/src/pro/whitebit.js +9 -0
- package/js/src/pro/woo.js +1 -0
- package/js/src/pro/woofipro.js +1 -0
- package/js/src/pro/xt.js +1 -0
- package/js/src/upbit.js +1 -1
- package/package.json +1 -1
package/js/src/pro/bitget.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import bitgetRest from '../bitget.js';
|
|
9
|
-
import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, RateLimitExceeded } from '../base/errors.js';
|
|
9
|
+
import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, RateLimitExceeded, UnsubscribeError } from '../base/errors.js';
|
|
10
10
|
import { Precise } from '../base/Precise.js';
|
|
11
11
|
import { ArrayCache, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
|
|
12
12
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
@@ -134,6 +134,19 @@ export default class bitget extends bitgetRest {
|
|
|
134
134
|
};
|
|
135
135
|
return await this.watchPublic(messageHash, args, params);
|
|
136
136
|
}
|
|
137
|
+
async unWatchTicker(symbol, params = {}) {
|
|
138
|
+
/**
|
|
139
|
+
* @method
|
|
140
|
+
* @name bitget#unWatchTicker
|
|
141
|
+
* @description unsubscribe from the ticker channel
|
|
142
|
+
* @see https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
|
|
143
|
+
* @see https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
|
|
144
|
+
* @param {string} symbol unified symbol of the market to unwatch the ticker for
|
|
145
|
+
* @returns {any} status of the unwatch request
|
|
146
|
+
*/
|
|
147
|
+
await this.loadMarkets();
|
|
148
|
+
return await this.unWatchChannel(symbol, 'ticker', 'ticker', params);
|
|
149
|
+
}
|
|
137
150
|
async watchTickers(symbols = undefined, params = {}) {
|
|
138
151
|
/**
|
|
139
152
|
* @method
|
|
@@ -346,6 +359,22 @@ export default class bitget extends bitgetRest {
|
|
|
346
359
|
}
|
|
347
360
|
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
|
|
348
361
|
}
|
|
362
|
+
async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
|
|
363
|
+
/**
|
|
364
|
+
* @method
|
|
365
|
+
* @name bitget#unWatchOHLCV
|
|
366
|
+
* @description unsubscribe from the ohlcv channel
|
|
367
|
+
* @see https://www.bitget.com/api-doc/spot/websocket/public/Candlesticks-Channel
|
|
368
|
+
* @see https://www.bitget.com/api-doc/contract/websocket/public/Candlesticks-Channel
|
|
369
|
+
* @param {string} symbol unified symbol of the market to unwatch the ohlcv for
|
|
370
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
371
|
+
*/
|
|
372
|
+
await this.loadMarkets();
|
|
373
|
+
const timeframes = this.safeDict(this.options, 'timeframes');
|
|
374
|
+
const interval = this.safeString(timeframes, timeframe);
|
|
375
|
+
const channel = 'candle' + interval;
|
|
376
|
+
return await this.unWatchChannel(symbol, channel, 'candles:' + timeframe, params);
|
|
377
|
+
}
|
|
349
378
|
handleOHLCV(client, message) {
|
|
350
379
|
//
|
|
351
380
|
// {
|
|
@@ -454,14 +483,18 @@ export default class bitget extends bitgetRest {
|
|
|
454
483
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
455
484
|
*/
|
|
456
485
|
await this.loadMarkets();
|
|
457
|
-
const market = this.market(symbol);
|
|
458
|
-
const messageHash = 'unsubscribe:orderbook:' + market['symbol'];
|
|
459
486
|
let channel = 'books';
|
|
460
487
|
const limit = this.safeInteger(params, 'limit');
|
|
461
488
|
if ((limit === 1) || (limit === 5) || (limit === 15)) {
|
|
462
489
|
params = this.omit(params, 'limit');
|
|
463
490
|
channel += limit.toString();
|
|
464
491
|
}
|
|
492
|
+
return await this.unWatchChannel(symbol, channel, 'orderbook', params);
|
|
493
|
+
}
|
|
494
|
+
async unWatchChannel(symbol, channel, messageHashTopic, params = {}) {
|
|
495
|
+
await this.loadMarkets();
|
|
496
|
+
const market = this.market(symbol);
|
|
497
|
+
const messageHash = 'unsubscribe:' + messageHashTopic + ':' + market['symbol'];
|
|
465
498
|
let instType = undefined;
|
|
466
499
|
[instType, params] = this.getInstType(market, params);
|
|
467
500
|
const args = {
|
|
@@ -685,6 +718,19 @@ export default class bitget extends bitgetRest {
|
|
|
685
718
|
}
|
|
686
719
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
687
720
|
}
|
|
721
|
+
async unWatchTrades(symbol, params = {}) {
|
|
722
|
+
/**
|
|
723
|
+
* @method
|
|
724
|
+
* @name bitget#unWatchTrades
|
|
725
|
+
* @description unsubscribe from the trades channel
|
|
726
|
+
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
727
|
+
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
728
|
+
* @param {string} symbol unified symbol of the market to unwatch the trades for
|
|
729
|
+
* @returns {any} status of the unwatch request
|
|
730
|
+
*/
|
|
731
|
+
await this.loadMarkets();
|
|
732
|
+
return await this.unWatchChannel(symbol, 'trade', 'trade', params);
|
|
733
|
+
}
|
|
688
734
|
handleTrades(client, message) {
|
|
689
735
|
//
|
|
690
736
|
// {
|
|
@@ -1871,6 +1917,112 @@ export default class bitget extends bitgetRest {
|
|
|
1871
1917
|
//
|
|
1872
1918
|
return message;
|
|
1873
1919
|
}
|
|
1920
|
+
handleOrderBookUnSubscription(client, message) {
|
|
1921
|
+
//
|
|
1922
|
+
// {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"books","instId":"BTCUSDT"}}
|
|
1923
|
+
//
|
|
1924
|
+
const arg = this.safeDict(message, 'arg', {});
|
|
1925
|
+
const instType = this.safeStringLower(arg, 'instType');
|
|
1926
|
+
const type = (instType === 'spot') ? 'spot' : 'contract';
|
|
1927
|
+
const instId = this.safeString(arg, 'instId');
|
|
1928
|
+
const market = this.safeMarket(instId, undefined, undefined, type);
|
|
1929
|
+
const symbol = market['symbol'];
|
|
1930
|
+
const messageHash = 'unsubscribe:orderbook:' + market['symbol'];
|
|
1931
|
+
const subMessageHash = 'orderbook:' + symbol;
|
|
1932
|
+
if (symbol in this.orderbooks) {
|
|
1933
|
+
delete this.orderbooks[symbol];
|
|
1934
|
+
}
|
|
1935
|
+
if (subMessageHash in client.subscriptions) {
|
|
1936
|
+
delete client.subscriptions[subMessageHash];
|
|
1937
|
+
}
|
|
1938
|
+
if (messageHash in client.subscriptions) {
|
|
1939
|
+
delete client.subscriptions[messageHash];
|
|
1940
|
+
}
|
|
1941
|
+
const error = new UnsubscribeError(this.id + 'orderbook ' + symbol);
|
|
1942
|
+
client.reject(error, subMessageHash);
|
|
1943
|
+
client.resolve(true, messageHash);
|
|
1944
|
+
}
|
|
1945
|
+
handleTradesUnSubscription(client, message) {
|
|
1946
|
+
//
|
|
1947
|
+
// {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"trade","instId":"BTCUSDT"}}
|
|
1948
|
+
//
|
|
1949
|
+
const arg = this.safeDict(message, 'arg', {});
|
|
1950
|
+
const instType = this.safeStringLower(arg, 'instType');
|
|
1951
|
+
const type = (instType === 'spot') ? 'spot' : 'contract';
|
|
1952
|
+
const instId = this.safeString(arg, 'instId');
|
|
1953
|
+
const market = this.safeMarket(instId, undefined, undefined, type);
|
|
1954
|
+
const symbol = market['symbol'];
|
|
1955
|
+
const messageHash = 'unsubscribe:trade:' + market['symbol'];
|
|
1956
|
+
const subMessageHash = 'trade:' + symbol;
|
|
1957
|
+
if (symbol in this.trades) {
|
|
1958
|
+
delete this.trades[symbol];
|
|
1959
|
+
}
|
|
1960
|
+
if (subMessageHash in client.subscriptions) {
|
|
1961
|
+
delete client.subscriptions[subMessageHash];
|
|
1962
|
+
}
|
|
1963
|
+
if (messageHash in client.subscriptions) {
|
|
1964
|
+
delete client.subscriptions[messageHash];
|
|
1965
|
+
}
|
|
1966
|
+
const error = new UnsubscribeError(this.id + 'trades ' + symbol);
|
|
1967
|
+
client.reject(error, subMessageHash);
|
|
1968
|
+
client.resolve(true, messageHash);
|
|
1969
|
+
}
|
|
1970
|
+
handleTickerUnSubscription(client, message) {
|
|
1971
|
+
//
|
|
1972
|
+
// {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"trade","instId":"BTCUSDT"}}
|
|
1973
|
+
//
|
|
1974
|
+
const arg = this.safeDict(message, 'arg', {});
|
|
1975
|
+
const instType = this.safeStringLower(arg, 'instType');
|
|
1976
|
+
const type = (instType === 'spot') ? 'spot' : 'contract';
|
|
1977
|
+
const instId = this.safeString(arg, 'instId');
|
|
1978
|
+
const market = this.safeMarket(instId, undefined, undefined, type);
|
|
1979
|
+
const symbol = market['symbol'];
|
|
1980
|
+
const messageHash = 'unsubscribe:ticker:' + market['symbol'];
|
|
1981
|
+
const subMessageHash = 'ticker:' + symbol;
|
|
1982
|
+
if (symbol in this.tickers) {
|
|
1983
|
+
delete this.tickers[symbol];
|
|
1984
|
+
}
|
|
1985
|
+
if (subMessageHash in client.subscriptions) {
|
|
1986
|
+
delete client.subscriptions[subMessageHash];
|
|
1987
|
+
}
|
|
1988
|
+
if (messageHash in client.subscriptions) {
|
|
1989
|
+
delete client.subscriptions[messageHash];
|
|
1990
|
+
}
|
|
1991
|
+
const error = new UnsubscribeError(this.id + 'ticker ' + symbol);
|
|
1992
|
+
client.reject(error, subMessageHash);
|
|
1993
|
+
client.resolve(true, messageHash);
|
|
1994
|
+
}
|
|
1995
|
+
handleOHLCVUnSubscription(client, message) {
|
|
1996
|
+
//
|
|
1997
|
+
// {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"candle1m","instId":"BTCUSDT"}}
|
|
1998
|
+
//
|
|
1999
|
+
const arg = this.safeDict(message, 'arg', {});
|
|
2000
|
+
const instType = this.safeStringLower(arg, 'instType');
|
|
2001
|
+
const type = (instType === 'spot') ? 'spot' : 'contract';
|
|
2002
|
+
const instId = this.safeString(arg, 'instId');
|
|
2003
|
+
const channel = this.safeString(arg, 'channel');
|
|
2004
|
+
const interval = channel.replace('candle', '');
|
|
2005
|
+
const timeframes = this.safeValue(this.options, 'timeframes');
|
|
2006
|
+
const timeframe = this.findTimeframe(interval, timeframes);
|
|
2007
|
+
const market = this.safeMarket(instId, undefined, undefined, type);
|
|
2008
|
+
const symbol = market['symbol'];
|
|
2009
|
+
const messageHash = 'unsubscribe:candles:' + timeframe + ':' + market['symbol'];
|
|
2010
|
+
const subMessageHash = 'candles:' + timeframe + ':' + symbol;
|
|
2011
|
+
if (symbol in this.ohlcvs) {
|
|
2012
|
+
if (timeframe in this.ohlcvs[symbol]) {
|
|
2013
|
+
delete this.ohlcvs[symbol][timeframe];
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
if (subMessageHash in client.subscriptions) {
|
|
2017
|
+
delete client.subscriptions[subMessageHash];
|
|
2018
|
+
}
|
|
2019
|
+
if (messageHash in client.subscriptions) {
|
|
2020
|
+
delete client.subscriptions[messageHash];
|
|
2021
|
+
}
|
|
2022
|
+
const error = new UnsubscribeError(this.id + ' ohlcv ' + timeframe + ' ' + symbol);
|
|
2023
|
+
client.reject(error, subMessageHash);
|
|
2024
|
+
client.resolve(true, messageHash);
|
|
2025
|
+
}
|
|
1874
2026
|
handleUnSubscriptionStatus(client, message) {
|
|
1875
2027
|
//
|
|
1876
2028
|
// {
|
|
@@ -1900,23 +2052,16 @@ export default class bitget extends bitgetRest {
|
|
|
1900
2052
|
const channel = this.safeString(arg, 'channel');
|
|
1901
2053
|
if (channel === 'books') {
|
|
1902
2054
|
// for now only unWatchOrderBook is supporteod
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
if (subMessageHash in client.subscriptions) {
|
|
1914
|
-
delete client.subscriptions[subMessageHash];
|
|
1915
|
-
}
|
|
1916
|
-
if (messageHash in client.subscriptions) {
|
|
1917
|
-
delete client.subscriptions[messageHash];
|
|
1918
|
-
}
|
|
1919
|
-
client.resolve(true, messageHash);
|
|
2055
|
+
this.handleOrderBookUnSubscription(client, message);
|
|
2056
|
+
}
|
|
2057
|
+
else if (channel === 'trade') {
|
|
2058
|
+
this.handleTradesUnSubscription(client, message);
|
|
2059
|
+
}
|
|
2060
|
+
else if (channel === 'ticker') {
|
|
2061
|
+
this.handleTickerUnSubscription(client, message);
|
|
2062
|
+
}
|
|
2063
|
+
else if (channel.startsWith('candle')) {
|
|
2064
|
+
this.handleOHLCVUnSubscription(client, message);
|
|
1920
2065
|
}
|
|
1921
2066
|
}
|
|
1922
2067
|
return message;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import hashkeyRest from '../hashkey.js';
|
|
2
|
+
import type { Balances, Dict, Int, Market, OHLCV, Order, OrderBook, Position, Str, Strings, Ticker, Trade } from '../base/types.js';
|
|
3
|
+
import Client from '../base/ws/Client.js';
|
|
4
|
+
export default class hashkey extends hashkeyRest {
|
|
5
|
+
describe(): any;
|
|
6
|
+
wathPublic(market: Market, topic: string, messageHash: string, params?: {}): Promise<any>;
|
|
7
|
+
watchPrivate(messageHash: any): Promise<any>;
|
|
8
|
+
getPrivateUrl(listenKey: any): string;
|
|
9
|
+
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
10
|
+
handleOHLCV(client: Client, message: any): void;
|
|
11
|
+
parseWsOHLCV(ohlcv: any, market?: Market): OHLCV;
|
|
12
|
+
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
13
|
+
handleTicker(client: Client, message: any): void;
|
|
14
|
+
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
15
|
+
handleTrades(client: Client, message: any): void;
|
|
16
|
+
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
17
|
+
handleOrderBook(client: Client, message: any): void;
|
|
18
|
+
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
19
|
+
handleOrder(client: Client, message: any): void;
|
|
20
|
+
parseWsOrder(order: Dict, market?: Market): Order;
|
|
21
|
+
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
22
|
+
handleMyTrade(client: Client, message: any, subscription?: {}): void;
|
|
23
|
+
parseWsTrade(trade: any, market?: any): Trade;
|
|
24
|
+
watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
|
|
25
|
+
handlePosition(client: Client, message: any): void;
|
|
26
|
+
parseWsPosition(position: any, market?: Market): Position;
|
|
27
|
+
watchBalance(params?: {}): Promise<Balances>;
|
|
28
|
+
setBalanceCache(client: Client, type: any, subscribeHash: any): void;
|
|
29
|
+
loadBalanceSnapshot(client: any, messageHash: any, type: any): Promise<void>;
|
|
30
|
+
handleBalance(client: Client, message: any): void;
|
|
31
|
+
authenticate(params?: {}): Promise<string>;
|
|
32
|
+
keepAliveListenKey(listenKey: any, params?: {}): Promise<void>;
|
|
33
|
+
handleMessage(client: Client, message: any): void;
|
|
34
|
+
}
|