ccxt 4.0.90 → 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 +928 -254
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +8 -3
- 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/mexc.js +3 -1
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/pro/hitbtc.js +893 -235
- package/dist/cjs/src/pro/krakenfutures.js +4 -2
- package/dist/cjs/src/pro/okx.js +6 -5
- package/dist/cjs/src/pro/poloniexfutures.js +2 -1
- package/dist/cjs/src/pro/probit.js +4 -2
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +6 -1
- package/js/src/abstract/binancecoinm.d.ts +6 -1
- package/js/src/abstract/binanceus.d.ts +6 -1
- package/js/src/abstract/binanceusdm.d.ts +6 -1
- package/js/src/abstract/gate.d.ts +1 -0
- package/js/src/abstract/gateio.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +1 -1
- package/js/src/binance.js +8 -3
- 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/mexc.js +3 -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/js/src/pro/krakenfutures.js +4 -2
- package/js/src/pro/okx.js +6 -5
- package/js/src/pro/poloniexfutures.js +2 -1
- package/js/src/pro/probit.js +4 -2
- package/package.json +1 -1
package/dist/ccxt.browser.js
CHANGED
|
@@ -16229,6 +16229,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
16229
16229
|
'continuousKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
|
|
16230
16230
|
'indexPriceKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
|
|
16231
16231
|
'markPriceKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
|
|
16232
|
+
'premiumIndexKlines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
|
|
16232
16233
|
'ticker/24hr': { 'cost': 1, 'noSymbol': 40 },
|
|
16233
16234
|
'ticker/price': { 'cost': 1, 'noSymbol': 2 },
|
|
16234
16235
|
'ticker/bookTicker': { 'cost': 1, 'noSymbol': 2 },
|
|
@@ -16248,6 +16249,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
16248
16249
|
'dapiPrivate': {
|
|
16249
16250
|
'get': {
|
|
16250
16251
|
'positionSide/dual': 30,
|
|
16252
|
+
'orderAmendment': 1,
|
|
16251
16253
|
'order': 1,
|
|
16252
16254
|
'openOrder': 1,
|
|
16253
16255
|
'openOrders': { 'cost': 1, 'noSymbol': 5 },
|
|
@@ -16261,8 +16263,11 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
16261
16263
|
'leverageBracket': 1,
|
|
16262
16264
|
'forceOrders': { 'cost': 20, 'noSymbol': 50 },
|
|
16263
16265
|
'adlQuantile': 5,
|
|
16264
|
-
'
|
|
16265
|
-
'
|
|
16266
|
+
'commissionRate': 20,
|
|
16267
|
+
'income/asyn': 5,
|
|
16268
|
+
'income/asyn/id': 5,
|
|
16269
|
+
'pmExchangeInfo': 0.5,
|
|
16270
|
+
'pmAccountInfo': 0.5, // Weight(IP): 5 => cost = 0.1 * 5 = 0.5
|
|
16266
16271
|
},
|
|
16267
16272
|
'post': {
|
|
16268
16273
|
'positionSide/dual': 1,
|
|
@@ -23354,7 +23359,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
23354
23359
|
* @param {int} [since] timestamp in ms
|
|
23355
23360
|
* @param {int} [limit] number of records, default 100, max 100
|
|
23356
23361
|
* @param {object} [params] exchange specific params
|
|
23357
|
-
* @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}
|
|
23358
23363
|
*/
|
|
23359
23364
|
await this.loadMarkets();
|
|
23360
23365
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
@@ -80374,7 +80379,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
80374
80379
|
* @param {int} [since] timestamp in ms
|
|
80375
80380
|
* @param {int} [limit] number of records
|
|
80376
80381
|
* @param {object} [params] exchange specific params
|
|
80377
|
-
* @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}
|
|
80378
80383
|
*/
|
|
80379
80384
|
await this.loadMarkets();
|
|
80380
80385
|
const request = {};
|
|
@@ -100933,7 +100938,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
100933
100938
|
* @param {int} [limit] number of records
|
|
100934
100939
|
* @param {object} [params] exchange specific params
|
|
100935
100940
|
* @param {int} [params.type] 'future', 'option'
|
|
100936
|
-
* @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}
|
|
100937
100942
|
*/
|
|
100938
100943
|
await this.loadMarkets();
|
|
100939
100944
|
let market = undefined;
|
|
@@ -106183,7 +106188,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
106183
106188
|
* @param {int} [since] timestamp in ms
|
|
106184
106189
|
* @param {int} [limit] number of records
|
|
106185
106190
|
* @param {object} [params] exchange specific params
|
|
106186
|
-
* @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}
|
|
106187
106192
|
*/
|
|
106188
106193
|
await this.loadMarkets();
|
|
106189
106194
|
let market = undefined;
|
|
@@ -115893,6 +115898,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
115893
115898
|
'spot/orders/{order_id}': 1.5,
|
|
115894
115899
|
},
|
|
115895
115900
|
'post': {
|
|
115901
|
+
'account_mode': 1.5,
|
|
115896
115902
|
'loans': 1.5,
|
|
115897
115903
|
'spot/orders': 1.5,
|
|
115898
115904
|
},
|
|
@@ -121403,7 +121409,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
121403
121409
|
* @param {int} [since] timestamp in ms
|
|
121404
121410
|
* @param {int} [limit] number of records
|
|
121405
121411
|
* @param {object} [params] exchange specific params
|
|
121406
|
-
* @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}
|
|
121407
121413
|
*/
|
|
121408
121414
|
this.checkRequiredSymbol('fetchSettlementHistory', symbol);
|
|
121409
121415
|
await this.loadMarkets();
|
|
@@ -136596,7 +136602,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
136596
136602
|
* @param {int} [params.until] timestamp in ms, value range = start_time -> current time,default = current time
|
|
136597
136603
|
* @param {int} [params.page_index] page index, default page 1 if not filled
|
|
136598
136604
|
* @param {int} [params.code] unified currency code, can be used when symbol is undefined
|
|
136599
|
-
* @returns
|
|
136605
|
+
* @returns {object[]} a list of [settlement history objects]{@link https://github.com/ccxt/ccxt/wiki/Manual#settlement-history-structure}
|
|
136600
136606
|
*/
|
|
136601
136607
|
const code = this.safeString(params, 'code');
|
|
136602
136608
|
const until = this.safeInteger2(params, 'until', 'till');
|
|
@@ -164104,7 +164110,9 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
164104
164110
|
//
|
|
164105
164111
|
// {}
|
|
164106
164112
|
//
|
|
164107
|
-
|
|
164113
|
+
const keys = Object.keys(response);
|
|
164114
|
+
const length = keys.length;
|
|
164115
|
+
status = length ? this.json(response) : 'ok';
|
|
164108
164116
|
}
|
|
164109
164117
|
else if (marketType === 'swap') {
|
|
164110
164118
|
response = await this.contractPublicGetPing(query);
|
|
@@ -184104,7 +184112,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
184104
184112
|
* @param {int} [since] timestamp in ms
|
|
184105
184113
|
* @param {int} [limit] number of records
|
|
184106
184114
|
* @param {object} [params] exchange specific params
|
|
184107
|
-
* @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}
|
|
184108
184116
|
*/
|
|
184109
184117
|
this.checkRequiredSymbol('fetchSettlementHistory', symbol);
|
|
184110
184118
|
await this.loadMarkets();
|
|
@@ -218671,10 +218679,14 @@ class gemini extends _gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
218671
218679
|
/* harmony export */ "Z": () => (/* binding */ hitbtc)
|
|
218672
218680
|
/* harmony export */ });
|
|
218673
218681
|
/* harmony import */ var _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4714);
|
|
218674
|
-
/* 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);
|
|
218675
218685
|
// ---------------------------------------------------------------------------
|
|
218676
218686
|
|
|
218677
218687
|
|
|
218688
|
+
|
|
218689
|
+
|
|
218678
218690
|
// ---------------------------------------------------------------------------
|
|
218679
218691
|
class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
218680
218692
|
describe() {
|
|
@@ -218682,145 +218694,245 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
218682
218694
|
'has': {
|
|
218683
218695
|
'ws': true,
|
|
218684
218696
|
'watchTicker': true,
|
|
218685
|
-
'watchTickers':
|
|
218697
|
+
'watchTickers': true,
|
|
218686
218698
|
'watchTrades': true,
|
|
218687
218699
|
'watchOrderBook': true,
|
|
218688
|
-
'watchBalance':
|
|
218700
|
+
'watchBalance': true,
|
|
218701
|
+
'watchOrders': true,
|
|
218689
218702
|
'watchOHLCV': true,
|
|
218703
|
+
'watchMyTrades': false,
|
|
218690
218704
|
},
|
|
218691
218705
|
'urls': {
|
|
218692
218706
|
'api': {
|
|
218693
|
-
'ws':
|
|
218707
|
+
'ws': {
|
|
218708
|
+
'public': 'wss://api.hitbtc.com/api/3/ws/public',
|
|
218709
|
+
'private': 'wss://api.hitbtc.com/api/3/ws/trading',
|
|
218710
|
+
},
|
|
218694
218711
|
},
|
|
218695
218712
|
},
|
|
218696
218713
|
'options': {
|
|
218697
218714
|
'tradesLimit': 1000,
|
|
218698
|
-
'
|
|
218699
|
-
'
|
|
218700
|
-
|
|
218701
|
-
|
|
218702
|
-
'
|
|
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'
|
|
218703
218723
|
},
|
|
218704
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
|
+
},
|
|
218705
218740
|
});
|
|
218706
218741
|
}
|
|
218707
|
-
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
|
+
*/
|
|
218708
218798
|
await this.loadMarkets();
|
|
218709
|
-
const
|
|
218710
|
-
|
|
218711
|
-
|
|
218712
|
-
|
|
218713
|
-
messageHash += ':' + timeframe;
|
|
218799
|
+
const url = this.urls['api']['ws']['public'];
|
|
218800
|
+
let messageHash = name;
|
|
218801
|
+
if (symbols !== undefined) {
|
|
218802
|
+
messageHash = messageHash + '::' + symbols.join(',');
|
|
218714
218803
|
}
|
|
218715
|
-
const methods = this.safeValue(this.options, 'methods', {});
|
|
218716
|
-
const method = this.safeString(methods, channel, channel);
|
|
218717
|
-
const requestId = this.nonce();
|
|
218718
218804
|
const subscribe = {
|
|
218719
|
-
'method':
|
|
218720
|
-
'
|
|
218721
|
-
|
|
218722
|
-
},
|
|
218723
|
-
'id': requestId,
|
|
218805
|
+
'method': 'subscribe',
|
|
218806
|
+
'id': this.nonce(),
|
|
218807
|
+
'ch': name,
|
|
218724
218808
|
};
|
|
218725
|
-
const request = this.
|
|
218809
|
+
const request = this.extend(subscribe, params);
|
|
218726
218810
|
return await this.watch(url, messageHash, request, messageHash);
|
|
218727
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
|
+
}
|
|
218728
218836
|
async watchOrderBook(symbol, limit = undefined, params = {}) {
|
|
218729
218837
|
/**
|
|
218730
218838
|
* @method
|
|
218731
218839
|
* @name hitbtc#watchOrderBook
|
|
218732
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
|
|
218733
218846
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
218734
218847
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
218735
218848
|
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
218736
|
-
* @
|
|
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
|
|
218737
218853
|
*/
|
|
218738
|
-
const
|
|
218739
|
-
|
|
218740
|
-
|
|
218741
|
-
|
|
218742
|
-
|
|
218743
|
-
|
|
218744
|
-
|
|
218745
|
-
// method: "snapshotOrderbook",
|
|
218746
|
-
// params: {
|
|
218747
|
-
// ask: [
|
|
218748
|
-
// { price: "6927.75", size: "0.11991" },
|
|
218749
|
-
// { price: "6927.76", size: "0.06200" },
|
|
218750
|
-
// { price: "6927.85", size: "0.01000" },
|
|
218751
|
-
// ],
|
|
218752
|
-
// bid: [
|
|
218753
|
-
// { price: "6926.18", size: "0.16898" },
|
|
218754
|
-
// { price: "6926.17", size: "0.06200" },
|
|
218755
|
-
// { price: "6925.97", size: "0.00125" },
|
|
218756
|
-
// ],
|
|
218757
|
-
// symbol: "BTCUSD",
|
|
218758
|
-
// sequence: 494854,
|
|
218759
|
-
// timestamp: "2020-04-03T08:58:53.460Z"
|
|
218760
|
-
// }
|
|
218761
|
-
// }
|
|
218762
|
-
//
|
|
218763
|
-
const params = this.safeValue(message, 'params', {});
|
|
218764
|
-
const marketId = this.safeString(params, 'symbol');
|
|
218765
|
-
const market = this.safeMarket(marketId);
|
|
218766
|
-
const symbol = market['symbol'];
|
|
218767
|
-
const timestamp = this.parse8601(this.safeString(params, 'timestamp'));
|
|
218768
|
-
const nonce = this.safeInteger(params, 'sequence');
|
|
218769
|
-
if (symbol in this.orderbooks) {
|
|
218770
|
-
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';
|
|
218771
218861
|
}
|
|
218772
|
-
|
|
218773
|
-
|
|
218774
|
-
|
|
218775
|
-
|
|
218776
|
-
|
|
218777
|
-
|
|
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();
|
|
218778
218879
|
}
|
|
218779
|
-
|
|
218880
|
+
handleOrderBook(client, message) {
|
|
218780
218881
|
//
|
|
218781
|
-
//
|
|
218782
|
-
//
|
|
218783
|
-
//
|
|
218784
|
-
//
|
|
218785
|
-
//
|
|
218786
|
-
//
|
|
218787
|
-
//
|
|
218788
|
-
//
|
|
218789
|
-
//
|
|
218790
|
-
//
|
|
218791
|
-
//
|
|
218792
|
-
//
|
|
218793
|
-
//
|
|
218794
|
-
//
|
|
218795
|
-
//
|
|
218796
|
-
//
|
|
218797
|
-
//
|
|
218798
|
-
//
|
|
218799
|
-
//
|
|
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
|
+
// }
|
|
218800
218903
|
//
|
|
218801
|
-
const
|
|
218802
|
-
const
|
|
218803
|
-
const
|
|
218804
|
-
|
|
218805
|
-
|
|
218806
|
-
const
|
|
218807
|
-
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');
|
|
218808
218920
|
const orderbook = this.orderbooks[symbol];
|
|
218809
|
-
const asks = this.safeValue(
|
|
218810
|
-
const bids = this.safeValue(
|
|
218921
|
+
const asks = this.safeValue(item, 'a', []);
|
|
218922
|
+
const bids = this.safeValue(item, 'b', []);
|
|
218811
218923
|
this.handleDeltas(orderbook['asks'], asks);
|
|
218812
218924
|
this.handleDeltas(orderbook['bids'], bids);
|
|
218813
218925
|
orderbook['timestamp'] = timestamp;
|
|
218814
218926
|
orderbook['datetime'] = this.iso8601(timestamp);
|
|
218815
218927
|
orderbook['nonce'] = nonce;
|
|
218928
|
+
orderbook['symbol'] = symbol;
|
|
218816
218929
|
this.orderbooks[symbol] = orderbook;
|
|
218817
|
-
const messageHash = 'orderbook:' + marketId;
|
|
218818
218930
|
client.resolve(orderbook, messageHash);
|
|
218819
218931
|
}
|
|
218820
218932
|
}
|
|
218821
218933
|
handleDelta(bookside, delta) {
|
|
218822
|
-
const price = this.
|
|
218823
|
-
const amount = this.
|
|
218934
|
+
const price = this.safeNumber(delta, 0);
|
|
218935
|
+
const amount = this.safeNumber(delta, 1);
|
|
218824
218936
|
bookside.store(price, amount);
|
|
218825
218937
|
}
|
|
218826
218938
|
handleDeltas(bookside, deltas) {
|
|
@@ -218833,192 +218945,714 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
218833
218945
|
* @method
|
|
218834
218946
|
* @name hitbtc#watchTicker
|
|
218835
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
|
|
218836
218952
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
218837
218953
|
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
218838
|
-
* @
|
|
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}
|
|
218839
218957
|
*/
|
|
218840
|
-
|
|
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);
|
|
218841
219010
|
}
|
|
218842
219011
|
handleTicker(client, message) {
|
|
218843
219012
|
//
|
|
218844
|
-
//
|
|
218845
|
-
//
|
|
218846
|
-
//
|
|
218847
|
-
//
|
|
218848
|
-
//
|
|
218849
|
-
//
|
|
218850
|
-
//
|
|
218851
|
-
//
|
|
218852
|
-
//
|
|
218853
|
-
//
|
|
218854
|
-
//
|
|
218855
|
-
//
|
|
218856
|
-
//
|
|
218857
|
-
//
|
|
218858
|
-
//
|
|
218859
|
-
//
|
|
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
|
+
// }
|
|
218860
219034
|
//
|
|
218861
|
-
|
|
218862
|
-
|
|
218863
|
-
|
|
218864
|
-
|
|
218865
|
-
|
|
218866
|
-
|
|
218867
|
-
|
|
218868
|
-
|
|
218869
|
-
|
|
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);
|
|
218870
219134
|
}
|
|
218871
219135
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
218872
219136
|
/**
|
|
218873
219137
|
* @method
|
|
218874
219138
|
* @name hitbtc#watchTrades
|
|
218875
219139
|
* @description get the list of most recent trades for a particular symbol
|
|
219140
|
+
* @see https://api.hitbtc.com/#subscribe-to-trades
|
|
218876
219141
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
218877
219142
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
218878
219143
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
218879
219144
|
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
218880
219145
|
* @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
|
|
218881
219146
|
*/
|
|
218882
|
-
|
|
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));
|
|
218883
219158
|
if (this.newUpdates) {
|
|
218884
219159
|
limit = trades.getLimit(symbol, limit);
|
|
218885
219160
|
}
|
|
218886
|
-
return this.filterBySinceLimit(trades, since, limit, 'timestamp'
|
|
219161
|
+
return this.filterBySinceLimit(trades, since, limit, 'timestamp');
|
|
218887
219162
|
}
|
|
218888
219163
|
handleTrades(client, message) {
|
|
218889
219164
|
//
|
|
218890
|
-
//
|
|
218891
|
-
//
|
|
218892
|
-
//
|
|
218893
|
-
//
|
|
218894
|
-
//
|
|
218895
|
-
//
|
|
218896
|
-
//
|
|
218897
|
-
// price: '6957.20',
|
|
218898
|
-
// quantity: '0.02779',
|
|
218899
|
-
// side: 'buy',
|
|
218900
|
-
// timestamp: '2020-04-03T10:28:20.032Z'
|
|
218901
|
-
// },
|
|
218902
|
-
// {
|
|
218903
|
-
// id: 814145792,
|
|
218904
|
-
// price: '6957.20',
|
|
218905
|
-
// quantity: '0.12918',
|
|
218906
|
-
// side: 'buy',
|
|
218907
|
-
// timestamp: '2020-04-03T10:28:20.039Z'
|
|
218908
|
-
// },
|
|
218909
|
-
// ],
|
|
218910
|
-
// symbol: 'BTCUSD'
|
|
218911
|
-
// }
|
|
218912
|
-
// }
|
|
219165
|
+
// {
|
|
219166
|
+
// "result": {
|
|
219167
|
+
// "ch": "trades", // Channel
|
|
219168
|
+
// "subscriptions": ["ETHBTC", "BTCUSDT"]
|
|
219169
|
+
// },
|
|
219170
|
+
// "id": 123
|
|
219171
|
+
// }
|
|
218913
219172
|
//
|
|
218914
|
-
|
|
218915
|
-
|
|
218916
|
-
|
|
218917
|
-
|
|
218918
|
-
|
|
218919
|
-
|
|
218920
|
-
|
|
218921
|
-
|
|
218922
|
-
|
|
218923
|
-
|
|
218924
|
-
|
|
218925
|
-
}
|
|
218926
|
-
|
|
218927
|
-
|
|
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);
|
|
218928
219216
|
for (let i = 0; i < trades.length; i++) {
|
|
218929
219217
|
stored.append(trades[i]);
|
|
218930
219218
|
}
|
|
219219
|
+
const messageHash = 'trades::' + symbol;
|
|
219220
|
+
client.resolve(stored, messageHash);
|
|
218931
219221
|
}
|
|
218932
|
-
else {
|
|
218933
|
-
const trade = this.parseTrade(message, market);
|
|
218934
|
-
stored.append(trade);
|
|
218935
|
-
}
|
|
218936
|
-
client.resolve(stored, messageHash);
|
|
218937
219222
|
return message;
|
|
218938
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
|
+
}
|
|
218939
219262
|
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
218940
219263
|
/**
|
|
218941
219264
|
* @method
|
|
218942
219265
|
* @name hitbtc#watchOHLCV
|
|
218943
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
|
|
218944
219268
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
218945
|
-
* @param {string} timeframe the length of time each candle represents
|
|
218946
|
-
* @param {int} [since]
|
|
218947
|
-
* @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)
|
|
218948
219272
|
* @param {object} [params] extra parameters specific to the hitbtc api endpoint
|
|
218949
|
-
* @returns {
|
|
219273
|
+
* @returns {[[int]]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
218950
219274
|
*/
|
|
218951
|
-
// if (limit === undefined) {
|
|
218952
|
-
// limit = 100;
|
|
218953
|
-
// }
|
|
218954
219275
|
const period = this.safeString(this.timeframes, timeframe, timeframe);
|
|
219276
|
+
const name = 'candles/' + period;
|
|
219277
|
+
const market = this.market(symbol);
|
|
218955
219278
|
const request = {
|
|
218956
219279
|
'params': {
|
|
218957
|
-
'
|
|
218958
|
-
// 'limit': limit,
|
|
219280
|
+
'symbols': [market['id']],
|
|
218959
219281
|
},
|
|
218960
219282
|
};
|
|
218961
|
-
|
|
218962
|
-
|
|
219283
|
+
if (limit !== undefined) {
|
|
219284
|
+
request['params']['limit'] = limit;
|
|
219285
|
+
}
|
|
219286
|
+
const ohlcv = await this.subscribePublic(name, [symbol], this.deepExtend(request, params));
|
|
218963
219287
|
if (this.newUpdates) {
|
|
218964
219288
|
limit = ohlcv.getLimit(symbol, limit);
|
|
218965
219289
|
}
|
|
218966
|
-
return this.filterBySinceLimit(ohlcv, since, limit, 0
|
|
219290
|
+
return this.filterBySinceLimit(ohlcv, since, limit, 0);
|
|
218967
219291
|
}
|
|
218968
219292
|
handleOHLCV(client, message) {
|
|
218969
219293
|
//
|
|
218970
|
-
//
|
|
218971
|
-
//
|
|
218972
|
-
//
|
|
218973
|
-
//
|
|
218974
|
-
//
|
|
218975
|
-
//
|
|
218976
|
-
//
|
|
218977
|
-
//
|
|
218978
|
-
//
|
|
218979
|
-
//
|
|
218980
|
-
//
|
|
218981
|
-
//
|
|
218982
|
-
//
|
|
218983
|
-
//
|
|
218984
|
-
//
|
|
218985
|
-
//
|
|
218986
|
-
// open: '6867.54',
|
|
218987
|
-
// close: '6859.26',
|
|
218988
|
-
// min: '6858.85',
|
|
218989
|
-
// max: '6867.54',
|
|
218990
|
-
// volume: '1.7766',
|
|
218991
|
-
// volumeQuote: '12191.5880395'
|
|
218992
|
-
// },
|
|
218993
|
-
// ],
|
|
218994
|
-
// symbol: 'BTCUSD',
|
|
218995
|
-
// period: 'M1'
|
|
218996
|
-
// }
|
|
218997
|
-
// }
|
|
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
|
+
// }
|
|
218998
219310
|
//
|
|
218999
|
-
|
|
219000
|
-
|
|
219001
|
-
|
|
219002
|
-
|
|
219003
|
-
|
|
219004
|
-
|
|
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);
|
|
219005
219331
|
const timeframe = this.findTimeframe(period);
|
|
219006
|
-
|
|
219007
|
-
|
|
219008
|
-
const
|
|
219009
|
-
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'];
|
|
219010
219336
|
this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
|
|
219011
219337
|
let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
|
|
219012
219338
|
if (stored === undefined) {
|
|
219013
219339
|
const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
|
|
219014
|
-
stored = new
|
|
219340
|
+
stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
|
|
219015
219341
|
this.ohlcvs[symbol][timeframe] = stored;
|
|
219016
219342
|
}
|
|
219017
|
-
|
|
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;
|
|
219018
219348
|
client.resolve(stored, messageHash);
|
|
219019
219349
|
}
|
|
219020
219350
|
return message;
|
|
219021
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
|
+
}
|
|
219022
219656
|
handleNotification(client, message) {
|
|
219023
219657
|
//
|
|
219024
219658
|
// { jsonrpc: '2.0', result: true, id: null }
|
|
@@ -219026,24 +219660,58 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
219026
219660
|
return message;
|
|
219027
219661
|
}
|
|
219028
219662
|
handleMessage(client, message) {
|
|
219029
|
-
|
|
219030
|
-
|
|
219031
|
-
'
|
|
219032
|
-
|
|
219033
|
-
|
|
219034
|
-
|
|
219035
|
-
|
|
219036
|
-
|
|
219037
|
-
|
|
219038
|
-
|
|
219039
|
-
|
|
219040
|
-
|
|
219041
|
-
|
|
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
|
+
}
|
|
219042
219685
|
}
|
|
219043
219686
|
else {
|
|
219044
|
-
|
|
219687
|
+
const success = this.safeValue(message, 'result');
|
|
219688
|
+
if ((success === true) && !('id' in message)) {
|
|
219689
|
+
this.handleAuthenticate(client, message);
|
|
219690
|
+
}
|
|
219045
219691
|
}
|
|
219046
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
|
+
}
|
|
219047
219715
|
}
|
|
219048
219716
|
|
|
219049
219717
|
|
|
@@ -224983,7 +225651,8 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
224983
225651
|
const symbol = symbols[i];
|
|
224984
225652
|
marketIds.push(this.marketId(symbol));
|
|
224985
225653
|
}
|
|
224986
|
-
|
|
225654
|
+
const length = symbols.length;
|
|
225655
|
+
if (length === 1) {
|
|
224987
225656
|
const market = this.market(marketIds[0]);
|
|
224988
225657
|
messageHash = messageHash + ':' + market['symbol'];
|
|
224989
225658
|
}
|
|
@@ -225501,7 +226170,8 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
225501
226170
|
symbols[symbol] = true;
|
|
225502
226171
|
cachedOrders.append(parsed);
|
|
225503
226172
|
}
|
|
225504
|
-
|
|
226173
|
+
const length = this.orders.length;
|
|
226174
|
+
if (length > 0) {
|
|
225505
226175
|
client.resolve(this.orders, 'orders');
|
|
225506
226176
|
const keys = Object.keys(symbols);
|
|
225507
226177
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -230915,9 +231585,10 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
230915
231585
|
// for context: https://www.okx.com/help-center/changes-to-v5-api-websocket-subscription-parameter-and-url
|
|
230916
231586
|
const isSandbox = this.options['sandboxMode'];
|
|
230917
231587
|
const sandboxSuffix = isSandbox ? '?brokerId=9999' : '';
|
|
231588
|
+
const isBusiness = (access === 'business');
|
|
230918
231589
|
const isPublic = (access === 'public');
|
|
230919
231590
|
const url = this.urls['api']['ws'];
|
|
230920
|
-
if ((channel.indexOf('candle') > -1) || (channel === 'orders-algo')) {
|
|
231591
|
+
if (isBusiness || (channel.indexOf('candle') > -1) || (channel === 'orders-algo')) {
|
|
230921
231592
|
return url + '/business' + sandboxSuffix;
|
|
230922
231593
|
}
|
|
230923
231594
|
else if (isPublic) {
|
|
@@ -231636,13 +232307,13 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
231636
232307
|
* @param {bool} [params.stop] true if fetching trigger or conditional trades
|
|
231637
232308
|
* @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure
|
|
231638
232309
|
*/
|
|
231639
|
-
await this.loadMarkets();
|
|
231640
|
-
await this.authenticate();
|
|
231641
232310
|
// By default, receive order updates from any instrument type
|
|
231642
232311
|
let type = undefined;
|
|
231643
232312
|
[type, params] = this.handleOptionAndParams(params, 'watchMyTrades', 'type', 'ANY');
|
|
231644
232313
|
const isStop = this.safeValue(params, 'stop', false);
|
|
231645
232314
|
params = this.omit(params, ['stop']);
|
|
232315
|
+
await this.loadMarkets();
|
|
232316
|
+
await this.authenticate({ 'access': isStop ? 'business' : 'private' });
|
|
231646
232317
|
const channel = isStop ? 'orders-algo' : 'orders';
|
|
231647
232318
|
let messageHash = channel + '::myTrades';
|
|
231648
232319
|
let market = undefined;
|
|
@@ -231678,13 +232349,13 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
231678
232349
|
* @param {bool} [params.stop] true if fetching trigger or conditional orders
|
|
231679
232350
|
* @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
231680
232351
|
*/
|
|
231681
|
-
await this.loadMarkets();
|
|
231682
|
-
await this.authenticate();
|
|
231683
232352
|
let type = undefined;
|
|
231684
232353
|
// By default, receive order updates from any instrument type
|
|
231685
232354
|
[type, params] = this.handleOptionAndParams(params, 'watchOrders', 'type', 'ANY');
|
|
231686
232355
|
const isStop = this.safeValue(params, 'stop', false);
|
|
231687
232356
|
params = this.omit(params, ['stop']);
|
|
232357
|
+
await this.loadMarkets();
|
|
232358
|
+
await this.authenticate({ 'access': isStop ? 'business' : 'private' });
|
|
231688
232359
|
let market = undefined;
|
|
231689
232360
|
if (symbol !== undefined) {
|
|
231690
232361
|
market = this.market(symbol);
|
|
@@ -235150,7 +235821,8 @@ class poloniexfutures extends _poloniexfutures_js__WEBPACK_IMPORTED_MODULE_0__/*
|
|
|
235150
235821
|
limit = orders.getLimit(symbol, limit);
|
|
235151
235822
|
}
|
|
235152
235823
|
orders = this.filterBySymbolSinceLimit(orders, symbol, since, limit);
|
|
235153
|
-
|
|
235824
|
+
const length = orders.length;
|
|
235825
|
+
if (length === 0) {
|
|
235154
235826
|
return await this.watchOrders(symbol, since, limit, params);
|
|
235155
235827
|
}
|
|
235156
235828
|
return orders;
|
|
@@ -236133,7 +236805,8 @@ class probit extends _probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
236133
236805
|
// }
|
|
236134
236806
|
//
|
|
236135
236807
|
const rawTrades = this.safeValue(message, 'data', []);
|
|
236136
|
-
|
|
236808
|
+
const length = rawTrades.length;
|
|
236809
|
+
if (length === 0) {
|
|
236137
236810
|
return;
|
|
236138
236811
|
}
|
|
236139
236812
|
const reset = this.safeValue(message, 'reset', false);
|
|
@@ -236219,7 +236892,8 @@ class probit extends _probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
236219
236892
|
// }
|
|
236220
236893
|
//
|
|
236221
236894
|
const rawOrders = this.safeValue(message, 'data', []);
|
|
236222
|
-
|
|
236895
|
+
const length = rawOrders.length;
|
|
236896
|
+
if (length === 0) {
|
|
236223
236897
|
return;
|
|
236224
236898
|
}
|
|
236225
236899
|
const messageHash = 'orders';
|
|
@@ -274857,7 +275531,7 @@ SOFTWARE.
|
|
|
274857
275531
|
|
|
274858
275532
|
//-----------------------------------------------------------------------------
|
|
274859
275533
|
// this is updated by vss.js when building
|
|
274860
|
-
const version = '4.0.
|
|
275534
|
+
const version = '4.0.93';
|
|
274861
275535
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
|
|
274862
275536
|
//-----------------------------------------------------------------------------
|
|
274863
275537
|
|