ccxt 4.5.1 → 4.5.3
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 +110 -112
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -9
- package/dist/cjs/src/ascendex.js +1 -1
- package/dist/cjs/src/base/Exchange.js +11 -0
- package/dist/cjs/src/binance.js +25 -25
- package/dist/cjs/src/bitget.js +2 -2
- package/dist/cjs/src/coincatch.js +2 -2
- package/dist/cjs/src/gate.js +27 -12
- package/dist/cjs/src/gemini.js +3 -3
- package/dist/cjs/src/htx.js +4 -4
- package/dist/cjs/src/indodax.js +11 -12
- package/dist/cjs/src/kucoinfutures.js +8 -8
- package/dist/cjs/src/mexc.js +30 -1
- package/dist/cjs/src/okx.js +19 -5
- package/dist/cjs/src/poloniex.js +1 -1
- package/dist/cjs/src/pro/binance.js +3 -3
- package/dist/cjs/src/pro/bitfinex.js +140 -0
- package/dist/cjs/src/pro/bitget.js +222 -42
- package/dist/cjs/src/pro/bitmart.js +1 -1
- package/dist/cjs/src/pro/bybit.js +3 -3
- package/dist/cjs/src/pro/gemini.js +7 -2
- package/dist/cjs/src/pro/hyperliquid.js +5 -0
- package/dist/cjs/src/pro/kraken.js +4 -6
- package/dist/cjs/src/pro/kucoin.js +64 -0
- package/dist/cjs/src/pro/mexc.js +7 -3
- package/dist/cjs/src/zonda.js +12 -0
- package/js/ccxt.d.ts +2 -11
- package/js/ccxt.js +2 -8
- package/js/src/ascendex.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +11 -0
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +25 -25
- package/js/src/bitget.js +2 -2
- package/js/src/coincatch.js +2 -2
- package/js/src/gate.js +27 -12
- package/js/src/gemini.js +3 -3
- package/js/src/htx.js +4 -4
- package/js/src/indodax.js +11 -12
- package/js/src/kucoinfutures.js +8 -8
- package/js/src/mexc.d.ts +3 -0
- package/js/src/mexc.js +30 -1
- package/js/src/okx.d.ts +4 -2
- package/js/src/okx.js +19 -5
- package/js/src/poloniex.js +1 -1
- package/js/src/pro/binance.js +3 -3
- package/js/src/pro/bitfinex.d.ts +30 -0
- package/js/src/pro/bitfinex.js +140 -0
- package/js/src/pro/bitget.d.ts +10 -0
- package/js/src/pro/bitget.js +228 -42
- package/js/src/pro/bitmart.js +1 -1
- package/js/src/pro/bybit.d.ts +2 -2
- package/js/src/pro/bybit.js +3 -3
- package/js/src/pro/gemini.d.ts +1 -1
- package/js/src/pro/gemini.js +7 -2
- package/js/src/pro/hyperliquid.js +5 -0
- package/js/src/pro/kraken.js +4 -6
- package/js/src/pro/kucoin.d.ts +22 -0
- package/js/src/pro/kucoin.js +64 -0
- package/js/src/pro/mexc.js +7 -3
- package/js/src/zonda.js +12 -0
- package/package.json +2 -1
- package/js/src/abstract/ellipx.d.ts +0 -28
- package/js/src/abstract/ellipx.js +0 -11
- package/js/src/abstract/vertex.d.ts +0 -22
- package/js/src/abstract/vertex.js +0 -11
- package/js/src/ellipx.d.ts +0 -237
- package/js/src/ellipx.js +0 -2071
- package/js/src/pro/vertex.d.ts +0 -104
- package/js/src/pro/vertex.js +0 -999
- package/js/src/vertex.d.ts +0 -346
- package/js/src/vertex.js +0 -3146
package/js/src/pro/bitfinex.js
CHANGED
|
@@ -25,6 +25,10 @@ export default class bitfinex extends bitfinexRest {
|
|
|
25
25
|
'watchBalance': true,
|
|
26
26
|
'watchOHLCV': true,
|
|
27
27
|
'watchOrders': true,
|
|
28
|
+
'unWatchTicker': true,
|
|
29
|
+
'unWatchTrades': true,
|
|
30
|
+
'unWatchOHLCV': true,
|
|
31
|
+
'unWatchOrderBook': true,
|
|
28
32
|
},
|
|
29
33
|
'urls': {
|
|
30
34
|
'api': {
|
|
@@ -67,6 +71,31 @@ export default class bitfinex extends bitfinexRest {
|
|
|
67
71
|
}
|
|
68
72
|
return result;
|
|
69
73
|
}
|
|
74
|
+
async unSubscribe(channel, topic, symbol, params = {}) {
|
|
75
|
+
await this.loadMarkets();
|
|
76
|
+
const market = this.market(symbol);
|
|
77
|
+
const marketId = market['id'];
|
|
78
|
+
const url = this.urls['api']['ws']['public'];
|
|
79
|
+
const client = this.client(url);
|
|
80
|
+
const subMessageHash = channel + ':' + marketId;
|
|
81
|
+
const messageHash = 'unsubscribe:' + channel + ':' + marketId;
|
|
82
|
+
const unSubTopic = 'unsubscribe' + ':' + topic + ':' + symbol;
|
|
83
|
+
const channelId = this.safeString(client.subscriptions, unSubTopic);
|
|
84
|
+
const request = {
|
|
85
|
+
'event': 'unsubscribe',
|
|
86
|
+
'chanId': channelId,
|
|
87
|
+
};
|
|
88
|
+
const unSubChanMsg = 'unsubscribe:' + channelId;
|
|
89
|
+
client.subscriptions[unSubChanMsg] = subMessageHash;
|
|
90
|
+
const subscription = {
|
|
91
|
+
'messageHashes': [messageHash],
|
|
92
|
+
'subMessageHashes': [subMessageHash],
|
|
93
|
+
'topic': topic,
|
|
94
|
+
'unsubscribe': true,
|
|
95
|
+
'symbols': [symbol],
|
|
96
|
+
};
|
|
97
|
+
return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash, subscription);
|
|
98
|
+
}
|
|
70
99
|
async subscribePrivate(messageHash) {
|
|
71
100
|
await this.loadMarkets();
|
|
72
101
|
await this.authenticate();
|
|
@@ -105,6 +134,42 @@ export default class bitfinex extends bitfinexRest {
|
|
|
105
134
|
}
|
|
106
135
|
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
|
|
107
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* @method
|
|
139
|
+
* @name bitfinex#unWatchOHLCV
|
|
140
|
+
* @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
141
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
142
|
+
* @param {string} timeframe the length of time each candle represents
|
|
143
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
144
|
+
* @returns {bool} true if successfully unsubscribed, false otherwise
|
|
145
|
+
*/
|
|
146
|
+
async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
|
|
147
|
+
await this.loadMarkets();
|
|
148
|
+
const market = this.market(symbol);
|
|
149
|
+
symbol = market['symbol'];
|
|
150
|
+
const interval = this.safeString(this.timeframes, timeframe, timeframe);
|
|
151
|
+
const channel = 'candles';
|
|
152
|
+
const subMessageHash = channel + ':' + interval + ':' + market['id'];
|
|
153
|
+
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
154
|
+
const url = this.urls['api']['ws']['public'];
|
|
155
|
+
const client = this.client(url);
|
|
156
|
+
const subId = 'unsubscribe:trade:' + interval + ':' + market['id']; // trade here because we use the key
|
|
157
|
+
const channelId = this.safeString(client.subscriptions, subId);
|
|
158
|
+
const request = {
|
|
159
|
+
'event': 'unsubscribe',
|
|
160
|
+
'chanId': channelId,
|
|
161
|
+
};
|
|
162
|
+
const unSubChanMsg = 'unsubscribe:' + channelId;
|
|
163
|
+
client.subscriptions[unSubChanMsg] = subMessageHash;
|
|
164
|
+
const subscription = {
|
|
165
|
+
'messageHashes': [messageHash],
|
|
166
|
+
'subMessageHashes': [subMessageHash],
|
|
167
|
+
'topic': 'ohlcv',
|
|
168
|
+
'unsubscribe': true,
|
|
169
|
+
'symbols': [symbol],
|
|
170
|
+
};
|
|
171
|
+
return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash, subscription);
|
|
172
|
+
}
|
|
108
173
|
handleOHLCV(client, message, subscription) {
|
|
109
174
|
//
|
|
110
175
|
// initial snapshot
|
|
@@ -205,6 +270,17 @@ export default class bitfinex extends bitfinexRest {
|
|
|
205
270
|
}
|
|
206
271
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
207
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* @method
|
|
275
|
+
* @name bitfinex#unWatchTrades
|
|
276
|
+
* @description unWatches the list of most recent trades for a particular symbol
|
|
277
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
278
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
279
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
280
|
+
*/
|
|
281
|
+
async unWatchTrades(symbol, params = {}) {
|
|
282
|
+
return await this.unSubscribe('trades', 'trades', symbol, params);
|
|
283
|
+
}
|
|
208
284
|
/**
|
|
209
285
|
* @method
|
|
210
286
|
* @name bitfinex#watchMyTrades
|
|
@@ -239,6 +315,17 @@ export default class bitfinex extends bitfinexRest {
|
|
|
239
315
|
async watchTicker(symbol, params = {}) {
|
|
240
316
|
return await this.subscribe('ticker', symbol, params);
|
|
241
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* @method
|
|
320
|
+
* @name bitfinex#unWatchTicker
|
|
321
|
+
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
322
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
323
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
324
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
325
|
+
*/
|
|
326
|
+
async unWatchTicker(symbol, params = {}) {
|
|
327
|
+
return await this.unSubscribe('ticker', 'ticker', symbol, params);
|
|
328
|
+
}
|
|
242
329
|
handleMyTrade(client, message, subscription = {}) {
|
|
243
330
|
//
|
|
244
331
|
// trade execution
|
|
@@ -832,6 +919,29 @@ export default class bitfinex extends bitfinexRest {
|
|
|
832
919
|
//
|
|
833
920
|
return message;
|
|
834
921
|
}
|
|
922
|
+
handleUnsubscriptionStatus(client, message) {
|
|
923
|
+
//
|
|
924
|
+
// {
|
|
925
|
+
// "event": "unsubscribed",
|
|
926
|
+
// "status": "OK",
|
|
927
|
+
// "chanId": CHANNEL_ID
|
|
928
|
+
// }
|
|
929
|
+
//
|
|
930
|
+
const channelId = this.safeString(message, 'chanId');
|
|
931
|
+
const unSubChannel = 'unsubscribe:' + channelId;
|
|
932
|
+
const subMessageHash = this.safeString(client.subscriptions, unSubChannel);
|
|
933
|
+
const subscription = this.safeDict(client.subscriptions, 'unsubscribe:' + subMessageHash);
|
|
934
|
+
delete client.subscriptions[unSubChannel];
|
|
935
|
+
const messageHashes = this.safeList(subscription, 'messageHashes', []);
|
|
936
|
+
const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
|
|
937
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
938
|
+
const messageHash = messageHashes[i];
|
|
939
|
+
const subHash = subMessageHashes[i];
|
|
940
|
+
this.cleanUnsubscription(client, subHash, messageHash);
|
|
941
|
+
}
|
|
942
|
+
this.cleanCache(subscription);
|
|
943
|
+
return true;
|
|
944
|
+
}
|
|
835
945
|
handleSubscriptionStatus(client, message) {
|
|
836
946
|
//
|
|
837
947
|
// {
|
|
@@ -845,8 +955,37 @@ export default class bitfinex extends bitfinexRest {
|
|
|
845
955
|
// "pair": "BTCUSD"
|
|
846
956
|
// }
|
|
847
957
|
//
|
|
958
|
+
// {
|
|
959
|
+
// event: 'subscribed',
|
|
960
|
+
// channel: 'candles',
|
|
961
|
+
// chanId: 128306,
|
|
962
|
+
// key: 'trade:1m:tBTCUST'
|
|
963
|
+
// }
|
|
964
|
+
//
|
|
848
965
|
const channelId = this.safeString(message, 'chanId');
|
|
849
966
|
client.subscriptions[channelId] = message;
|
|
967
|
+
// store the opposite direction too for unWatch
|
|
968
|
+
const mappings = {
|
|
969
|
+
'book': 'orderbook',
|
|
970
|
+
'candles': 'ohlcv',
|
|
971
|
+
'ticker': 'ticker',
|
|
972
|
+
'trades': 'trades',
|
|
973
|
+
};
|
|
974
|
+
const unifiedChannel = this.safeString(mappings, this.safeString(message, 'channel'));
|
|
975
|
+
if ('key' in message) {
|
|
976
|
+
// handle ohlcv differently because the message is different
|
|
977
|
+
const key = this.safeString(message, 'key');
|
|
978
|
+
const subKeyId = 'unsubscribe:' + key;
|
|
979
|
+
client.subscriptions[subKeyId] = channelId;
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
const marketId = this.safeString(message, 'symbol');
|
|
983
|
+
const symbol = this.safeSymbol(marketId);
|
|
984
|
+
if (unifiedChannel !== undefined) {
|
|
985
|
+
const subId = 'unsubscribe:' + unifiedChannel + ':' + symbol;
|
|
986
|
+
client.subscriptions[subId] = channelId;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
850
989
|
return message;
|
|
851
990
|
}
|
|
852
991
|
async authenticate(params = {}) {
|
|
@@ -1153,6 +1292,7 @@ export default class bitfinex extends bitfinexRest {
|
|
|
1153
1292
|
const methods = {
|
|
1154
1293
|
'info': this.handleSystemStatus,
|
|
1155
1294
|
'subscribed': this.handleSubscriptionStatus,
|
|
1295
|
+
'unsubscribed': this.handleUnsubscriptionStatus,
|
|
1156
1296
|
'auth': this.handleAuthenticationMessage,
|
|
1157
1297
|
};
|
|
1158
1298
|
const method = this.safeValue(methods, event);
|
package/js/src/pro/bitget.d.ts
CHANGED
|
@@ -69,11 +69,13 @@ export default class bitget extends bitgetRest {
|
|
|
69
69
|
* @description watches historical candlestick data containing the open, high, low, close price, and the volume of a market
|
|
70
70
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Candlesticks-Channel
|
|
71
71
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/Candlesticks-Channel
|
|
72
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/Candlesticks-Channel
|
|
72
73
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
73
74
|
* @param {string} timeframe the length of time each candle represents
|
|
74
75
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
75
76
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
76
77
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
78
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
77
79
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
78
80
|
*/
|
|
79
81
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
@@ -83,9 +85,11 @@ export default class bitget extends bitgetRest {
|
|
|
83
85
|
* @description unsubscribe from the ohlcv channel
|
|
84
86
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Candlesticks-Channel
|
|
85
87
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/Candlesticks-Channel
|
|
88
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/Candlesticks-Channel
|
|
86
89
|
* @param {string} symbol unified symbol of the market to unwatch the ohlcv for
|
|
87
90
|
* @param {string} [timeframe] the period for the ratio, default is 1 minute
|
|
88
91
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
92
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
89
93
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
90
94
|
*/
|
|
91
95
|
unWatchOHLCV(symbol: string, timeframe?: string, params?: {}): Promise<any>;
|
|
@@ -138,10 +142,12 @@ export default class bitget extends bitgetRest {
|
|
|
138
142
|
* @description get the list of most recent trades for a particular symbol
|
|
139
143
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
140
144
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
145
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
141
146
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
142
147
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
143
148
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
144
149
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
150
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
145
151
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
146
152
|
*/
|
|
147
153
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
@@ -151,10 +157,12 @@ export default class bitget extends bitgetRest {
|
|
|
151
157
|
* @description get the list of most recent trades for a particular symbol
|
|
152
158
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
153
159
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
160
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
154
161
|
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
155
162
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
156
163
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
157
164
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
165
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
158
166
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
159
167
|
*/
|
|
160
168
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
@@ -164,8 +172,10 @@ export default class bitget extends bitgetRest {
|
|
|
164
172
|
* @description unsubscribe from the trades channel
|
|
165
173
|
* @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
|
|
166
174
|
* @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
|
|
175
|
+
* @see https://www.bitget.com/api-doc/uta/websocket/public/New-Trades-Channel
|
|
167
176
|
* @param {string} symbol unified symbol of the market to unwatch the trades for
|
|
168
177
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
178
|
+
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
|
|
169
179
|
* @returns {any} status of the unwatch request
|
|
170
180
|
*/
|
|
171
181
|
unWatchTrades(symbol: string, params?: {}): Promise<any>;
|