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
package/dist/cjs/ccxt.js
CHANGED
|
@@ -169,7 +169,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
169
169
|
|
|
170
170
|
//-----------------------------------------------------------------------------
|
|
171
171
|
// this is updated by vss.js when building
|
|
172
|
-
const version = '4.2.
|
|
172
|
+
const version = '4.2.10';
|
|
173
173
|
Exchange["default"].ccxtVersion = version;
|
|
174
174
|
const exchanges = {
|
|
175
175
|
'ace': ace,
|
|
@@ -2862,11 +2862,11 @@ class Exchange {
|
|
|
2862
2862
|
}
|
|
2863
2863
|
return result;
|
|
2864
2864
|
}
|
|
2865
|
-
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1) {
|
|
2865
|
+
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
2866
2866
|
bidasks = this.toArray(bidasks);
|
|
2867
2867
|
const result = [];
|
|
2868
2868
|
for (let i = 0; i < bidasks.length; i++) {
|
|
2869
|
-
result.push(this.parseBidAsk(bidasks[i], priceKey, amountKey));
|
|
2869
|
+
result.push(this.parseBidAsk(bidasks[i], priceKey, amountKey, countOrIdKey));
|
|
2870
2870
|
}
|
|
2871
2871
|
return result;
|
|
2872
2872
|
}
|
|
@@ -3035,9 +3035,9 @@ class Exchange {
|
|
|
3035
3035
|
const value = this.safeString2(dictionary, key1, key2);
|
|
3036
3036
|
return this.parseNumber(value, d);
|
|
3037
3037
|
}
|
|
3038
|
-
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1) {
|
|
3039
|
-
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey);
|
|
3040
|
-
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey);
|
|
3038
|
+
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
3039
|
+
const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey, countOrIdKey);
|
|
3040
|
+
const asks = this.parseBidsAsks(this.safeValue(orderbook, asksKey, []), priceKey, amountKey, countOrIdKey);
|
|
3041
3041
|
return {
|
|
3042
3042
|
'symbol': symbol,
|
|
3043
3043
|
'bids': this.sortBy(bids, 0, true),
|
|
@@ -3352,10 +3352,15 @@ class Exchange {
|
|
|
3352
3352
|
async fetchBidsAsks(symbols = undefined, params = {}) {
|
|
3353
3353
|
throw new errors.NotSupported(this.id + ' fetchBidsAsks() is not supported yet');
|
|
3354
3354
|
}
|
|
3355
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
3355
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
3356
3356
|
const price = this.safeNumber(bidask, priceKey);
|
|
3357
3357
|
const amount = this.safeNumber(bidask, amountKey);
|
|
3358
|
-
|
|
3358
|
+
const countOrId = this.safeInteger(bidask, countOrIdKey);
|
|
3359
|
+
const bidAsk = [price, amount];
|
|
3360
|
+
if (countOrId !== undefined) {
|
|
3361
|
+
bidAsk.push(countOrId);
|
|
3362
|
+
}
|
|
3363
|
+
return bidAsk;
|
|
3359
3364
|
}
|
|
3360
3365
|
safeCurrency(currencyId, currency = undefined) {
|
|
3361
3366
|
if ((currencyId === undefined) && (currency !== undefined)) {
|
|
@@ -3403,7 +3408,7 @@ class Exchange {
|
|
|
3403
3408
|
}
|
|
3404
3409
|
}
|
|
3405
3410
|
}
|
|
3406
|
-
else if (delimiter !== undefined) {
|
|
3411
|
+
else if (delimiter !== undefined && delimiter !== '') {
|
|
3407
3412
|
const parts = marketId.split(delimiter);
|
|
3408
3413
|
const partsLength = parts.length;
|
|
3409
3414
|
if (partsLength === 2) {
|
|
@@ -3564,6 +3569,30 @@ class Exchange {
|
|
|
3564
3569
|
}
|
|
3565
3570
|
return [value, params];
|
|
3566
3571
|
}
|
|
3572
|
+
handleOptionAndParams2(params, methodName, methodName2, optionName, defaultValue = undefined) {
|
|
3573
|
+
// This method can be used to obtain method specific properties, i.e: this.handleOptionAndParams (params, 'fetchPosition', 'marginMode', 'isolated')
|
|
3574
|
+
const defaultOptionName = 'default' + this.capitalize(optionName); // we also need to check the 'defaultXyzWhatever'
|
|
3575
|
+
// check if params contain the key
|
|
3576
|
+
let value = this.safeValue2(params, optionName, defaultOptionName);
|
|
3577
|
+
if (value !== undefined) {
|
|
3578
|
+
params = this.omit(params, [optionName, defaultOptionName]);
|
|
3579
|
+
}
|
|
3580
|
+
else {
|
|
3581
|
+
// check if exchange has properties for this method
|
|
3582
|
+
const exchangeWideMethodOptions = this.safeValue2(this.options, methodName, methodName2);
|
|
3583
|
+
if (exchangeWideMethodOptions !== undefined) {
|
|
3584
|
+
// check if the option is defined inside this method's props
|
|
3585
|
+
value = this.safeValue2(exchangeWideMethodOptions, optionName, defaultOptionName);
|
|
3586
|
+
}
|
|
3587
|
+
if (value === undefined) {
|
|
3588
|
+
// if it's still undefined, check if global exchange-wide option exists
|
|
3589
|
+
value = this.safeValue2(this.options, optionName, defaultOptionName);
|
|
3590
|
+
}
|
|
3591
|
+
// if it's still undefined, use the default value
|
|
3592
|
+
value = (value !== undefined) ? value : defaultValue;
|
|
3593
|
+
}
|
|
3594
|
+
return [value, params];
|
|
3595
|
+
}
|
|
3567
3596
|
handleOption(methodName, optionName, defaultValue = undefined) {
|
|
3568
3597
|
// eslint-disable-next-line no-unused-vars
|
|
3569
3598
|
const [result, empty] = this.handleOptionAndParams({}, methodName, optionName, defaultValue);
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -3145,7 +3145,12 @@ class binance extends binance$1 {
|
|
|
3145
3145
|
response = await this.dapiPublicGetTickerBookTicker(params);
|
|
3146
3146
|
}
|
|
3147
3147
|
else {
|
|
3148
|
-
|
|
3148
|
+
const request = {};
|
|
3149
|
+
if (symbols !== undefined) {
|
|
3150
|
+
const marketIds = this.marketIds(symbols);
|
|
3151
|
+
request['symbols'] = this.json(marketIds);
|
|
3152
|
+
}
|
|
3153
|
+
response = await this.publicGetTickerBookTicker(this.extend(request, params));
|
|
3149
3154
|
}
|
|
3150
3155
|
return this.parseTickers(response, symbols);
|
|
3151
3156
|
}
|
package/dist/cjs/src/bitmart.js
CHANGED
|
@@ -306,7 +306,11 @@ class bitmart extends bitmart$1 {
|
|
|
306
306
|
'30012': errors.AuthenticationError,
|
|
307
307
|
'30013': errors.RateLimitExceeded,
|
|
308
308
|
'30014': errors.ExchangeNotAvailable,
|
|
309
|
-
|
|
309
|
+
'30016': errors.OnMaintenance,
|
|
310
|
+
'30017': errors.RateLimitExceeded,
|
|
311
|
+
'30018': errors.BadRequest,
|
|
312
|
+
'30019': errors.PermissionDenied,
|
|
313
|
+
// funding account & sub account errors
|
|
310
314
|
'60000': errors.BadRequest,
|
|
311
315
|
'60001': errors.BadRequest,
|
|
312
316
|
'60002': errors.BadRequest,
|
|
@@ -323,13 +327,31 @@ class bitmart extends bitmart$1 {
|
|
|
323
327
|
'60020': errors.PermissionDenied,
|
|
324
328
|
'60021': errors.PermissionDenied,
|
|
325
329
|
'60022': errors.PermissionDenied,
|
|
330
|
+
'60026': errors.PermissionDenied,
|
|
331
|
+
'60027': errors.PermissionDenied,
|
|
332
|
+
'60028': errors.AccountSuspended,
|
|
333
|
+
'60029': errors.AccountSuspended,
|
|
326
334
|
'60030': errors.BadRequest,
|
|
327
335
|
'60031': errors.BadRequest,
|
|
328
336
|
'60050': errors.ExchangeError,
|
|
329
337
|
'60051': errors.ExchangeError,
|
|
330
338
|
'61001': errors.InsufficientFunds,
|
|
331
339
|
'61003': errors.BadRequest,
|
|
332
|
-
|
|
340
|
+
'61004': errors.BadRequest,
|
|
341
|
+
'61005': errors.BadRequest,
|
|
342
|
+
'61006': errors.NotSupported,
|
|
343
|
+
'61007': errors.ExchangeError,
|
|
344
|
+
'61008': errors.ExchangeError,
|
|
345
|
+
// spot public errors
|
|
346
|
+
'70000': errors.ExchangeError,
|
|
347
|
+
'70001': errors.BadRequest,
|
|
348
|
+
'70002': errors.BadSymbol,
|
|
349
|
+
'71001': errors.BadRequest,
|
|
350
|
+
'71002': errors.BadRequest,
|
|
351
|
+
'71003': errors.BadRequest,
|
|
352
|
+
'71004': errors.BadRequest,
|
|
353
|
+
'71005': errors.BadRequest,
|
|
354
|
+
// spot & margin errors
|
|
333
355
|
'50000': errors.BadRequest,
|
|
334
356
|
'50001': errors.BadSymbol,
|
|
335
357
|
'50002': errors.BadRequest,
|
|
@@ -349,26 +371,75 @@ class bitmart extends bitmart$1 {
|
|
|
349
371
|
'50016': errors.BadRequest,
|
|
350
372
|
'50017': errors.BadRequest,
|
|
351
373
|
'50018': errors.BadRequest,
|
|
352
|
-
'50019': errors.
|
|
353
|
-
'51004': errors.InsufficientFunds,
|
|
354
|
-
// '50019': ExchangeError, // 400, Invalid status. validate status is [1=Failed, 2=Success, 3=Frozen Failed, 4=Frozen Success, 5=Partially Filled, 6=Fully Fulled, 7=Canceling, 8=Canceled
|
|
374
|
+
'50019': errors.ExchangeError,
|
|
355
375
|
'50020': errors.InsufficientFunds,
|
|
356
376
|
'50021': errors.BadRequest,
|
|
357
377
|
'50022': errors.ExchangeNotAvailable,
|
|
358
378
|
'50023': errors.BadSymbol,
|
|
379
|
+
'50024': errors.BadRequest,
|
|
380
|
+
'50025': errors.BadRequest,
|
|
381
|
+
'50026': errors.BadRequest,
|
|
382
|
+
'50027': errors.BadRequest,
|
|
383
|
+
'50028': errors.BadRequest,
|
|
359
384
|
'50029': errors.InvalidOrder,
|
|
360
|
-
'50030': errors.
|
|
385
|
+
'50030': errors.OrderNotFound,
|
|
386
|
+
'50031': errors.OrderNotFound,
|
|
361
387
|
'50032': errors.OrderNotFound,
|
|
388
|
+
'50033': errors.InvalidOrder,
|
|
362
389
|
// below Error codes used interchangeably for both failed postOnly and IOC orders depending on market price and order side
|
|
363
|
-
'50035': errors.InvalidOrder,
|
|
364
390
|
'50034': errors.InvalidOrder,
|
|
391
|
+
'50035': errors.InvalidOrder,
|
|
392
|
+
'50036': errors.ExchangeError,
|
|
393
|
+
'50037': errors.BadRequest,
|
|
394
|
+
'50038': errors.BadRequest,
|
|
395
|
+
'50039': errors.BadRequest,
|
|
396
|
+
'50040': errors.BadSymbol,
|
|
397
|
+
'50041': errors.ExchangeError,
|
|
398
|
+
'50042': errors.BadRequest,
|
|
399
|
+
'51000': errors.BadSymbol,
|
|
400
|
+
'51001': errors.ExchangeError,
|
|
401
|
+
'51002': errors.ExchangeError,
|
|
402
|
+
'51003': errors.ExchangeError,
|
|
403
|
+
'51004': errors.InsufficientFunds,
|
|
404
|
+
'51005': errors.InvalidOrder,
|
|
405
|
+
'51006': errors.InvalidOrder,
|
|
406
|
+
'51007': errors.BadRequest,
|
|
407
|
+
'51008': errors.ExchangeError,
|
|
408
|
+
'51009': errors.InvalidOrder,
|
|
409
|
+
'51010': errors.InvalidOrder,
|
|
365
410
|
'51011': errors.InvalidOrder,
|
|
411
|
+
'51012': errors.InvalidOrder,
|
|
412
|
+
'51013': errors.InvalidOrder,
|
|
413
|
+
'51014': errors.InvalidOrder,
|
|
414
|
+
'51015': errors.InvalidOrder,
|
|
415
|
+
'52000': errors.BadRequest,
|
|
416
|
+
'52001': errors.BadRequest,
|
|
417
|
+
'52002': errors.BadRequest,
|
|
418
|
+
'52003': errors.BadRequest,
|
|
419
|
+
'52004': errors.BadRequest,
|
|
366
420
|
'53000': errors.AccountSuspended,
|
|
367
421
|
'53001': errors.AccountSuspended,
|
|
422
|
+
'53002': errors.PermissionDenied,
|
|
423
|
+
'53003': errors.PermissionDenied,
|
|
424
|
+
'53005': errors.PermissionDenied,
|
|
425
|
+
'53006': errors.PermissionDenied,
|
|
426
|
+
'53007': errors.PermissionDenied,
|
|
427
|
+
'53008': errors.PermissionDenied,
|
|
428
|
+
'53009': errors.PermissionDenied,
|
|
429
|
+
'53010': errors.PermissionDenied,
|
|
368
430
|
'57001': errors.BadRequest,
|
|
369
431
|
'58001': errors.BadRequest,
|
|
370
432
|
'59001': errors.ExchangeError,
|
|
371
433
|
'59002': errors.ExchangeError,
|
|
434
|
+
'59003': errors.ExchangeError,
|
|
435
|
+
'59004': errors.ExchangeError,
|
|
436
|
+
'59005': errors.PermissionDenied,
|
|
437
|
+
'59006': errors.ExchangeError,
|
|
438
|
+
'59007': errors.ExchangeError,
|
|
439
|
+
'59008': errors.ExchangeError,
|
|
440
|
+
'59009': errors.ExchangeError,
|
|
441
|
+
'59010': errors.InsufficientFunds,
|
|
442
|
+
'59011': errors.ExchangeError,
|
|
372
443
|
// contract errors
|
|
373
444
|
'40001': errors.ExchangeError,
|
|
374
445
|
'40002': errors.ExchangeError,
|
|
@@ -404,14 +475,22 @@ class bitmart extends bitmart$1 {
|
|
|
404
475
|
'40032': errors.InvalidOrder,
|
|
405
476
|
'40033': errors.InvalidOrder,
|
|
406
477
|
'40034': errors.BadSymbol,
|
|
407
|
-
'
|
|
408
|
-
'
|
|
409
|
-
'
|
|
410
|
-
'
|
|
411
|
-
'
|
|
412
|
-
'
|
|
413
|
-
'
|
|
414
|
-
'
|
|
478
|
+
'40035': errors.OrderNotFound,
|
|
479
|
+
'40036': errors.InvalidOrder,
|
|
480
|
+
'40037': errors.OrderNotFound,
|
|
481
|
+
'40038': errors.BadRequest,
|
|
482
|
+
'40039': errors.BadRequest,
|
|
483
|
+
'40040': errors.InvalidOrder,
|
|
484
|
+
'40041': errors.InvalidOrder,
|
|
485
|
+
'40042': errors.InvalidOrder,
|
|
486
|
+
'40043': errors.InvalidOrder,
|
|
487
|
+
'40044': errors.InvalidOrder,
|
|
488
|
+
'40045': errors.InvalidOrder,
|
|
489
|
+
'40046': errors.PermissionDenied,
|
|
490
|
+
'40047': errors.PermissionDenied,
|
|
491
|
+
'40048': errors.BadRequest,
|
|
492
|
+
'40049': errors.BadRequest,
|
|
493
|
+
'40050': errors.InvalidOrder, // 403, Client OrderId duplicated with existing orders
|
|
415
494
|
},
|
|
416
495
|
'broad': {},
|
|
417
496
|
},
|
package/dist/cjs/src/bl3p.js
CHANGED
|
@@ -146,7 +146,7 @@ class bl3p extends bl3p$1 {
|
|
|
146
146
|
const response = await this.privatePostGENMKTMoneyInfo(params);
|
|
147
147
|
return this.parseBalance(response);
|
|
148
148
|
}
|
|
149
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
149
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
150
150
|
const price = this.safeString(bidask, priceKey);
|
|
151
151
|
const size = this.safeString(bidask, amountKey);
|
|
152
152
|
return [
|
package/dist/cjs/src/btcalpha.js
CHANGED
|
@@ -359,7 +359,7 @@ class btcalpha extends btcalpha$1 {
|
|
|
359
359
|
const response = await this.publicGetOrderbookPairName(this.extend(request, params));
|
|
360
360
|
return this.parseOrderBook(response, market['symbol'], undefined, 'buy', 'sell', 'price', 'amount');
|
|
361
361
|
}
|
|
362
|
-
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1) {
|
|
362
|
+
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
363
363
|
const result = [];
|
|
364
364
|
for (let i = 0; i < bidasks.length; i++) {
|
|
365
365
|
const bidask = bidasks[i];
|
|
@@ -770,6 +770,7 @@ class cryptocom extends cryptocom$1 {
|
|
|
770
770
|
// "p": "26386.00",
|
|
771
771
|
// "q": "0.00453",
|
|
772
772
|
// "t": 1686944282062,
|
|
773
|
+
// "tn" : 1704476468851524373,
|
|
773
774
|
// "d": "4611686018455979970",
|
|
774
775
|
// "i": "BTC_USD"
|
|
775
776
|
// },
|
|
@@ -1940,7 +1941,8 @@ class cryptocom extends cryptocom$1 {
|
|
|
1940
1941
|
// "s": "sell",
|
|
1941
1942
|
// "p": "26386.00",
|
|
1942
1943
|
// "q": "0.00453",
|
|
1943
|
-
// "
|
|
1944
|
+
// "tn": 1686944282062,
|
|
1945
|
+
// "tn": 1704476468851524373,
|
|
1944
1946
|
// "d": "4611686018455979970",
|
|
1945
1947
|
// "i": "BTC_USD"
|
|
1946
1948
|
// }
|
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -1723,27 +1723,18 @@ class deribit extends deribit$1 {
|
|
|
1723
1723
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
1724
1724
|
* @param {string} type 'market' or 'limit'
|
|
1725
1725
|
* @param {string} side 'buy' or 'sell'
|
|
1726
|
-
* @param {float} amount how much
|
|
1726
|
+
* @param {float} amount how much you want to trade in units of the base currency. For inverse perpetual and futures the amount is in the quote currency USD. For options it is in the underlying assets base currency.
|
|
1727
1727
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1728
1728
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1729
|
+
* @param {string} [params.trigger] the trigger type 'index_price', 'mark_price', or 'last_price', default is 'last_price'
|
|
1730
|
+
* @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
1729
1731
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1730
1732
|
*/
|
|
1731
1733
|
await this.loadMarkets();
|
|
1732
1734
|
const market = this.market(symbol);
|
|
1733
|
-
if (market['inverse']) {
|
|
1734
|
-
amount = this.amountToPrecision(symbol, amount);
|
|
1735
|
-
}
|
|
1736
|
-
else if (market['settle'] === 'USDC') {
|
|
1737
|
-
amount = this.amountToPrecision(symbol, amount);
|
|
1738
|
-
}
|
|
1739
|
-
else {
|
|
1740
|
-
amount = this.currencyToPrecision(symbol, amount);
|
|
1741
|
-
}
|
|
1742
1735
|
const request = {
|
|
1743
1736
|
'instrument_name': market['id'],
|
|
1744
|
-
|
|
1745
|
-
// for options it is in corresponding cryptocurrency contracts, e.g., BTC or ETH
|
|
1746
|
-
'amount': amount,
|
|
1737
|
+
'amount': this.amountToPrecision(symbol, amount),
|
|
1747
1738
|
'type': type, // limit, stop_limit, market, stop_market, default is limit
|
|
1748
1739
|
// 'label': 'string', // user-defined label for the order (maximum 64 characters)
|
|
1749
1740
|
// 'price': this.priceToPrecision (symbol, 123.45), // only for limit and stop_limit orders
|
|
@@ -1756,12 +1747,15 @@ class deribit extends deribit$1 {
|
|
|
1756
1747
|
// 'trigger': 'index_price', // mark_price, last_price, required for stop_limit orders
|
|
1757
1748
|
// 'advanced': 'usd', // 'implv', advanced option order type, options only
|
|
1758
1749
|
};
|
|
1750
|
+
const trigger = this.safeString(params, 'trigger', 'last_price');
|
|
1759
1751
|
const timeInForce = this.safeStringUpper(params, 'timeInForce');
|
|
1760
1752
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
|
|
1761
1753
|
// only stop loss sell orders are allowed when price crossed from above
|
|
1762
1754
|
const stopLossPrice = this.safeValue(params, 'stopLossPrice');
|
|
1763
1755
|
// only take profit buy orders are allowed when price crossed from below
|
|
1764
1756
|
const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
|
|
1757
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trigger_offset');
|
|
1758
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
1765
1759
|
const isStopLimit = type === 'stop_limit';
|
|
1766
1760
|
const isStopMarket = type === 'stop_market';
|
|
1767
1761
|
const isTakeLimit = type === 'take_limit';
|
|
@@ -1783,10 +1777,15 @@ class deribit extends deribit$1 {
|
|
|
1783
1777
|
else {
|
|
1784
1778
|
request['type'] = 'market';
|
|
1785
1779
|
}
|
|
1786
|
-
if (
|
|
1780
|
+
if (isTrailingAmountOrder) {
|
|
1781
|
+
request['trigger'] = trigger;
|
|
1782
|
+
request['type'] = 'trailing_stop';
|
|
1783
|
+
request['trigger_offset'] = this.parseToNumeric(trailingAmount);
|
|
1784
|
+
}
|
|
1785
|
+
else if (isStopOrder) {
|
|
1787
1786
|
const triggerPrice = (stopLossPrice !== undefined) ? stopLossPrice : takeProfitPrice;
|
|
1788
1787
|
request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
|
|
1789
|
-
request['trigger'] =
|
|
1788
|
+
request['trigger'] = trigger;
|
|
1790
1789
|
if (isStopLossOrder) {
|
|
1791
1790
|
if (isMarketOrder) {
|
|
1792
1791
|
// stop_market (sell only)
|
|
@@ -1826,7 +1825,7 @@ class deribit extends deribit$1 {
|
|
|
1826
1825
|
request['time_in_force'] = 'fill_or_kill';
|
|
1827
1826
|
}
|
|
1828
1827
|
}
|
|
1829
|
-
params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly']);
|
|
1828
|
+
params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly', 'trailingAmount']);
|
|
1830
1829
|
let response = undefined;
|
|
1831
1830
|
if (this.capitalize(side) === 'Buy') {
|
|
1832
1831
|
response = await this.privateGetBuy(this.extend(request, params));
|
|
@@ -1893,25 +1892,43 @@ class deribit extends deribit$1 {
|
|
|
1893
1892
|
return this.parseOrder(order, market);
|
|
1894
1893
|
}
|
|
1895
1894
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
1895
|
+
/**
|
|
1896
|
+
* @method
|
|
1897
|
+
* @name deribit#editOrder
|
|
1898
|
+
* @description edit a trade order
|
|
1899
|
+
* @see https://docs.deribit.com/#private-edit
|
|
1900
|
+
* @param {string} id edit order id
|
|
1901
|
+
* @param {string} [symbol] unified symbol of the market to edit an order in
|
|
1902
|
+
* @param {string} [type] 'market' or 'limit'
|
|
1903
|
+
* @param {string} [side] 'buy' or 'sell'
|
|
1904
|
+
* @param {float} amount how much you want to trade in units of the base currency, inverse swap and future use the quote currency
|
|
1905
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
|
|
1906
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1907
|
+
* @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
1908
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1909
|
+
*/
|
|
1896
1910
|
if (amount === undefined) {
|
|
1897
1911
|
throw new errors.ArgumentsRequired(this.id + ' editOrder() requires an amount argument');
|
|
1898
1912
|
}
|
|
1899
|
-
if (price === undefined) {
|
|
1900
|
-
throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a price argument');
|
|
1901
|
-
}
|
|
1902
1913
|
await this.loadMarkets();
|
|
1903
1914
|
const request = {
|
|
1904
1915
|
'order_id': id,
|
|
1905
|
-
// for perpetual and futures the amount is in USD
|
|
1906
|
-
// for options it is in corresponding cryptocurrency contracts, e.g., BTC or ETH
|
|
1907
1916
|
'amount': this.amountToPrecision(symbol, amount),
|
|
1908
|
-
'price': this.priceToPrecision(symbol, price), // required
|
|
1909
1917
|
// 'post_only': false, // if the new price would cause the order to be filled immediately (as taker), the price will be changed to be just below the spread.
|
|
1910
1918
|
// 'reject_post_only': false, // if true the order is put to order book unmodified or request is rejected
|
|
1911
1919
|
// 'reduce_only': false, // if true, the order is intended to only reduce a current position
|
|
1912
1920
|
// 'stop_price': false, // stop price, required for stop_limit orders
|
|
1913
1921
|
// 'advanced': 'usd', // 'implv', advanced option order type, options only
|
|
1914
1922
|
};
|
|
1923
|
+
if (price !== undefined) {
|
|
1924
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
1925
|
+
}
|
|
1926
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trigger_offset');
|
|
1927
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
1928
|
+
if (isTrailingAmountOrder) {
|
|
1929
|
+
request['trigger_offset'] = this.parseToNumeric(trailingAmount);
|
|
1930
|
+
params = this.omit(params, 'trigger_offset');
|
|
1931
|
+
}
|
|
1915
1932
|
const response = await this.privateGetEdit(this.extend(request, params));
|
|
1916
1933
|
const result = this.safeValue(response, 'result', {});
|
|
1917
1934
|
const order = this.safeValue(result, 'order');
|
package/dist/cjs/src/kraken.js
CHANGED
|
@@ -751,7 +751,7 @@ class kraken extends kraken$1 {
|
|
|
751
751
|
'tierBased': true,
|
|
752
752
|
};
|
|
753
753
|
}
|
|
754
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
754
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
755
755
|
const price = this.safeNumber(bidask, priceKey);
|
|
756
756
|
const amount = this.safeNumber(bidask, amountKey);
|
|
757
757
|
const timestamp = this.safeInteger(bidask, 2);
|
package/dist/cjs/src/kucoin.js
CHANGED
|
@@ -2419,7 +2419,7 @@ class kucoin extends kucoin$1 {
|
|
|
2419
2419
|
// }
|
|
2420
2420
|
// }
|
|
2421
2421
|
const responseData = this.safeValue(response, 'data', {});
|
|
2422
|
-
const orders = this.safeValue(responseData, 'items',
|
|
2422
|
+
const orders = this.safeValue(responseData, 'items', responseData);
|
|
2423
2423
|
return this.parseOrders(orders, market, since, limit);
|
|
2424
2424
|
}
|
|
2425
2425
|
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
package/dist/cjs/src/lykke.js
CHANGED
|
@@ -1078,7 +1078,7 @@ class lykke extends lykke$1 {
|
|
|
1078
1078
|
//
|
|
1079
1079
|
return this.parseTrades(payload, market, since, limit);
|
|
1080
1080
|
}
|
|
1081
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
|
|
1081
|
+
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
1082
1082
|
const price = this.safeString(bidask, priceKey);
|
|
1083
1083
|
const amount = Precise["default"].stringAbs(this.safeString(bidask, amountKey));
|
|
1084
1084
|
return [this.parseNumber(price), this.parseNumber(amount)];
|
package/dist/cjs/src/ndax.js
CHANGED
|
@@ -518,7 +518,7 @@ class ndax extends ndax$1 {
|
|
|
518
518
|
'info': market,
|
|
519
519
|
};
|
|
520
520
|
}
|
|
521
|
-
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8) {
|
|
521
|
+
parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8, countOrIdKey = 2) {
|
|
522
522
|
let nonce = undefined;
|
|
523
523
|
const result = {
|
|
524
524
|
'symbol': symbol,
|
|
@@ -864,7 +864,10 @@ class binance extends binance$1 {
|
|
|
864
864
|
name = this.safeString(params, 'name', name);
|
|
865
865
|
params = this.omit(params, 'name');
|
|
866
866
|
let wsParams = [];
|
|
867
|
-
|
|
867
|
+
let messageHash = 'tickers';
|
|
868
|
+
if (symbols !== undefined) {
|
|
869
|
+
messageHash = 'tickers::' + symbols.join(',');
|
|
870
|
+
}
|
|
868
871
|
if (name === 'bookTicker') {
|
|
869
872
|
if (marketIds === undefined) {
|
|
870
873
|
throw new errors.ArgumentsRequired(this.id + ' watchTickers() requires symbols for bookTicker');
|
|
@@ -1057,6 +1060,19 @@ class binance extends binance$1 {
|
|
|
1057
1060
|
this.tickers[symbol] = result;
|
|
1058
1061
|
newTickers.push(result);
|
|
1059
1062
|
}
|
|
1063
|
+
const messageHashes = this.findMessageHashes(client, 'tickers::');
|
|
1064
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
1065
|
+
const messageHash = messageHashes[i];
|
|
1066
|
+
const parts = messageHash.split('::');
|
|
1067
|
+
const symbolsString = parts[1];
|
|
1068
|
+
const symbols = symbolsString.split(',');
|
|
1069
|
+
const tickers = this.filterByArray(newTickers, 'symbol', symbols);
|
|
1070
|
+
const tickersSymbols = Object.keys(tickers);
|
|
1071
|
+
const numTickers = tickersSymbols.length;
|
|
1072
|
+
if (numTickers > 0) {
|
|
1073
|
+
client.resolve(tickers, messageHash);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1060
1076
|
client.resolve(newTickers, 'tickers');
|
|
1061
1077
|
}
|
|
1062
1078
|
signParams(params = {}) {
|
|
@@ -153,7 +153,9 @@ class bitget extends bitget$1 {
|
|
|
153
153
|
}
|
|
154
154
|
const tickers = await this.watchPublicMultiple(messageHashes, topics, params);
|
|
155
155
|
if (this.newUpdates) {
|
|
156
|
-
|
|
156
|
+
const result = {};
|
|
157
|
+
result[tickers['symbol']] = tickers;
|
|
158
|
+
return result;
|
|
157
159
|
}
|
|
158
160
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
159
161
|
}
|
|
@@ -290,22 +290,39 @@ class bitmart extends bitmart$1 {
|
|
|
290
290
|
const market = this.getMarketFromSymbols(symbols);
|
|
291
291
|
let type = 'spot';
|
|
292
292
|
[type, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
|
|
293
|
+
const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
|
|
293
294
|
symbols = this.marketSymbols(symbols);
|
|
294
|
-
|
|
295
|
-
|
|
295
|
+
let messageHash = 'tickers::' + type;
|
|
296
|
+
if (symbols !== undefined) {
|
|
297
|
+
messageHash += '::' + symbols.join(',');
|
|
296
298
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
299
|
+
let request = undefined;
|
|
300
|
+
let tickers = undefined;
|
|
301
|
+
const isSpot = (type === 'spot');
|
|
302
|
+
if (isSpot) {
|
|
303
|
+
if (symbols === undefined) {
|
|
304
|
+
throw new errors.ArgumentsRequired(this.id + ' watchTickers() for ' + type + ' market type requires symbols argument to be provided');
|
|
305
|
+
}
|
|
306
|
+
const marketIds = this.marketIds(symbols);
|
|
307
|
+
const finalArray = [];
|
|
308
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
309
|
+
finalArray.push('spot/ticker:' + marketIds[i]);
|
|
310
|
+
}
|
|
311
|
+
request = {
|
|
312
|
+
'op': 'subscribe',
|
|
313
|
+
'args': finalArray,
|
|
314
|
+
};
|
|
315
|
+
tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
request = {
|
|
319
|
+
'action': 'subscribe',
|
|
320
|
+
'args': ['futures/ticker'],
|
|
321
|
+
};
|
|
322
|
+
tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
300
323
|
}
|
|
301
|
-
const messageHash = 'tickers';
|
|
302
|
-
const request = {
|
|
303
|
-
'action': 'subscribe',
|
|
304
|
-
'args': ['futures/ticker'],
|
|
305
|
-
};
|
|
306
|
-
const newTickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
307
324
|
if (this.newUpdates) {
|
|
308
|
-
return
|
|
325
|
+
return tickers;
|
|
309
326
|
}
|
|
310
327
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
311
328
|
}
|
|
@@ -704,7 +721,7 @@ class bitmart extends bitmart$1 {
|
|
|
704
721
|
// }
|
|
705
722
|
//
|
|
706
723
|
const marketId = this.safeString(position, 'symbol');
|
|
707
|
-
market = this.safeMarket(marketId, market,
|
|
724
|
+
market = this.safeMarket(marketId, market, undefined, 'swap');
|
|
708
725
|
const symbol = market['symbol'];
|
|
709
726
|
const openTimestamp = this.safeInteger(position, 'create_time');
|
|
710
727
|
const timestamp = this.safeInteger(position, 'update_time');
|
|
@@ -890,16 +907,36 @@ class bitmart extends bitmart$1 {
|
|
|
890
907
|
const messageHash = table + ':' + marketId;
|
|
891
908
|
this.tickers[symbol] = ticker;
|
|
892
909
|
client.resolve(ticker, messageHash);
|
|
910
|
+
this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
|
|
893
911
|
}
|
|
894
912
|
}
|
|
895
913
|
else {
|
|
914
|
+
// on each update for contract markets, single ticker is provided
|
|
896
915
|
const ticker = this.parseWsSwapTicker(data);
|
|
897
916
|
const symbol = this.safeString(ticker, 'symbol');
|
|
898
917
|
this.tickers[symbol] = ticker;
|
|
899
|
-
client.resolve(ticker, 'tickers');
|
|
918
|
+
client.resolve(ticker, 'tickers::swap');
|
|
919
|
+
this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
|
|
900
920
|
}
|
|
901
921
|
return message;
|
|
902
922
|
}
|
|
923
|
+
resolveMessageHashesForSymbol(client, symbol, result, prexif) {
|
|
924
|
+
const prefixSeparator = '::';
|
|
925
|
+
const symbolsSeparator = ',';
|
|
926
|
+
const messageHashes = this.findMessageHashes(client, prexif);
|
|
927
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
928
|
+
const messageHash = messageHashes[i];
|
|
929
|
+
const parts = messageHash.split(prefixSeparator);
|
|
930
|
+
const length = parts.length;
|
|
931
|
+
const symbolsString = parts[length - 1];
|
|
932
|
+
const symbols = symbolsString.split(symbolsSeparator);
|
|
933
|
+
if (this.inArray(symbol, symbols)) {
|
|
934
|
+
const response = {};
|
|
935
|
+
response[symbol] = result;
|
|
936
|
+
client.resolve(response, messageHash);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
903
940
|
parseWsSwapTicker(ticker, market = undefined) {
|
|
904
941
|
//
|
|
905
942
|
// {
|
|
@@ -1046,7 +1083,7 @@ class bitmart extends bitmart$1 {
|
|
|
1046
1083
|
}
|
|
1047
1084
|
else {
|
|
1048
1085
|
const marketId = this.safeString(data, 'symbol');
|
|
1049
|
-
const market = this.safeMarket(marketId, undefined,
|
|
1086
|
+
const market = this.safeMarket(marketId, undefined, undefined, 'swap');
|
|
1050
1087
|
const symbol = market['symbol'];
|
|
1051
1088
|
const items = this.safeValue(data, 'items', []);
|
|
1052
1089
|
this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
|