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