ccxt 4.0.91 → 4.0.94
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 +951 -285
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bigone.js +5 -3
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/bitopro.js +34 -34
- package/dist/cjs/src/bybit.js +1 -1
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/delta.js +1 -1
- package/dist/cjs/src/gate.js +2 -1
- package/dist/cjs/src/hollaex.js +3 -0
- package/dist/cjs/src/huobi.js +3 -3
- package/dist/cjs/src/okx.js +3 -3
- package/dist/cjs/src/pro/binance.js +3 -3
- package/dist/cjs/src/pro/hitbtc.js +893 -235
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/gate.d.ts +1 -0
- package/js/src/abstract/gateio.d.ts +1 -0
- package/js/src/bigone.js +5 -3
- package/js/src/binance.js +1 -1
- package/js/src/bitopro.js +34 -34
- package/js/src/bybit.js +1 -1
- package/js/src/cryptocom.js +1 -1
- package/js/src/delta.js +1 -1
- package/js/src/gate.js +2 -1
- package/js/src/hollaex.js +3 -0
- package/js/src/huobi.js +3 -3
- package/js/src/okx.js +3 -3
- package/js/src/pro/binance.js +3 -3
- package/js/src/pro/hitbtc.d.ts +19 -4
- package/js/src/pro/hitbtc.js +894 -236
- package/package.json +1 -1
package/dist/ccxt.browser.js
CHANGED
|
@@ -13861,6 +13861,7 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
13861
13861
|
'options': {
|
|
13862
13862
|
'accountsByType': {
|
|
13863
13863
|
'spot': 'SPOT',
|
|
13864
|
+
'fund': 'FUND',
|
|
13864
13865
|
'funding': 'FUND',
|
|
13865
13866
|
'future': 'CONTRACT',
|
|
13866
13867
|
'swap': 'CONTRACT',
|
|
@@ -15320,7 +15321,7 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
15320
15321
|
const txid = this.safeString(transaction, 'txid');
|
|
15321
15322
|
const address = this.safeString(transaction, 'target_address');
|
|
15322
15323
|
const tag = this.safeString(transaction, 'memo');
|
|
15323
|
-
const type = ('customer_id' in transaction) ? '
|
|
15324
|
+
const type = ('customer_id' in transaction) ? 'withdrawal' : 'deposit';
|
|
15324
15325
|
return {
|
|
15325
15326
|
'info': transaction,
|
|
15326
15327
|
'id': id,
|
|
@@ -15449,10 +15450,11 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
15449
15450
|
* @method
|
|
15450
15451
|
* @name bigone#transfer
|
|
15451
15452
|
* @description transfer currency internally between wallets on the same account
|
|
15453
|
+
* @see https://open.big.one/docs/spot_transfer.html#transfer-of-user
|
|
15452
15454
|
* @param {string} code unified currency code
|
|
15453
15455
|
* @param {float} amount amount to transfer
|
|
15454
|
-
* @param {string} fromAccount
|
|
15455
|
-
* @param {string} toAccount
|
|
15456
|
+
* @param {string} fromAccount 'SPOT', 'FUND', or 'CONTRACT'
|
|
15457
|
+
* @param {string} toAccount 'SPOT', 'FUND', or 'CONTRACT'
|
|
15456
15458
|
* @param {object} [params] extra parameters specific to the bigone api endpoint
|
|
15457
15459
|
* @returns {object} a [transfer structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure}
|
|
15458
15460
|
*/
|
|
@@ -23359,7 +23361,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23359
23361
|
* @param {int} [since] timestamp in ms
|
|
23360
23362
|
* @param {int} [limit] number of records, default 100, max 100
|
|
23361
23363
|
* @param {object} [params] exchange specific params
|
|
23362
|
-
* @returns {object[]} a list of [settlement history objects]
|
|
23364
|
+
* @returns {object[]} a list of [settlement history objects]{@link https://github.com/ccxt/ccxt/wiki/Manual#settlement-history-structure}
|
|
23363
23365
|
*/
|
|
23364
23366
|
await this.loadMarkets();
|
|
23365
23367
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
@@ -49394,42 +49396,42 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
49394
49396
|
},
|
|
49395
49397
|
'api': {
|
|
49396
49398
|
'public': {
|
|
49397
|
-
'get':
|
|
49398
|
-
'order-book/{pair}',
|
|
49399
|
-
'tickers',
|
|
49400
|
-
'tickers/{pair}',
|
|
49401
|
-
'trades/{pair}',
|
|
49402
|
-
'provisioning/currencies',
|
|
49403
|
-
'provisioning/trading-pairs',
|
|
49404
|
-
'provisioning/limitations-and-fees',
|
|
49405
|
-
'trading-history/{pair}',
|
|
49406
|
-
|
|
49399
|
+
'get': {
|
|
49400
|
+
'order-book/{pair}': 1,
|
|
49401
|
+
'tickers': 1,
|
|
49402
|
+
'tickers/{pair}': 1,
|
|
49403
|
+
'trades/{pair}': 1,
|
|
49404
|
+
'provisioning/currencies': 1,
|
|
49405
|
+
'provisioning/trading-pairs': 1,
|
|
49406
|
+
'provisioning/limitations-and-fees': 1,
|
|
49407
|
+
'trading-history/{pair}': 1,
|
|
49408
|
+
},
|
|
49407
49409
|
},
|
|
49408
49410
|
'private': {
|
|
49409
|
-
'get':
|
|
49410
|
-
'accounts/balance',
|
|
49411
|
-
'orders/history',
|
|
49412
|
-
'orders/all/{pair}',
|
|
49413
|
-
'orders/trades/{pair}',
|
|
49414
|
-
'orders/{pair}/{orderId}',
|
|
49415
|
-
'wallet/withdraw/{currency}/{serial}',
|
|
49416
|
-
'wallet/withdraw/{currency}/id/{id}',
|
|
49417
|
-
'wallet/depositHistory/{currency}',
|
|
49418
|
-
'wallet/withdrawHistory/{currency}',
|
|
49419
|
-
|
|
49420
|
-
'post':
|
|
49421
|
-
'orders/{pair}',
|
|
49422
|
-
'orders/batch',
|
|
49423
|
-
'wallet/withdraw/{currency}',
|
|
49424
|
-
|
|
49425
|
-
'put':
|
|
49426
|
-
'orders',
|
|
49427
|
-
|
|
49428
|
-
'delete':
|
|
49429
|
-
'orders/{pair}/{id}',
|
|
49430
|
-
'orders/all',
|
|
49431
|
-
'orders/{pair}',
|
|
49432
|
-
|
|
49411
|
+
'get': {
|
|
49412
|
+
'accounts/balance': 1,
|
|
49413
|
+
'orders/history': 1,
|
|
49414
|
+
'orders/all/{pair}': 1,
|
|
49415
|
+
'orders/trades/{pair}': 1,
|
|
49416
|
+
'orders/{pair}/{orderId}': 1,
|
|
49417
|
+
'wallet/withdraw/{currency}/{serial}': 1,
|
|
49418
|
+
'wallet/withdraw/{currency}/id/{id}': 1,
|
|
49419
|
+
'wallet/depositHistory/{currency}': 1,
|
|
49420
|
+
'wallet/withdrawHistory/{currency}': 1,
|
|
49421
|
+
},
|
|
49422
|
+
'post': {
|
|
49423
|
+
'orders/{pair}': 1 / 2,
|
|
49424
|
+
'orders/batch': 20 / 3,
|
|
49425
|
+
'wallet/withdraw/{currency}': 10, // 60/m => 1/s => 10/1 = 10
|
|
49426
|
+
},
|
|
49427
|
+
'put': {
|
|
49428
|
+
'orders': 5, // 2/s => 10/2 = 5
|
|
49429
|
+
},
|
|
49430
|
+
'delete': {
|
|
49431
|
+
'orders/{pair}/{id}': 2 / 3,
|
|
49432
|
+
'orders/all': 5,
|
|
49433
|
+
'orders/{pair}': 5, // 2/s => 10/2 = 5
|
|
49434
|
+
},
|
|
49433
49435
|
},
|
|
49434
49436
|
},
|
|
49435
49437
|
'fees': {
|
|
@@ -80379,7 +80381,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
80379
80381
|
* @param {int} [since] timestamp in ms
|
|
80380
80382
|
* @param {int} [limit] number of records
|
|
80381
80383
|
* @param {object} [params] exchange specific params
|
|
80382
|
-
* @returns {object[]} a list of [settlement history objects]
|
|
80384
|
+
* @returns {object[]} a list of [settlement history objects]{@link https://github.com/ccxt/ccxt/wiki/Manual#settlement-history-structure}
|
|
80383
80385
|
*/
|
|
80384
80386
|
await this.loadMarkets();
|
|
80385
80387
|
const request = {};
|
|
@@ -100938,7 +100940,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
100938
100940
|
* @param {int} [limit] number of records
|
|
100939
100941
|
* @param {object} [params] exchange specific params
|
|
100940
100942
|
* @param {int} [params.type] 'future', 'option'
|
|
100941
|
-
* @returns {object[]} a list of [settlement history objects]
|
|
100943
|
+
* @returns {object[]} a list of [settlement history objects]{@link https://github.com/ccxt/ccxt/wiki/Manual#settlement-history-structure}
|
|
100942
100944
|
*/
|
|
100943
100945
|
await this.loadMarkets();
|
|
100944
100946
|
let market = undefined;
|
|
@@ -106188,7 +106190,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
106188
106190
|
* @param {int} [since] timestamp in ms
|
|
106189
106191
|
* @param {int} [limit] number of records
|
|
106190
106192
|
* @param {object} [params] exchange specific params
|
|
106191
|
-
* @returns {object[]} a list of [settlement history objects]
|
|
106193
|
+
* @returns {object[]} a list of [settlement history objects]{@link https://github.com/ccxt/ccxt/wiki/Manual#settlement-history-structure}
|
|
106192
106194
|
*/
|
|
106193
106195
|
await this.loadMarkets();
|
|
106194
106196
|
let market = undefined;
|
|
@@ -115898,6 +115900,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
115898
115900
|
'spot/orders/{order_id}': 1.5,
|
|
115899
115901
|
},
|
|
115900
115902
|
'post': {
|
|
115903
|
+
'account_mode': 1.5,
|
|
115901
115904
|
'loans': 1.5,
|
|
115902
115905
|
'spot/orders': 1.5,
|
|
115903
115906
|
},
|
|
@@ -121408,7 +121411,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
121408
121411
|
* @param {int} [since] timestamp in ms
|
|
121409
121412
|
* @param {int} [limit] number of records
|
|
121410
121413
|
* @param {object} [params] exchange specific params
|
|
121411
|
-
* @returns {object[]} a list of [settlement history objects]
|
|
121414
|
+
* @returns {object[]} a list of [settlement history objects]{@link https://github.com/ccxt/ccxt/wiki/Manual#settlement-history-structure}
|
|
121412
121415
|
*/
|
|
121413
121416
|
this.checkRequiredSymbol('fetchSettlementHistory', symbol);
|
|
121414
121417
|
await this.loadMarkets();
|
|
@@ -126897,6 +126900,7 @@ class hollaex extends _abstract_hollaex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
126897
126900
|
'createMarketBuyOrder': true,
|
|
126898
126901
|
'createMarketSellOrder': true,
|
|
126899
126902
|
'createOrder': true,
|
|
126903
|
+
'createPostOnlyOrder': true,
|
|
126900
126904
|
'createReduceOnlyOrder': false,
|
|
126901
126905
|
'createStopLimitOrder': true,
|
|
126902
126906
|
'createStopMarketOrder': true,
|
|
@@ -127985,6 +127989,8 @@ class hollaex extends _abstract_hollaex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
127985
127989
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
127986
127990
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
127987
127991
|
* @param {object} [params] extra parameters specific to the hollaex api endpoint
|
|
127992
|
+
* @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
|
|
127993
|
+
* @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
|
|
127988
127994
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
127989
127995
|
*/
|
|
127990
127996
|
await this.loadMarkets();
|
|
@@ -133550,10 +133556,10 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
133550
133556
|
}
|
|
133551
133557
|
}
|
|
133552
133558
|
else {
|
|
133553
|
-
const clientOrderId = this.
|
|
133559
|
+
const clientOrderId = this.safeInteger2(params, 'client_order_id', 'clientOrderId');
|
|
133554
133560
|
if (clientOrderId !== undefined) {
|
|
133555
133561
|
request['client_order_id'] = clientOrderId;
|
|
133556
|
-
params = this.omit(params, ['
|
|
133562
|
+
params = this.omit(params, ['clientOrderId']);
|
|
133557
133563
|
}
|
|
133558
133564
|
if (type === 'limit' || type === 'ioc' || type === 'fok' || type === 'post_only') {
|
|
133559
133565
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
@@ -136601,7 +136607,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
136601
136607
|
* @param {int} [params.until] timestamp in ms, value range = start_time -> current time,default = current time
|
|
136602
136608
|
* @param {int} [params.page_index] page index, default page 1 if not filled
|
|
136603
136609
|
* @param {int} [params.code] unified currency code, can be used when symbol is undefined
|
|
136604
|
-
* @returns
|
|
136610
|
+
* @returns {object[]} a list of [settlement history objects]{@link https://github.com/ccxt/ccxt/wiki/Manual#settlement-history-structure}
|
|
136605
136611
|
*/
|
|
136606
136612
|
const code = this.safeString(params, 'code');
|
|
136607
136613
|
const until = this.safeInteger2(params, 'until', 'till');
|
|
@@ -180076,7 +180082,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
180076
180082
|
else {
|
|
180077
180083
|
request['slOrdPx'] = '-1'; // market sl order
|
|
180078
180084
|
}
|
|
180079
|
-
const stopLossTriggerPriceType = this.safeString2(stopLoss, 'triggerPriceType', 'slTriggerPxType');
|
|
180085
|
+
const stopLossTriggerPriceType = this.safeString2(stopLoss, 'triggerPriceType', 'slTriggerPxType', 'last');
|
|
180080
180086
|
if (stopLossTriggerPriceType !== undefined) {
|
|
180081
180087
|
if ((stopLossTriggerPriceType !== 'last') && (stopLossTriggerPriceType !== 'index') && (stopLossTriggerPriceType !== 'mark')) {
|
|
180082
180088
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' createOrder() stop loss trigger price type must be one of "last", "index" or "mark"');
|
|
@@ -180116,7 +180122,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
180116
180122
|
else {
|
|
180117
180123
|
request['tpOrdPx'] = '-1'; // market tp order
|
|
180118
180124
|
}
|
|
180119
|
-
const takeProfitTriggerPriceType = this.safeString2(
|
|
180125
|
+
const takeProfitTriggerPriceType = this.safeString2(takeProfit, 'triggerPriceType', 'tpTriggerPxType', 'last');
|
|
180120
180126
|
if (takeProfitTriggerPriceType !== undefined) {
|
|
180121
180127
|
if ((takeProfitTriggerPriceType !== 'last') && (takeProfitTriggerPriceType !== 'index') && (takeProfitTriggerPriceType !== 'mark')) {
|
|
180122
180128
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' createOrder() take profit trigger price type must be one of "last", "index" or "mark"');
|
|
@@ -184111,7 +184117,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
184111
184117
|
* @param {int} [since] timestamp in ms
|
|
184112
184118
|
* @param {int} [limit] number of records
|
|
184113
184119
|
* @param {object} [params] exchange specific params
|
|
184114
|
-
* @returns {object[]} a list of [settlement history objects]
|
|
184120
|
+
* @returns {object[]} a list of [settlement history objects]{@link https://github.com/ccxt/ccxt/wiki/Manual#settlement-history-structure}
|
|
184115
184121
|
*/
|
|
184116
184122
|
this.checkRequiredSymbol('fetchSettlementHistory', symbol);
|
|
184117
184123
|
await this.loadMarkets();
|
|
@@ -195371,8 +195377,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
195371
195377
|
for (let i = 0; i < symbols.length; i++) {
|
|
195372
195378
|
const symbol = symbols[i];
|
|
195373
195379
|
const market = this.market(symbol);
|
|
195374
|
-
const
|
|
195375
|
-
subParams.push(
|
|
195380
|
+
const symbolHash = market['lowercaseId'] + '@' + name + '@' + watchOrderBookRate + 'ms';
|
|
195381
|
+
subParams.push(symbolHash);
|
|
195376
195382
|
}
|
|
195377
195383
|
const request = {
|
|
195378
195384
|
'method': 'SUBSCRIBE',
|
|
@@ -195586,7 +195592,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
195586
195592
|
delete this.orderbooks[symbol];
|
|
195587
195593
|
}
|
|
195588
195594
|
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
195589
|
-
subscription
|
|
195595
|
+
subscription = this.extend(subscription, { 'symbol': symbol });
|
|
195590
195596
|
// fetch the snapshot in a separate async call
|
|
195591
195597
|
this.spawn(this.fetchOrderBookSnapshot, client, message, subscription);
|
|
195592
195598
|
}
|
|
@@ -218678,10 +218684,14 @@ class gemini extends _gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
218678
218684
|
/* harmony export */ "Z": () => (/* binding */ hitbtc)
|
|
218679
218685
|
/* harmony export */ });
|
|
218680
218686
|
/* harmony import */ var _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4714);
|
|
218681
|
-
/* harmony import */ var
|
|
218687
|
+
/* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3020);
|
|
218688
|
+
/* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1372);
|
|
218689
|
+
/* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6689);
|
|
218682
218690
|
// ---------------------------------------------------------------------------
|
|
218683
218691
|
|
|
218684
218692
|
|
|
218693
|
+
|
|
218694
|
+
|
|
218685
218695
|
// ---------------------------------------------------------------------------
|
|
218686
218696
|
class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
218687
218697
|
describe() {
|
|
@@ -218689,145 +218699,245 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
218689
218699
|
'has': {
|
|
218690
218700
|
'ws': true,
|
|
218691
218701
|
'watchTicker': true,
|
|
218692
|
-
'watchTickers':
|
|
218702
|
+
'watchTickers': true,
|
|
218693
218703
|
'watchTrades': true,
|
|
218694
218704
|
'watchOrderBook': true,
|
|
218695
|
-
'watchBalance':
|
|
218705
|
+
'watchBalance': true,
|
|
218706
|
+
'watchOrders': true,
|
|
218696
218707
|
'watchOHLCV': true,
|
|
218708
|
+
'watchMyTrades': false,
|
|
218697
218709
|
},
|
|
218698
218710
|
'urls': {
|
|
218699
218711
|
'api': {
|
|
218700
|
-
'ws':
|
|
218712
|
+
'ws': {
|
|
218713
|
+
'public': 'wss://api.hitbtc.com/api/3/ws/public',
|
|
218714
|
+
'private': 'wss://api.hitbtc.com/api/3/ws/trading',
|
|
218715
|
+
},
|
|
218701
218716
|
},
|
|
218702
218717
|
},
|
|
218703
218718
|
'options': {
|
|
218704
218719
|
'tradesLimit': 1000,
|
|
218705
|
-
'
|
|
218706
|
-
'
|
|
218707
|
-
|
|
218708
|
-
|
|
218709
|
-
'
|
|
218720
|
+
'watchTicker': {
|
|
218721
|
+
'method': 'ticker/{speed}', // 'ticker/{speed}' or 'ticker/price/{speed}'
|
|
218722
|
+
},
|
|
218723
|
+
'watchTickers': {
|
|
218724
|
+
'method': 'ticker/{speed}', // 'ticker/{speed}','ticker/price/{speed}', 'ticker/{speed}/batch', or 'ticker/{speed}/price/batch''
|
|
218710
218725
|
},
|
|
218726
|
+
'watchOrderBook': {
|
|
218727
|
+
'method': 'orderbook/full', // 'orderbook/full', 'orderbook/{depth}/{speed}', 'orderbook/{depth}/{speed}/batch', 'orderbook/top/{speed}', or 'orderbook/top/{speed}/batch'
|
|
218728
|
+
},
|
|
218729
|
+
},
|
|
218730
|
+
'timeframes': {
|
|
218731
|
+
'1m': 'M1',
|
|
218732
|
+
'3m': 'M3',
|
|
218733
|
+
'5m': 'M5',
|
|
218734
|
+
'15m': 'M15',
|
|
218735
|
+
'30m': 'M30',
|
|
218736
|
+
'1h': 'H1',
|
|
218737
|
+
'4h': 'H4',
|
|
218738
|
+
'1d': 'D1',
|
|
218739
|
+
'1w': 'D7',
|
|
218740
|
+
'1M': '1M',
|
|
218741
|
+
},
|
|
218742
|
+
'streaming': {
|
|
218743
|
+
'keepAlive': 4000,
|
|
218711
218744
|
},
|
|
218712
218745
|
});
|
|
218713
218746
|
}
|
|
218714
|
-
async
|
|
218747
|
+
async authenticate() {
|
|
218748
|
+
/**
|
|
218749
|
+
* @ignore
|
|
218750
|
+
* @method
|
|
218751
|
+
* @description authenticates the user to access private web socket channels
|
|
218752
|
+
* @see https://api.hitbtc.com/#socket-authentication
|
|
218753
|
+
* @returns {object} response from exchange
|
|
218754
|
+
*/
|
|
218755
|
+
this.checkRequiredCredentials();
|
|
218756
|
+
const url = this.urls['api']['ws']['private'];
|
|
218757
|
+
const messageHash = 'authenticated';
|
|
218758
|
+
const client = this.client(url);
|
|
218759
|
+
const future = client.future(messageHash);
|
|
218760
|
+
const authenticated = this.safeValue(client.subscriptions, messageHash);
|
|
218761
|
+
if (authenticated === undefined) {
|
|
218762
|
+
const timestamp = this.milliseconds();
|
|
218763
|
+
const signature = this.hmac(this.encode(this.numberToString(timestamp)), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_1__/* .sha256 */ .J, 'hex');
|
|
218764
|
+
const request = {
|
|
218765
|
+
'method': 'login',
|
|
218766
|
+
'params': {
|
|
218767
|
+
'type': 'HS256',
|
|
218768
|
+
'api_key': this.apiKey,
|
|
218769
|
+
'timestamp': timestamp,
|
|
218770
|
+
'signature': signature,
|
|
218771
|
+
},
|
|
218772
|
+
};
|
|
218773
|
+
this.watch(url, messageHash, request, messageHash);
|
|
218774
|
+
//
|
|
218775
|
+
// {
|
|
218776
|
+
// jsonrpc: '2.0',
|
|
218777
|
+
// result: true
|
|
218778
|
+
// }
|
|
218779
|
+
//
|
|
218780
|
+
// # Failure to return results
|
|
218781
|
+
//
|
|
218782
|
+
// {
|
|
218783
|
+
// jsonrpc: '2.0',
|
|
218784
|
+
// error: {
|
|
218785
|
+
// code: 1002,
|
|
218786
|
+
// message: 'Authorization is required or has been failed',
|
|
218787
|
+
// description: 'invalid signature format'
|
|
218788
|
+
// }
|
|
218789
|
+
// }
|
|
218790
|
+
//
|
|
218791
|
+
}
|
|
218792
|
+
return future;
|
|
218793
|
+
}
|
|
218794
|
+
async subscribePublic(name, symbols = undefined, params = {}) {
|
|
218795
|
+
/**
|
|
218796
|
+
* @ignore
|
|
218797
|
+
* @method
|
|
218798
|
+
* @param {string} name websocket endpoint name
|
|
218799
|
+
* @param {[string]} [symbols] unified CCXT symbol(s)
|
|
218800
|
+
* @param {object} [params] extra parameters specific to the hitbtc api
|
|
218801
|
+
* @returns
|
|
218802
|
+
*/
|
|
218715
218803
|
await this.loadMarkets();
|
|
218716
|
-
const
|
|
218717
|
-
|
|
218718
|
-
|
|
218719
|
-
|
|
218720
|
-
messageHash += ':' + timeframe;
|
|
218804
|
+
const url = this.urls['api']['ws']['public'];
|
|
218805
|
+
let messageHash = name;
|
|
218806
|
+
if (symbols !== undefined) {
|
|
218807
|
+
messageHash = messageHash + '::' + symbols.join(',');
|
|
218721
218808
|
}
|
|
218722
|
-
const methods = this.safeValue(this.options, 'methods', {});
|
|
218723
|
-
const method = this.safeString(methods, channel, channel);
|
|
218724
|
-
const requestId = this.nonce();
|
|
218725
218809
|
const subscribe = {
|
|
218726
|
-
'method':
|
|
218727
|
-
'
|
|
218728
|
-
|
|
218729
|
-
},
|
|
218730
|
-
'id': requestId,
|
|
218810
|
+
'method': 'subscribe',
|
|
218811
|
+
'id': this.nonce(),
|
|
218812
|
+
'ch': name,
|
|
218731
218813
|
};
|
|
218732
|
-
const request = this.
|
|
218814
|
+
const request = this.extend(subscribe, params);
|
|
218733
218815
|
return await this.watch(url, messageHash, request, messageHash);
|
|
218734
218816
|
}
|
|
218817
|
+
async subscribePrivate(name, symbol = undefined, params = {}) {
|
|
218818
|
+
/**
|
|
218819
|
+
* @ignore
|
|
218820
|
+
* @method
|
|
218821
|
+
* @param {string} name websocket endpoint name
|
|
218822
|
+
* @param {string} [symbol] unified CCXT symbol
|
|
218823
|
+
* @param {object} [params] extra parameters specific to the hitbtc api
|
|
218824
|
+
* @returns
|
|
218825
|
+
*/
|
|
218826
|
+
await this.loadMarkets();
|
|
218827
|
+
await this.authenticate();
|
|
218828
|
+
const url = this.urls['api']['ws']['private'];
|
|
218829
|
+
const splitName = name.split('_subscribe');
|
|
218830
|
+
let messageHash = this.safeString(splitName, 0);
|
|
218831
|
+
if (symbol !== undefined) {
|
|
218832
|
+
messageHash = messageHash + '::' + symbol;
|
|
218833
|
+
}
|
|
218834
|
+
const subscribe = {
|
|
218835
|
+
'method': name,
|
|
218836
|
+
'params': params,
|
|
218837
|
+
'id': this.nonce(),
|
|
218838
|
+
};
|
|
218839
|
+
return await this.watch(url, messageHash, subscribe, messageHash);
|
|
218840
|
+
}
|
|
218735
218841
|
async watchOrderBook(symbol, limit = undefined, params = {}) {
|
|
218736
218842
|
/**
|
|
218737
218843
|
* @method
|
|
218738
218844
|
* @name hitbtc#watchOrderBook
|
|
218739
218845
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
218846
|
+
* @see https://api.hitbtc.com/#subscribe-to-full-order-book
|
|
218847
|
+
* @see https://api.hitbtc.com/#subscribe-to-partial-order-book
|
|
218848
|
+
* @see https://api.hitbtc.com/#subscribe-to-partial-order-book-in-batches
|
|
218849
|
+
* @see https://api.hitbtc.com/#subscribe-to-top-of-book
|
|
218850
|
+
* @see https://api.hitbtc.com/#subscribe-to-top-of-book-in-batches
|
|
218740
218851
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
218741
218852
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
218742
218853
|
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
218743
|
-
* @
|
|
218854
|
+
* @param {string} [params.method] 'orderbook/full', 'orderbook/{depth}/{speed}', 'orderbook/{depth}/{speed}/batch', 'orderbook/top/{speed}', or 'orderbook/top/{speed}/batch'
|
|
218855
|
+
* @param {int} [params.depth] 5 , 10, or 20 (default)
|
|
218856
|
+
* @param {int} [params.speed] 100 (default), 500, or 1000
|
|
218857
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
218744
218858
|
*/
|
|
218745
|
-
const
|
|
218746
|
-
|
|
218747
|
-
|
|
218748
|
-
|
|
218749
|
-
|
|
218750
|
-
|
|
218751
|
-
|
|
218752
|
-
// method: "snapshotOrderbook",
|
|
218753
|
-
// params: {
|
|
218754
|
-
// ask: [
|
|
218755
|
-
// { price: "6927.75", size: "0.11991" },
|
|
218756
|
-
// { price: "6927.76", size: "0.06200" },
|
|
218757
|
-
// { price: "6927.85", size: "0.01000" },
|
|
218758
|
-
// ],
|
|
218759
|
-
// bid: [
|
|
218760
|
-
// { price: "6926.18", size: "0.16898" },
|
|
218761
|
-
// { price: "6926.17", size: "0.06200" },
|
|
218762
|
-
// { price: "6925.97", size: "0.00125" },
|
|
218763
|
-
// ],
|
|
218764
|
-
// symbol: "BTCUSD",
|
|
218765
|
-
// sequence: 494854,
|
|
218766
|
-
// timestamp: "2020-04-03T08:58:53.460Z"
|
|
218767
|
-
// }
|
|
218768
|
-
// }
|
|
218769
|
-
//
|
|
218770
|
-
const params = this.safeValue(message, 'params', {});
|
|
218771
|
-
const marketId = this.safeString(params, 'symbol');
|
|
218772
|
-
const market = this.safeMarket(marketId);
|
|
218773
|
-
const symbol = market['symbol'];
|
|
218774
|
-
const timestamp = this.parse8601(this.safeString(params, 'timestamp'));
|
|
218775
|
-
const nonce = this.safeInteger(params, 'sequence');
|
|
218776
|
-
if (symbol in this.orderbooks) {
|
|
218777
|
-
delete this.orderbooks[symbol];
|
|
218859
|
+
const options = this.safeValue(this.options, 'watchOrderBook');
|
|
218860
|
+
const defaultMethod = this.safeString(options, 'method', 'orderbook/full');
|
|
218861
|
+
let name = this.safeString2(params, 'method', 'defaultMethod', defaultMethod);
|
|
218862
|
+
const depth = this.safeString(params, 'depth', '20');
|
|
218863
|
+
const speed = this.safeString(params, 'depth', '100');
|
|
218864
|
+
if (name === 'orderbook/{depth}/{speed}') {
|
|
218865
|
+
name = 'orderbook/D' + depth + '/' + speed + 'ms';
|
|
218778
218866
|
}
|
|
218779
|
-
|
|
218780
|
-
|
|
218781
|
-
|
|
218782
|
-
|
|
218783
|
-
|
|
218784
|
-
|
|
218867
|
+
else if (name === 'orderbook/{depth}/{speed}/batch') {
|
|
218868
|
+
name = 'orderbook/D' + depth + '/' + speed + 'ms/batch';
|
|
218869
|
+
}
|
|
218870
|
+
else if (name === 'orderbook/top/{speed}') {
|
|
218871
|
+
name = 'orderbook/top/' + speed + 'ms';
|
|
218872
|
+
}
|
|
218873
|
+
else if (name === 'orderbook/top/{speed}/batch') {
|
|
218874
|
+
name = 'orderbook/top/' + speed + 'ms/batch';
|
|
218875
|
+
}
|
|
218876
|
+
const market = this.market(symbol);
|
|
218877
|
+
const request = {
|
|
218878
|
+
'params': {
|
|
218879
|
+
'symbols': [market['id']],
|
|
218880
|
+
},
|
|
218881
|
+
};
|
|
218882
|
+
const orderbook = await this.subscribePublic(name, [symbol], this.deepExtend(request, params));
|
|
218883
|
+
return orderbook.limit();
|
|
218785
218884
|
}
|
|
218786
|
-
|
|
218885
|
+
handleOrderBook(client, message) {
|
|
218787
218886
|
//
|
|
218788
|
-
//
|
|
218789
|
-
//
|
|
218790
|
-
//
|
|
218791
|
-
//
|
|
218792
|
-
//
|
|
218793
|
-
//
|
|
218794
|
-
//
|
|
218795
|
-
//
|
|
218796
|
-
//
|
|
218797
|
-
//
|
|
218798
|
-
//
|
|
218799
|
-
//
|
|
218800
|
-
//
|
|
218801
|
-
//
|
|
218802
|
-
//
|
|
218803
|
-
//
|
|
218804
|
-
//
|
|
218805
|
-
//
|
|
218806
|
-
//
|
|
218887
|
+
// {
|
|
218888
|
+
// "ch": "orderbook/full", // Channel
|
|
218889
|
+
// "snapshot": {
|
|
218890
|
+
// "ETHBTC": {
|
|
218891
|
+
// "t": 1626866578796, // Timestamp in milliseconds
|
|
218892
|
+
// "s": 27617207, // Sequence number
|
|
218893
|
+
// "a": [ // Asks
|
|
218894
|
+
// ["0.060506", "0"],
|
|
218895
|
+
// ["0.060549", "12.6431"],
|
|
218896
|
+
// ["0.060570", "0"],
|
|
218897
|
+
// ["0.060612", "0"]
|
|
218898
|
+
// ],
|
|
218899
|
+
// "b": [ // Bids
|
|
218900
|
+
// ["0.060439", "4.4095"],
|
|
218901
|
+
// ["0.060414", "0"],
|
|
218902
|
+
// ["0.060407", "7.3349"],
|
|
218903
|
+
// ["0.060390", "0"]
|
|
218904
|
+
// ]
|
|
218905
|
+
// }
|
|
218906
|
+
// }
|
|
218907
|
+
// }
|
|
218807
218908
|
//
|
|
218808
|
-
const
|
|
218809
|
-
const
|
|
218810
|
-
const
|
|
218811
|
-
|
|
218812
|
-
|
|
218813
|
-
const
|
|
218814
|
-
const
|
|
218909
|
+
const data = this.safeValue2(message, 'snapshot', 'update', {});
|
|
218910
|
+
const marketIds = Object.keys(data);
|
|
218911
|
+
const channel = this.safeString(message, 'ch');
|
|
218912
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
218913
|
+
const marketId = marketIds[i];
|
|
218914
|
+
const market = this.safeMarket(marketId);
|
|
218915
|
+
const symbol = market['symbol'];
|
|
218916
|
+
const item = data[marketId];
|
|
218917
|
+
const messageHash = channel + '::' + symbol;
|
|
218918
|
+
if (!(symbol in this.orderbooks)) {
|
|
218919
|
+
const subscription = this.safeValue(client.subscriptions, messageHash, {});
|
|
218920
|
+
const limit = this.safeInteger(subscription, 'limit');
|
|
218921
|
+
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
218922
|
+
}
|
|
218923
|
+
const timestamp = this.safeInteger(item, 't');
|
|
218924
|
+
const nonce = this.safeInteger(item, 's');
|
|
218815
218925
|
const orderbook = this.orderbooks[symbol];
|
|
218816
|
-
const asks = this.safeValue(
|
|
218817
|
-
const bids = this.safeValue(
|
|
218926
|
+
const asks = this.safeValue(item, 'a', []);
|
|
218927
|
+
const bids = this.safeValue(item, 'b', []);
|
|
218818
218928
|
this.handleDeltas(orderbook['asks'], asks);
|
|
218819
218929
|
this.handleDeltas(orderbook['bids'], bids);
|
|
218820
218930
|
orderbook['timestamp'] = timestamp;
|
|
218821
218931
|
orderbook['datetime'] = this.iso8601(timestamp);
|
|
218822
218932
|
orderbook['nonce'] = nonce;
|
|
218933
|
+
orderbook['symbol'] = symbol;
|
|
218823
218934
|
this.orderbooks[symbol] = orderbook;
|
|
218824
|
-
const messageHash = 'orderbook:' + marketId;
|
|
218825
218935
|
client.resolve(orderbook, messageHash);
|
|
218826
218936
|
}
|
|
218827
218937
|
}
|
|
218828
218938
|
handleDelta(bookside, delta) {
|
|
218829
|
-
const price = this.
|
|
218830
|
-
const amount = this.
|
|
218939
|
+
const price = this.safeNumber(delta, 0);
|
|
218940
|
+
const amount = this.safeNumber(delta, 1);
|
|
218831
218941
|
bookside.store(price, amount);
|
|
218832
218942
|
}
|
|
218833
218943
|
handleDeltas(bookside, deltas) {
|
|
@@ -218840,192 +218950,714 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
218840
218950
|
* @method
|
|
218841
218951
|
* @name hitbtc#watchTicker
|
|
218842
218952
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
218953
|
+
* @see https://api.hitbtc.com/#subscribe-to-ticker
|
|
218954
|
+
* @see https://api.hitbtc.com/#subscribe-to-ticker-in-batches
|
|
218955
|
+
* @see https://api.hitbtc.com/#subscribe-to-mini-ticker
|
|
218956
|
+
* @see https://api.hitbtc.com/#subscribe-to-mini-ticker-in-batches
|
|
218843
218957
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
218844
218958
|
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
218845
|
-
* @
|
|
218959
|
+
* @param {string} [params.method] 'ticker/{speed}' (default), or 'ticker/price/{speed}'
|
|
218960
|
+
* @param {string} [params.speed] '1s' (default), or '3s'
|
|
218961
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
218962
|
+
*/
|
|
218963
|
+
const options = this.safeValue(this.options, 'watchTicker');
|
|
218964
|
+
const defaultMethod = this.safeString(options, 'method', 'ticker/{speed}');
|
|
218965
|
+
const method = this.safeString2(params, 'method', 'defaultMethod', defaultMethod);
|
|
218966
|
+
const speed = this.safeString(params, 'speed', '1s');
|
|
218967
|
+
const name = this.implodeParams(method, { 'speed': speed });
|
|
218968
|
+
params = this.omit(params, ['method', 'speed']);
|
|
218969
|
+
const market = this.market(symbol);
|
|
218970
|
+
const request = {
|
|
218971
|
+
'params': {
|
|
218972
|
+
'symbols': [market['id']],
|
|
218973
|
+
},
|
|
218974
|
+
};
|
|
218975
|
+
return await this.subscribePublic(name, [symbol], this.deepExtend(request, params));
|
|
218976
|
+
}
|
|
218977
|
+
async watchTickers(symbols = undefined, params = {}) {
|
|
218978
|
+
/**
|
|
218979
|
+
* @method
|
|
218980
|
+
* @name hitbtc#watchTicker
|
|
218981
|
+
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
218982
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
218983
|
+
* @param {object} params extra parameters specific to the hitbtc api endpoint
|
|
218984
|
+
* @param {string} params.method 'ticker/{speed}' (default),'ticker/price/{speed}', 'ticker/{speed}/batch', or 'ticker/{speed}/price/batch''
|
|
218985
|
+
* @param {string} params.speed '1s' (default), or '3s'
|
|
218986
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
|
|
218846
218987
|
*/
|
|
218847
|
-
|
|
218988
|
+
await this.loadMarkets();
|
|
218989
|
+
const options = this.safeValue(this.options, 'watchTicker');
|
|
218990
|
+
const defaultMethod = this.safeString(options, 'method', 'ticker/{speed}');
|
|
218991
|
+
const method = this.safeString2(params, 'method', 'defaultMethod', defaultMethod);
|
|
218992
|
+
const speed = this.safeString(params, 'speed', '1s');
|
|
218993
|
+
const name = this.implodeParams(method, { 'speed': speed });
|
|
218994
|
+
params = this.omit(params, ['method', 'speed']);
|
|
218995
|
+
const marketIds = [];
|
|
218996
|
+
if (symbols === undefined) {
|
|
218997
|
+
marketIds.push('*');
|
|
218998
|
+
}
|
|
218999
|
+
else {
|
|
219000
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
219001
|
+
const marketId = this.marketId(symbols[i]);
|
|
219002
|
+
marketIds.push(marketId);
|
|
219003
|
+
}
|
|
219004
|
+
}
|
|
219005
|
+
const request = {
|
|
219006
|
+
'params': {
|
|
219007
|
+
'symbols': marketIds,
|
|
219008
|
+
},
|
|
219009
|
+
};
|
|
219010
|
+
const tickers = await this.subscribePublic(name, symbols, this.deepExtend(request, params));
|
|
219011
|
+
if (this.newUpdates) {
|
|
219012
|
+
return tickers;
|
|
219013
|
+
}
|
|
219014
|
+
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
218848
219015
|
}
|
|
218849
219016
|
handleTicker(client, message) {
|
|
218850
219017
|
//
|
|
218851
|
-
//
|
|
218852
|
-
//
|
|
218853
|
-
//
|
|
218854
|
-
//
|
|
218855
|
-
//
|
|
218856
|
-
//
|
|
218857
|
-
//
|
|
218858
|
-
//
|
|
218859
|
-
//
|
|
218860
|
-
//
|
|
218861
|
-
//
|
|
218862
|
-
//
|
|
218863
|
-
//
|
|
218864
|
-
//
|
|
218865
|
-
//
|
|
218866
|
-
//
|
|
219018
|
+
// {
|
|
219019
|
+
// "ch": "ticker/1s",
|
|
219020
|
+
// "data": {
|
|
219021
|
+
// "ETHBTC": {
|
|
219022
|
+
// "t": 1614815872000, // Timestamp in milliseconds
|
|
219023
|
+
// "a": "0.031175", // Best ask
|
|
219024
|
+
// "A": "0.03329", // Best ask quantity
|
|
219025
|
+
// "b": "0.031148", // Best bid
|
|
219026
|
+
// "B": "0.10565", // Best bid quantity
|
|
219027
|
+
// "c": "0.031210", // Last price
|
|
219028
|
+
// "o": "0.030781", // Open price
|
|
219029
|
+
// "h": "0.031788", // High price
|
|
219030
|
+
// "l": "0.030733", // Low price
|
|
219031
|
+
// "v": "62.587", // Base asset volume
|
|
219032
|
+
// "q": "1.951420577", // Quote asset volume
|
|
219033
|
+
// "p": "0.000429", // Price change
|
|
219034
|
+
// "P": "1.39", // Price change percent
|
|
219035
|
+
// "L": 1182694927 // Last trade identifier
|
|
219036
|
+
// }
|
|
219037
|
+
// }
|
|
219038
|
+
// }
|
|
218867
219039
|
//
|
|
218868
|
-
|
|
218869
|
-
|
|
218870
|
-
|
|
218871
|
-
|
|
218872
|
-
|
|
218873
|
-
|
|
218874
|
-
|
|
218875
|
-
|
|
218876
|
-
|
|
219040
|
+
// {
|
|
219041
|
+
// "ch": "ticker/price/1s",
|
|
219042
|
+
// "data": {
|
|
219043
|
+
// "BTCUSDT": {
|
|
219044
|
+
// "t": 1614815872030,
|
|
219045
|
+
// "o": "32636.79",
|
|
219046
|
+
// "c": "32085.51",
|
|
219047
|
+
// "h": "33379.92",
|
|
219048
|
+
// "l": "30683.28",
|
|
219049
|
+
// "v": "11.90667",
|
|
219050
|
+
// "q": "384081.1955629"
|
|
219051
|
+
// }
|
|
219052
|
+
// }
|
|
219053
|
+
// }
|
|
219054
|
+
//
|
|
219055
|
+
const data = this.safeValue(message, 'data', {});
|
|
219056
|
+
const marketIds = Object.keys(data);
|
|
219057
|
+
const channel = this.safeString(message, 'ch');
|
|
219058
|
+
const newTickers = [];
|
|
219059
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
219060
|
+
const marketId = marketIds[i];
|
|
219061
|
+
const market = this.safeMarket(marketId);
|
|
219062
|
+
const symbol = market['symbol'];
|
|
219063
|
+
const ticker = this.parseWsTicker(data[marketId], market);
|
|
219064
|
+
this.tickers[symbol] = ticker;
|
|
219065
|
+
newTickers.push(ticker);
|
|
219066
|
+
const messageHash = channel + '::' + symbol;
|
|
219067
|
+
client.resolve(this.tickers[symbol], messageHash);
|
|
219068
|
+
}
|
|
219069
|
+
const messageHashes = this.findMessageHashes(client, channel + '::');
|
|
219070
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
219071
|
+
const messageHash = messageHashes[i];
|
|
219072
|
+
const parts = messageHash.split('::');
|
|
219073
|
+
const symbolsString = parts[1];
|
|
219074
|
+
const symbols = symbolsString.split(',');
|
|
219075
|
+
const tickers = this.filterByArray(newTickers, 'symbol', symbols);
|
|
219076
|
+
const tickersSymbols = Object.keys(tickers);
|
|
219077
|
+
const numTickers = tickersSymbols.length;
|
|
219078
|
+
if (numTickers > 0) {
|
|
219079
|
+
client.resolve(tickers, messageHash);
|
|
219080
|
+
}
|
|
219081
|
+
}
|
|
219082
|
+
client.resolve(this.tickers, channel);
|
|
219083
|
+
return message;
|
|
219084
|
+
}
|
|
219085
|
+
parseWsTicker(ticker, market = undefined) {
|
|
219086
|
+
//
|
|
219087
|
+
// {
|
|
219088
|
+
// "t": 1614815872000, // Timestamp in milliseconds
|
|
219089
|
+
// "a": "0.031175", // Best ask
|
|
219090
|
+
// "A": "0.03329", // Best ask quantity
|
|
219091
|
+
// "b": "0.031148", // Best bid
|
|
219092
|
+
// "B": "0.10565", // Best bid quantity
|
|
219093
|
+
// "c": "0.031210", // Last price
|
|
219094
|
+
// "o": "0.030781", // Open price
|
|
219095
|
+
// "h": "0.031788", // High price
|
|
219096
|
+
// "l": "0.030733", // Low price
|
|
219097
|
+
// "v": "62.587", // Base asset volume
|
|
219098
|
+
// "q": "1.951420577", // Quote asset volume
|
|
219099
|
+
// "p": "0.000429", // Price change
|
|
219100
|
+
// "P": "1.39", // Price change percent
|
|
219101
|
+
// "L": 1182694927 // Last trade identifier
|
|
219102
|
+
// }
|
|
219103
|
+
//
|
|
219104
|
+
// {
|
|
219105
|
+
// "t": 1614815872030,
|
|
219106
|
+
// "o": "32636.79",
|
|
219107
|
+
// "c": "32085.51",
|
|
219108
|
+
// "h": "33379.92",
|
|
219109
|
+
// "l": "30683.28",
|
|
219110
|
+
// "v": "11.90667",
|
|
219111
|
+
// "q": "384081.1955629"
|
|
219112
|
+
// }
|
|
219113
|
+
//
|
|
219114
|
+
const timestamp = this.safeInteger(ticker, 't');
|
|
219115
|
+
const symbol = this.safeSymbol(undefined, market);
|
|
219116
|
+
const last = this.safeString(ticker, 'c');
|
|
219117
|
+
return this.safeTicker({
|
|
219118
|
+
'symbol': symbol,
|
|
219119
|
+
'timestamp': timestamp,
|
|
219120
|
+
'datetime': this.iso8601(timestamp),
|
|
219121
|
+
'high': this.safeString(ticker, 'h'),
|
|
219122
|
+
'low': this.safeString(ticker, 'l'),
|
|
219123
|
+
'bid': this.safeString(ticker, 'b'),
|
|
219124
|
+
'bidVolume': this.safeString(ticker, 'B'),
|
|
219125
|
+
'ask': this.safeString(ticker, 'a'),
|
|
219126
|
+
'askVolume': this.safeString(ticker, 'A'),
|
|
219127
|
+
'vwap': undefined,
|
|
219128
|
+
'open': this.safeString(ticker, 'o'),
|
|
219129
|
+
'close': last,
|
|
219130
|
+
'last': last,
|
|
219131
|
+
'previousClose': undefined,
|
|
219132
|
+
'change': undefined,
|
|
219133
|
+
'percentage': undefined,
|
|
219134
|
+
'average': undefined,
|
|
219135
|
+
'baseVolume': this.safeString(ticker, 'v'),
|
|
219136
|
+
'quoteVolume': this.safeString(ticker, 'q'),
|
|
219137
|
+
'info': ticker,
|
|
219138
|
+
}, market);
|
|
218877
219139
|
}
|
|
218878
219140
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
218879
219141
|
/**
|
|
218880
219142
|
* @method
|
|
218881
219143
|
* @name hitbtc#watchTrades
|
|
218882
219144
|
* @description get the list of most recent trades for a particular symbol
|
|
219145
|
+
* @see https://api.hitbtc.com/#subscribe-to-trades
|
|
218883
219146
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
218884
219147
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
218885
219148
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
218886
219149
|
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
218887
219150
|
* @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
|
|
218888
219151
|
*/
|
|
218889
|
-
|
|
219152
|
+
await this.loadMarkets();
|
|
219153
|
+
const market = this.market(symbol);
|
|
219154
|
+
const request = {
|
|
219155
|
+
'params': {
|
|
219156
|
+
'symbols': [market['id']],
|
|
219157
|
+
},
|
|
219158
|
+
};
|
|
219159
|
+
if (limit !== undefined) {
|
|
219160
|
+
request['limit'] = limit;
|
|
219161
|
+
}
|
|
219162
|
+
const trades = await this.subscribePublic('trades', [symbol], this.deepExtend(request, params));
|
|
218890
219163
|
if (this.newUpdates) {
|
|
218891
219164
|
limit = trades.getLimit(symbol, limit);
|
|
218892
219165
|
}
|
|
218893
|
-
return this.filterBySinceLimit(trades, since, limit, 'timestamp'
|
|
219166
|
+
return this.filterBySinceLimit(trades, since, limit, 'timestamp');
|
|
218894
219167
|
}
|
|
218895
219168
|
handleTrades(client, message) {
|
|
218896
219169
|
//
|
|
218897
|
-
//
|
|
218898
|
-
//
|
|
218899
|
-
//
|
|
218900
|
-
//
|
|
218901
|
-
//
|
|
218902
|
-
//
|
|
218903
|
-
//
|
|
218904
|
-
// price: '6957.20',
|
|
218905
|
-
// quantity: '0.02779',
|
|
218906
|
-
// side: 'buy',
|
|
218907
|
-
// timestamp: '2020-04-03T10:28:20.032Z'
|
|
218908
|
-
// },
|
|
218909
|
-
// {
|
|
218910
|
-
// id: 814145792,
|
|
218911
|
-
// price: '6957.20',
|
|
218912
|
-
// quantity: '0.12918',
|
|
218913
|
-
// side: 'buy',
|
|
218914
|
-
// timestamp: '2020-04-03T10:28:20.039Z'
|
|
218915
|
-
// },
|
|
218916
|
-
// ],
|
|
218917
|
-
// symbol: 'BTCUSD'
|
|
218918
|
-
// }
|
|
218919
|
-
// }
|
|
219170
|
+
// {
|
|
219171
|
+
// "result": {
|
|
219172
|
+
// "ch": "trades", // Channel
|
|
219173
|
+
// "subscriptions": ["ETHBTC", "BTCUSDT"]
|
|
219174
|
+
// },
|
|
219175
|
+
// "id": 123
|
|
219176
|
+
// }
|
|
218920
219177
|
//
|
|
218921
|
-
|
|
218922
|
-
|
|
218923
|
-
|
|
218924
|
-
|
|
218925
|
-
|
|
218926
|
-
|
|
218927
|
-
|
|
218928
|
-
|
|
218929
|
-
|
|
218930
|
-
|
|
218931
|
-
|
|
218932
|
-
}
|
|
218933
|
-
|
|
218934
|
-
|
|
219178
|
+
// Notification snapshot
|
|
219179
|
+
//
|
|
219180
|
+
// {
|
|
219181
|
+
// "ch": "trades", // Channel
|
|
219182
|
+
// "snapshot": {
|
|
219183
|
+
// "BTCUSDT": [{
|
|
219184
|
+
// "t": 1626861109494, // Timestamp in milliseconds
|
|
219185
|
+
// "i": 1555634969, // Trade identifier
|
|
219186
|
+
// "p": "30881.96", // Price
|
|
219187
|
+
// "q": "12.66828", // Quantity
|
|
219188
|
+
// "s": "buy" // Side
|
|
219189
|
+
// }]
|
|
219190
|
+
// }
|
|
219191
|
+
// }
|
|
219192
|
+
//
|
|
219193
|
+
// Notification update
|
|
219194
|
+
//
|
|
219195
|
+
// {
|
|
219196
|
+
// "ch": "trades",
|
|
219197
|
+
// "update": {
|
|
219198
|
+
// "BTCUSDT": [{
|
|
219199
|
+
// "t": 1626861123552,
|
|
219200
|
+
// "i": 1555634969,
|
|
219201
|
+
// "p": "30877.68",
|
|
219202
|
+
// "q": "0.00006",
|
|
219203
|
+
// "s": "sell"
|
|
219204
|
+
// }]
|
|
219205
|
+
// }
|
|
219206
|
+
// }
|
|
219207
|
+
//
|
|
219208
|
+
const data = this.safeValue2(message, 'snapshot', 'update', {});
|
|
219209
|
+
const marketIds = Object.keys(data);
|
|
219210
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
219211
|
+
const marketId = marketIds[i];
|
|
219212
|
+
const market = this.safeMarket(marketId);
|
|
219213
|
+
const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
219214
|
+
const symbol = market['symbol'];
|
|
219215
|
+
let stored = this.safeValue(this.trades, symbol);
|
|
219216
|
+
if (stored === undefined) {
|
|
219217
|
+
stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCache */ .ZL(tradesLimit);
|
|
219218
|
+
this.trades[symbol] = stored;
|
|
219219
|
+
}
|
|
219220
|
+
const trades = this.parseWsTrades(data[marketId], market);
|
|
218935
219221
|
for (let i = 0; i < trades.length; i++) {
|
|
218936
219222
|
stored.append(trades[i]);
|
|
218937
219223
|
}
|
|
219224
|
+
const messageHash = 'trades::' + symbol;
|
|
219225
|
+
client.resolve(stored, messageHash);
|
|
218938
219226
|
}
|
|
218939
|
-
else {
|
|
218940
|
-
const trade = this.parseTrade(message, market);
|
|
218941
|
-
stored.append(trade);
|
|
218942
|
-
}
|
|
218943
|
-
client.resolve(stored, messageHash);
|
|
218944
219227
|
return message;
|
|
218945
219228
|
}
|
|
219229
|
+
parseWsTrades(trades, market = undefined, since = undefined, limit = undefined, params = {}) {
|
|
219230
|
+
trades = this.toArray(trades);
|
|
219231
|
+
let result = [];
|
|
219232
|
+
for (let i = 0; i < trades.length; i++) {
|
|
219233
|
+
const trade = this.extend(this.parseWsTrade(trades[i], market), params);
|
|
219234
|
+
result.push(trade);
|
|
219235
|
+
}
|
|
219236
|
+
result = this.sortBy2(result, 'timestamp', 'id');
|
|
219237
|
+
const symbol = this.safeString(market, 'symbol');
|
|
219238
|
+
return this.filterBySymbolSinceLimit(result, symbol, since, limit);
|
|
219239
|
+
}
|
|
219240
|
+
parseWsTrade(trade, market = undefined) {
|
|
219241
|
+
//
|
|
219242
|
+
// {
|
|
219243
|
+
// "t": 1626861123552, // Timestamp in milliseconds
|
|
219244
|
+
// "i": 1555634969, // Trade identifier
|
|
219245
|
+
// "p": "30877.68", // Price
|
|
219246
|
+
// "q": "0.00006", // Quantity
|
|
219247
|
+
// "s": "sell" // Side
|
|
219248
|
+
// }
|
|
219249
|
+
//
|
|
219250
|
+
const timestamp = this.safeInteger(trade, 't');
|
|
219251
|
+
return this.safeTrade({
|
|
219252
|
+
'info': trade,
|
|
219253
|
+
'id': this.safeString(trade, 'i'),
|
|
219254
|
+
'order': undefined,
|
|
219255
|
+
'timestamp': timestamp,
|
|
219256
|
+
'datetime': this.iso8601(timestamp),
|
|
219257
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
219258
|
+
'type': undefined,
|
|
219259
|
+
'side': this.safeString(trade, 's'),
|
|
219260
|
+
'takerOrMaker': undefined,
|
|
219261
|
+
'price': this.safeString(trade, 'p'),
|
|
219262
|
+
'amount': this.safeString(trade, 'q'),
|
|
219263
|
+
'cost': undefined,
|
|
219264
|
+
'fee': undefined,
|
|
219265
|
+
}, market);
|
|
219266
|
+
}
|
|
218946
219267
|
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
218947
219268
|
/**
|
|
218948
219269
|
* @method
|
|
218949
219270
|
* @name hitbtc#watchOHLCV
|
|
218950
219271
|
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
219272
|
+
* @see https://api.hitbtc.com/#subscribe-to-candles
|
|
218951
219273
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
218952
|
-
* @param {string} timeframe the length of time each candle represents
|
|
218953
|
-
* @param {int} [since]
|
|
218954
|
-
* @param {int} [limit]
|
|
219274
|
+
* @param {string} [timeframe] the length of time each candle represents
|
|
219275
|
+
* @param {int} [since] not used by hitbtc watchOHLCV
|
|
219276
|
+
* @param {int} [limit] 0 – 1000, default value = 0 (no history returned)
|
|
218955
219277
|
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
218956
|
-
* @returns {
|
|
219278
|
+
* @returns {[[int]]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
218957
219279
|
*/
|
|
218958
|
-
// if (limit === undefined) {
|
|
218959
|
-
// limit = 100;
|
|
218960
|
-
// }
|
|
218961
219280
|
const period = this.safeString(this.timeframes, timeframe, timeframe);
|
|
219281
|
+
const name = 'candles/' + period;
|
|
219282
|
+
const market = this.market(symbol);
|
|
218962
219283
|
const request = {
|
|
218963
219284
|
'params': {
|
|
218964
|
-
'
|
|
218965
|
-
// 'limit': limit,
|
|
219285
|
+
'symbols': [market['id']],
|
|
218966
219286
|
},
|
|
218967
219287
|
};
|
|
218968
|
-
|
|
218969
|
-
|
|
219288
|
+
if (limit !== undefined) {
|
|
219289
|
+
request['params']['limit'] = limit;
|
|
219290
|
+
}
|
|
219291
|
+
const ohlcv = await this.subscribePublic(name, [symbol], this.deepExtend(request, params));
|
|
218970
219292
|
if (this.newUpdates) {
|
|
218971
219293
|
limit = ohlcv.getLimit(symbol, limit);
|
|
218972
219294
|
}
|
|
218973
|
-
return this.filterBySinceLimit(ohlcv, since, limit, 0
|
|
219295
|
+
return this.filterBySinceLimit(ohlcv, since, limit, 0);
|
|
218974
219296
|
}
|
|
218975
219297
|
handleOHLCV(client, message) {
|
|
218976
219298
|
//
|
|
218977
|
-
//
|
|
218978
|
-
//
|
|
218979
|
-
//
|
|
218980
|
-
//
|
|
218981
|
-
//
|
|
218982
|
-
//
|
|
218983
|
-
//
|
|
218984
|
-
//
|
|
218985
|
-
//
|
|
218986
|
-
//
|
|
218987
|
-
//
|
|
218988
|
-
//
|
|
218989
|
-
//
|
|
218990
|
-
//
|
|
218991
|
-
//
|
|
218992
|
-
//
|
|
218993
|
-
// open: '6867.54',
|
|
218994
|
-
// close: '6859.26',
|
|
218995
|
-
// min: '6858.85',
|
|
218996
|
-
// max: '6867.54',
|
|
218997
|
-
// volume: '1.7766',
|
|
218998
|
-
// volumeQuote: '12191.5880395'
|
|
218999
|
-
// },
|
|
219000
|
-
// ],
|
|
219001
|
-
// symbol: 'BTCUSD',
|
|
219002
|
-
// period: 'M1'
|
|
219003
|
-
// }
|
|
219004
|
-
// }
|
|
219299
|
+
// {
|
|
219300
|
+
// "ch": "candles/M1", // Channel
|
|
219301
|
+
// "snapshot": {
|
|
219302
|
+
// "BTCUSDT": [{
|
|
219303
|
+
// "t": 1626860340000, // Message timestamp
|
|
219304
|
+
// "o": "30881.95", // Open price
|
|
219305
|
+
// "c": "30890.96", // Last price
|
|
219306
|
+
// "h": "30900.8", // High price
|
|
219307
|
+
// "l": "30861.27", // Low price
|
|
219308
|
+
// "v": "1.27852", // Base asset volume
|
|
219309
|
+
// "q": "39493.9021811" // Quote asset volume
|
|
219310
|
+
// }
|
|
219311
|
+
// ...
|
|
219312
|
+
// ]
|
|
219313
|
+
// }
|
|
219314
|
+
// }
|
|
219005
219315
|
//
|
|
219006
|
-
|
|
219007
|
-
|
|
219008
|
-
|
|
219009
|
-
|
|
219010
|
-
|
|
219011
|
-
|
|
219316
|
+
// {
|
|
219317
|
+
// "ch": "candles/M1",
|
|
219318
|
+
// "update": {
|
|
219319
|
+
// "ETHBTC": [{
|
|
219320
|
+
// "t": 1626860880000,
|
|
219321
|
+
// "o": "0.060711",
|
|
219322
|
+
// "c": "0.060749",
|
|
219323
|
+
// "h": "0.060749",
|
|
219324
|
+
// "l": "0.060711",
|
|
219325
|
+
// "v": "12.2800",
|
|
219326
|
+
// "q": "0.7455339675"
|
|
219327
|
+
// }]
|
|
219328
|
+
// }
|
|
219329
|
+
// }
|
|
219330
|
+
//
|
|
219331
|
+
const data = this.safeValue2(message, 'snapshot', 'update', {});
|
|
219332
|
+
const marketIds = Object.keys(data);
|
|
219333
|
+
const channel = this.safeString(message, 'ch');
|
|
219334
|
+
const splitChannel = channel.split('/');
|
|
219335
|
+
const period = this.safeString(splitChannel, 1);
|
|
219012
219336
|
const timeframe = this.findTimeframe(period);
|
|
219013
|
-
|
|
219014
|
-
|
|
219015
|
-
const
|
|
219016
|
-
const
|
|
219337
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
219338
|
+
const marketId = marketIds[i];
|
|
219339
|
+
const market = this.safeMarket(marketId);
|
|
219340
|
+
const symbol = market['symbol'];
|
|
219017
219341
|
this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
|
|
219018
219342
|
let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
|
|
219019
219343
|
if (stored === undefined) {
|
|
219020
219344
|
const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
|
|
219021
|
-
stored = new
|
|
219345
|
+
stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
|
|
219022
219346
|
this.ohlcvs[symbol][timeframe] = stored;
|
|
219023
219347
|
}
|
|
219024
|
-
|
|
219348
|
+
const ohlcvs = this.parseWsOHLCVs(data[marketId], market);
|
|
219349
|
+
for (let i = 0; i < ohlcvs.length; i++) {
|
|
219350
|
+
stored.append(ohlcvs[i]);
|
|
219351
|
+
}
|
|
219352
|
+
const messageHash = channel + '::' + symbol;
|
|
219025
219353
|
client.resolve(stored, messageHash);
|
|
219026
219354
|
}
|
|
219027
219355
|
return message;
|
|
219028
219356
|
}
|
|
219357
|
+
parseWsOHLCV(ohlcv, market = undefined) {
|
|
219358
|
+
//
|
|
219359
|
+
// {
|
|
219360
|
+
// "t": 1626860340000, // Message timestamp
|
|
219361
|
+
// "o": "30881.95", // Open price
|
|
219362
|
+
// "c": "30890.96", // Last price
|
|
219363
|
+
// "h": "30900.8", // High price
|
|
219364
|
+
// "l": "30861.27", // Low price
|
|
219365
|
+
// "v": "1.27852", // Base asset volume
|
|
219366
|
+
// "q": "39493.9021811" // Quote asset volume
|
|
219367
|
+
// }
|
|
219368
|
+
//
|
|
219369
|
+
return [
|
|
219370
|
+
this.safeInteger(ohlcv, 't'),
|
|
219371
|
+
this.safeNumber(ohlcv, 'o'),
|
|
219372
|
+
this.safeNumber(ohlcv, 'h'),
|
|
219373
|
+
this.safeNumber(ohlcv, 'l'),
|
|
219374
|
+
this.safeNumber(ohlcv, 'c'),
|
|
219375
|
+
this.safeNumber(ohlcv, 'v'),
|
|
219376
|
+
];
|
|
219377
|
+
}
|
|
219378
|
+
async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
219379
|
+
/**
|
|
219380
|
+
* @method
|
|
219381
|
+
* @name hitbtc#watchOrders
|
|
219382
|
+
* @description watches information on multiple orders made by the user
|
|
219383
|
+
* @see https://api.hitbtc.com/#subscribe-to-reports
|
|
219384
|
+
* @see https://api.hitbtc.com/#subscribe-to-reports-2
|
|
219385
|
+
* @see https://api.hitbtc.com/#subscribe-to-reports-3
|
|
219386
|
+
* @param {string} [symbol] unified CCXT market symbol
|
|
219387
|
+
* @param {int} [since] timestamp in ms of the earliest order to fetch
|
|
219388
|
+
* @param {int} [limit] the maximum amount of orders to fetch
|
|
219389
|
+
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
219390
|
+
* @returns {[object]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
219391
|
+
*/
|
|
219392
|
+
await this.loadMarkets();
|
|
219393
|
+
let marketType = undefined;
|
|
219394
|
+
let market = undefined;
|
|
219395
|
+
if (symbol !== undefined) {
|
|
219396
|
+
market = this.market(symbol);
|
|
219397
|
+
}
|
|
219398
|
+
[marketType, params] = this.handleMarketTypeAndParams('watchOrders', market, params);
|
|
219399
|
+
const name = this.getSupportedMapping(marketType, {
|
|
219400
|
+
'spot': 'spot_subscribe',
|
|
219401
|
+
'margin': 'margin_subscribe',
|
|
219402
|
+
'swap': 'futures_subscribe',
|
|
219403
|
+
'future': 'futures_subscribe',
|
|
219404
|
+
});
|
|
219405
|
+
const orders = await this.subscribePrivate(name, symbol, params);
|
|
219406
|
+
if (this.newUpdates) {
|
|
219407
|
+
limit = orders.getLimit(symbol, limit);
|
|
219408
|
+
}
|
|
219409
|
+
return this.filterBySinceLimit(orders, since, limit, 'timestamp');
|
|
219410
|
+
}
|
|
219411
|
+
handleOrder(client, message) {
|
|
219412
|
+
//
|
|
219413
|
+
// {
|
|
219414
|
+
// "jsonrpc": "2.0",
|
|
219415
|
+
// "method": "spot_order", // "margin_order", "future_order"
|
|
219416
|
+
// "params": {
|
|
219417
|
+
// "id": 584244931496,
|
|
219418
|
+
// "client_order_id": "b5acd79c0a854b01b558665bcf379456",
|
|
219419
|
+
// "symbol": "BTCUSDT",
|
|
219420
|
+
// "side": "buy",
|
|
219421
|
+
// "status": "new",
|
|
219422
|
+
// "type": "limit",
|
|
219423
|
+
// "time_in_force": "GTC",
|
|
219424
|
+
// "quantity": "0.01000",
|
|
219425
|
+
// "quantity_cumulative": "0",
|
|
219426
|
+
// "price": "0.01", // only updates and snapshots
|
|
219427
|
+
// "post_only": false,
|
|
219428
|
+
// "reduce_only": false, // only margin and contract
|
|
219429
|
+
// "display_quantity": "0", // only updates and snapshot
|
|
219430
|
+
// "created_at": "2021-07-02T22:52:32.864Z",
|
|
219431
|
+
// "updated_at": "2021-07-02T22:52:32.864Z",
|
|
219432
|
+
// "trade_id": 1361977606, // only trades
|
|
219433
|
+
// "trade_quantity": "0.00001", // only trades
|
|
219434
|
+
// "trade_price": "49595.04", // only trades
|
|
219435
|
+
// "trade_fee": "0.001239876000", // only trades
|
|
219436
|
+
// "trade_taker": true, // only trades, only spot
|
|
219437
|
+
// "trade_position_id": 485308, // only trades, only margin
|
|
219438
|
+
// "report_type": "new" // "trade", "status" (snapshot)
|
|
219439
|
+
// }
|
|
219440
|
+
// }
|
|
219441
|
+
//
|
|
219442
|
+
// {
|
|
219443
|
+
// "jsonrpc": "2.0",
|
|
219444
|
+
// "method": "spot_orders", // "margin_orders", "future_orders"
|
|
219445
|
+
// "params": [
|
|
219446
|
+
// {
|
|
219447
|
+
// "id": 584244931496,
|
|
219448
|
+
// "client_order_id": "b5acd79c0a854b01b558665bcf379456",
|
|
219449
|
+
// "symbol": "BTCUSDT",
|
|
219450
|
+
// "side": "buy",
|
|
219451
|
+
// "status": "new",
|
|
219452
|
+
// "type": "limit",
|
|
219453
|
+
// "time_in_force": "GTC",
|
|
219454
|
+
// "quantity": "0.01000",
|
|
219455
|
+
// "quantity_cumulative": "0",
|
|
219456
|
+
// "price": "0.01", // only updates and snapshots
|
|
219457
|
+
// "post_only": false,
|
|
219458
|
+
// "reduce_only": false, // only margin and contract
|
|
219459
|
+
// "display_quantity": "0", // only updates and snapshot
|
|
219460
|
+
// "created_at": "2021-07-02T22:52:32.864Z",
|
|
219461
|
+
// "updated_at": "2021-07-02T22:52:32.864Z",
|
|
219462
|
+
// "trade_id": 1361977606, // only trades
|
|
219463
|
+
// "trade_quantity": "0.00001", // only trades
|
|
219464
|
+
// "trade_price": "49595.04", // only trades
|
|
219465
|
+
// "trade_fee": "0.001239876000", // only trades
|
|
219466
|
+
// "trade_taker": true, // only trades, only spot
|
|
219467
|
+
// "trade_position_id": 485308, // only trades, only margin
|
|
219468
|
+
// "report_type": "new" // "trade", "status" (snapshot)
|
|
219469
|
+
// }
|
|
219470
|
+
// ]
|
|
219471
|
+
// }
|
|
219472
|
+
//
|
|
219473
|
+
if (this.orders === undefined) {
|
|
219474
|
+
const limit = this.safeInteger(this.options, 'ordersLimit');
|
|
219475
|
+
this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
|
|
219476
|
+
}
|
|
219477
|
+
const data = this.safeValue(message, 'params', []);
|
|
219478
|
+
if (Array.isArray(data)) {
|
|
219479
|
+
for (let i = 0; i < data.length; i++) {
|
|
219480
|
+
const order = data[i];
|
|
219481
|
+
this.handleOrderHelper(client, message, order);
|
|
219482
|
+
}
|
|
219483
|
+
}
|
|
219484
|
+
else {
|
|
219485
|
+
this.handleOrderHelper(client, message, data);
|
|
219486
|
+
}
|
|
219487
|
+
return message;
|
|
219488
|
+
}
|
|
219489
|
+
handleOrderHelper(client, message, order) {
|
|
219490
|
+
const orders = this.orders;
|
|
219491
|
+
const marketId = this.safeStringLower2(order, 'instrument', 'symbol');
|
|
219492
|
+
const method = this.safeString(message, 'method');
|
|
219493
|
+
const splitMethod = method.split('_order');
|
|
219494
|
+
const messageHash = this.safeString(splitMethod, 0);
|
|
219495
|
+
const symbol = this.safeSymbol(marketId);
|
|
219496
|
+
const parsed = this.parseOrder(order);
|
|
219497
|
+
orders.append(parsed);
|
|
219498
|
+
client.resolve(orders, messageHash);
|
|
219499
|
+
client.resolve(orders, messageHash + '::' + symbol);
|
|
219500
|
+
}
|
|
219501
|
+
parseWsOrderTrade(trade, market = undefined) {
|
|
219502
|
+
//
|
|
219503
|
+
// {
|
|
219504
|
+
// "id": 584244931496,
|
|
219505
|
+
// "client_order_id": "b5acd79c0a854b01b558665bcf379456",
|
|
219506
|
+
// "symbol": "BTCUSDT",
|
|
219507
|
+
// "side": "buy",
|
|
219508
|
+
// "status": "new",
|
|
219509
|
+
// "type": "limit",
|
|
219510
|
+
// "time_in_force": "GTC",
|
|
219511
|
+
// "quantity": "0.01000",
|
|
219512
|
+
// "quantity_cumulative": "0",
|
|
219513
|
+
// "price": "0.01", // only updates and snapshots
|
|
219514
|
+
// "post_only": false,
|
|
219515
|
+
// "reduce_only": false, // only margin and contract
|
|
219516
|
+
// "display_quantity": "0", // only updates and snapshot
|
|
219517
|
+
// "created_at": "2021-07-02T22:52:32.864Z",
|
|
219518
|
+
// "updated_at": "2021-07-02T22:52:32.864Z",
|
|
219519
|
+
// "trade_id": 1361977606, // only trades
|
|
219520
|
+
// "trade_quantity": "0.00001", // only trades
|
|
219521
|
+
// "trade_price": "49595.04", // only trades
|
|
219522
|
+
// "trade_fee": "0.001239876000", // only trades
|
|
219523
|
+
// "trade_taker": true, // only trades, only spot
|
|
219524
|
+
// "trade_position_id": 485308, // only trades, only margin
|
|
219525
|
+
// "report_type": "new" // "trade", "status" (snapshot)
|
|
219526
|
+
// }
|
|
219527
|
+
//
|
|
219528
|
+
const timestamp = this.safeInteger(trade, 'created_at');
|
|
219529
|
+
const marketId = this.safeString(trade, 'symbol');
|
|
219530
|
+
return this.safeTrade({
|
|
219531
|
+
'info': trade,
|
|
219532
|
+
'id': this.safeString(trade, 'trade_id'),
|
|
219533
|
+
'order': this.safeString(trade, 'id'),
|
|
219534
|
+
'timestamp': timestamp,
|
|
219535
|
+
'datetime': this.iso8601(timestamp),
|
|
219536
|
+
'symbol': this.safeMarket(marketId, market),
|
|
219537
|
+
'type': undefined,
|
|
219538
|
+
'side': this.safeString(trade, 'side'),
|
|
219539
|
+
'takerOrMaker': this.safeString(trade, 'trade_taker'),
|
|
219540
|
+
'price': this.safeString(trade, 'trade_price'),
|
|
219541
|
+
'amount': this.safeString(trade, 'trade_quantity'),
|
|
219542
|
+
'cost': undefined,
|
|
219543
|
+
'fee': {
|
|
219544
|
+
'cost': this.safeString(trade, 'trade_fee'),
|
|
219545
|
+
'currency': undefined,
|
|
219546
|
+
'rate': undefined,
|
|
219547
|
+
},
|
|
219548
|
+
}, market);
|
|
219549
|
+
}
|
|
219550
|
+
parseWsOrder(order, market = undefined) {
|
|
219551
|
+
//
|
|
219552
|
+
// {
|
|
219553
|
+
// "id": 584244931496,
|
|
219554
|
+
// "client_order_id": "b5acd79c0a854b01b558665bcf379456",
|
|
219555
|
+
// "symbol": "BTCUSDT",
|
|
219556
|
+
// "side": "buy",
|
|
219557
|
+
// "status": "new",
|
|
219558
|
+
// "type": "limit",
|
|
219559
|
+
// "time_in_force": "GTC",
|
|
219560
|
+
// "quantity": "0.01000",
|
|
219561
|
+
// "quantity_cumulative": "0",
|
|
219562
|
+
// "price": "0.01", // only updates and snapshots
|
|
219563
|
+
// "post_only": false,
|
|
219564
|
+
// "reduce_only": false, // only margin and contract
|
|
219565
|
+
// "display_quantity": "0", // only updates and snapshot
|
|
219566
|
+
// "created_at": "2021-07-02T22:52:32.864Z",
|
|
219567
|
+
// "updated_at": "2021-07-02T22:52:32.864Z",
|
|
219568
|
+
// "trade_id": 1361977606, // only trades
|
|
219569
|
+
// "trade_quantity": "0.00001", // only trades
|
|
219570
|
+
// "trade_price": "49595.04", // only trades
|
|
219571
|
+
// "trade_fee": "0.001239876000", // only trades
|
|
219572
|
+
// "trade_taker": true, // only trades, only spot
|
|
219573
|
+
// "trade_position_id": 485308, // only trades, only margin
|
|
219574
|
+
// "report_type": "new" // "trade", "status" (snapshot)
|
|
219575
|
+
// }
|
|
219576
|
+
//
|
|
219577
|
+
const timestamp = this.safeString(order, 'created_at');
|
|
219578
|
+
const marketId = this.safeSymbol(order, 'symbol');
|
|
219579
|
+
market = this.safeMarket(marketId, market);
|
|
219580
|
+
const tradeId = this.safeString(order, 'trade_id');
|
|
219581
|
+
let trades = undefined;
|
|
219582
|
+
if (tradeId !== undefined) {
|
|
219583
|
+
const trade = this.parseWsOrderTrade(order, market);
|
|
219584
|
+
trades = [trade];
|
|
219585
|
+
}
|
|
219586
|
+
return this.safeOrder({
|
|
219587
|
+
'info': order,
|
|
219588
|
+
'id': this.safeString(order, 'id'),
|
|
219589
|
+
'clientOrderId': this.safeString(order, 'client_order_id'),
|
|
219590
|
+
'timestamp': timestamp,
|
|
219591
|
+
'datetime': this.iso8601(timestamp),
|
|
219592
|
+
'lastTradeTimestamp': undefined,
|
|
219593
|
+
'symbol': market['symbol'],
|
|
219594
|
+
'price': this.safeString(order, 'price'),
|
|
219595
|
+
'amount': this.safeString(order, 'quantity'),
|
|
219596
|
+
'type': this.safeString(order, 'type'),
|
|
219597
|
+
'side': this.safeStringUpper(order, 'side'),
|
|
219598
|
+
'timeInForce': this.safeString(order, 'time_in_force'),
|
|
219599
|
+
'postOnly': this.safeString(order, 'post_only'),
|
|
219600
|
+
'reduceOnly': this.safeValue(order, 'reduce_only'),
|
|
219601
|
+
'filled': undefined,
|
|
219602
|
+
'remaining': undefined,
|
|
219603
|
+
'cost': undefined,
|
|
219604
|
+
'status': this.parseOrderStatus(this.safeString(order, 'status')),
|
|
219605
|
+
'average': undefined,
|
|
219606
|
+
'trades': trades,
|
|
219607
|
+
'fee': undefined,
|
|
219608
|
+
}, market);
|
|
219609
|
+
}
|
|
219610
|
+
async watchBalance(params = {}) {
|
|
219611
|
+
/**
|
|
219612
|
+
* @method
|
|
219613
|
+
* @name hitbtc#watchBalance
|
|
219614
|
+
* @description watches balance updates, cannot subscribe to margin account balances
|
|
219615
|
+
* @see https://api.hitbtc.com/#subscribe-to-spot-balances
|
|
219616
|
+
* @see https://api.hitbtc.com/#subscribe-to-futures-balances
|
|
219617
|
+
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
219618
|
+
* @param {string} [params.type] 'spot', 'swap', or 'future'
|
|
219619
|
+
*
|
|
219620
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
219621
|
+
* @param {string} [params.mode] 'updates' or 'batches' (default), 'updates' = messages arrive after balance updates, 'batches' = messages arrive at equal intervals if there were any updates
|
|
219622
|
+
* @returns {[object]} a list of [balance structures]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
219623
|
+
*/
|
|
219624
|
+
await this.loadMarkets();
|
|
219625
|
+
let type = undefined;
|
|
219626
|
+
[type, params] = this.handleMarketTypeAndParams('watchBalance', undefined, params);
|
|
219627
|
+
const name = this.getSupportedMapping(type, {
|
|
219628
|
+
'spot': 'spot_balance_subscribe',
|
|
219629
|
+
'swap': 'futures_balance_subscribe',
|
|
219630
|
+
'future': 'futures_balance_subscribe',
|
|
219631
|
+
});
|
|
219632
|
+
const mode = this.safeString(params, 'mode', 'batches');
|
|
219633
|
+
params = this.omit(params, 'mode');
|
|
219634
|
+
const request = {
|
|
219635
|
+
'mode': mode,
|
|
219636
|
+
};
|
|
219637
|
+
return await this.subscribePrivate(name, undefined, this.extend(request, params));
|
|
219638
|
+
}
|
|
219639
|
+
handleBalance(client, message) {
|
|
219640
|
+
//
|
|
219641
|
+
// {
|
|
219642
|
+
// "jsonrpc": "2.0",
|
|
219643
|
+
// "method": "futures_balance",
|
|
219644
|
+
// "params": [
|
|
219645
|
+
// {
|
|
219646
|
+
// "currency": "BCN",
|
|
219647
|
+
// "available": "100.000000000000",
|
|
219648
|
+
// "reserved": "0",
|
|
219649
|
+
// "reserved_margin": "0"
|
|
219650
|
+
// },
|
|
219651
|
+
// ...
|
|
219652
|
+
// ]
|
|
219653
|
+
// }
|
|
219654
|
+
//
|
|
219655
|
+
const messageHash = this.safeString(message, 'method');
|
|
219656
|
+
const params = this.safeValue(message, 'params');
|
|
219657
|
+
const balance = this.parseBalance(params);
|
|
219658
|
+
this.balance = this.deepExtend(this.balance, balance);
|
|
219659
|
+
client.resolve(this.balance, messageHash);
|
|
219660
|
+
}
|
|
219029
219661
|
handleNotification(client, message) {
|
|
219030
219662
|
//
|
|
219031
219663
|
// { jsonrpc: '2.0', result: true, id: null }
|
|
@@ -219033,23 +219665,57 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
219033
219665
|
return message;
|
|
219034
219666
|
}
|
|
219035
219667
|
handleMessage(client, message) {
|
|
219036
|
-
|
|
219037
|
-
|
|
219038
|
-
'
|
|
219039
|
-
|
|
219040
|
-
|
|
219041
|
-
|
|
219042
|
-
|
|
219043
|
-
|
|
219044
|
-
|
|
219045
|
-
|
|
219046
|
-
|
|
219047
|
-
|
|
219048
|
-
|
|
219668
|
+
let channel = this.safeString2(message, 'ch', 'method');
|
|
219669
|
+
if (channel !== undefined) {
|
|
219670
|
+
const splitChannel = channel.split('/');
|
|
219671
|
+
channel = this.safeString(splitChannel, 0);
|
|
219672
|
+
const methods = {
|
|
219673
|
+
'candles': this.handleOHLCV,
|
|
219674
|
+
'ticker': this.handleTicker,
|
|
219675
|
+
'trades': this.handleTrades,
|
|
219676
|
+
'orderbook': this.handleOrderBook,
|
|
219677
|
+
'spot_order': this.handleOrder,
|
|
219678
|
+
'spot_orders': this.handleOrder,
|
|
219679
|
+
'margin_order': this.handleOrder,
|
|
219680
|
+
'margin_orders': this.handleOrder,
|
|
219681
|
+
'futures_order': this.handleOrder,
|
|
219682
|
+
'futures_orders': this.handleOrder,
|
|
219683
|
+
'spot_balance': this.handleBalance,
|
|
219684
|
+
'futures_balance': this.handleBalance,
|
|
219685
|
+
};
|
|
219686
|
+
const method = this.safeValue(methods, channel);
|
|
219687
|
+
if (method !== undefined) {
|
|
219688
|
+
method.call(this, client, message);
|
|
219689
|
+
}
|
|
219049
219690
|
}
|
|
219050
219691
|
else {
|
|
219051
|
-
|
|
219692
|
+
const success = this.safeValue(message, 'result');
|
|
219693
|
+
if ((success === true) && !('id' in message)) {
|
|
219694
|
+
this.handleAuthenticate(client, message);
|
|
219695
|
+
}
|
|
219696
|
+
}
|
|
219697
|
+
}
|
|
219698
|
+
handleAuthenticate(client, message) {
|
|
219699
|
+
//
|
|
219700
|
+
// {
|
|
219701
|
+
// jsonrpc: '2.0',
|
|
219702
|
+
// result: true
|
|
219703
|
+
// }
|
|
219704
|
+
//
|
|
219705
|
+
const success = this.safeValue(message, 'result');
|
|
219706
|
+
const messageHash = 'authenticated';
|
|
219707
|
+
if (success) {
|
|
219708
|
+
const future = this.safeValue(client.futures, messageHash);
|
|
219709
|
+
future.resolve(true);
|
|
219710
|
+
}
|
|
219711
|
+
else {
|
|
219712
|
+
const error = new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.AuthenticationError(this.id + ' ' + this.json(message));
|
|
219713
|
+
client.reject(error, messageHash);
|
|
219714
|
+
if (messageHash in client.subscriptions) {
|
|
219715
|
+
delete client.subscriptions[messageHash];
|
|
219716
|
+
}
|
|
219052
219717
|
}
|
|
219718
|
+
return message;
|
|
219053
219719
|
}
|
|
219054
219720
|
}
|
|
219055
219721
|
|
|
@@ -274870,7 +275536,7 @@ SOFTWARE.
|
|
|
274870
275536
|
|
|
274871
275537
|
//-----------------------------------------------------------------------------
|
|
274872
275538
|
// this is updated by vss.js when building
|
|
274873
|
-
const version = '4.0.
|
|
275539
|
+
const version = '4.0.94';
|
|
274874
275540
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
|
|
274875
275541
|
//-----------------------------------------------------------------------------
|
|
274876
275542
|
|