ccxt 4.2.8 → 4.2.10
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/build.sh +18 -2
- package/dist/ccxt.browser.js +387 -149
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +37 -8
- package/dist/cjs/src/binance.js +6 -1
- package/dist/cjs/src/bitmart.js +94 -15
- package/dist/cjs/src/bl3p.js +1 -1
- package/dist/cjs/src/btcalpha.js +1 -1
- package/dist/cjs/src/cryptocom.js +3 -1
- package/dist/cjs/src/deribit.js +39 -22
- package/dist/cjs/src/kraken.js +1 -1
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/lykke.js +1 -1
- package/dist/cjs/src/ndax.js +1 -1
- package/dist/cjs/src/pro/binance.js +17 -1
- package/dist/cjs/src/pro/bitget.js +3 -1
- package/dist/cjs/src/pro/bitmart.js +52 -15
- package/dist/cjs/src/pro/blockchaincom.js +2 -28
- package/dist/cjs/src/pro/bybit.js +3 -1
- package/dist/cjs/src/pro/coinbasepro.js +9 -16
- package/dist/cjs/src/pro/cryptocom.js +110 -28
- package/dist/cjs/src/pro/luno.js +5 -5
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +4 -3
- package/js/src/base/Exchange.js +37 -8
- package/js/src/binance.js +6 -1
- package/js/src/bitmart.js +95 -16
- package/js/src/bl3p.d.ts +2 -2
- package/js/src/bl3p.js +1 -1
- package/js/src/btcalpha.d.ts +2 -2
- package/js/src/btcalpha.js +1 -1
- package/js/src/cryptocom.js +3 -1
- package/js/src/deribit.js +39 -22
- package/js/src/kraken.d.ts +2 -2
- package/js/src/kraken.js +1 -1
- package/js/src/kucoin.js +1 -1
- package/js/src/lykke.d.ts +2 -2
- package/js/src/lykke.js +1 -1
- package/js/src/ndax.d.ts +2 -2
- package/js/src/ndax.js +1 -1
- package/js/src/pro/binance.js +17 -1
- package/js/src/pro/bitget.js +3 -1
- package/js/src/pro/bitmart.d.ts +1 -0
- package/js/src/pro/bitmart.js +52 -15
- package/js/src/pro/blockchaincom.d.ts +1 -11
- package/js/src/pro/blockchaincom.js +2 -28
- package/js/src/pro/bybit.js +3 -1
- package/js/src/pro/coinbasepro.js +9 -16
- package/js/src/pro/cryptocom.d.ts +3 -1
- package/js/src/pro/cryptocom.js +111 -29
- package/js/src/pro/luno.d.ts +4 -4
- package/js/src/pro/luno.js +5 -5
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/package.json +1 -1
|
@@ -695,7 +695,7 @@ class blockchaincom extends blockchaincom$1 {
|
|
|
695
695
|
return message;
|
|
696
696
|
}
|
|
697
697
|
else if (event === 'snapshot') {
|
|
698
|
-
const snapshot = this.
|
|
698
|
+
const snapshot = this.parseOrderBook(message, symbol, timestamp, 'bids', 'asks', 'px', 'qty', 'num');
|
|
699
699
|
storedOrderBook.reset(snapshot);
|
|
700
700
|
}
|
|
701
701
|
else if (event === 'updated') {
|
|
@@ -711,34 +711,8 @@ class blockchaincom extends blockchaincom$1 {
|
|
|
711
711
|
}
|
|
712
712
|
client.resolve(storedOrderBook, messageHash);
|
|
713
713
|
}
|
|
714
|
-
parseCountedBidAsk(bidAsk, priceKey = 0, amountKey = 1, countKey = 2) {
|
|
715
|
-
const price = this.safeNumber(bidAsk, priceKey);
|
|
716
|
-
const amount = this.safeNumber(bidAsk, amountKey);
|
|
717
|
-
const count = this.safeNumber(bidAsk, countKey);
|
|
718
|
-
return [price, amount, count];
|
|
719
|
-
}
|
|
720
|
-
parseCountedBidsAsks(bidasks, priceKey = 0, amountKey = 1, countKey = 2) {
|
|
721
|
-
bidasks = this.toArray(bidasks);
|
|
722
|
-
const result = [];
|
|
723
|
-
for (let i = 0; i < bidasks.length; i++) {
|
|
724
|
-
result.push(this.parseCountedBidAsk(bidasks[i], priceKey, amountKey, countKey));
|
|
725
|
-
}
|
|
726
|
-
return result;
|
|
727
|
-
}
|
|
728
|
-
parseCountedOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, countKey = 2) {
|
|
729
|
-
const bids = this.parseCountedBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey, countKey);
|
|
730
|
-
const asks = this.parseCountedBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey, countKey);
|
|
731
|
-
return {
|
|
732
|
-
'symbol': symbol,
|
|
733
|
-
'bids': this.sortBy(bids, 0, true),
|
|
734
|
-
'asks': this.sortBy(asks, 0),
|
|
735
|
-
'timestamp': timestamp,
|
|
736
|
-
'datetime': this.iso8601(timestamp),
|
|
737
|
-
'nonce': undefined,
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
714
|
handleDelta(bookside, delta) {
|
|
741
|
-
const bookArray = this.
|
|
715
|
+
const bookArray = this.parseBidAsk(delta, 'px', 'qty', 'num');
|
|
742
716
|
bookside.storeArray(bookArray);
|
|
743
717
|
}
|
|
744
718
|
handleDeltas(bookside, deltas) {
|
|
@@ -222,7 +222,9 @@ class bybit extends bybit$1 {
|
|
|
222
222
|
}
|
|
223
223
|
const ticker = await this.watchTopics(url, messageHashes, topics, params);
|
|
224
224
|
if (this.newUpdates) {
|
|
225
|
-
|
|
225
|
+
const result = {};
|
|
226
|
+
result[ticker['symbol']] = ticker;
|
|
227
|
+
return result;
|
|
226
228
|
}
|
|
227
229
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
228
230
|
}
|
|
@@ -89,7 +89,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
89
89
|
const symbol = symbols[i];
|
|
90
90
|
market = this.market(symbol);
|
|
91
91
|
productIds.push(market['id']);
|
|
92
|
-
messageHashes.push(messageHashStart + ':' + market['
|
|
92
|
+
messageHashes.push(messageHashStart + ':' + market['symbol']);
|
|
93
93
|
}
|
|
94
94
|
let url = this.urls['api']['ws'];
|
|
95
95
|
if ('signature' in params) {
|
|
@@ -134,10 +134,12 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
134
134
|
throw new errors.BadSymbol(this.id + ' watchTickers requires a non-empty symbols array');
|
|
135
135
|
}
|
|
136
136
|
const channel = 'ticker';
|
|
137
|
-
const messageHash = '
|
|
138
|
-
const
|
|
137
|
+
const messageHash = 'ticker';
|
|
138
|
+
const ticker = await this.subscribeMultiple(channel, symbols, messageHash, params);
|
|
139
139
|
if (this.newUpdates) {
|
|
140
|
-
|
|
140
|
+
const result = {};
|
|
141
|
+
result[ticker['symbol']] = ticker;
|
|
142
|
+
return result;
|
|
141
143
|
}
|
|
142
144
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
143
145
|
}
|
|
@@ -749,19 +751,10 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
749
751
|
const ticker = this.parseTicker(message);
|
|
750
752
|
const symbol = ticker['symbol'];
|
|
751
753
|
this.tickers[symbol] = ticker;
|
|
752
|
-
const
|
|
753
|
-
const
|
|
754
|
+
const messageHash = 'ticker:' + symbol;
|
|
755
|
+
const idMessageHash = 'ticker:' + marketId;
|
|
754
756
|
client.resolve(ticker, messageHash);
|
|
755
|
-
|
|
756
|
-
for (let i = 0; i < messageHashes.length; i++) {
|
|
757
|
-
const currentMessageHash = messageHashes[i];
|
|
758
|
-
const parts = currentMessageHash.split('::');
|
|
759
|
-
const symbolsString = parts[1];
|
|
760
|
-
const symbols = symbolsString.split(',');
|
|
761
|
-
if (this.inArray(symbol, symbols)) {
|
|
762
|
-
client.resolve(ticker, currentMessageHash);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
757
|
+
client.resolve(ticker, idMessageHash);
|
|
765
758
|
}
|
|
766
759
|
return message;
|
|
767
760
|
}
|
|
@@ -71,6 +71,8 @@ class cryptocom extends cryptocom$1 {
|
|
|
71
71
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
72
72
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
73
73
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
74
|
+
* @param {string} [params.bookSubscriptionType] The subscription type. Allowed values: SNAPSHOT full snapshot. This is the default if not specified. SNAPSHOT_AND_UPDATE delta updates
|
|
75
|
+
* @param {int} [params.bookUpdateFrequency] Book update interval in ms. Allowed values: 100 for snapshot subscription 10 for delta subscription
|
|
74
76
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
75
77
|
*/
|
|
76
78
|
return await this.watchOrderBookForSymbols([symbol], limit, params);
|
|
@@ -84,6 +86,8 @@ class cryptocom extends cryptocom$1 {
|
|
|
84
86
|
* @param {string[]} symbols unified array of symbols
|
|
85
87
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
86
88
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
89
|
+
* @param {string} [params.bookSubscriptionType] The subscription type. Allowed values: SNAPSHOT full snapshot. This is the default if not specified. SNAPSHOT_AND_UPDATE delta updates
|
|
90
|
+
* @param {int} [params.bookUpdateFrequency] Book update interval in ms. Allowed values: 100 for snapshot subscription 10 for delta subscription
|
|
87
91
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
88
92
|
*/
|
|
89
93
|
await this.loadMarkets();
|
|
@@ -91,12 +95,26 @@ class cryptocom extends cryptocom$1 {
|
|
|
91
95
|
const topics = [];
|
|
92
96
|
const messageHashes = [];
|
|
93
97
|
if (!limit) {
|
|
94
|
-
limit =
|
|
98
|
+
limit = 50;
|
|
99
|
+
}
|
|
100
|
+
const topicParams = this.safeValue(params, 'params');
|
|
101
|
+
if (topicParams === undefined) {
|
|
102
|
+
params['params'] = {};
|
|
103
|
+
}
|
|
104
|
+
let bookSubscriptionType = undefined;
|
|
105
|
+
[bookSubscriptionType, params] = this.handleOptionAndParams2(params, 'watchOrderBook', 'watchOrderBookForSymbols', 'bookSubscriptionType', 'SNAPSHOT_AND_UPDATE');
|
|
106
|
+
if (bookSubscriptionType !== undefined) {
|
|
107
|
+
params['params']['bookSubscriptionType'] = bookSubscriptionType;
|
|
108
|
+
}
|
|
109
|
+
let bookUpdateFrequency = undefined;
|
|
110
|
+
[bookUpdateFrequency, params] = this.handleOptionAndParams2(params, 'watchOrderBook', 'watchOrderBookForSymbols', 'bookUpdateFrequency');
|
|
111
|
+
if (bookUpdateFrequency !== undefined) {
|
|
112
|
+
params['params']['bookSubscriptionType'] = bookSubscriptionType;
|
|
95
113
|
}
|
|
96
114
|
for (let i = 0; i < symbols.length; i++) {
|
|
97
115
|
const symbol = symbols[i];
|
|
98
116
|
const market = this.market(symbol);
|
|
99
|
-
const currentTopic = 'book' + '.' + market['id'] + '.' + limit;
|
|
117
|
+
const currentTopic = 'book' + '.' + market['id'] + '.' + limit.toString();
|
|
100
118
|
const messageHash = 'orderbook:' + market['symbol'];
|
|
101
119
|
messageHashes.push(messageHash);
|
|
102
120
|
topics.push(currentTopic);
|
|
@@ -104,27 +122,72 @@ class cryptocom extends cryptocom$1 {
|
|
|
104
122
|
const orderbook = await this.watchPublicMultiple(messageHashes, topics, params);
|
|
105
123
|
return orderbook.limit();
|
|
106
124
|
}
|
|
107
|
-
|
|
108
|
-
|
|
125
|
+
handleDelta(bookside, delta) {
|
|
126
|
+
const price = this.safeFloat(delta, 0);
|
|
127
|
+
const amount = this.safeFloat(delta, 1);
|
|
128
|
+
const count = this.safeInteger(delta, 2);
|
|
129
|
+
bookside.store(price, amount, count);
|
|
130
|
+
}
|
|
131
|
+
handleDeltas(bookside, deltas) {
|
|
132
|
+
for (let i = 0; i < deltas.length; i++) {
|
|
133
|
+
this.handleDelta(bookside, deltas[i]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
handleOrderBook(client, message) {
|
|
109
137
|
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
138
|
+
// snapshot
|
|
139
|
+
// {
|
|
140
|
+
// "instrument_name":"LTC_USDT",
|
|
141
|
+
// "subscription":"book.LTC_USDT.150",
|
|
142
|
+
// "channel":"book",
|
|
143
|
+
// "depth":150,
|
|
144
|
+
// "data": [
|
|
145
|
+
// {
|
|
146
|
+
// "bids": [
|
|
147
|
+
// [122.21, 0.74041, 4]
|
|
148
|
+
// ],
|
|
149
|
+
// "asks": [
|
|
150
|
+
// [122.29, 0.00002, 1]
|
|
151
|
+
// ]
|
|
152
|
+
// "t": 1648123943803,
|
|
153
|
+
// "s":754560122
|
|
154
|
+
// }
|
|
155
|
+
// ]
|
|
156
|
+
// }
|
|
157
|
+
// update
|
|
158
|
+
// {
|
|
159
|
+
// "instrument_name":"BTC_USDT",
|
|
160
|
+
// "subscription":"book.BTC_USDT.50",
|
|
161
|
+
// "channel":"book.update",
|
|
162
|
+
// "depth":50,
|
|
163
|
+
// "data":[
|
|
164
|
+
// {
|
|
165
|
+
// "update":{
|
|
166
|
+
// "asks":[
|
|
167
|
+
// [
|
|
168
|
+
// "43755.46",
|
|
169
|
+
// "0.10000",
|
|
170
|
+
// "1"
|
|
171
|
+
// ],
|
|
172
|
+
// ...
|
|
173
|
+
// ],
|
|
174
|
+
// "bids":[
|
|
175
|
+
// [
|
|
176
|
+
// "43737.46",
|
|
177
|
+
// "0.14096",
|
|
178
|
+
// "1"
|
|
179
|
+
// ],
|
|
180
|
+
// ...
|
|
181
|
+
// ]
|
|
182
|
+
// },
|
|
183
|
+
// "t":1704484068898,
|
|
184
|
+
// "tt":1704484068892,
|
|
185
|
+
// "u":78795598253024,
|
|
186
|
+
// "pu":78795598162080,
|
|
187
|
+
// "cs":-781431132
|
|
188
|
+
// }
|
|
189
|
+
// ]
|
|
190
|
+
// }
|
|
128
191
|
//
|
|
129
192
|
const marketId = this.safeString(message, 'instrument_name');
|
|
130
193
|
const market = this.safeMarket(marketId);
|
|
@@ -132,14 +195,32 @@ class cryptocom extends cryptocom$1 {
|
|
|
132
195
|
let data = this.safeValue(message, 'data');
|
|
133
196
|
data = this.safeValue(data, 0);
|
|
134
197
|
const timestamp = this.safeInteger(data, 't');
|
|
135
|
-
const snapshot = this.parseOrderBook(data, symbol, timestamp);
|
|
136
|
-
snapshot['nonce'] = this.safeInteger(data, 's');
|
|
137
198
|
let orderbook = this.safeValue(this.orderbooks, symbol);
|
|
138
199
|
if (orderbook === undefined) {
|
|
139
200
|
const limit = this.safeInteger(message, 'depth');
|
|
140
|
-
orderbook = this.
|
|
201
|
+
orderbook = this.countedOrderBook({}, limit);
|
|
141
202
|
}
|
|
142
|
-
|
|
203
|
+
const channel = this.safeString(message, 'channel');
|
|
204
|
+
const nonce = this.safeInteger2(data, 'u', 's');
|
|
205
|
+
let books = data;
|
|
206
|
+
if (channel === 'book') { // snapshot
|
|
207
|
+
orderbook.reset({});
|
|
208
|
+
orderbook['symbol'] = symbol;
|
|
209
|
+
orderbook['timestamp'] = timestamp;
|
|
210
|
+
orderbook['datetime'] = this.iso8601(timestamp);
|
|
211
|
+
orderbook['nonce'] = nonce;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
books = this.safeValue(data, 'update', {});
|
|
215
|
+
const previousNonce = this.safeInteger(data, 'pu');
|
|
216
|
+
const currentNonce = orderbook['nonce'];
|
|
217
|
+
if (currentNonce !== previousNonce) {
|
|
218
|
+
throw new errors.InvalidNonce(this.id + ' watchOrderBook() ' + symbol + ' ' + previousNonce + ' != ' + nonce);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
this.handleDeltas(orderbook['asks'], this.safeValue(books, 'asks', []));
|
|
222
|
+
this.handleDeltas(orderbook['bids'], this.safeValue(books, 'bids', []));
|
|
223
|
+
orderbook['nonce'] = nonce;
|
|
143
224
|
this.orderbooks[symbol] = orderbook;
|
|
144
225
|
const messageHash = 'orderbook:' + symbol;
|
|
145
226
|
client.resolve(orderbook, messageHash);
|
|
@@ -761,7 +842,7 @@ class cryptocom extends cryptocom$1 {
|
|
|
761
842
|
},
|
|
762
843
|
'nonce': id,
|
|
763
844
|
};
|
|
764
|
-
const message = this.
|
|
845
|
+
const message = this.deepExtend(request, params);
|
|
765
846
|
return await this.watchMultiple(url, messageHashes, message, messageHashes);
|
|
766
847
|
}
|
|
767
848
|
async watchPrivateRequest(nonce, params = {}) {
|
|
@@ -828,7 +909,8 @@ class cryptocom extends cryptocom$1 {
|
|
|
828
909
|
'candlestick': this.handleOHLCV,
|
|
829
910
|
'ticker': this.handleTicker,
|
|
830
911
|
'trade': this.handleTrades,
|
|
831
|
-
'book': this.
|
|
912
|
+
'book': this.handleOrderBook,
|
|
913
|
+
'book.update': this.handleOrderBook,
|
|
832
914
|
'user.order': this.handleOrders,
|
|
833
915
|
'user.trade': this.handleTrades,
|
|
834
916
|
'user.balance': this.handleBalance,
|
package/dist/cjs/src/pro/luno.js
CHANGED
|
@@ -210,9 +210,9 @@ class luno extends luno$1 {
|
|
|
210
210
|
storedOrderBook['nonce'] = nonce;
|
|
211
211
|
client.resolve(storedOrderBook, messageHash);
|
|
212
212
|
}
|
|
213
|
-
customParseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 'price', amountKey = 'volume',
|
|
214
|
-
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey,
|
|
215
|
-
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey,
|
|
213
|
+
customParseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 'price', amountKey = 'volume', countOrIdKey = 2) {
|
|
214
|
+
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey, countOrIdKey);
|
|
215
|
+
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey, countOrIdKey);
|
|
216
216
|
return {
|
|
217
217
|
'symbol': symbol,
|
|
218
218
|
'bids': this.sortBy(bids, 0, true),
|
|
@@ -222,7 +222,7 @@ class luno extends luno$1 {
|
|
|
222
222
|
'nonce': undefined,
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
|
-
parseBidsAsks(bidasks, priceKey = 'price', amountKey = 'volume', thirdKey =
|
|
225
|
+
parseBidsAsks(bidasks, priceKey = 'price', amountKey = 'volume', thirdKey = 2) {
|
|
226
226
|
bidasks = this.toArray(bidasks);
|
|
227
227
|
const result = [];
|
|
228
228
|
for (let i = 0; i < bidasks.length; i++) {
|
|
@@ -230,7 +230,7 @@ class luno extends luno$1 {
|
|
|
230
230
|
}
|
|
231
231
|
return result;
|
|
232
232
|
}
|
|
233
|
-
customParseBidAsk(bidask, priceKey = 'price', amountKey = 'volume', thirdKey =
|
|
233
|
+
customParseBidAsk(bidask, priceKey = 'price', amountKey = 'volume', thirdKey = 2) {
|
|
234
234
|
const price = this.safeNumber(bidask, priceKey);
|
|
235
235
|
const amount = this.safeNumber(bidask, amountKey);
|
|
236
236
|
const result = [price, 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.2.
|
|
7
|
+
declare const version = "4.2.9";
|
|
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, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.10';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -678,7 +678,7 @@ export default class Exchange {
|
|
|
678
678
|
marketIds(symbols: any): any;
|
|
679
679
|
marketSymbols(symbols: any, type?: string, allowEmpty?: boolean, sameTypeOnly?: boolean, sameSubTypeOnly?: boolean): any;
|
|
680
680
|
marketCodes(codes: any): any;
|
|
681
|
-
parseBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType): any[];
|
|
681
|
+
parseBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): any[];
|
|
682
682
|
fetchL2OrderBook(symbol: string, limit?: Int, params?: {}): Promise<any>;
|
|
683
683
|
filterBySymbol(objects: any, symbol?: string): any;
|
|
684
684
|
parseOHLCV(ohlcv: any, market?: Market): OHLCV;
|
|
@@ -690,7 +690,7 @@ export default class Exchange {
|
|
|
690
690
|
selectNetworkIdFromRawNetworks(currencyCode: any, networkCode: any, indexedNetworkEntries: any): any;
|
|
691
691
|
selectNetworkKeyFromNetworks(currencyCode: any, networkCode: any, indexedNetworkEntries: any, isIndexedByUnifiedNetworkCode?: boolean): any;
|
|
692
692
|
safeNumber2(dictionary: any, key1: any, key2: any, d?: any): number;
|
|
693
|
-
parseOrderBook(orderbook: object, symbol: string, timestamp?: Int, bidsKey?: string, asksKey?: string, priceKey?: IndexType, amountKey?: IndexType): OrderBook;
|
|
693
|
+
parseOrderBook(orderbook: object, symbol: string, timestamp?: Int, bidsKey?: string, asksKey?: string, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): OrderBook;
|
|
694
694
|
parseOHLCVs(ohlcvs: object[], market?: any, timeframe?: string, since?: Int, limit?: Int): OHLCV[];
|
|
695
695
|
parseLeverageTiers(response: any, symbols?: string[], marketIdKey?: any): {};
|
|
696
696
|
loadTradingLimits(symbols?: string[], reload?: boolean, params?: {}): Promise<Dictionary<any>>;
|
|
@@ -726,7 +726,7 @@ export default class Exchange {
|
|
|
726
726
|
fetchPositions(symbols?: string[], params?: {}): Promise<Position[]>;
|
|
727
727
|
fetchPositionsRisk(symbols?: string[], params?: {}): Promise<Position[]>;
|
|
728
728
|
fetchBidsAsks(symbols?: string[], params?: {}): Promise<Dictionary<Ticker>>;
|
|
729
|
-
parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType): number[];
|
|
729
|
+
parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
|
|
730
730
|
safeCurrency(currencyId: Str, currency?: Currency): CurrencyInterface;
|
|
731
731
|
safeMarket(marketId: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
|
|
732
732
|
checkRequiredCredentials(error?: boolean): boolean;
|
|
@@ -750,6 +750,7 @@ export default class Exchange {
|
|
|
750
750
|
fetchCrossBorrowRate(code: string, params?: {}): Promise<any>;
|
|
751
751
|
fetchIsolatedBorrowRate(symbol: string, params?: {}): Promise<any>;
|
|
752
752
|
handleOptionAndParams(params: any, methodName: any, optionName: any, defaultValue?: any): any[];
|
|
753
|
+
handleOptionAndParams2(params: any, methodName: any, methodName2: any, optionName: any, defaultValue?: any): any[];
|
|
753
754
|
handleOption(methodName: any, optionName: any, defaultValue?: any): any;
|
|
754
755
|
handleMarketTypeAndParams(methodName: string, market?: Market, params?: {}): any;
|
|
755
756
|
handleSubTypeAndParams(methodName: any, market?: any, params?: {}, defaultValue?: any): any[];
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -2858,11 +2858,11 @@ export default class Exchange {
|
|
|
2858
2858
|
}
|
|
2859
2859
|
return result;
|
|
2860
2860
|
}
|
|
2861
|
-
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1) {
|
|
2861
|
+
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
2862
2862
|
bidasks = this.toArray(bidasks);
|
|
2863
2863
|
const result = [];
|
|
2864
2864
|
for (let i = 0; i < bidasks.length; i++) {
|
|
2865
|
-
result.push(this.parseBidAsk(bidasks[i], priceKey, amountKey));
|
|
2865
|
+
result.push(this.parseBidAsk(bidasks[i], priceKey, amountKey, countOrIdKey));
|
|
2866
2866
|
}
|
|
2867
2867
|
return result;
|
|
2868
2868
|
}
|
|
@@ -3031,9 +3031,9 @@ export default class Exchange {
|
|
|
3031
3031
|
const value = this.safeString2(dictionary, key1, key2);
|
|
3032
3032
|
return this.parseNumber(value, d);
|
|
3033
3033
|
}
|
|
3034
|
-
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1) {
|
|
3035
|
-
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey);
|
|
3036
|
-
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey);
|
|
3034
|
+
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
3035
|
+
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey, countOrIdKey);
|
|
3036
|
+
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey, countOrIdKey);
|
|
3037
3037
|
return {
|
|
3038
3038
|
'symbol': symbol,
|
|
3039
3039
|
'bids': this.sortBy(bids, 0, true),
|
|
@@ -3348,10 +3348,15 @@ export default class Exchange {
|
|
|
3348
3348
|
async fetchBidsAsks(symbols = undefined, params = {}) {
|
|
3349
3349
|
throw new NotSupported(this.id + ' fetchBidsAsks() is not supported yet');
|
|
3350
3350
|
}
|
|
3351
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
3351
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
3352
3352
|
const price = this.safeNumber(bidask, priceKey);
|
|
3353
3353
|
const amount = this.safeNumber(bidask, amountKey);
|
|
3354
|
-
|
|
3354
|
+
const countOrId = this.safeInteger(bidask, countOrIdKey);
|
|
3355
|
+
const bidAsk = [price, amount];
|
|
3356
|
+
if (countOrId !== undefined) {
|
|
3357
|
+
bidAsk.push(countOrId);
|
|
3358
|
+
}
|
|
3359
|
+
return bidAsk;
|
|
3355
3360
|
}
|
|
3356
3361
|
safeCurrency(currencyId, currency = undefined) {
|
|
3357
3362
|
if ((currencyId === undefined) && (currency !== undefined)) {
|
|
@@ -3399,7 +3404,7 @@ export default class Exchange {
|
|
|
3399
3404
|
}
|
|
3400
3405
|
}
|
|
3401
3406
|
}
|
|
3402
|
-
else if (delimiter !== undefined) {
|
|
3407
|
+
else if (delimiter !== undefined && delimiter !== '') {
|
|
3403
3408
|
const parts = marketId.split(delimiter);
|
|
3404
3409
|
const partsLength = parts.length;
|
|
3405
3410
|
if (partsLength === 2) {
|
|
@@ -3560,6 +3565,30 @@ export default class Exchange {
|
|
|
3560
3565
|
}
|
|
3561
3566
|
return [value, params];
|
|
3562
3567
|
}
|
|
3568
|
+
handleOptionAndParams2(params, methodName, methodName2, optionName, defaultValue = undefined) {
|
|
3569
|
+
// This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
|
|
3570
|
+
const defaultOptionName = 'default' + this.capitalize(optionName); // we also need to check the 'defaultXyzWhatever'
|
|
3571
|
+
// check if params contain the key
|
|
3572
|
+
let value = this.safeValue2(params, optionName, defaultOptionName);
|
|
3573
|
+
if (value !== undefined) {
|
|
3574
|
+
params = this.omit(params, [optionName, defaultOptionName]);
|
|
3575
|
+
}
|
|
3576
|
+
else {
|
|
3577
|
+
// check if exchange has properties for this method
|
|
3578
|
+
const exchangeWideMethodOptions = this.safeValue2(this.options, methodName, methodName2);
|
|
3579
|
+
if (exchangeWideMethodOptions !== undefined) {
|
|
3580
|
+
// check if the option is defined inside this method's props
|
|
3581
|
+
value = this.safeValue2(exchangeWideMethodOptions, optionName, defaultOptionName);
|
|
3582
|
+
}
|
|
3583
|
+
if (value === undefined) {
|
|
3584
|
+
// if it's still undefined, check if global exchange-wide option exists
|
|
3585
|
+
value = this.safeValue2(this.options, optionName, defaultOptionName);
|
|
3586
|
+
}
|
|
3587
|
+
// if it's still undefined, use the default value
|
|
3588
|
+
value = (value !== undefined) ? value : defaultValue;
|
|
3589
|
+
}
|
|
3590
|
+
return [value, params];
|
|
3591
|
+
}
|
|
3563
3592
|
handleOption(methodName, optionName, defaultValue = undefined) {
|
|
3564
3593
|
// eslint-disable-next-line no-unused-vars
|
|
3565
3594
|
const [result, empty] = this.handleOptionAndParams({}, methodName, optionName, defaultValue);
|
package/js/src/binance.js
CHANGED
|
@@ -3148,7 +3148,12 @@ export default class binance extends Exchange {
|
|
|
3148
3148
|
response = await this.dapiPublicGetTickerBookTicker(params);
|
|
3149
3149
|
}
|
|
3150
3150
|
else {
|
|
3151
|
-
|
|
3151
|
+
const request = {};
|
|
3152
|
+
if (symbols !== undefined) {
|
|
3153
|
+
const marketIds = this.marketIds(symbols);
|
|
3154
|
+
request['symbols'] = this.json(marketIds);
|
|
3155
|
+
}
|
|
3156
|
+
response = await this.publicGetTickerBookTicker(this.extend(request, params));
|
|
3152
3157
|
}
|
|
3153
3158
|
return this.parseTickers(response, symbols);
|
|
3154
3159
|
}
|