ccxt 4.2.9 → 4.2.11
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 +2 -2
- package/dist/ccxt.browser.js +322 -164
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +48 -8
- package/dist/cjs/src/binance.js +6 -1
- package/dist/cjs/src/bingx.js +0 -10
- package/dist/cjs/src/bitget.js +14 -5
- package/dist/cjs/src/bl3p.js +1 -1
- package/dist/cjs/src/btcalpha.js +1 -1
- package/dist/cjs/src/bybit.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 +30 -6
- package/dist/cjs/src/lykke.js +1 -1
- package/dist/cjs/src/ndax.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +49 -27
- package/dist/cjs/src/pro/blockchaincom.js +2 -28
- 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 +5 -3
- package/js/src/base/Exchange.js +48 -8
- package/js/src/binance.js +6 -1
- package/js/src/bingx.d.ts +0 -1
- package/js/src/bingx.js +0 -10
- package/js/src/bitget.js +14 -5
- 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/bybit.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 +30 -6
- 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/bitmart.d.ts +1 -0
- package/js/src/pro/bitmart.js +49 -27
- package/js/src/pro/blockchaincom.d.ts +1 -11
- package/js/src/pro/blockchaincom.js +2 -28
- 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/package.json +11 -11
- package/tests-manager.sh +2 -2
|
@@ -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.10";
|
|
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.11';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -555,6 +555,7 @@ export default class Exchange {
|
|
|
555
555
|
getProperty(obj: any, property: any, defaultValue?: any): any;
|
|
556
556
|
setProperty(obj: any, property: any, defaultValue?: any): void;
|
|
557
557
|
axolotl(payload: any, hexKey: any, ed25519: any): string;
|
|
558
|
+
fixStringifiedJsonMembers(content: any): any;
|
|
558
559
|
handleDeltas(orderbook: any, deltas: any): void;
|
|
559
560
|
handleDelta(bookside: any, delta: any): void;
|
|
560
561
|
getCacheIndex(orderbook: any, deltas: any): number;
|
|
@@ -678,7 +679,7 @@ export default class Exchange {
|
|
|
678
679
|
marketIds(symbols: any): any;
|
|
679
680
|
marketSymbols(symbols: any, type?: string, allowEmpty?: boolean, sameTypeOnly?: boolean, sameSubTypeOnly?: boolean): any;
|
|
680
681
|
marketCodes(codes: any): any;
|
|
681
|
-
parseBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType): any[];
|
|
682
|
+
parseBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): any[];
|
|
682
683
|
fetchL2OrderBook(symbol: string, limit?: Int, params?: {}): Promise<any>;
|
|
683
684
|
filterBySymbol(objects: any, symbol?: string): any;
|
|
684
685
|
parseOHLCV(ohlcv: any, market?: Market): OHLCV;
|
|
@@ -690,7 +691,7 @@ export default class Exchange {
|
|
|
690
691
|
selectNetworkIdFromRawNetworks(currencyCode: any, networkCode: any, indexedNetworkEntries: any): any;
|
|
691
692
|
selectNetworkKeyFromNetworks(currencyCode: any, networkCode: any, indexedNetworkEntries: any, isIndexedByUnifiedNetworkCode?: boolean): any;
|
|
692
693
|
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;
|
|
694
|
+
parseOrderBook(orderbook: object, symbol: string, timestamp?: Int, bidsKey?: string, asksKey?: string, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): OrderBook;
|
|
694
695
|
parseOHLCVs(ohlcvs: object[], market?: any, timeframe?: string, since?: Int, limit?: Int): OHLCV[];
|
|
695
696
|
parseLeverageTiers(response: any, symbols?: string[], marketIdKey?: any): {};
|
|
696
697
|
loadTradingLimits(symbols?: string[], reload?: boolean, params?: {}): Promise<Dictionary<any>>;
|
|
@@ -726,7 +727,7 @@ export default class Exchange {
|
|
|
726
727
|
fetchPositions(symbols?: string[], params?: {}): Promise<Position[]>;
|
|
727
728
|
fetchPositionsRisk(symbols?: string[], params?: {}): Promise<Position[]>;
|
|
728
729
|
fetchBidsAsks(symbols?: string[], params?: {}): Promise<Dictionary<Ticker>>;
|
|
729
|
-
parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType): number[];
|
|
730
|
+
parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
|
|
730
731
|
safeCurrency(currencyId: Str, currency?: Currency): CurrencyInterface;
|
|
731
732
|
safeMarket(marketId: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
|
|
732
733
|
checkRequiredCredentials(error?: boolean): boolean;
|
|
@@ -750,6 +751,7 @@ export default class Exchange {
|
|
|
750
751
|
fetchCrossBorrowRate(code: string, params?: {}): Promise<any>;
|
|
751
752
|
fetchIsolatedBorrowRate(symbol: string, params?: {}): Promise<any>;
|
|
752
753
|
handleOptionAndParams(params: any, methodName: any, optionName: any, defaultValue?: any): any[];
|
|
754
|
+
handleOptionAndParams2(params: any, methodName: any, methodName2: any, optionName: any, defaultValue?: any): any[];
|
|
753
755
|
handleOption(methodName: any, optionName: any, defaultValue?: any): any;
|
|
754
756
|
handleMarketTypeAndParams(methodName: string, market?: Market, params?: {}): any;
|
|
755
757
|
handleSubTypeAndParams(methodName: any, market?: any, params?: {}, defaultValue?: any): any[];
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -1291,6 +1291,17 @@ export default class Exchange {
|
|
|
1291
1291
|
axolotl(payload, hexKey, ed25519) {
|
|
1292
1292
|
return axolotl(payload, hexKey, ed25519);
|
|
1293
1293
|
}
|
|
1294
|
+
fixStringifiedJsonMembers(content) {
|
|
1295
|
+
// used for instance in bingx
|
|
1296
|
+
// when stringified json has members with their values also stringified, like:
|
|
1297
|
+
// '{"code":0, "data":{"order":{"orderId":1742968678528512345,"symbol":"BTC-USDT", "takeProfit":"{\"type\":\"TAKE_PROFIT\",\"stopPrice\":43320.1}","reduceOnly":false}}}'
|
|
1298
|
+
// we can fix with below manipulations
|
|
1299
|
+
// @ts-ignore
|
|
1300
|
+
let modifiedContent = content.replaceAll('\\', '');
|
|
1301
|
+
modifiedContent = modifiedContent.replaceAll('"{', '{');
|
|
1302
|
+
modifiedContent = modifiedContent.replaceAll('}"', '}');
|
|
1303
|
+
return modifiedContent;
|
|
1304
|
+
}
|
|
1294
1305
|
/* eslint-enable */
|
|
1295
1306
|
// ------------------------------------------------------------------------
|
|
1296
1307
|
// ########################################################################
|
|
@@ -2858,11 +2869,11 @@ export default class Exchange {
|
|
|
2858
2869
|
}
|
|
2859
2870
|
return result;
|
|
2860
2871
|
}
|
|
2861
|
-
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1) {
|
|
2872
|
+
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
2862
2873
|
bidasks = this.toArray(bidasks);
|
|
2863
2874
|
const result = [];
|
|
2864
2875
|
for (let i = 0; i < bidasks.length; i++) {
|
|
2865
|
-
result.push(this.parseBidAsk(bidasks[i], priceKey, amountKey));
|
|
2876
|
+
result.push(this.parseBidAsk(bidasks[i], priceKey, amountKey, countOrIdKey));
|
|
2866
2877
|
}
|
|
2867
2878
|
return result;
|
|
2868
2879
|
}
|
|
@@ -3031,9 +3042,9 @@ export default class Exchange {
|
|
|
3031
3042
|
const value = this.safeString2(dictionary, key1, key2);
|
|
3032
3043
|
return this.parseNumber(value, d);
|
|
3033
3044
|
}
|
|
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);
|
|
3045
|
+
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
3046
|
+
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey, countOrIdKey);
|
|
3047
|
+
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey, countOrIdKey);
|
|
3037
3048
|
return {
|
|
3038
3049
|
'symbol': symbol,
|
|
3039
3050
|
'bids': this.sortBy(bids, 0, true),
|
|
@@ -3348,10 +3359,15 @@ export default class Exchange {
|
|
|
3348
3359
|
async fetchBidsAsks(symbols = undefined, params = {}) {
|
|
3349
3360
|
throw new NotSupported(this.id + ' fetchBidsAsks() is not supported yet');
|
|
3350
3361
|
}
|
|
3351
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
3362
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
3352
3363
|
const price = this.safeNumber(bidask, priceKey);
|
|
3353
3364
|
const amount = this.safeNumber(bidask, amountKey);
|
|
3354
|
-
|
|
3365
|
+
const countOrId = this.safeInteger(bidask, countOrIdKey);
|
|
3366
|
+
const bidAsk = [price, amount];
|
|
3367
|
+
if (countOrId !== undefined) {
|
|
3368
|
+
bidAsk.push(countOrId);
|
|
3369
|
+
}
|
|
3370
|
+
return bidAsk;
|
|
3355
3371
|
}
|
|
3356
3372
|
safeCurrency(currencyId, currency = undefined) {
|
|
3357
3373
|
if ((currencyId === undefined) && (currency !== undefined)) {
|
|
@@ -3399,7 +3415,7 @@ export default class Exchange {
|
|
|
3399
3415
|
}
|
|
3400
3416
|
}
|
|
3401
3417
|
}
|
|
3402
|
-
else if (delimiter !== undefined) {
|
|
3418
|
+
else if (delimiter !== undefined && delimiter !== '') {
|
|
3403
3419
|
const parts = marketId.split(delimiter);
|
|
3404
3420
|
const partsLength = parts.length;
|
|
3405
3421
|
if (partsLength === 2) {
|
|
@@ -3560,6 +3576,30 @@ export default class Exchange {
|
|
|
3560
3576
|
}
|
|
3561
3577
|
return [value, params];
|
|
3562
3578
|
}
|
|
3579
|
+
handleOptionAndParams2(params, methodName, methodName2, optionName, defaultValue = undefined) {
|
|
3580
|
+
// This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
|
|
3581
|
+
const defaultOptionName = 'default' + this.capitalize(optionName); // we also need to check the 'defaultXyzWhatever'
|
|
3582
|
+
// check if params contain the key
|
|
3583
|
+
let value = this.safeValue2(params, optionName, defaultOptionName);
|
|
3584
|
+
if (value !== undefined) {
|
|
3585
|
+
params = this.omit(params, [optionName, defaultOptionName]);
|
|
3586
|
+
}
|
|
3587
|
+
else {
|
|
3588
|
+
// check if exchange has properties for this method
|
|
3589
|
+
const exchangeWideMethodOptions = this.safeValue2(this.options, methodName, methodName2);
|
|
3590
|
+
if (exchangeWideMethodOptions !== undefined) {
|
|
3591
|
+
// check if the option is defined inside this method's props
|
|
3592
|
+
value = this.safeValue2(exchangeWideMethodOptions, optionName, defaultOptionName);
|
|
3593
|
+
}
|
|
3594
|
+
if (value === undefined) {
|
|
3595
|
+
// if it's still undefined, check if global exchange-wide option exists
|
|
3596
|
+
value = this.safeValue2(this.options, optionName, defaultOptionName);
|
|
3597
|
+
}
|
|
3598
|
+
// if it's still undefined, use the default value
|
|
3599
|
+
value = (value !== undefined) ? value : defaultValue;
|
|
3600
|
+
}
|
|
3601
|
+
return [value, params];
|
|
3602
|
+
}
|
|
3563
3603
|
handleOption(methodName, optionName, defaultValue = undefined) {
|
|
3564
3604
|
// eslint-disable-next-line no-unused-vars
|
|
3565
3605
|
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
|
}
|
package/js/src/bingx.d.ts
CHANGED
|
@@ -66,7 +66,6 @@ export default class bingx extends Exchange {
|
|
|
66
66
|
createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
67
67
|
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
|
|
68
68
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
69
|
-
fixStringifiedJsonMembers(content: any): any;
|
|
70
69
|
createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
|
|
71
70
|
parseOrderSide(side: any): string;
|
|
72
71
|
parseOrder(order: any, market?: Market): Order;
|
package/js/src/bingx.js
CHANGED
|
@@ -1909,16 +1909,6 @@ export default class bingx extends Exchange {
|
|
|
1909
1909
|
const order = this.safeValue(data, 'order', data);
|
|
1910
1910
|
return this.parseOrder(order, market);
|
|
1911
1911
|
}
|
|
1912
|
-
fixStringifiedJsonMembers(content) {
|
|
1913
|
-
// when stringified json has members with their values also stringified, like:
|
|
1914
|
-
// '{"code":0, "data":{"order":{"orderId":1742968678528512345,"symbol":"BTC-USDT", "takeProfit":"{\"type\":\"TAKE_PROFIT\",\"stopPrice\":43320.1}","reduceOnly":false}}}'
|
|
1915
|
-
// we can fix with below manipulations
|
|
1916
|
-
// @ts-ignore
|
|
1917
|
-
let modifiedContent = content.replaceAll('\\', '');
|
|
1918
|
-
modifiedContent = modifiedContent.replaceAll('"{', '{');
|
|
1919
|
-
modifiedContent = modifiedContent.replaceAll('}"', '}');
|
|
1920
|
-
return modifiedContent;
|
|
1921
|
-
}
|
|
1922
1912
|
async createOrders(orders, params = {}) {
|
|
1923
1913
|
/**
|
|
1924
1914
|
* @method
|
package/js/src/bitget.js
CHANGED
|
@@ -4011,6 +4011,7 @@ export default class bitget extends Exchange {
|
|
|
4011
4011
|
* @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
|
|
4012
4012
|
* @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
|
|
4013
4013
|
* @param {string} [params.triggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
|
|
4014
|
+
* @param {boolean} [params.oneWayMode] *swap and future only* required to set this to true in one_way_mode and you can leave this as undefined in hedge_mode, can adjust the mode using the setPositionMode() method
|
|
4014
4015
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4015
4016
|
*/
|
|
4016
4017
|
await this.loadMarkets();
|
|
@@ -4204,15 +4205,23 @@ export default class bitget extends Exchange {
|
|
|
4204
4205
|
}
|
|
4205
4206
|
const marginModeRequest = (marginMode === 'cross') ? 'crossed' : 'isolated';
|
|
4206
4207
|
request['marginMode'] = marginModeRequest;
|
|
4208
|
+
const oneWayMode = this.safeValue(params, 'oneWayMode', false);
|
|
4209
|
+
params = this.omit(params, 'oneWayMode');
|
|
4207
4210
|
let requestSide = side;
|
|
4208
4211
|
if (reduceOnly) {
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4212
|
+
if (oneWayMode) {
|
|
4213
|
+
request['reduceOnly'] = 'YES';
|
|
4214
|
+
}
|
|
4215
|
+
else {
|
|
4216
|
+
// on bitget hedge mode if the position is long the side is always buy, and if the position is short the side is always sell
|
|
4217
|
+
requestSide = (side === 'buy') ? 'sell' : 'buy';
|
|
4218
|
+
request['tradeSide'] = 'Close';
|
|
4219
|
+
}
|
|
4213
4220
|
}
|
|
4214
4221
|
else {
|
|
4215
|
-
|
|
4222
|
+
if (!oneWayMode) {
|
|
4223
|
+
request['tradeSide'] = 'Open';
|
|
4224
|
+
}
|
|
4216
4225
|
}
|
|
4217
4226
|
request['side'] = requestSide;
|
|
4218
4227
|
}
|
package/js/src/bl3p.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bl3p.js';
|
|
2
|
-
import type { Balances, Int, Market, OrderBook, OrderSide, OrderType, Str, Ticker, Trade } from './base/types.js';
|
|
2
|
+
import type { Balances, Int, Market, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, IndexType } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class bl3p
|
|
5
5
|
* @augments Exchange
|
|
@@ -8,7 +8,7 @@ export default class bl3p extends Exchange {
|
|
|
8
8
|
describe(): any;
|
|
9
9
|
parseBalance(response: any): Balances;
|
|
10
10
|
fetchBalance(params?: {}): Promise<Balances>;
|
|
11
|
-
parseBidAsk(bidask: any, priceKey?:
|
|
11
|
+
parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
|
|
12
12
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
13
13
|
parseTicker(ticker: any, market?: Market): Ticker;
|
|
14
14
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
package/js/src/bl3p.js
CHANGED
|
@@ -149,7 +149,7 @@ export default class bl3p extends Exchange {
|
|
|
149
149
|
const response = await this.privatePostGENMKTMoneyInfo(params);
|
|
150
150
|
return this.parseBalance(response);
|
|
151
151
|
}
|
|
152
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
152
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
153
153
|
const price = this.safeString(bidask, priceKey);
|
|
154
154
|
const size = this.safeString(bidask, amountKey);
|
|
155
155
|
return [
|
package/js/src/btcalpha.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/btcalpha.js';
|
|
2
|
-
import type { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
|
|
2
|
+
import type { IndexType, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class btcalpha
|
|
5
5
|
* @augments Exchange
|
|
@@ -12,7 +12,7 @@ export default class btcalpha extends Exchange {
|
|
|
12
12
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
13
13
|
parseTicker(ticker: any, market?: Market): Ticker;
|
|
14
14
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
15
|
-
parseBidsAsks(bidasks: any, priceKey?:
|
|
15
|
+
parseBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): any[];
|
|
16
16
|
parseTrade(trade: any, market?: Market): Trade;
|
|
17
17
|
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
18
18
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
package/js/src/btcalpha.js
CHANGED
|
@@ -362,7 +362,7 @@ export default class btcalpha extends Exchange {
|
|
|
362
362
|
const response = await this.publicGetOrderbookPairName(this.extend(request, params));
|
|
363
363
|
return this.parseOrderBook(response, market['symbol'], undefined, 'buy', 'sell', 'price', 'amount');
|
|
364
364
|
}
|
|
365
|
-
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1) {
|
|
365
|
+
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
366
366
|
const result = [];
|
|
367
367
|
for (let i = 0; i < bidasks.length; i++) {
|
|
368
368
|
const bidask = bidasks[i];
|
package/js/src/bybit.js
CHANGED
|
@@ -319,7 +319,7 @@ export default class bybit extends Exchange {
|
|
|
319
319
|
'v5/asset/deposit/query-internal-record': 5,
|
|
320
320
|
'v5/asset/deposit/query-address': 10,
|
|
321
321
|
'v5/asset/deposit/query-sub-member-address': 10,
|
|
322
|
-
'v5/asset/coin/query-info':
|
|
322
|
+
'v5/asset/coin/query-info': 28,
|
|
323
323
|
'v5/asset/withdraw/query-record': 10,
|
|
324
324
|
'v5/asset/withdraw/withdrawable-amount': 5,
|
|
325
325
|
// user
|
package/js/src/cryptocom.js
CHANGED
|
@@ -773,6 +773,7 @@ export default class cryptocom extends Exchange {
|
|
|
773
773
|
// "p": "26386.00",
|
|
774
774
|
// "q": "0.00453",
|
|
775
775
|
// "t": 1686944282062,
|
|
776
|
+
// "tn" : 1704476468851524373,
|
|
776
777
|
// "d": "4611686018455979970",
|
|
777
778
|
// "i": "BTC_USD"
|
|
778
779
|
// },
|
|
@@ -1943,7 +1944,8 @@ export default class cryptocom extends Exchange {
|
|
|
1943
1944
|
// "s": "sell",
|
|
1944
1945
|
// "p": "26386.00",
|
|
1945
1946
|
// "q": "0.00453",
|
|
1946
|
-
// "
|
|
1947
|
+
// "tn": 1686944282062,
|
|
1948
|
+
// "tn": 1704476468851524373,
|
|
1947
1949
|
// "d": "4611686018455979970",
|
|
1948
1950
|
// "i": "BTC_USD"
|
|
1949
1951
|
// }
|