ccxt 4.2.90 → 4.2.91
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/CHANGELOG.md +44 -16
- package/README.md +3 -3
- package/dist/ccxt.browser.js +339 -161
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +1 -9
- package/dist/cjs/src/coinbase.js +3 -1
- package/dist/cjs/src/gemini.js +2 -1
- package/dist/cjs/src/kraken.js +11 -9
- package/dist/cjs/src/okx.js +30 -30
- package/dist/cjs/src/pro/bitmex.js +39 -18
- package/dist/cjs/src/pro/kucoin.js +91 -0
- package/dist/cjs/src/pro/kucoinfutures.js +151 -82
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.js +1 -9
- package/js/src/coinbase.js +3 -1
- package/js/src/gemini.js +2 -1
- package/js/src/kraken.js +11 -9
- package/js/src/okx.js +30 -30
- package/js/src/pro/bitmex.d.ts +1 -0
- package/js/src/pro/bitmex.js +39 -18
- package/js/src/pro/kucoin.d.ts +4 -0
- package/js/src/pro/kucoin.js +91 -0
- package/js/src/pro/kucoinfutures.d.ts +9 -5
- package/js/src/pro/kucoinfutures.js +151 -82
- package/package.json +1 -1
package/dist/ccxt.browser.js
CHANGED
|
@@ -9315,7 +9315,7 @@ class Exchange {
|
|
|
9315
9315
|
parseToInt(number) {
|
|
9316
9316
|
// Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
|
|
9317
9317
|
// using a number as parameter which is not valid in ts
|
|
9318
|
-
const stringifiedNumber =
|
|
9318
|
+
const stringifiedNumber = this.numberToString(number);
|
|
9319
9319
|
const convertedNumber = parseFloat(stringifiedNumber);
|
|
9320
9320
|
return parseInt(convertedNumber);
|
|
9321
9321
|
}
|
|
@@ -11808,13 +11808,6 @@ class Exchange {
|
|
|
11808
11808
|
if (!this.substituteCommonCurrencyCodes) {
|
|
11809
11809
|
return code;
|
|
11810
11810
|
}
|
|
11811
|
-
// if the provided code already exists as a value in commonCurrencies dict, then we should not again transform it
|
|
11812
|
-
// more details at: https://github.com/ccxt/ccxt/issues/21112#issuecomment-2031293691
|
|
11813
|
-
const commonCurrencies = Object.values(this.commonCurrencies);
|
|
11814
|
-
const exists = this.inArray(code, commonCurrencies);
|
|
11815
|
-
if (exists) {
|
|
11816
|
-
return code;
|
|
11817
|
-
}
|
|
11818
11811
|
return this.safeString(this.commonCurrencies, code, code);
|
|
11819
11812
|
}
|
|
11820
11813
|
currency(code) {
|
|
@@ -12465,7 +12458,6 @@ class Exchange {
|
|
|
12465
12458
|
* @returns {object} objects with withdraw and deposit fees, indexed by currency codes
|
|
12466
12459
|
*/
|
|
12467
12460
|
const depositWithdrawFees = {};
|
|
12468
|
-
codes = this.marketCodes(codes);
|
|
12469
12461
|
const isArray = Array.isArray(response);
|
|
12470
12462
|
let responseKeys = response;
|
|
12471
12463
|
if (!isArray) {
|
|
@@ -94765,6 +94757,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
94765
94757
|
'CGLD': 'CELO',
|
|
94766
94758
|
},
|
|
94767
94759
|
'options': {
|
|
94760
|
+
'brokerId': 'ccxt',
|
|
94768
94761
|
'stablePairs': ['BUSD-USD', 'CBETH-ETH', 'DAI-USD', 'GUSD-USD', 'GYEN-USD', 'PAX-USD', 'PAX-USDT', 'USDC-EUR', 'USDC-GBP', 'USDT-EUR', 'USDT-GBP', 'USDT-USD', 'USDT-USDC', 'WBTC-BTC'],
|
|
94769
94762
|
'fetchCurrencies': {
|
|
94770
94763
|
'expires': 5000,
|
|
@@ -96775,8 +96768,9 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
96775
96768
|
*/
|
|
96776
96769
|
await this.loadMarkets();
|
|
96777
96770
|
const market = this.market(symbol);
|
|
96771
|
+
const id = this.safeString(this.options, 'brokerId', 'ccxt');
|
|
96778
96772
|
let request = {
|
|
96779
|
-
'client_order_id': this.uuid(),
|
|
96773
|
+
'client_order_id': id + '-' + this.uuid(),
|
|
96780
96774
|
'product_id': market['id'],
|
|
96781
96775
|
'side': side.toUpperCase(),
|
|
96782
96776
|
};
|
|
@@ -145334,7 +145328,8 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
145334
145328
|
// '<td>0.01 USD', // quote currency price increment
|
|
145335
145329
|
// '</tr>'
|
|
145336
145330
|
// ]
|
|
145337
|
-
|
|
145331
|
+
let marketId = cells[0].replace('<td>', '');
|
|
145332
|
+
marketId = marketId.replace('*', '');
|
|
145338
145333
|
// const base = this.safeCurrencyCode (baseId);
|
|
145339
145334
|
const minAmountString = cells[1].replace('<td>', '');
|
|
145340
145335
|
const minAmountParts = minAmountString.split(' ');
|
|
@@ -170547,10 +170542,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
170547
170542
|
if (currencyId !== undefined) {
|
|
170548
170543
|
if (currencyId.length > 3) {
|
|
170549
170544
|
if ((currencyId.indexOf('X') === 0) || (currencyId.indexOf('Z') === 0)) {
|
|
170550
|
-
if (currencyId.indexOf('.') > 0) {
|
|
170551
|
-
return super.safeCurrency(currencyId, currency);
|
|
170552
|
-
}
|
|
170553
|
-
else {
|
|
170545
|
+
if (!(currencyId.indexOf('.') > 0)) {
|
|
170554
170546
|
currencyId = currencyId.slice(1);
|
|
170555
170547
|
}
|
|
170556
170548
|
}
|
|
@@ -170599,8 +170591,13 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
170599
170591
|
// {
|
|
170600
170592
|
// "error": [],
|
|
170601
170593
|
// "result": {
|
|
170602
|
-
// "
|
|
170603
|
-
//
|
|
170594
|
+
// "BCH": {
|
|
170595
|
+
// "aclass": "currency",
|
|
170596
|
+
// "altname": "BCH",
|
|
170597
|
+
// "decimals": 10,
|
|
170598
|
+
// "display_decimals": 5
|
|
170599
|
+
// "status": "enabled",
|
|
170600
|
+
// },
|
|
170604
170601
|
// ...
|
|
170605
170602
|
// },
|
|
170606
170603
|
// }
|
|
@@ -170615,15 +170612,15 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
170615
170612
|
// see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
|
|
170616
170613
|
// to add support for multiple withdrawal/deposit methods and
|
|
170617
170614
|
// differentiated fees for each particular method
|
|
170618
|
-
const code = this.safeCurrencyCode(
|
|
170615
|
+
const code = this.safeCurrencyCode(id);
|
|
170619
170616
|
const precision = this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals')));
|
|
170620
170617
|
// assumes all currencies are active except those listed above
|
|
170621
|
-
const active =
|
|
170618
|
+
const active = this.safeString(currency, 'status') === 'enabled';
|
|
170622
170619
|
result[code] = {
|
|
170623
170620
|
'id': id,
|
|
170624
170621
|
'code': code,
|
|
170625
170622
|
'info': currency,
|
|
170626
|
-
'name':
|
|
170623
|
+
'name': this.safeString(currency, 'altname'),
|
|
170627
170624
|
'active': active,
|
|
170628
170625
|
'deposit': undefined,
|
|
170629
170626
|
'withdraw': undefined,
|
|
@@ -208126,7 +208123,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208126
208123
|
// ]
|
|
208127
208124
|
// }
|
|
208128
208125
|
//
|
|
208129
|
-
const data = this.
|
|
208126
|
+
const data = this.safeList(response, 'data', []);
|
|
208130
208127
|
const dataLength = data.length;
|
|
208131
208128
|
const update = {
|
|
208132
208129
|
'updated': undefined,
|
|
@@ -208174,8 +208171,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208174
208171
|
// "msg": ""
|
|
208175
208172
|
// }
|
|
208176
208173
|
//
|
|
208177
|
-
const data = this.
|
|
208178
|
-
const first = this.
|
|
208174
|
+
const data = this.safeList(response, 'data', []);
|
|
208175
|
+
const first = this.safeDict(data, 0, {});
|
|
208179
208176
|
return this.safeInteger(first, 'ts');
|
|
208180
208177
|
}
|
|
208181
208178
|
async fetchAccounts(params = {}) {
|
|
@@ -208207,7 +208204,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208207
208204
|
// "msg": ""
|
|
208208
208205
|
// }
|
|
208209
208206
|
//
|
|
208210
|
-
const data = this.
|
|
208207
|
+
const data = this.safeList(response, 'data', []);
|
|
208211
208208
|
const result = [];
|
|
208212
208209
|
for (let i = 0; i < data.length; i++) {
|
|
208213
208210
|
const account = data[i];
|
|
@@ -208232,7 +208229,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208232
208229
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
208233
208230
|
* @returns {object[]} an array of objects representing market data
|
|
208234
208231
|
*/
|
|
208235
|
-
const types = this.
|
|
208232
|
+
const types = this.safeList(this.options, 'fetchMarkets', []);
|
|
208236
208233
|
let promises = [];
|
|
208237
208234
|
let result = [];
|
|
208238
208235
|
for (let i = 0; i < types.length; i++) {
|
|
@@ -208336,7 +208333,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208336
208333
|
}
|
|
208337
208334
|
}
|
|
208338
208335
|
const tickSize = this.safeString(market, 'tickSz');
|
|
208339
|
-
const fees = this.
|
|
208336
|
+
const fees = this.safeDict2(this.fees, type, 'trading', {});
|
|
208340
208337
|
let maxLeverage = this.safeString(market, 'lever', '1');
|
|
208341
208338
|
maxLeverage = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMax(maxLeverage, '1');
|
|
208342
208339
|
const maxSpotCost = this.safeNumber(market, 'maxMktSz');
|
|
@@ -208395,7 +208392,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208395
208392
|
'instType': this.convertToInstrumentType(type),
|
|
208396
208393
|
};
|
|
208397
208394
|
if (type === 'option') {
|
|
208398
|
-
const optionsUnderlying = this.
|
|
208395
|
+
const optionsUnderlying = this.safeList(this.options, 'defaultUnderlying', ['BTC-USD', 'ETH-USD']);
|
|
208399
208396
|
const promises = [];
|
|
208400
208397
|
for (let i = 0; i < optionsUnderlying.length; i++) {
|
|
208401
208398
|
const underlying = optionsUnderlying[i];
|
|
@@ -208405,8 +208402,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208405
208402
|
const promisesResult = await Promise.all(promises);
|
|
208406
208403
|
let markets = [];
|
|
208407
208404
|
for (let i = 0; i < promisesResult.length; i++) {
|
|
208408
|
-
const res = this.
|
|
208409
|
-
const options = this.
|
|
208405
|
+
const res = this.safeDict(promisesResult, i, {});
|
|
208406
|
+
const options = this.safeList(res, 'data', []);
|
|
208410
208407
|
markets = this.arrayConcat(markets, options);
|
|
208411
208408
|
}
|
|
208412
208409
|
return this.parseMarkets(markets);
|
|
@@ -208445,7 +208442,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208445
208442
|
// "msg": ""
|
|
208446
208443
|
// }
|
|
208447
208444
|
//
|
|
208448
|
-
const dataResponse = this.
|
|
208445
|
+
const dataResponse = this.safeList(response, 'data', []);
|
|
208449
208446
|
return this.parseMarkets(dataResponse);
|
|
208450
208447
|
}
|
|
208451
208448
|
safeNetwork(networkId) {
|
|
@@ -208522,7 +208519,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208522
208519
|
// "msg": ""
|
|
208523
208520
|
// }
|
|
208524
208521
|
//
|
|
208525
|
-
const data = this.
|
|
208522
|
+
const data = this.safeList(response, 'data', []);
|
|
208526
208523
|
const result = {};
|
|
208527
208524
|
const dataByCurrencyId = this.groupBy(data, 'ccy');
|
|
208528
208525
|
const currencyIds = Object.keys(dataByCurrencyId);
|
|
@@ -208538,11 +208535,11 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208538
208535
|
let maxPrecision = undefined;
|
|
208539
208536
|
for (let j = 0; j < chains.length; j++) {
|
|
208540
208537
|
const chain = chains[j];
|
|
208541
|
-
const canDeposit = this.
|
|
208538
|
+
const canDeposit = this.safeBool(chain, 'canDep');
|
|
208542
208539
|
depositEnabled = (canDeposit) ? canDeposit : depositEnabled;
|
|
208543
|
-
const canWithdraw = this.
|
|
208540
|
+
const canWithdraw = this.safeBool(chain, 'canWd');
|
|
208544
208541
|
withdrawEnabled = (canWithdraw) ? canWithdraw : withdrawEnabled;
|
|
208545
|
-
const canInternal = this.
|
|
208542
|
+
const canInternal = this.safeBool(chain, 'canInternal');
|
|
208546
208543
|
const active = (canDeposit && canWithdraw && canInternal) ? true : false;
|
|
208547
208544
|
currencyActive = (active) ? active : currencyActive;
|
|
208548
208545
|
const networkId = this.safeString(chain, 'chain');
|
|
@@ -208575,7 +208572,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208575
208572
|
};
|
|
208576
208573
|
}
|
|
208577
208574
|
}
|
|
208578
|
-
const firstChain = this.
|
|
208575
|
+
const firstChain = this.safeDict(chains, 0, {});
|
|
208579
208576
|
result[code] = {
|
|
208580
208577
|
'info': undefined,
|
|
208581
208578
|
'code': code,
|
|
@@ -208651,8 +208648,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208651
208648
|
// ]
|
|
208652
208649
|
// }
|
|
208653
208650
|
//
|
|
208654
|
-
const data = this.
|
|
208655
|
-
const first = this.
|
|
208651
|
+
const data = this.safeList(response, 'data', []);
|
|
208652
|
+
const first = this.safeDict(data, 0, {});
|
|
208656
208653
|
const timestamp = this.safeInteger(first, 'ts');
|
|
208657
208654
|
return this.parseOrderBook(first, symbol, timestamp);
|
|
208658
208655
|
}
|
|
@@ -208753,7 +208750,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208753
208750
|
// ]
|
|
208754
208751
|
// }
|
|
208755
208752
|
//
|
|
208756
|
-
const data = this.
|
|
208753
|
+
const data = this.safeList(response, 'data', []);
|
|
208757
208754
|
const first = this.safeDict(data, 0, {});
|
|
208758
208755
|
return this.parseTicker(first, market);
|
|
208759
208756
|
}
|
|
@@ -208776,7 +208773,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
208776
208773
|
'instType': this.convertToInstrumentType(marketType),
|
|
208777
208774
|
};
|
|
208778
208775
|
if (marketType === 'option') {
|
|
208779
|
-
const defaultUnderlying = this.
|
|
208776
|
+
const defaultUnderlying = this.safeString(this.options, 'defaultUnderlying', 'BTC-USD');
|
|
208780
208777
|
const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
|
|
208781
208778
|
if (currencyId === undefined) {
|
|
208782
208779
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
|
|
@@ -209042,7 +209039,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
209042
209039
|
}
|
|
209043
209040
|
const price = this.safeString(params, 'price');
|
|
209044
209041
|
params = this.omit(params, 'price');
|
|
209045
|
-
const options = this.
|
|
209042
|
+
const options = this.safeDict(this.options, 'fetchOHLCV', {});
|
|
209046
209043
|
const timezone = this.safeString(options, 'timezone', 'UTC');
|
|
209047
209044
|
if (limit === undefined) {
|
|
209048
209045
|
limit = 100; // default 100, max 100
|
|
@@ -209175,7 +209172,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
209175
209172
|
// }
|
|
209176
209173
|
//
|
|
209177
209174
|
const rates = [];
|
|
209178
|
-
const data = this.
|
|
209175
|
+
const data = this.safeList(response, 'data', []);
|
|
209179
209176
|
for (let i = 0; i < data.length; i++) {
|
|
209180
209177
|
const rate = data[i];
|
|
209181
209178
|
const timestamp = this.safeInteger(rate, 'fundingTime');
|
|
@@ -209200,10 +209197,10 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
209200
209197
|
}
|
|
209201
209198
|
parseTradingBalance(response) {
|
|
209202
209199
|
const result = { 'info': response };
|
|
209203
|
-
const data = this.
|
|
209204
|
-
const first = this.
|
|
209200
|
+
const data = this.safeList(response, 'data', []);
|
|
209201
|
+
const first = this.safeDict(data, 0, {});
|
|
209205
209202
|
const timestamp = this.safeInteger(first, 'uTime');
|
|
209206
|
-
const details = this.
|
|
209203
|
+
const details = this.safeList(first, 'details', []);
|
|
209207
209204
|
for (let i = 0; i < details.length; i++) {
|
|
209208
209205
|
const balance = details[i];
|
|
209209
209206
|
const currencyId = this.safeString(balance, 'ccy');
|
|
@@ -209228,7 +209225,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
209228
209225
|
}
|
|
209229
209226
|
parseFundingBalance(response) {
|
|
209230
209227
|
const result = { 'info': response };
|
|
209231
|
-
const data = this.
|
|
209228
|
+
const data = this.safeList(response, 'data', []);
|
|
209232
209229
|
for (let i = 0; i < data.length; i++) {
|
|
209233
209230
|
const balance = data[i];
|
|
209234
209231
|
const currencyId = this.safeString(balance, 'ccy');
|
|
@@ -209312,8 +209309,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
209312
209309
|
// "msg": ""
|
|
209313
209310
|
// }
|
|
209314
209311
|
//
|
|
209315
|
-
const data = this.
|
|
209316
|
-
const first = this.
|
|
209312
|
+
const data = this.safeList(response, 'data', []);
|
|
209313
|
+
const first = this.safeDict(data, 0, {});
|
|
209317
209314
|
return this.parseTradingFee(first, market);
|
|
209318
209315
|
}
|
|
209319
209316
|
async fetchBalance(params = {}) {
|
|
@@ -209801,8 +209798,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
209801
209798
|
else {
|
|
209802
209799
|
response = await this.privatePostTradeBatchOrders(request);
|
|
209803
209800
|
}
|
|
209804
|
-
const data = this.
|
|
209805
|
-
const first = this.
|
|
209801
|
+
const data = this.safeList(response, 'data', []);
|
|
209802
|
+
const first = this.safeDict(data, 0, {});
|
|
209806
209803
|
const order = this.parseOrder(first, market);
|
|
209807
209804
|
order['type'] = type;
|
|
209808
209805
|
order['side'] = side;
|
|
@@ -211313,7 +211310,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
211313
211310
|
// ]
|
|
211314
211311
|
// }
|
|
211315
211312
|
//
|
|
211316
|
-
const data = this.
|
|
211313
|
+
const data = this.safeList(response, 'data', []);
|
|
211317
211314
|
return this.parseLedger(data, currency, since, limit);
|
|
211318
211315
|
}
|
|
211319
211316
|
parseLedgerEntryType(type) {
|
|
@@ -239776,8 +239773,8 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
239776
239773
|
for (let i = 0; i < marketIds.length; i++) {
|
|
239777
239774
|
const marketId = marketIds[i];
|
|
239778
239775
|
const market = this.safeMarket(marketId);
|
|
239779
|
-
const messageHash = table + ':' + marketId;
|
|
239780
239776
|
const symbol = market['symbol'];
|
|
239777
|
+
const messageHash = table + ':' + symbol;
|
|
239781
239778
|
const trades = this.parseTrades(dataByMarketIds[marketId], market);
|
|
239782
239779
|
let stored = this.safeValue(this.trades, symbol);
|
|
239783
239780
|
if (stored === undefined) {
|
|
@@ -239802,23 +239799,7 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
239802
239799
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
239803
239800
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
239804
239801
|
*/
|
|
239805
|
-
await this.
|
|
239806
|
-
const market = this.market(symbol);
|
|
239807
|
-
symbol = market['symbol'];
|
|
239808
|
-
const table = 'trade';
|
|
239809
|
-
const messageHash = table + ':' + market['id'];
|
|
239810
|
-
const url = this.urls['api']['ws'];
|
|
239811
|
-
const request = {
|
|
239812
|
-
'op': 'subscribe',
|
|
239813
|
-
'args': [
|
|
239814
|
-
messageHash,
|
|
239815
|
-
],
|
|
239816
|
-
};
|
|
239817
|
-
const trades = await this.watch(url, messageHash, this.extend(request, params), messageHash);
|
|
239818
|
-
if (this.newUpdates) {
|
|
239819
|
-
limit = trades.getLimit(symbol, limit);
|
|
239820
|
-
}
|
|
239821
|
-
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
239802
|
+
return await this.watchTradesForSymbols([symbol], since, limit, params);
|
|
239822
239803
|
}
|
|
239823
239804
|
async authenticate(params = {}) {
|
|
239824
239805
|
const url = this.urls['api']['ws'];
|
|
@@ -240451,6 +240432,43 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
240451
240432
|
const orderbook = await this.watchMultiple(url, messageHashes, this.deepExtend(request, params), topics);
|
|
240452
240433
|
return orderbook.limit();
|
|
240453
240434
|
}
|
|
240435
|
+
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
240436
|
+
/**
|
|
240437
|
+
* @method
|
|
240438
|
+
* @name bitmex#watchTradesForSymbols
|
|
240439
|
+
* @description get the list of most recent trades for a list of symbols
|
|
240440
|
+
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
240441
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
240442
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
240443
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
240444
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
240445
|
+
*/
|
|
240446
|
+
await this.loadMarkets();
|
|
240447
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
240448
|
+
const table = 'trade';
|
|
240449
|
+
const topics = [];
|
|
240450
|
+
const messageHashes = [];
|
|
240451
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
240452
|
+
const symbol = symbols[i];
|
|
240453
|
+
const market = this.market(symbol);
|
|
240454
|
+
const topic = table + ':' + market['id'];
|
|
240455
|
+
topics.push(topic);
|
|
240456
|
+
const messageHash = table + ':' + symbol;
|
|
240457
|
+
messageHashes.push(messageHash);
|
|
240458
|
+
}
|
|
240459
|
+
const url = this.urls['api']['ws'];
|
|
240460
|
+
const request = {
|
|
240461
|
+
'op': 'subscribe',
|
|
240462
|
+
'args': topics,
|
|
240463
|
+
};
|
|
240464
|
+
const trades = await this.watchMultiple(url, messageHashes, this.deepExtend(request, params), topics);
|
|
240465
|
+
if (this.newUpdates) {
|
|
240466
|
+
const first = this.safeValue(trades, 0);
|
|
240467
|
+
const tradeSymbol = this.safeString(first, 'symbol');
|
|
240468
|
+
limit = trades.getLimit(tradeSymbol, limit);
|
|
240469
|
+
}
|
|
240470
|
+
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
240471
|
+
}
|
|
240454
240472
|
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
240455
240473
|
/**
|
|
240456
240474
|
* @method
|
|
@@ -266864,8 +266882,8 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
266864
266882
|
/* harmony export */ Z: () => (/* binding */ kucoin)
|
|
266865
266883
|
/* harmony export */ });
|
|
266866
266884
|
/* harmony import */ var _kucoin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3583);
|
|
266867
|
-
/* harmony import */ var
|
|
266868
|
-
/* harmony import */ var
|
|
266885
|
+
/* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
|
|
266886
|
+
/* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3020);
|
|
266869
266887
|
// ---------------------------------------------------------------------------
|
|
266870
266888
|
|
|
266871
266889
|
|
|
@@ -266883,6 +266901,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
266883
266901
|
'cancelOrderWs': false,
|
|
266884
266902
|
'cancelOrdersWs': false,
|
|
266885
266903
|
'cancelAllOrdersWs': false,
|
|
266904
|
+
'watchBidsAsks': true,
|
|
266886
266905
|
'watchOrderBook': true,
|
|
266887
266906
|
'watchOrders': true,
|
|
266888
266907
|
'watchMyTrades': true,
|
|
@@ -267150,6 +267169,92 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267150
267169
|
}
|
|
267151
267170
|
}
|
|
267152
267171
|
}
|
|
267172
|
+
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
267173
|
+
/**
|
|
267174
|
+
* @method
|
|
267175
|
+
* @name kucoin#watchBidsAsks
|
|
267176
|
+
* @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/level1-bbo-market-data
|
|
267177
|
+
* @description watches best bid & ask for symbols
|
|
267178
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
267179
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
267180
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
267181
|
+
*/
|
|
267182
|
+
const ticker = await this.watchMultiHelper('watchBidsAsks', '/spotMarket/level1:', symbols, params);
|
|
267183
|
+
if (this.newUpdates) {
|
|
267184
|
+
const tickers = {};
|
|
267185
|
+
tickers[ticker['symbol']] = ticker;
|
|
267186
|
+
return tickers;
|
|
267187
|
+
}
|
|
267188
|
+
return this.filterByArray(this.bidsasks, 'symbol', symbols);
|
|
267189
|
+
}
|
|
267190
|
+
async watchMultiHelper(methodName, channelName, symbols = undefined, params = {}) {
|
|
267191
|
+
await this.loadMarkets();
|
|
267192
|
+
symbols = this.marketSymbols(symbols, undefined, false, true, false);
|
|
267193
|
+
const length = symbols.length;
|
|
267194
|
+
if (length > 100) {
|
|
267195
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' ' + methodName + '() accepts a maximum of 100 symbols');
|
|
267196
|
+
}
|
|
267197
|
+
const messageHashes = [];
|
|
267198
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
267199
|
+
const symbol = symbols[i];
|
|
267200
|
+
const market = this.market(symbol);
|
|
267201
|
+
messageHashes.push('bidask@' + market['symbol']);
|
|
267202
|
+
}
|
|
267203
|
+
const url = await this.negotiate(false);
|
|
267204
|
+
const marketIds = this.marketIds(symbols);
|
|
267205
|
+
const joined = marketIds.join(',');
|
|
267206
|
+
const requestId = this.requestId().toString();
|
|
267207
|
+
const request = {
|
|
267208
|
+
'id': requestId,
|
|
267209
|
+
'type': 'subscribe',
|
|
267210
|
+
'topic': channelName + joined,
|
|
267211
|
+
'response': true,
|
|
267212
|
+
};
|
|
267213
|
+
const message = this.extend(request, params);
|
|
267214
|
+
return await this.watchMultiple(url, messageHashes, message, messageHashes);
|
|
267215
|
+
}
|
|
267216
|
+
handleBidAsk(client, message) {
|
|
267217
|
+
//
|
|
267218
|
+
// arrives one symbol dict
|
|
267219
|
+
//
|
|
267220
|
+
// {
|
|
267221
|
+
// topic: '/spotMarket/level1:ETH-USDT',
|
|
267222
|
+
// type: 'message',
|
|
267223
|
+
// data: {
|
|
267224
|
+
// asks: [ '3347.42', '2.0778387' ],
|
|
267225
|
+
// bids: [ '3347.41', '6.0411697' ],
|
|
267226
|
+
// timestamp: 1712231142085
|
|
267227
|
+
// },
|
|
267228
|
+
// subject: 'level1'
|
|
267229
|
+
// }
|
|
267230
|
+
//
|
|
267231
|
+
const parsedTicker = this.parseWsBidAsk(message);
|
|
267232
|
+
const symbol = parsedTicker['symbol'];
|
|
267233
|
+
this.bidsasks[symbol] = parsedTicker;
|
|
267234
|
+
const messageHash = 'bidask@' + symbol;
|
|
267235
|
+
client.resolve(parsedTicker, messageHash);
|
|
267236
|
+
}
|
|
267237
|
+
parseWsBidAsk(ticker, market = undefined) {
|
|
267238
|
+
const topic = this.safeString(ticker, 'topic');
|
|
267239
|
+
const parts = topic.split(':');
|
|
267240
|
+
const marketId = parts[1];
|
|
267241
|
+
market = this.safeMarket(marketId, market);
|
|
267242
|
+
const symbol = this.safeString(market, 'symbol');
|
|
267243
|
+
const data = this.safeDict(ticker, 'data', {});
|
|
267244
|
+
const ask = this.safeList(data, 'asks', []);
|
|
267245
|
+
const bid = this.safeList(data, 'bids', []);
|
|
267246
|
+
const timestamp = this.safeInteger(data, 'timestamp');
|
|
267247
|
+
return this.safeTicker({
|
|
267248
|
+
'symbol': symbol,
|
|
267249
|
+
'timestamp': timestamp,
|
|
267250
|
+
'datetime': this.iso8601(timestamp),
|
|
267251
|
+
'ask': this.safeNumber(ask, 0),
|
|
267252
|
+
'askVolume': this.safeNumber(ask, 1),
|
|
267253
|
+
'bid': this.safeNumber(bid, 0),
|
|
267254
|
+
'bidVolume': this.safeNumber(bid, 1),
|
|
267255
|
+
'info': ticker,
|
|
267256
|
+
}, market);
|
|
267257
|
+
}
|
|
267153
267258
|
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
267154
267259
|
/**
|
|
267155
267260
|
* @method
|
|
@@ -267211,7 +267316,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267211
267316
|
let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
|
|
267212
267317
|
if (stored === undefined) {
|
|
267213
267318
|
const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
|
|
267214
|
-
stored = new
|
|
267319
|
+
stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
|
|
267215
267320
|
this.ohlcvs[symbol][timeframe] = stored;
|
|
267216
267321
|
}
|
|
267217
267322
|
const ohlcv = this.parseOHLCV(candles, market);
|
|
@@ -267244,7 +267349,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267244
267349
|
*/
|
|
267245
267350
|
const symbolsLength = symbols.length;
|
|
267246
267351
|
if (symbolsLength === 0) {
|
|
267247
|
-
throw new
|
|
267352
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
|
|
267248
267353
|
}
|
|
267249
267354
|
await this.loadMarkets();
|
|
267250
267355
|
symbols = this.marketSymbols(symbols);
|
|
@@ -267294,7 +267399,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267294
267399
|
let trades = this.safeValue(this.trades, symbol);
|
|
267295
267400
|
if (trades === undefined) {
|
|
267296
267401
|
const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
267297
|
-
trades = new
|
|
267402
|
+
trades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCache */ .ZL(limit);
|
|
267298
267403
|
this.trades[symbol] = trades;
|
|
267299
267404
|
}
|
|
267300
267405
|
trades.append(trade);
|
|
@@ -267349,11 +267454,11 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267349
267454
|
*/
|
|
267350
267455
|
const symbolsLength = symbols.length;
|
|
267351
267456
|
if (symbolsLength === 0) {
|
|
267352
|
-
throw new
|
|
267457
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols');
|
|
267353
267458
|
}
|
|
267354
267459
|
if (limit !== undefined) {
|
|
267355
267460
|
if ((limit !== 20) && (limit !== 100) && (limit !== 50) && (limit !== 5)) {
|
|
267356
|
-
throw new
|
|
267461
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + " watchOrderBook 'limit' argument must be undefined, 5, 20, 50 or 100");
|
|
267357
267462
|
}
|
|
267358
267463
|
}
|
|
267359
267464
|
await this.loadMarkets();
|
|
@@ -267541,6 +267646,9 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267541
267646
|
// }
|
|
267542
267647
|
//
|
|
267543
267648
|
const id = this.safeString(message, 'id');
|
|
267649
|
+
if (!(id in client.subscriptions)) {
|
|
267650
|
+
return;
|
|
267651
|
+
}
|
|
267544
267652
|
const subscriptionHash = this.safeString(client.subscriptions, id);
|
|
267545
267653
|
const subscription = this.safeValue(client.subscriptions, subscriptionHash);
|
|
267546
267654
|
delete client.subscriptions[id];
|
|
@@ -267710,8 +267818,8 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267710
267818
|
const isTriggerOrder = (triggerPrice !== undefined);
|
|
267711
267819
|
if (this.orders === undefined) {
|
|
267712
267820
|
const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
|
|
267713
|
-
this.orders = new
|
|
267714
|
-
this.triggerOrders = new
|
|
267821
|
+
this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
|
|
267822
|
+
this.triggerOrders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
|
|
267715
267823
|
}
|
|
267716
267824
|
const cachedOrders = isTriggerOrder ? this.triggerOrders : this.orders;
|
|
267717
267825
|
const orders = this.safeValue(cachedOrders.hashmap, symbol, {});
|
|
@@ -267759,7 +267867,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267759
267867
|
handleMyTrade(client, message) {
|
|
267760
267868
|
if (this.myTrades === undefined) {
|
|
267761
267869
|
const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
267762
|
-
this.myTrades = new
|
|
267870
|
+
this.myTrades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
|
|
267763
267871
|
}
|
|
267764
267872
|
const data = this.safeDict(message, 'data');
|
|
267765
267873
|
const parsed = this.parseWsTrade(data);
|
|
@@ -267914,6 +268022,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
267914
268022
|
}
|
|
267915
268023
|
const subject = this.safeString(message, 'subject');
|
|
267916
268024
|
const methods = {
|
|
268025
|
+
'level1': this.handleBidAsk,
|
|
267917
268026
|
'level2': this.handleOrderBook,
|
|
267918
268027
|
'trade.l2update': this.handleOrderBook,
|
|
267919
268028
|
'trade.ticker': this.handleTicker,
|
|
@@ -268003,6 +268112,8 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268003
268112
|
'has': {
|
|
268004
268113
|
'ws': true,
|
|
268005
268114
|
'watchTicker': true,
|
|
268115
|
+
'watchTickers': true,
|
|
268116
|
+
'watchBidsAsks': true,
|
|
268006
268117
|
'watchTrades': true,
|
|
268007
268118
|
'watchOrderBook': true,
|
|
268008
268119
|
'watchOrders': true,
|
|
@@ -268032,9 +268143,6 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268032
268143
|
'snapshotDelay': 20,
|
|
268033
268144
|
'snapshotMaxRetries': 3,
|
|
268034
268145
|
},
|
|
268035
|
-
'watchTicker': {
|
|
268036
|
-
'name': 'contractMarket/tickerV2', // market/ticker
|
|
268037
|
-
},
|
|
268038
268146
|
'watchPosition': {
|
|
268039
268147
|
'fetchPositionSnapshot': true,
|
|
268040
268148
|
'awaitPositionSnapshot': true, // whether to wait for the position snapshot before providing updates
|
|
@@ -268137,7 +268245,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268137
268245
|
}
|
|
268138
268246
|
return await this.watch(url, messageHash, message, subscriptionHash, subscription);
|
|
268139
268247
|
}
|
|
268140
|
-
async subscribeMultiple(url, messageHashes, topic, subscriptionHashes,
|
|
268248
|
+
async subscribeMultiple(url, messageHashes, topic, subscriptionHashes, subscriptionArgs, params = {}) {
|
|
268141
268249
|
const requestId = this.requestId().toString();
|
|
268142
268250
|
const request = {
|
|
268143
268251
|
'id': requestId,
|
|
@@ -268145,24 +268253,14 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268145
268253
|
'topic': topic,
|
|
268146
268254
|
'response': true,
|
|
268147
268255
|
};
|
|
268148
|
-
|
|
268149
|
-
const subscriptionRequest = {
|
|
268150
|
-
'id': requestId,
|
|
268151
|
-
};
|
|
268152
|
-
if (subscription === undefined) {
|
|
268153
|
-
subscription = subscriptionRequest;
|
|
268154
|
-
}
|
|
268155
|
-
else {
|
|
268156
|
-
subscription = this.extend(subscriptionRequest, subscription);
|
|
268157
|
-
}
|
|
268158
|
-
return await this.watchMultiple(url, messageHashes, message, subscriptionHashes, subscription);
|
|
268256
|
+
return await this.watchMultiple(url, messageHashes, this.extend(request, params), subscriptionHashes, subscriptionArgs);
|
|
268159
268257
|
}
|
|
268160
268258
|
async watchTicker(symbol, params = {}) {
|
|
268161
268259
|
/**
|
|
268162
268260
|
* @method
|
|
268163
268261
|
* @name kucoinfutures#watchTicker
|
|
268164
268262
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
268165
|
-
* @see https://
|
|
268263
|
+
* @see https://www.kucoin.com/docs/websocket/futures-trading/public-channels/get-ticker
|
|
268166
268264
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
268167
268265
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
268168
268266
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -268170,30 +268268,48 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268170
268268
|
await this.loadMarkets();
|
|
268171
268269
|
const market = this.market(symbol);
|
|
268172
268270
|
symbol = market['symbol'];
|
|
268173
|
-
|
|
268174
|
-
const
|
|
268175
|
-
|
|
268176
|
-
|
|
268177
|
-
|
|
268178
|
-
|
|
268271
|
+
params['callerMethodName'] = 'watchTicker';
|
|
268272
|
+
const tickers = await this.watchTickers([symbol], params);
|
|
268273
|
+
return tickers[symbol];
|
|
268274
|
+
}
|
|
268275
|
+
async watchTickers(symbols = undefined, params = {}) {
|
|
268276
|
+
/**
|
|
268277
|
+
* @method
|
|
268278
|
+
* @name kucoinfutures#watchTickers
|
|
268279
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
268280
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
268281
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
268282
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
268283
|
+
*/
|
|
268284
|
+
await this.loadMarkets();
|
|
268285
|
+
const ticker = await this.watchMultiRequest('watchTickers', '/contractMarket/ticker:', symbols, params);
|
|
268286
|
+
if (this.newUpdates) {
|
|
268287
|
+
const tickers = {};
|
|
268288
|
+
tickers[ticker['symbol']] = ticker;
|
|
268289
|
+
return tickers;
|
|
268290
|
+
}
|
|
268291
|
+
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
268179
268292
|
}
|
|
268180
268293
|
handleTicker(client, message) {
|
|
268181
268294
|
//
|
|
268182
|
-
//
|
|
268295
|
+
// ticker (v1)
|
|
268183
268296
|
//
|
|
268184
268297
|
// {
|
|
268185
|
-
//
|
|
268186
|
-
//
|
|
268187
|
-
//
|
|
268188
|
-
//
|
|
268189
|
-
//
|
|
268190
|
-
//
|
|
268191
|
-
//
|
|
268192
|
-
//
|
|
268193
|
-
//
|
|
268194
|
-
//
|
|
268195
|
-
//
|
|
268196
|
-
//
|
|
268298
|
+
// "subject": "ticker",
|
|
268299
|
+
// "topic": "/contractMarket/ticker:XBTUSDM",
|
|
268300
|
+
// "data": {
|
|
268301
|
+
// "symbol": "XBTUSDM", //Market of the symbol
|
|
268302
|
+
// "sequence": 45, //Sequence number which is used to judge the continuity of the pushed messages
|
|
268303
|
+
// "side": "sell", //Transaction side of the last traded taker order
|
|
268304
|
+
// "price": "3600.0", //Filled price
|
|
268305
|
+
// "size": 16, //Filled quantity
|
|
268306
|
+
// "tradeId": "5c9dcf4170744d6f5a3d32fb", //Order ID
|
|
268307
|
+
// "bestBidSize": 795, //Best bid size
|
|
268308
|
+
// "bestBidPrice": "3200.0", //Best bid
|
|
268309
|
+
// "bestAskPrice": "3600.0", //Best ask size
|
|
268310
|
+
// "bestAskSize": 284, //Best ask
|
|
268311
|
+
// "ts": 1553846081210004941 //Filled time - nanosecond
|
|
268312
|
+
// }
|
|
268197
268313
|
// }
|
|
268198
268314
|
//
|
|
268199
268315
|
const data = this.safeValue(message, 'data', {});
|
|
@@ -268201,9 +268317,95 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268201
268317
|
const market = this.safeMarket(marketId, undefined, '-');
|
|
268202
268318
|
const ticker = this.parseTicker(data, market);
|
|
268203
268319
|
this.tickers[market['symbol']] = ticker;
|
|
268204
|
-
|
|
268205
|
-
|
|
268206
|
-
|
|
268320
|
+
client.resolve(ticker, this.getMessageHash('ticker', market['symbol']));
|
|
268321
|
+
}
|
|
268322
|
+
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
268323
|
+
/**
|
|
268324
|
+
* @method
|
|
268325
|
+
* @name kucoinfutures#watchBidsAsks
|
|
268326
|
+
* @see https://www.kucoin.com/docs/websocket/futures-trading/public-channels/get-ticker-v2
|
|
268327
|
+
* @description watches best bid & ask for symbols
|
|
268328
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
268329
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
268330
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
268331
|
+
*/
|
|
268332
|
+
const ticker = await this.watchMultiRequest('watchBidsAsks', '/contractMarket/tickerV2:', symbols, params);
|
|
268333
|
+
if (this.newUpdates) {
|
|
268334
|
+
const tickers = {};
|
|
268335
|
+
tickers[ticker['symbol']] = ticker;
|
|
268336
|
+
return tickers;
|
|
268337
|
+
}
|
|
268338
|
+
return this.filterByArray(this.bidsasks, 'symbol', symbols);
|
|
268339
|
+
}
|
|
268340
|
+
async watchMultiRequest(methodName, channelName, symbols = undefined, params = {}) {
|
|
268341
|
+
await this.loadMarkets();
|
|
268342
|
+
[methodName, params] = this.handleParamString(params, 'callerMethodName', methodName);
|
|
268343
|
+
const isBidsAsks = (methodName === 'watchBidsAsks');
|
|
268344
|
+
symbols = this.marketSymbols(symbols, undefined, false, true, false);
|
|
268345
|
+
const length = symbols.length;
|
|
268346
|
+
if (length > 100) {
|
|
268347
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' ' + methodName + '() accepts a maximum of 100 symbols');
|
|
268348
|
+
}
|
|
268349
|
+
const messageHashes = [];
|
|
268350
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
268351
|
+
const symbol = symbols[i];
|
|
268352
|
+
const market = this.market(symbol);
|
|
268353
|
+
const prefix = isBidsAsks ? 'bidask' : 'ticker';
|
|
268354
|
+
messageHashes.push(this.getMessageHash(prefix, market['symbol']));
|
|
268355
|
+
}
|
|
268356
|
+
const url = await this.negotiate(false);
|
|
268357
|
+
const marketIds = this.marketIds(symbols);
|
|
268358
|
+
const joined = marketIds.join(',');
|
|
268359
|
+
const requestId = this.requestId().toString();
|
|
268360
|
+
const request = {
|
|
268361
|
+
'id': requestId,
|
|
268362
|
+
'type': 'subscribe',
|
|
268363
|
+
'topic': channelName + joined,
|
|
268364
|
+
'response': true,
|
|
268365
|
+
};
|
|
268366
|
+
const subscription = {
|
|
268367
|
+
'id': requestId,
|
|
268368
|
+
};
|
|
268369
|
+
return await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscription);
|
|
268370
|
+
}
|
|
268371
|
+
handleBidAsk(client, message) {
|
|
268372
|
+
//
|
|
268373
|
+
// arrives one symbol dict
|
|
268374
|
+
//
|
|
268375
|
+
// {
|
|
268376
|
+
// "subject": "tickerV2",
|
|
268377
|
+
// "topic": "/contractMarket/tickerV2:XBTUSDM",
|
|
268378
|
+
// "data": {
|
|
268379
|
+
// "symbol": "XBTUSDM", //Market of the symbol
|
|
268380
|
+
// "bestBidSize": 795, // Best bid size
|
|
268381
|
+
// "bestBidPrice": 3200.0, // Best bid
|
|
268382
|
+
// "bestAskPrice": 3600.0, // Best ask
|
|
268383
|
+
// "bestAskSize": 284, // Best ask size
|
|
268384
|
+
// "ts": 1553846081210004941 // Filled time - nanosecond
|
|
268385
|
+
// }
|
|
268386
|
+
// }
|
|
268387
|
+
//
|
|
268388
|
+
const parsedTicker = this.parseWsBidAsk(message);
|
|
268389
|
+
const symbol = parsedTicker['symbol'];
|
|
268390
|
+
this.bidsasks[symbol] = parsedTicker;
|
|
268391
|
+
client.resolve(parsedTicker, this.getMessageHash('bidask', symbol));
|
|
268392
|
+
}
|
|
268393
|
+
parseWsBidAsk(ticker, market = undefined) {
|
|
268394
|
+
const data = this.safeDict(ticker, 'data', {});
|
|
268395
|
+
const marketId = this.safeString(data, 'symbol');
|
|
268396
|
+
market = this.safeMarket(marketId, market);
|
|
268397
|
+
const symbol = this.safeString(market, 'symbol');
|
|
268398
|
+
const timestamp = this.safeIntegerProduct(data, 'ts', 0.000001);
|
|
268399
|
+
return this.safeTicker({
|
|
268400
|
+
'symbol': symbol,
|
|
268401
|
+
'timestamp': timestamp,
|
|
268402
|
+
'datetime': this.iso8601(timestamp),
|
|
268403
|
+
'ask': this.safeNumber(data, 'bestAskPrice'),
|
|
268404
|
+
'askVolume': this.safeNumber(data, 'bestAskSize'),
|
|
268405
|
+
'bid': this.safeNumber(data, 'bestBidPrice'),
|
|
268406
|
+
'bidVolume': this.safeNumber(data, 'bestBidSize'),
|
|
268407
|
+
'info': ticker,
|
|
268408
|
+
}, market);
|
|
268207
268409
|
}
|
|
268208
268410
|
async watchPosition(symbol = undefined, params = {}) {
|
|
268209
268411
|
/**
|
|
@@ -268422,7 +268624,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268422
268624
|
messageHashes.push('trades:' + symbol);
|
|
268423
268625
|
subscriptionHashes.push('/contractMarket/execution:' + marketId);
|
|
268424
268626
|
}
|
|
268425
|
-
const trades = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, params);
|
|
268627
|
+
const trades = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, undefined, params);
|
|
268426
268628
|
if (this.newUpdates) {
|
|
268427
268629
|
const first = this.safeValue(trades, 0);
|
|
268428
268630
|
const tradeSymbol = this.safeString(first, 'symbol');
|
|
@@ -268508,9 +268710,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268508
268710
|
const marketIds = this.marketIds(symbols);
|
|
268509
268711
|
const url = await this.negotiate(false);
|
|
268510
268712
|
const topic = '/contractMarket/level2:' + marketIds.join(',');
|
|
268511
|
-
const
|
|
268512
|
-
'method': this.handleOrderBookSubscription,
|
|
268513
|
-
'symbols': symbols,
|
|
268713
|
+
const subscriptionArgs = {
|
|
268514
268714
|
'limit': limit,
|
|
268515
268715
|
};
|
|
268516
268716
|
const subscriptionHashes = [];
|
|
@@ -268521,7 +268721,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268521
268721
|
messageHashes.push('orderbook:' + symbol);
|
|
268522
268722
|
subscriptionHashes.push('/contractMarket/level2:' + marketId);
|
|
268523
268723
|
}
|
|
268524
|
-
const orderbook = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes,
|
|
268724
|
+
const orderbook = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, subscriptionArgs, params);
|
|
268525
268725
|
return orderbook.limit();
|
|
268526
268726
|
}
|
|
268527
268727
|
handleDelta(orderbook, delta) {
|
|
@@ -268572,11 +268772,13 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268572
268772
|
const marketId = this.safeString(topicParts, 1);
|
|
268573
268773
|
const symbol = this.safeSymbol(marketId, undefined, '-');
|
|
268574
268774
|
const messageHash = 'orderbook:' + symbol;
|
|
268575
|
-
|
|
268576
|
-
|
|
268577
|
-
|
|
268578
|
-
|
|
268775
|
+
if (!(symbol in this.orderbooks)) {
|
|
268776
|
+
const subscriptionArgs = this.safeDict(client.subscriptions, topic, {});
|
|
268777
|
+
const limit = this.safeInteger(subscriptionArgs, 'limit');
|
|
268778
|
+
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
268579
268779
|
}
|
|
268780
|
+
const storedOrderBook = this.orderbooks[symbol];
|
|
268781
|
+
const nonce = this.safeInteger(storedOrderBook, 'nonce');
|
|
268580
268782
|
const deltaEnd = this.safeInteger(data, 'sequence');
|
|
268581
268783
|
if (nonce === undefined) {
|
|
268582
268784
|
const cacheLength = storedOrderBook.cache.length;
|
|
@@ -268622,39 +268824,6 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268622
268824
|
}
|
|
268623
268825
|
return cache.length;
|
|
268624
268826
|
}
|
|
268625
|
-
handleOrderBookSubscription(client, message, subscription) {
|
|
268626
|
-
const limit = this.safeInteger(subscription, 'limit');
|
|
268627
|
-
const symbols = this.safeValue(subscription, 'symbols');
|
|
268628
|
-
if (symbols === undefined) {
|
|
268629
|
-
const symbol = this.safeString(subscription, 'symbol');
|
|
268630
|
-
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
268631
|
-
}
|
|
268632
|
-
else {
|
|
268633
|
-
for (let i = 0; i < symbols.length; i++) {
|
|
268634
|
-
const symbol = symbols[i];
|
|
268635
|
-
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
268636
|
-
}
|
|
268637
|
-
}
|
|
268638
|
-
// moved snapshot initialization to handleOrderBook to fix
|
|
268639
|
-
// https://github.com/ccxt/ccxt/issues/6820
|
|
268640
|
-
// the general idea is to fetch the snapshot after the first delta
|
|
268641
|
-
// but not before, because otherwise we cannot synchronize the feed
|
|
268642
|
-
}
|
|
268643
|
-
handleSubscriptionStatus(client, message) {
|
|
268644
|
-
//
|
|
268645
|
-
// {
|
|
268646
|
-
// "id": "1578090438322",
|
|
268647
|
-
// "type": "ack"
|
|
268648
|
-
// }
|
|
268649
|
-
//
|
|
268650
|
-
const id = this.safeString(message, 'id');
|
|
268651
|
-
const subscriptionsById = this.indexBy(client.subscriptions, 'id');
|
|
268652
|
-
const subscription = this.safeValue(subscriptionsById, id, {});
|
|
268653
|
-
const method = this.safeValue(subscription, 'method');
|
|
268654
|
-
if (method !== undefined) {
|
|
268655
|
-
method.call(this, client, message, subscription);
|
|
268656
|
-
}
|
|
268657
|
-
}
|
|
268658
268827
|
handleSystemStatus(client, message) {
|
|
268659
268828
|
//
|
|
268660
268829
|
// todo: answer the question whether handleSystemStatus should be renamed
|
|
@@ -268913,7 +269082,8 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268913
269082
|
const subject = this.safeString(message, 'subject');
|
|
268914
269083
|
const methods = {
|
|
268915
269084
|
'level2': this.handleOrderBook,
|
|
268916
|
-
'
|
|
269085
|
+
'ticker': this.handleTicker,
|
|
269086
|
+
'tickerV2': this.handleBidAsk,
|
|
268917
269087
|
'availableBalance.change': this.handleBalance,
|
|
268918
269088
|
'match': this.handleTrade,
|
|
268919
269089
|
'orderChange': this.handleOrder,
|
|
@@ -268927,6 +269097,15 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268927
269097
|
method.call(this, client, message);
|
|
268928
269098
|
}
|
|
268929
269099
|
}
|
|
269100
|
+
getMessageHash(elementName, symbol = undefined) {
|
|
269101
|
+
// elementName can be 'ticker', 'bidask', ...
|
|
269102
|
+
if (symbol !== undefined) {
|
|
269103
|
+
return elementName + '@' + symbol;
|
|
269104
|
+
}
|
|
269105
|
+
else {
|
|
269106
|
+
return elementName + 's@all';
|
|
269107
|
+
}
|
|
269108
|
+
}
|
|
268930
269109
|
ping(client) {
|
|
268931
269110
|
// kucoin does not support built-in ws protocol-level ping-pong
|
|
268932
269111
|
// instead it requires a custom json-based text ping-pong
|
|
@@ -268966,7 +269145,6 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
268966
269145
|
const methods = {
|
|
268967
269146
|
// 'heartbeat': this.handleHeartbeat,
|
|
268968
269147
|
'welcome': this.handleSystemStatus,
|
|
268969
|
-
'ack': this.handleSubscriptionStatus,
|
|
268970
269148
|
'message': this.handleSubject,
|
|
268971
269149
|
'pong': this.handlePong,
|
|
268972
269150
|
'error': this.handleErrorMessage,
|
|
@@ -325367,7 +325545,7 @@ SOFTWARE.
|
|
|
325367
325545
|
|
|
325368
325546
|
//-----------------------------------------------------------------------------
|
|
325369
325547
|
// this is updated by vss.js when building
|
|
325370
|
-
const version = '4.2.
|
|
325548
|
+
const version = '4.2.91';
|
|
325371
325549
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
325372
325550
|
//-----------------------------------------------------------------------------
|
|
325373
325551
|
|