ccxt 4.2.21 → 4.2.23
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 +574 -81
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bigone.js +1 -0
- package/dist/cjs/src/binance.js +14 -3
- package/dist/cjs/src/bitfinex2.js +89 -0
- package/dist/cjs/src/bitget.js +11 -1
- package/dist/cjs/src/bitrue.js +1 -0
- package/dist/cjs/src/bybit.js +57 -9
- package/dist/cjs/src/coinbasepro.js +1 -0
- package/dist/cjs/src/coinex.js +60 -14
- package/dist/cjs/src/deribit.js +164 -0
- package/dist/cjs/src/okcoin.js +3 -0
- package/dist/cjs/src/okx.js +81 -31
- package/dist/cjs/src/phemex.js +17 -5
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/bequant.js +6 -1
- package/dist/cjs/src/pro/binance.js +8 -5
- package/dist/cjs/src/pro/binancecoinm.js +6 -1
- package/dist/cjs/src/pro/binanceus.js +6 -1
- package/dist/cjs/src/pro/bitcoincom.js +6 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitrue.js +6 -1
- package/dist/cjs/src/pro/hitbtc.js +6 -0
- package/dist/cjs/src/pro/okx.js +23 -5
- package/dist/cjs/src/woo.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +3 -0
- package/js/src/abstract/binancecoinm.d.ts +3 -0
- package/js/src/abstract/binanceus.d.ts +4 -0
- package/js/src/abstract/binanceusdm.d.ts +3 -0
- package/js/src/bigone.js +1 -0
- package/js/src/binance.js +14 -3
- package/js/src/bitfinex2.d.ts +2 -0
- package/js/src/bitfinex2.js +89 -0
- package/js/src/bitget.js +11 -1
- package/js/src/bitrue.js +1 -0
- package/js/src/bybit.d.ts +2 -1
- package/js/src/bybit.js +57 -9
- package/js/src/coinbasepro.js +1 -0
- package/js/src/coinex.d.ts +1 -0
- package/js/src/coinex.js +60 -14
- package/js/src/deribit.d.ts +6 -1
- package/js/src/deribit.js +164 -0
- package/js/src/okcoin.js +3 -0
- package/js/src/okx.js +81 -31
- package/js/src/phemex.js +17 -5
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/bequant.js +6 -1
- package/js/src/pro/binance.js +8 -5
- package/js/src/pro/binancecoinm.js +6 -1
- package/js/src/pro/binanceus.js +6 -1
- package/js/src/pro/bitcoincom.js +6 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitrue.js +6 -1
- package/js/src/pro/hitbtc.js +6 -0
- package/js/src/pro/okx.js +23 -5
- package/js/src/woo.js +1 -1
- package/jsdoc2md.js +38 -16
- package/package.json +4 -1
- package/skip-tests.json +4 -0
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -402,6 +402,170 @@ class deribit extends deribit$1 {
|
|
|
402
402
|
},
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
|
+
convertExpireDate(date) {
|
|
406
|
+
// parse YYMMDD to timestamp
|
|
407
|
+
const year = date.slice(0, 2);
|
|
408
|
+
const month = date.slice(2, 4);
|
|
409
|
+
const day = date.slice(4, 6);
|
|
410
|
+
const reconstructedDate = '20' + year + '-' + month + '-' + day + 'T00:00:00Z';
|
|
411
|
+
return reconstructedDate;
|
|
412
|
+
}
|
|
413
|
+
convertMarketIdExpireDate(date) {
|
|
414
|
+
// parse 19JAN24 to 240119
|
|
415
|
+
const monthMappping = {
|
|
416
|
+
'JAN': '01',
|
|
417
|
+
'FEB': '02',
|
|
418
|
+
'MAR': '03',
|
|
419
|
+
'APR': '04',
|
|
420
|
+
'MAY': '05',
|
|
421
|
+
'JUN': '06',
|
|
422
|
+
'JUL': '07',
|
|
423
|
+
'AUG': '08',
|
|
424
|
+
'SEP': '09',
|
|
425
|
+
'OCT': '10',
|
|
426
|
+
'NOV': '11',
|
|
427
|
+
'DEC': '12',
|
|
428
|
+
};
|
|
429
|
+
const year = date.slice(0, 2);
|
|
430
|
+
const monthName = date.slice(2, 5);
|
|
431
|
+
const month = this.safeString(monthMappping, monthName);
|
|
432
|
+
const day = date.slice(5, 7);
|
|
433
|
+
const reconstructedDate = day + month + year;
|
|
434
|
+
return reconstructedDate;
|
|
435
|
+
}
|
|
436
|
+
convertExpireDateToMarketIdDate(date) {
|
|
437
|
+
// parse 240119 to 19JAN24
|
|
438
|
+
const year = date.slice(0, 2);
|
|
439
|
+
const monthRaw = date.slice(2, 4);
|
|
440
|
+
let month = undefined;
|
|
441
|
+
const day = date.slice(4, 6);
|
|
442
|
+
if (monthRaw === '01') {
|
|
443
|
+
month = 'JAN';
|
|
444
|
+
}
|
|
445
|
+
else if (monthRaw === '02') {
|
|
446
|
+
month = 'FEB';
|
|
447
|
+
}
|
|
448
|
+
else if (monthRaw === '03') {
|
|
449
|
+
month = 'MAR';
|
|
450
|
+
}
|
|
451
|
+
else if (monthRaw === '04') {
|
|
452
|
+
month = 'APR';
|
|
453
|
+
}
|
|
454
|
+
else if (monthRaw === '05') {
|
|
455
|
+
month = 'MAY';
|
|
456
|
+
}
|
|
457
|
+
else if (monthRaw === '06') {
|
|
458
|
+
month = 'JUN';
|
|
459
|
+
}
|
|
460
|
+
else if (monthRaw === '07') {
|
|
461
|
+
month = 'JUL';
|
|
462
|
+
}
|
|
463
|
+
else if (monthRaw === '08') {
|
|
464
|
+
month = 'AUG';
|
|
465
|
+
}
|
|
466
|
+
else if (monthRaw === '09') {
|
|
467
|
+
month = 'SEP';
|
|
468
|
+
}
|
|
469
|
+
else if (monthRaw === '10') {
|
|
470
|
+
month = 'OCT';
|
|
471
|
+
}
|
|
472
|
+
else if (monthRaw === '11') {
|
|
473
|
+
month = 'NOV';
|
|
474
|
+
}
|
|
475
|
+
else if (monthRaw === '12') {
|
|
476
|
+
month = 'DEC';
|
|
477
|
+
}
|
|
478
|
+
const reconstructedDate = day + month + year;
|
|
479
|
+
return reconstructedDate;
|
|
480
|
+
}
|
|
481
|
+
createExpiredOptionMarket(symbol) {
|
|
482
|
+
// support expired option contracts
|
|
483
|
+
let quote = 'USD';
|
|
484
|
+
let settle = undefined;
|
|
485
|
+
const optionParts = symbol.split('-');
|
|
486
|
+
const symbolBase = symbol.split('/');
|
|
487
|
+
let base = undefined;
|
|
488
|
+
let expiry = undefined;
|
|
489
|
+
if (symbol.indexOf('/') > -1) {
|
|
490
|
+
base = this.safeString(symbolBase, 0);
|
|
491
|
+
expiry = this.safeString(optionParts, 1);
|
|
492
|
+
if (symbol.indexOf('USDC') > -1) {
|
|
493
|
+
base = base + '_USDC';
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
base = this.safeString(optionParts, 0);
|
|
498
|
+
expiry = this.convertMarketIdExpireDate(this.safeString(optionParts, 1));
|
|
499
|
+
}
|
|
500
|
+
if (symbol.indexOf('USDC') > -1) {
|
|
501
|
+
quote = 'USDC';
|
|
502
|
+
settle = 'USDC';
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
settle = base;
|
|
506
|
+
}
|
|
507
|
+
let splitBase = base;
|
|
508
|
+
if (base.indexOf('_') > -1) {
|
|
509
|
+
const splitSymbol = base.split('_');
|
|
510
|
+
splitBase = this.safeString(splitSymbol, 0);
|
|
511
|
+
}
|
|
512
|
+
const strike = this.safeString(optionParts, 2);
|
|
513
|
+
const optionType = this.safeString(optionParts, 3);
|
|
514
|
+
const datetime = this.convertExpireDate(expiry);
|
|
515
|
+
const timestamp = this.parse8601(datetime);
|
|
516
|
+
return {
|
|
517
|
+
'id': base + '-' + this.convertExpireDateToMarketIdDate(expiry) + '-' + strike + '-' + optionType,
|
|
518
|
+
'symbol': splitBase + '/' + quote + ':' + settle + '-' + expiry + '-' + strike + '-' + optionType,
|
|
519
|
+
'base': base,
|
|
520
|
+
'quote': quote,
|
|
521
|
+
'settle': settle,
|
|
522
|
+
'baseId': base,
|
|
523
|
+
'quoteId': quote,
|
|
524
|
+
'settleId': settle,
|
|
525
|
+
'active': false,
|
|
526
|
+
'type': 'option',
|
|
527
|
+
'linear': undefined,
|
|
528
|
+
'inverse': undefined,
|
|
529
|
+
'spot': false,
|
|
530
|
+
'swap': false,
|
|
531
|
+
'future': false,
|
|
532
|
+
'option': true,
|
|
533
|
+
'margin': false,
|
|
534
|
+
'contract': true,
|
|
535
|
+
'contractSize': undefined,
|
|
536
|
+
'expiry': timestamp,
|
|
537
|
+
'expiryDatetime': datetime,
|
|
538
|
+
'optionType': (optionType === 'C') ? 'call' : 'put',
|
|
539
|
+
'strike': this.parseNumber(strike),
|
|
540
|
+
'precision': {
|
|
541
|
+
'amount': undefined,
|
|
542
|
+
'price': undefined,
|
|
543
|
+
},
|
|
544
|
+
'limits': {
|
|
545
|
+
'amount': {
|
|
546
|
+
'min': undefined,
|
|
547
|
+
'max': undefined,
|
|
548
|
+
},
|
|
549
|
+
'price': {
|
|
550
|
+
'min': undefined,
|
|
551
|
+
'max': undefined,
|
|
552
|
+
},
|
|
553
|
+
'cost': {
|
|
554
|
+
'min': undefined,
|
|
555
|
+
'max': undefined,
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
'info': undefined,
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
|
|
562
|
+
const isOption = (marketId !== undefined) && ((marketId.endsWith('-C')) || (marketId.endsWith('-P')));
|
|
563
|
+
if (isOption && !(marketId in this.markets_by_id)) {
|
|
564
|
+
// handle expired option contracts
|
|
565
|
+
return this.createExpiredOptionMarket(marketId);
|
|
566
|
+
}
|
|
567
|
+
return super.safeMarket(marketId, market, delimiter, marketType);
|
|
568
|
+
}
|
|
405
569
|
async fetchTime(params = {}) {
|
|
406
570
|
/**
|
|
407
571
|
* @method
|
package/dist/cjs/src/okcoin.js
CHANGED
|
@@ -46,6 +46,9 @@ class okcoin extends okcoin$1 {
|
|
|
46
46
|
'fetchCurrencies': true,
|
|
47
47
|
'fetchDepositAddress': true,
|
|
48
48
|
'fetchDeposits': true,
|
|
49
|
+
'fetchFundingHistory': false,
|
|
50
|
+
'fetchFundingRate': false,
|
|
51
|
+
'fetchFundingRateHistory': false,
|
|
49
52
|
'fetchLedger': true,
|
|
50
53
|
'fetchMarkets': true,
|
|
51
54
|
'fetchMyTrades': true,
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -2914,12 +2914,26 @@ class okx extends okx$1 {
|
|
|
2914
2914
|
const request = {
|
|
2915
2915
|
'instId': market['id'],
|
|
2916
2916
|
};
|
|
2917
|
+
let isAlgoOrder = undefined;
|
|
2918
|
+
if ((type === 'trigger') || (type === 'conditional') || (type === 'move_order_stop') || (type === 'oco') || (type === 'iceberg') || (type === 'twap')) {
|
|
2919
|
+
isAlgoOrder = true;
|
|
2920
|
+
}
|
|
2917
2921
|
const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
|
|
2918
2922
|
if (clientOrderId !== undefined) {
|
|
2919
|
-
|
|
2923
|
+
if (isAlgoOrder) {
|
|
2924
|
+
request['algoClOrdId'] = clientOrderId;
|
|
2925
|
+
}
|
|
2926
|
+
else {
|
|
2927
|
+
request['clOrdId'] = clientOrderId;
|
|
2928
|
+
}
|
|
2920
2929
|
}
|
|
2921
2930
|
else {
|
|
2922
|
-
|
|
2931
|
+
if (isAlgoOrder) {
|
|
2932
|
+
request['algoId'] = id;
|
|
2933
|
+
}
|
|
2934
|
+
else {
|
|
2935
|
+
request['ordId'] = id;
|
|
2936
|
+
}
|
|
2923
2937
|
}
|
|
2924
2938
|
let stopLossTriggerPrice = this.safeValue2(params, 'stopLossPrice', 'newSlTriggerPx');
|
|
2925
2939
|
let stopLossPrice = this.safeValue(params, 'newSlOrdPx');
|
|
@@ -2931,37 +2945,62 @@ class okx extends okx$1 {
|
|
|
2931
2945
|
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
2932
2946
|
const stopLossDefined = (stopLoss !== undefined);
|
|
2933
2947
|
const takeProfitDefined = (takeProfit !== undefined);
|
|
2934
|
-
if (
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2948
|
+
if (isAlgoOrder) {
|
|
2949
|
+
if ((stopLossTriggerPrice === undefined) && (takeProfitTriggerPrice === undefined)) {
|
|
2950
|
+
throw new errors.BadRequest(this.id + ' editOrder() requires a stopLossPrice or takeProfitPrice parameter for editing an algo order');
|
|
2951
|
+
}
|
|
2952
|
+
if (stopLossTriggerPrice !== undefined) {
|
|
2953
|
+
if (stopLossPrice === undefined) {
|
|
2954
|
+
throw new errors.BadRequest(this.id + ' editOrder() requires a newSlOrdPx parameter for editing an algo order');
|
|
2955
|
+
}
|
|
2956
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2957
|
+
request['newSlOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2958
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2959
|
+
}
|
|
2960
|
+
if (takeProfitTriggerPrice !== undefined) {
|
|
2961
|
+
if (takeProfitPrice === undefined) {
|
|
2962
|
+
throw new errors.BadRequest(this.id + ' editOrder() requires a newTpOrdPx parameter for editing an algo order');
|
|
2963
|
+
}
|
|
2964
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2965
|
+
request['newTpOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2966
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
else {
|
|
2970
|
+
if (stopLossTriggerPrice !== undefined) {
|
|
2971
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2972
|
+
request['newSlOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2973
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2974
|
+
}
|
|
2975
|
+
if (takeProfitTriggerPrice !== undefined) {
|
|
2976
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2977
|
+
request['newTpOrdPx'] = (type === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2978
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2979
|
+
}
|
|
2980
|
+
if (stopLossDefined) {
|
|
2981
|
+
stopLossTriggerPrice = this.safeValue(stopLoss, 'triggerPrice');
|
|
2982
|
+
stopLossPrice = this.safeValue(stopLoss, 'price');
|
|
2983
|
+
const stopLossType = this.safeString(stopLoss, 'type');
|
|
2984
|
+
request['newSlTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
2985
|
+
request['newSlOrdPx'] = (stopLossType === 'market') ? '-1' : this.priceToPrecision(symbol, stopLossPrice);
|
|
2986
|
+
request['newSlTriggerPxType'] = stopLossTriggerPriceType;
|
|
2987
|
+
}
|
|
2988
|
+
if (takeProfitDefined) {
|
|
2989
|
+
takeProfitTriggerPrice = this.safeValue(takeProfit, 'triggerPrice');
|
|
2990
|
+
takeProfitPrice = this.safeValue(takeProfit, 'price');
|
|
2991
|
+
const takeProfitType = this.safeString(takeProfit, 'type');
|
|
2992
|
+
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2993
|
+
request['newTpOrdPx'] = (takeProfitType === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
2994
|
+
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
2995
|
+
}
|
|
2959
2996
|
}
|
|
2960
2997
|
if (amount !== undefined) {
|
|
2961
2998
|
request['newSz'] = this.amountToPrecision(symbol, amount);
|
|
2962
2999
|
}
|
|
2963
|
-
if (
|
|
2964
|
-
|
|
3000
|
+
if (!isAlgoOrder) {
|
|
3001
|
+
if (price !== undefined) {
|
|
3002
|
+
request['newPx'] = this.priceToPrecision(symbol, price);
|
|
3003
|
+
}
|
|
2965
3004
|
}
|
|
2966
3005
|
params = this.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit']);
|
|
2967
3006
|
return this.extend(request, params);
|
|
@@ -2971,7 +3010,8 @@ class okx extends okx$1 {
|
|
|
2971
3010
|
* @method
|
|
2972
3011
|
* @name okx#editOrder
|
|
2973
3012
|
* @description edit a trade order
|
|
2974
|
-
* @see https://www.okx.com/docs-v5/en/#
|
|
3013
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-amend-order
|
|
3014
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-amend-algo-order
|
|
2975
3015
|
* @param {string} id order id
|
|
2976
3016
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2977
3017
|
* @param {string} type 'market' or 'limit'
|
|
@@ -2999,7 +3039,17 @@ class okx extends okx$1 {
|
|
|
2999
3039
|
await this.loadMarkets();
|
|
3000
3040
|
const market = this.market(symbol);
|
|
3001
3041
|
const request = this.editOrderRequest(id, symbol, type, side, amount, price, params);
|
|
3002
|
-
|
|
3042
|
+
let isAlgoOrder = undefined;
|
|
3043
|
+
if ((type === 'trigger') || (type === 'conditional') || (type === 'move_order_stop') || (type === 'oco') || (type === 'iceberg') || (type === 'twap')) {
|
|
3044
|
+
isAlgoOrder = true;
|
|
3045
|
+
}
|
|
3046
|
+
let response = undefined;
|
|
3047
|
+
if (isAlgoOrder) {
|
|
3048
|
+
response = await this.privatePostTradeAmendAlgos(this.extend(request, params));
|
|
3049
|
+
}
|
|
3050
|
+
else {
|
|
3051
|
+
response = await this.privatePostTradeAmendOrder(this.extend(request, params));
|
|
3052
|
+
}
|
|
3003
3053
|
//
|
|
3004
3054
|
// {
|
|
3005
3055
|
// "code": "0",
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -1915,16 +1915,19 @@ class phemex extends phemex$1 {
|
|
|
1915
1915
|
* @method
|
|
1916
1916
|
* @name phemex#fetchBalance
|
|
1917
1917
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1918
|
+
* @see https://phemex-docs.github.io/#query-wallets
|
|
1918
1919
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-account-positions
|
|
1920
|
+
* @see https://phemex-docs.github.io/#query-trading-account-and-positions
|
|
1919
1921
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1920
1922
|
* @param {string} [params.type] spot or swap
|
|
1923
|
+
* @param {string} [params.code] *swap only* currency code of the balance to query (USD, USDT, etc), default is USDT
|
|
1921
1924
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1922
1925
|
*/
|
|
1923
1926
|
await this.loadMarkets();
|
|
1924
1927
|
let type = undefined;
|
|
1925
1928
|
[type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1926
1929
|
const code = this.safeString(params, 'code');
|
|
1927
|
-
params = this.omit(params, ['
|
|
1930
|
+
params = this.omit(params, ['code']);
|
|
1928
1931
|
let response = undefined;
|
|
1929
1932
|
const request = {};
|
|
1930
1933
|
if ((type !== 'spot') && (type !== 'swap')) {
|
|
@@ -1932,7 +1935,7 @@ class phemex extends phemex$1 {
|
|
|
1932
1935
|
}
|
|
1933
1936
|
if (type === 'swap') {
|
|
1934
1937
|
let settle = undefined;
|
|
1935
|
-
[settle, params] = this.handleOptionAndParams(params, 'fetchBalance', 'settle');
|
|
1938
|
+
[settle, params] = this.handleOptionAndParams(params, 'fetchBalance', 'settle', 'USDT');
|
|
1936
1939
|
if (code !== undefined || settle !== undefined) {
|
|
1937
1940
|
let coin = undefined;
|
|
1938
1941
|
if (code !== undefined) {
|
|
@@ -3542,8 +3545,10 @@ class phemex extends phemex$1 {
|
|
|
3542
3545
|
* @description fetch all open positions
|
|
3543
3546
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#query-trading-account-and-positions
|
|
3544
3547
|
* @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-account-positions
|
|
3545
|
-
* @
|
|
3548
|
+
* @see https://phemex-docs.github.io/#query-account-positions-with-unrealized-pnl
|
|
3549
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
3546
3550
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3551
|
+
* @param {string} [param.method] *USDT contracts only* 'privateGetGAccountsAccountPositions' or 'privateGetAccountsPositions' default is 'privateGetGAccountsAccountPositions'
|
|
3547
3552
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3548
3553
|
*/
|
|
3549
3554
|
await this.loadMarkets();
|
|
@@ -3578,7 +3583,14 @@ class phemex extends phemex$1 {
|
|
|
3578
3583
|
};
|
|
3579
3584
|
let response = undefined;
|
|
3580
3585
|
if (isUSDTSettled) {
|
|
3581
|
-
|
|
3586
|
+
let method = undefined;
|
|
3587
|
+
[method, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'privateGetGAccountsAccountPositions');
|
|
3588
|
+
if (method === 'privateGetGAccountsAccountPositions') {
|
|
3589
|
+
response = await this.privateGetGAccountsAccountPositions(this.extend(request, params));
|
|
3590
|
+
}
|
|
3591
|
+
else {
|
|
3592
|
+
response = await this.privateGetAccountsPositions(this.extend(request, params));
|
|
3593
|
+
}
|
|
3582
3594
|
}
|
|
3583
3595
|
else {
|
|
3584
3596
|
response = await this.privateGetAccountsAccountPositions(this.extend(request, params));
|
|
@@ -3754,7 +3766,7 @@ class phemex extends phemex$1 {
|
|
|
3754
3766
|
const contracts = this.safeString(position, 'size');
|
|
3755
3767
|
const contractSize = this.safeValue(market, 'contractSize');
|
|
3756
3768
|
const contractSizeString = this.numberToString(contractSize);
|
|
3757
|
-
const leverage = this.
|
|
3769
|
+
const leverage = this.parseNumber(Precise["default"].stringAbs((this.safeString(position, 'leverage', 'leverageRr'))));
|
|
3758
3770
|
const entryPriceString = this.safeString2(position, 'avgEntryPrice', 'avgEntryPriceRp');
|
|
3759
3771
|
const rawSide = this.safeString(position, 'side');
|
|
3760
3772
|
let side = undefined;
|
package/dist/cjs/src/poloniex.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var hitbtc = require('./hitbtc.js');
|
|
4
|
+
var bequant$1 = require('../bequant.js');
|
|
4
5
|
|
|
5
6
|
// ---------------------------------------------------------------------------
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
8
|
class bequant extends hitbtc {
|
|
8
9
|
describe() {
|
|
9
|
-
|
|
10
|
+
// eslint-disable-next-line new-cap
|
|
11
|
+
const restInstance = new bequant$1();
|
|
12
|
+
const restDescribe = restInstance.describe();
|
|
13
|
+
const extended = this.deepExtend(super.describe(), restDescribe);
|
|
14
|
+
return this.deepExtend(extended, {
|
|
10
15
|
'id': 'bequant',
|
|
11
16
|
'name': 'Bequant',
|
|
12
17
|
'countries': ['MT'],
|
|
@@ -44,7 +44,7 @@ class binance extends binance$1 {
|
|
|
44
44
|
'ws': {
|
|
45
45
|
'spot': 'wss://testnet.binance.vision/ws',
|
|
46
46
|
'margin': 'wss://testnet.binance.vision/ws',
|
|
47
|
-
'future': 'wss://
|
|
47
|
+
'future': 'wss://fstream.binancefuture.com/ws',
|
|
48
48
|
'delivery': 'wss://dstream.binancefuture.com/ws',
|
|
49
49
|
'ws': 'wss://testnet.binance.vision/ws-api/v3',
|
|
50
50
|
},
|
|
@@ -986,7 +986,7 @@ class binance extends binance$1 {
|
|
|
986
986
|
}
|
|
987
987
|
else {
|
|
988
988
|
// take the timestamp of the closing price for candlestick streams
|
|
989
|
-
timestamp = this.
|
|
989
|
+
timestamp = this.safeInteger2(message, 'C', 'E');
|
|
990
990
|
}
|
|
991
991
|
const marketId = this.safeString(message, 's');
|
|
992
992
|
const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
|
|
@@ -1977,12 +1977,13 @@ class binance extends binance$1 {
|
|
|
1977
1977
|
/**
|
|
1978
1978
|
* @method
|
|
1979
1979
|
* @name binance#watchOrders
|
|
1980
|
-
* @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
|
|
1981
1980
|
* @description watches information on multiple orders made by the user
|
|
1982
|
-
* @
|
|
1981
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
|
|
1982
|
+
* @param {string} symbol unified market symbol of the market the orders were made in
|
|
1983
1983
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1984
1984
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1985
1985
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1986
|
+
* @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for spot margin
|
|
1986
1987
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1987
1988
|
*/
|
|
1988
1989
|
await this.loadMarkets();
|
|
@@ -2005,8 +2006,10 @@ class binance extends binance$1 {
|
|
|
2005
2006
|
}
|
|
2006
2007
|
params = this.extend(params, { 'type': type, 'symbol': symbol }); // needed inside authenticate for isolated margin
|
|
2007
2008
|
await this.authenticate(params);
|
|
2009
|
+
let marginMode = undefined;
|
|
2010
|
+
[marginMode, params] = this.handleMarginModeAndParams('watchOrders', params);
|
|
2008
2011
|
let urlType = type;
|
|
2009
|
-
if (type === 'margin') {
|
|
2012
|
+
if ((type === 'margin') || ((type === 'spot') && (marginMode !== undefined))) {
|
|
2010
2013
|
urlType = 'spot'; // spot-margin shares the same stream as regular spot
|
|
2011
2014
|
}
|
|
2012
2015
|
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var binance = require('./binance.js');
|
|
4
|
+
var binancecoinm$1 = require('../binancecoinm.js');
|
|
4
5
|
|
|
5
6
|
// ---------------------------------------------------------------------------
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
8
|
class binancecoinm extends binance {
|
|
8
9
|
describe() {
|
|
9
|
-
|
|
10
|
+
// eslint-disable-next-line new-cap
|
|
11
|
+
const restInstance = new binancecoinm$1();
|
|
12
|
+
const restDescribe = restInstance.describe();
|
|
13
|
+
const extended = this.deepExtend(super.describe(), restDescribe);
|
|
14
|
+
return this.deepExtend(extended, {
|
|
10
15
|
'id': 'binancecoinm',
|
|
11
16
|
'name': 'Binance COIN-M',
|
|
12
17
|
'urls': {
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var binance = require('./binance.js');
|
|
4
|
+
var binanceus$1 = require('../binanceus.js');
|
|
4
5
|
|
|
5
6
|
// ---------------------------------------------------------------------------
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
8
|
class binanceus extends binance {
|
|
8
9
|
describe() {
|
|
9
|
-
|
|
10
|
+
// eslint-disable-next-line new-cap
|
|
11
|
+
const restInstance = new binanceus$1();
|
|
12
|
+
const restDescribe = restInstance.describe();
|
|
13
|
+
const extended = this.deepExtend(super.describe(), restDescribe);
|
|
14
|
+
return this.deepExtend(extended, {
|
|
10
15
|
'id': 'binanceus',
|
|
11
16
|
'name': 'Binance US',
|
|
12
17
|
'countries': ['US'],
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var hitbtc = require('./hitbtc.js');
|
|
4
|
+
var bequant = require('../bequant.js');
|
|
4
5
|
|
|
5
6
|
// ---------------------------------------------------------------------------
|
|
6
7
|
// ---------------------------------------------------------------------------
|
|
7
8
|
class bitcoincom extends hitbtc {
|
|
8
9
|
describe() {
|
|
9
|
-
|
|
10
|
+
// eslint-disable-next-line new-cap
|
|
11
|
+
const restInstance = new bequant();
|
|
12
|
+
const restDescribe = restInstance.describe();
|
|
13
|
+
const extended = this.deepExtend(super.describe(), restDescribe);
|
|
14
|
+
return this.deepExtend(extended, {
|
|
10
15
|
'id': 'bitcoincom',
|
|
11
16
|
'name': 'bitcoin.com',
|
|
12
17
|
'countries': ['KN'],
|
|
@@ -1245,7 +1245,7 @@ class bitget extends bitget$1 {
|
|
|
1245
1245
|
'price': this.safeString(order, 'price'),
|
|
1246
1246
|
'stopPrice': triggerPrice,
|
|
1247
1247
|
'triggerPrice': triggerPrice,
|
|
1248
|
-
'amount': this.
|
|
1248
|
+
'amount': this.safeString(order, 'baseVolume'),
|
|
1249
1249
|
'cost': this.safeStringN(order, ['notional', 'notionalUsd', 'quoteSize']),
|
|
1250
1250
|
'average': this.omitZero(this.safeString2(order, 'priceAvg', 'fillPrice')),
|
|
1251
1251
|
'filled': this.safeString2(order, 'accBaseVolume', 'baseVolume'),
|
|
@@ -346,7 +346,12 @@ class bitrue extends bitrue$1 {
|
|
|
346
346
|
const symbol = market['symbol'];
|
|
347
347
|
const timestamp = this.safeInteger(message, 'ts');
|
|
348
348
|
const tick = this.safeValue(message, 'tick', {});
|
|
349
|
-
|
|
349
|
+
let orderbook = this.safeValue(this.orderbooks, symbol);
|
|
350
|
+
if (orderbook === undefined) {
|
|
351
|
+
orderbook = this.orderBook();
|
|
352
|
+
}
|
|
353
|
+
const snapshot = this.parseOrderBook(tick, symbol, timestamp, 'buys', 'asks');
|
|
354
|
+
orderbook.reset(snapshot);
|
|
350
355
|
this.orderbooks[symbol] = orderbook;
|
|
351
356
|
const messageHash = 'orderbook:' + symbol;
|
|
352
357
|
client.resolve(orderbook, messageHash);
|
|
@@ -32,6 +32,12 @@ class hitbtc extends hitbtc$1 {
|
|
|
32
32
|
'private': 'wss://api.hitbtc.com/api/3/ws/trading',
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
+
'test': {
|
|
36
|
+
'ws': {
|
|
37
|
+
'public': 'wss://api.demo.hitbtc.com/api/3/ws/public',
|
|
38
|
+
'private': 'wss://api.demo.hitbtc.com/api/3/ws/trading',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
35
41
|
},
|
|
36
42
|
'options': {
|
|
37
43
|
'tradesLimit': 1000,
|
package/dist/cjs/src/pro/okx.js
CHANGED
|
@@ -850,13 +850,15 @@ class okx extends okx$1 {
|
|
|
850
850
|
/**
|
|
851
851
|
* @method
|
|
852
852
|
* @name okx#watchMyTrades
|
|
853
|
-
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel
|
|
854
853
|
* @description watches information on multiple trades made by the user
|
|
854
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel
|
|
855
855
|
* @param {string} [symbol] unified market symbol of the market trades were made in
|
|
856
856
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
857
857
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
858
858
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
859
859
|
* @param {bool} [params.stop] true if fetching trigger or conditional trades
|
|
860
|
+
* @param {string} [params.type] 'spot', 'swap', 'future', 'option', 'ANY', 'SPOT', 'MARGIN', 'SWAP', 'FUTURES' or 'OPTION'
|
|
861
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated', for automatically setting the type to spot margin
|
|
860
862
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
|
|
861
863
|
*/
|
|
862
864
|
// By default, receive order updates from any instrument type
|
|
@@ -878,7 +880,14 @@ class okx extends okx$1 {
|
|
|
878
880
|
if (type === 'future') {
|
|
879
881
|
type = 'futures';
|
|
880
882
|
}
|
|
881
|
-
|
|
883
|
+
let uppercaseType = type.toUpperCase();
|
|
884
|
+
let marginMode = undefined;
|
|
885
|
+
[marginMode, params] = this.handleMarginModeAndParams('watchMyTrades', params);
|
|
886
|
+
if (uppercaseType === 'SPOT') {
|
|
887
|
+
if (marginMode !== undefined) {
|
|
888
|
+
uppercaseType = 'MARGIN';
|
|
889
|
+
}
|
|
890
|
+
}
|
|
882
891
|
const request = {
|
|
883
892
|
'instType': uppercaseType,
|
|
884
893
|
};
|
|
@@ -1011,13 +1020,15 @@ class okx extends okx$1 {
|
|
|
1011
1020
|
/**
|
|
1012
1021
|
* @method
|
|
1013
1022
|
* @name okx#watchOrders
|
|
1014
|
-
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel
|
|
1015
1023
|
* @description watches information on multiple orders made by the user
|
|
1016
|
-
* @
|
|
1024
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel
|
|
1025
|
+
* @param {string} [symbol] unified market symbol of the market the orders were made in
|
|
1017
1026
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1018
1027
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1019
1028
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1020
1029
|
* @param {bool} [params.stop] true if fetching trigger or conditional orders
|
|
1030
|
+
* @param {string} [params.type] 'spot', 'swap', 'future', 'option', 'ANY', 'SPOT', 'MARGIN', 'SWAP', 'FUTURES' or 'OPTION'
|
|
1031
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated', for automatically setting the type to spot margin
|
|
1021
1032
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1022
1033
|
*/
|
|
1023
1034
|
let type = undefined;
|
|
@@ -1036,7 +1047,14 @@ class okx extends okx$1 {
|
|
|
1036
1047
|
if (type === 'future') {
|
|
1037
1048
|
type = 'futures';
|
|
1038
1049
|
}
|
|
1039
|
-
|
|
1050
|
+
let uppercaseType = type.toUpperCase();
|
|
1051
|
+
let marginMode = undefined;
|
|
1052
|
+
[marginMode, params] = this.handleMarginModeAndParams('watchOrders', params);
|
|
1053
|
+
if (uppercaseType === 'SPOT') {
|
|
1054
|
+
if (marginMode !== undefined) {
|
|
1055
|
+
uppercaseType = 'MARGIN';
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1040
1058
|
const request = {
|
|
1041
1059
|
'instType': uppercaseType,
|
|
1042
1060
|
};
|
package/dist/cjs/src/woo.js
CHANGED
|
@@ -58,7 +58,7 @@ class woo extends woo$1 {
|
|
|
58
58
|
'fetchClosedOrder': false,
|
|
59
59
|
'fetchClosedOrders': false,
|
|
60
60
|
'fetchCurrencies': true,
|
|
61
|
-
'fetchDepositAddress':
|
|
61
|
+
'fetchDepositAddress': true,
|
|
62
62
|
'fetchDeposits': true,
|
|
63
63
|
'fetchDepositsWithdrawals': true,
|
|
64
64
|
'fetchFundingHistory': true,
|