ccxt 4.1.1 → 4.1.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 +3 -3
- package/dist/ccxt.browser.js +545 -159
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +6 -0
- package/dist/cjs/src/binance.js +84 -0
- package/dist/cjs/src/bingx.js +140 -124
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/bitmart.js +176 -0
- package/dist/cjs/src/bitrue.js +1 -1
- package/dist/cjs/src/bybit.js +27 -8
- package/dist/cjs/src/coinbasepro.js +1 -0
- package/dist/cjs/src/deribit.js +1 -1
- package/dist/cjs/src/okx.js +27 -11
- package/dist/cjs/src/pro/binance.js +11 -5
- package/dist/cjs/src/pro/coinbasepro.js +70 -8
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/coinbaseprime.d.ts +1 -0
- package/js/src/abstract/coinbasepro.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +6 -0
- package/js/src/binance.js +84 -0
- package/js/src/bingx.js +140 -124
- package/js/src/bitget.js +1 -1
- package/js/src/bitmart.d.ts +3 -0
- package/js/src/bitmart.js +176 -0
- package/js/src/bitrue.js +1 -1
- package/js/src/bybit.js +27 -8
- package/js/src/coinbasepro.js +1 -0
- package/js/src/deribit.js +1 -1
- package/js/src/okx.js +27 -11
- package/js/src/pro/binance.js +11 -5
- package/js/src/pro/coinbasepro.d.ts +3 -24
- package/js/src/pro/coinbasepro.js +70 -8
- package/package.json +1 -1
- package/skip-tests.json +6 -1
package/dist/cjs/src/okx.js
CHANGED
|
@@ -2083,15 +2083,32 @@ class okx extends okx$1 {
|
|
|
2083
2083
|
defaultType = this.safeString(options, 'type', defaultType); // Candles or HistoryCandles
|
|
2084
2084
|
const type = this.safeString(params, 'type', defaultType);
|
|
2085
2085
|
params = this.omit(params, 'type');
|
|
2086
|
-
let method = 'publicGetMarket' + type;
|
|
2087
2086
|
const isHistoryCandles = (type === 'HistoryCandles');
|
|
2087
|
+
let response = undefined;
|
|
2088
2088
|
if (price === 'mark') {
|
|
2089
|
-
|
|
2089
|
+
if (isHistoryCandles) {
|
|
2090
|
+
response = await this.publicGetMarketHistoryMarkPriceCandles(this.extend(request, params));
|
|
2091
|
+
}
|
|
2092
|
+
else {
|
|
2093
|
+
response = await this.publicGetMarketMarkPriceCandles(this.extend(request, params));
|
|
2094
|
+
}
|
|
2090
2095
|
}
|
|
2091
2096
|
else if (price === 'index') {
|
|
2092
|
-
|
|
2097
|
+
if (isHistoryCandles) {
|
|
2098
|
+
response = await this.publicGetMarketHistoryIndexCandles(this.extend(request, params));
|
|
2099
|
+
}
|
|
2100
|
+
else {
|
|
2101
|
+
response = await this.publicGetMarketIndexCandles(this.extend(request, params));
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
else {
|
|
2105
|
+
if (isHistoryCandles) {
|
|
2106
|
+
response = await this.publicGetMarketHistoryCandles(this.extend(request, params));
|
|
2107
|
+
}
|
|
2108
|
+
else {
|
|
2109
|
+
response = await this.publicGetMarketCandles(this.extend(request, params));
|
|
2110
|
+
}
|
|
2093
2111
|
}
|
|
2094
|
-
const response = await this[method](this.extend(request, params));
|
|
2095
2112
|
//
|
|
2096
2113
|
// {
|
|
2097
2114
|
// "code": "0",
|
|
@@ -2303,17 +2320,16 @@ class okx extends okx$1 {
|
|
|
2303
2320
|
*/
|
|
2304
2321
|
await this.loadMarkets();
|
|
2305
2322
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
2306
|
-
|
|
2323
|
+
const request = {
|
|
2324
|
+
// 'ccy': 'BTC,ETH', // comma-separated list of currency ids
|
|
2325
|
+
};
|
|
2326
|
+
let response = undefined;
|
|
2307
2327
|
if (marketType === 'funding') {
|
|
2308
|
-
|
|
2328
|
+
response = await this.privateGetAssetBalances(this.extend(request, query));
|
|
2309
2329
|
}
|
|
2310
2330
|
else {
|
|
2311
|
-
|
|
2331
|
+
response = await this.privateGetAccountBalance(this.extend(request, query));
|
|
2312
2332
|
}
|
|
2313
|
-
const request = {
|
|
2314
|
-
// 'ccy': 'BTC,ETH', // comma-separated list of currency ids
|
|
2315
|
-
};
|
|
2316
|
-
const response = await this[method](this.extend(request, query));
|
|
2317
2333
|
//
|
|
2318
2334
|
// {
|
|
2319
2335
|
// "code": "0",
|
|
@@ -140,14 +140,20 @@ class binance extends binance$1 {
|
|
|
140
140
|
// valid <levels> are 5, 10, or 20
|
|
141
141
|
//
|
|
142
142
|
// default 100, max 1000, valid limits 5, 10, 20, 50, 100, 500, 1000
|
|
143
|
+
await this.loadMarkets();
|
|
144
|
+
const market = this.market(symbol);
|
|
143
145
|
if (limit !== undefined) {
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
+
if (market['contract']) {
|
|
147
|
+
if ((limit !== 5) && (limit !== 10) && (limit !== 20) && (limit !== 50) && (limit !== 100) && (limit !== 500) && (limit !== 1000)) {
|
|
148
|
+
throw new errors.ExchangeError(this.id + ' watchOrderBook limit argument must be undefined, 5, 10, 20, 50, 100, 500 or 1000');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
if (limit > 5000) {
|
|
153
|
+
throw new errors.ExchangeError(this.id + ' watchOrderBook limit argument must be less than or equal to 5000');
|
|
154
|
+
}
|
|
146
155
|
}
|
|
147
156
|
}
|
|
148
|
-
//
|
|
149
|
-
await this.loadMarkets();
|
|
150
|
-
const market = this.market(symbol);
|
|
151
157
|
let type = market['type'];
|
|
152
158
|
if (market['contract']) {
|
|
153
159
|
type = market['linear'] ? 'future' : 'delivery';
|
|
@@ -19,9 +19,11 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
19
19
|
'watchTickers': true,
|
|
20
20
|
'watchTrades': true,
|
|
21
21
|
'watchTradesForSymbols': true,
|
|
22
|
+
'watchMyTradesForSymbols': true,
|
|
22
23
|
'watchBalance': false,
|
|
23
24
|
'watchStatus': false,
|
|
24
25
|
'watchOrders': true,
|
|
26
|
+
'watchOrdersForSymbols': true,
|
|
25
27
|
'watchMyTrades': true,
|
|
26
28
|
},
|
|
27
29
|
'urls': {
|
|
@@ -209,6 +211,54 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
209
211
|
}
|
|
210
212
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
211
213
|
}
|
|
214
|
+
async watchMyTradesForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
215
|
+
/**
|
|
216
|
+
* @method
|
|
217
|
+
* @name coinbasepro#watchMyTradesForSymbols
|
|
218
|
+
* @description watches information on multiple trades made by the user
|
|
219
|
+
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
220
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
221
|
+
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
222
|
+
* @param {object} [params] extra parameters specific to the coinbasepro api endpoint
|
|
223
|
+
* @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure
|
|
224
|
+
*/
|
|
225
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
226
|
+
await this.loadMarkets();
|
|
227
|
+
const name = 'user';
|
|
228
|
+
const messageHash = 'multipleMyTrades::';
|
|
229
|
+
const authentication = this.authenticate();
|
|
230
|
+
const trades = await this.subscribeMultiple(name, symbols, messageHash, this.extend(params, authentication));
|
|
231
|
+
if (this.newUpdates) {
|
|
232
|
+
const first = this.safeValue(trades, 0);
|
|
233
|
+
const tradeSymbol = this.safeString(first, 'symbol');
|
|
234
|
+
limit = trades.getLimit(tradeSymbol, limit);
|
|
235
|
+
}
|
|
236
|
+
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
237
|
+
}
|
|
238
|
+
async watchOrdersForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
239
|
+
/**
|
|
240
|
+
* @method
|
|
241
|
+
* @name coinbasepro#watchOrdersForSymbols
|
|
242
|
+
* @description watches information on multiple orders made by the user
|
|
243
|
+
* @param {string[]} symbols unified symbol of the market to fetch orders for
|
|
244
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
245
|
+
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
246
|
+
* @param {object} [params] extra parameters specific to the coinbasepro api endpoint
|
|
247
|
+
* @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
248
|
+
*/
|
|
249
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
250
|
+
await this.loadMarkets();
|
|
251
|
+
const name = 'user';
|
|
252
|
+
const messageHash = 'multipleOrders::';
|
|
253
|
+
const authentication = this.authenticate();
|
|
254
|
+
const orders = await this.subscribeMultiple(name, symbols, messageHash, this.extend(params, authentication));
|
|
255
|
+
if (this.newUpdates) {
|
|
256
|
+
const first = this.safeValue(orders, 0);
|
|
257
|
+
const tradeSymbol = this.safeString(first, 'symbol');
|
|
258
|
+
limit = orders.getLimit(tradeSymbol, limit);
|
|
259
|
+
}
|
|
260
|
+
return this.filterBySinceLimit(orders, since, limit, 'timestamp', true);
|
|
261
|
+
}
|
|
212
262
|
async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
213
263
|
/**
|
|
214
264
|
* @method
|
|
@@ -348,6 +398,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
348
398
|
const marketId = this.safeString(message, 'product_id');
|
|
349
399
|
if (marketId !== undefined) {
|
|
350
400
|
const trade = this.parseWsTrade(message);
|
|
401
|
+
const symbol = trade['symbol'];
|
|
351
402
|
const type = 'myTrades';
|
|
352
403
|
const messageHash = type + ':' + marketId;
|
|
353
404
|
let tradesArray = this.myTrades;
|
|
@@ -358,6 +409,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
358
409
|
}
|
|
359
410
|
tradesArray.append(trade);
|
|
360
411
|
client.resolve(tradesArray, messageHash);
|
|
412
|
+
this.resolvePromiseIfMessagehashMatches(client, 'multipleMyTrades::', symbol, tradesArray);
|
|
361
413
|
}
|
|
362
414
|
return message;
|
|
363
415
|
}
|
|
@@ -414,14 +466,25 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
414
466
|
// }
|
|
415
467
|
const parsed = super.parseTrade(trade);
|
|
416
468
|
let feeRate = undefined;
|
|
469
|
+
let isMaker = false;
|
|
417
470
|
if ('maker_fee_rate' in trade) {
|
|
471
|
+
isMaker = true;
|
|
418
472
|
parsed['takerOrMaker'] = 'maker';
|
|
419
473
|
feeRate = this.safeNumber(trade, 'maker_fee_rate');
|
|
420
474
|
}
|
|
421
475
|
else {
|
|
422
476
|
parsed['takerOrMaker'] = 'taker';
|
|
423
477
|
feeRate = this.safeNumber(trade, 'taker_fee_rate');
|
|
424
|
-
|
|
478
|
+
// side always represents the maker side of the trade
|
|
479
|
+
// so if we're taker, we invert it
|
|
480
|
+
const currentSide = parsed['side'];
|
|
481
|
+
parsed['side'] = this.safeString({
|
|
482
|
+
'buy': 'sell',
|
|
483
|
+
'sell': 'buy',
|
|
484
|
+
}, currentSide, currentSide);
|
|
485
|
+
}
|
|
486
|
+
const idKey = isMaker ? 'maker_order_id' : 'taker_order_id';
|
|
487
|
+
parsed['order'] = this.safeString(trade, idKey);
|
|
425
488
|
market = this.market(parsed['symbol']);
|
|
426
489
|
const feeCurrency = market['quote'];
|
|
427
490
|
let feeCost = undefined;
|
|
@@ -547,6 +610,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
547
610
|
const parsed = this.parseWsOrder(message);
|
|
548
611
|
orders.append(parsed);
|
|
549
612
|
client.resolve(orders, messageHash);
|
|
613
|
+
this.resolvePromiseIfMessagehashMatches(client, 'multipleOrders::', symbol, orders);
|
|
550
614
|
}
|
|
551
615
|
else {
|
|
552
616
|
const sequence = this.safeInteger(message, 'sequence');
|
|
@@ -590,6 +654,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
590
654
|
// update the newUpdates count
|
|
591
655
|
orders.append(previousOrder);
|
|
592
656
|
client.resolve(orders, messageHash);
|
|
657
|
+
this.resolvePromiseIfMessagehashMatches(client, 'multipleOrders::', symbol, orders);
|
|
593
658
|
}
|
|
594
659
|
else if ((type === 'received') || (type === 'done')) {
|
|
595
660
|
const info = this.extend(previousOrder['info'], message);
|
|
@@ -605,6 +670,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
605
670
|
// update the newUpdates count
|
|
606
671
|
orders.append(previousOrder);
|
|
607
672
|
client.resolve(orders, messageHash);
|
|
673
|
+
this.resolvePromiseIfMessagehashMatches(client, 'multipleOrders::', symbol, orders);
|
|
608
674
|
}
|
|
609
675
|
}
|
|
610
676
|
}
|
|
@@ -635,11 +701,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
635
701
|
remaining = amount - filled;
|
|
636
702
|
}
|
|
637
703
|
}
|
|
638
|
-
|
|
639
|
-
if ((price !== undefined) && (amount !== undefined)) {
|
|
640
|
-
cost = price * amount;
|
|
641
|
-
}
|
|
642
|
-
return {
|
|
704
|
+
return this.safeOrder({
|
|
643
705
|
'info': order,
|
|
644
706
|
'symbol': symbol,
|
|
645
707
|
'id': id,
|
|
@@ -655,14 +717,14 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
655
717
|
'stopPrice': undefined,
|
|
656
718
|
'triggerPrice': undefined,
|
|
657
719
|
'amount': amount,
|
|
658
|
-
'cost':
|
|
720
|
+
'cost': undefined,
|
|
659
721
|
'average': undefined,
|
|
660
722
|
'filled': filled,
|
|
661
723
|
'remaining': remaining,
|
|
662
724
|
'status': status,
|
|
663
725
|
'fee': undefined,
|
|
664
726
|
'trades': undefined,
|
|
665
|
-
};
|
|
727
|
+
});
|
|
666
728
|
}
|
|
667
729
|
handleTicker(client, message) {
|
|
668
730
|
//
|
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position } 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.1.
|
|
7
|
+
declare const version = "4.1.2";
|
|
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.1.
|
|
41
|
+
const version = '4.1.3';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -11,6 +11,7 @@ interface coinbasepro {
|
|
|
11
11
|
publicGetProductsIdTrades(params?: {}): Promise<implicitReturnType>;
|
|
12
12
|
publicGetTime(params?: {}): Promise<implicitReturnType>;
|
|
13
13
|
publicGetProductsSparkLines(params?: {}): Promise<implicitReturnType>;
|
|
14
|
+
privateGetAddressBook(params?: {}): Promise<implicitReturnType>;
|
|
14
15
|
privateGetAccounts(params?: {}): Promise<implicitReturnType>;
|
|
15
16
|
privateGetAccountsId(params?: {}): Promise<implicitReturnType>;
|
|
16
17
|
privateGetAccountsIdHolds(params?: {}): Promise<implicitReturnType>;
|
|
@@ -11,6 +11,7 @@ interface Exchange {
|
|
|
11
11
|
publicGetProductsIdTrades(params?: {}): Promise<implicitReturnType>;
|
|
12
12
|
publicGetTime(params?: {}): Promise<implicitReturnType>;
|
|
13
13
|
publicGetProductsSparkLines(params?: {}): Promise<implicitReturnType>;
|
|
14
|
+
privateGetAddressBook(params?: {}): Promise<implicitReturnType>;
|
|
14
15
|
privateGetAccounts(params?: {}): Promise<implicitReturnType>;
|
|
15
16
|
privateGetAccountsId(params?: {}): Promise<implicitReturnType>;
|
|
16
17
|
privateGetAccountsIdHolds(params?: {}): Promise<implicitReturnType>;
|
|
@@ -535,6 +535,8 @@ export default class Exchange {
|
|
|
535
535
|
fetchTradesWs(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
536
536
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
537
537
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
538
|
+
watchMyTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
539
|
+
watchOrdersForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
538
540
|
watchOHLCVForSymbols(symbolsAndTimeframes: string[][], since?: Int, limit?: Int, params?: {}): Promise<Dictionary<Dictionary<OHLCV[]>>>;
|
|
539
541
|
watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
|
|
540
542
|
fetchDepositAddresses(codes?: string[], params?: {}): Promise<any>;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -1304,6 +1304,12 @@ export default class Exchange {
|
|
|
1304
1304
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
1305
1305
|
throw new NotSupported(this.id + ' watchTradesForSymbols() is not supported yet');
|
|
1306
1306
|
}
|
|
1307
|
+
async watchMyTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
1308
|
+
throw new NotSupported(this.id + ' watchMyTradesForSymbols() is not supported yet');
|
|
1309
|
+
}
|
|
1310
|
+
async watchOrdersForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
1311
|
+
throw new NotSupported(this.id + ' watchOrdersForSymbols() is not supported yet');
|
|
1312
|
+
}
|
|
1307
1313
|
async watchOHLCVForSymbols(symbolsAndTimeframes, since = undefined, limit = undefined, params = {}) {
|
|
1308
1314
|
throw new NotSupported(this.id + ' watchOHLCVForSymbols() is not supported yet');
|
|
1309
1315
|
}
|