ccxt 4.5.61 → 4.5.62
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 +16 -15
- package/dist/ccxt.browser.min.js +4 -4
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +1 -1
- package/dist/cjs/src/bingx.js +3 -3
- package/dist/cjs/src/bitmex.js +1 -1
- package/dist/cjs/src/bitvavo.js +1 -1
- package/dist/cjs/src/btcturk.js +1 -1
- package/dist/cjs/src/extended.js +2 -2
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/pro/htx.js +438 -100
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.js +1 -1
- package/js/src/bingx.js +3 -3
- package/js/src/bitmex.js +1 -1
- package/js/src/bitvavo.js +1 -1
- package/js/src/btcturk.js +1 -1
- package/js/src/extended.js +2 -2
- package/js/src/gate.js +1 -1
- package/js/src/pro/htx.d.ts +7 -6
- package/js/src/pro/htx.js +438 -98
- package/package.json +2 -2
package/js/src/pro/htx.js
CHANGED
|
@@ -51,6 +51,7 @@ export default class htx extends htxRest {
|
|
|
51
51
|
'linear': {
|
|
52
52
|
'public': 'wss://api.hbdm.vn/linear-swap-ws',
|
|
53
53
|
'private': 'wss://api.hbdm.vn/linear-swap-notification',
|
|
54
|
+
'privateV5': 'wss://api.hbdm.vn/ws/v5/notification',
|
|
54
55
|
},
|
|
55
56
|
'inverse': {
|
|
56
57
|
'public': 'wss://api.hbdm.vn/ws',
|
|
@@ -65,6 +66,7 @@ export default class htx extends htxRest {
|
|
|
65
66
|
'linear': {
|
|
66
67
|
'public': 'wss://api.hbdm.vn/linear-swap-ws',
|
|
67
68
|
'private': 'wss://api.hbdm.vn/linear-swap-notification',
|
|
69
|
+
'privateV5': 'wss://api.hbdm.vn/ws/v5/notification',
|
|
68
70
|
},
|
|
69
71
|
},
|
|
70
72
|
},
|
|
@@ -79,6 +81,7 @@ export default class htx extends htxRest {
|
|
|
79
81
|
'linear': {
|
|
80
82
|
'public': 'wss://api.hbdm.vn/linear-swap-ws',
|
|
81
83
|
'private': 'wss://api.hbdm.vn/linear-swap-notification',
|
|
84
|
+
'privateV5': 'wss://api.hbdm.vn/ws/v5/notification',
|
|
82
85
|
},
|
|
83
86
|
'inverse': {
|
|
84
87
|
'public': 'wss://api.hbdm.vn/ws',
|
|
@@ -89,6 +92,7 @@ export default class htx extends htxRest {
|
|
|
89
92
|
'linear': {
|
|
90
93
|
'public': 'wss://api.hbdm.vn/linear-swap-ws',
|
|
91
94
|
'private': 'wss://api.hbdm.vn/linear-swap-notification',
|
|
95
|
+
'privateV5': 'wss://api.hbdm.vn/ws/v5/notification',
|
|
92
96
|
},
|
|
93
97
|
'inverse': {
|
|
94
98
|
'public': 'wss://api.hbdm.vn/swap-ws',
|
|
@@ -782,6 +786,7 @@ export default class htx extends htxRest {
|
|
|
782
786
|
* @name htx#watchMyTrades
|
|
783
787
|
* @description watches information on multiple trades made by the user
|
|
784
788
|
* @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec53dd5-7773-11ed-9966-0242ac110003
|
|
789
|
+
* @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb89359-77b5-11ed-9966-195a35275ff
|
|
785
790
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
786
791
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
787
792
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
@@ -812,6 +817,10 @@ export default class htx extends htxRest {
|
|
|
812
817
|
subType = this.safeString(params, 'subType', subType);
|
|
813
818
|
params = this.omit(params, ['type', 'subType']);
|
|
814
819
|
}
|
|
820
|
+
const linear = (subType === 'linear');
|
|
821
|
+
const swap = (type === 'swap');
|
|
822
|
+
const future = (type === 'future');
|
|
823
|
+
const isV5Linear = (linear && (swap || future));
|
|
815
824
|
if (type === 'spot') {
|
|
816
825
|
let mode = undefined;
|
|
817
826
|
if (mode === undefined) {
|
|
@@ -822,6 +831,12 @@ export default class htx extends htxRest {
|
|
|
822
831
|
messageHash = 'trade.clearing' + '#' + marketId + '#' + mode;
|
|
823
832
|
channel = messageHash;
|
|
824
833
|
}
|
|
834
|
+
else if (isV5Linear) {
|
|
835
|
+
const channelAndMessageHashAndParams = this.getV5LinearChannelAndMessageHash('trade', market, params);
|
|
836
|
+
channel = this.safeString(channelAndMessageHashAndParams, 0);
|
|
837
|
+
messageHash = this.safeString(channelAndMessageHashAndParams, 1);
|
|
838
|
+
params = this.safeValue(channelAndMessageHashAndParams, 2, {});
|
|
839
|
+
}
|
|
825
840
|
else {
|
|
826
841
|
const channelAndMessageHash = this.getOrderChannelAndMessageHash(type, subType, market, params);
|
|
827
842
|
channel = this.safeString(channelAndMessageHash, 0);
|
|
@@ -830,7 +845,10 @@ export default class htx extends htxRest {
|
|
|
830
845
|
// like symbol/margin/subtype/type variations
|
|
831
846
|
messageHash = orderMessageHash + ':' + 'trade';
|
|
832
847
|
}
|
|
833
|
-
|
|
848
|
+
const subscriptionParams = {
|
|
849
|
+
'isV5': isV5Linear,
|
|
850
|
+
};
|
|
851
|
+
trades = await this.subscribePrivate(channel, messageHash, type, subType, params, subscriptionParams);
|
|
834
852
|
if (this.newUpdates) {
|
|
835
853
|
limit = trades.getLimit(symbol, limit);
|
|
836
854
|
}
|
|
@@ -881,11 +899,22 @@ export default class htx extends htxRest {
|
|
|
881
899
|
}
|
|
882
900
|
return [channel, messageHash];
|
|
883
901
|
}
|
|
902
|
+
getV5LinearChannelAndMessageHash(topic, market = undefined, params = {}) {
|
|
903
|
+
const contractCode = (market !== undefined) ? market['id'] : this.safeString(params, 'contract_code', '*');
|
|
904
|
+
const channel = topic;
|
|
905
|
+
const messageHash = (contractCode === '*') ? topic : (topic + '.' + contractCode.toLowerCase());
|
|
906
|
+
params = this.omit(params, 'contract_code');
|
|
907
|
+
const requestParams = this.extend({
|
|
908
|
+
'contract_code': contractCode,
|
|
909
|
+
}, params);
|
|
910
|
+
return [channel, messageHash, requestParams];
|
|
911
|
+
}
|
|
884
912
|
/**
|
|
885
913
|
* @method
|
|
886
914
|
* @name htx#watchOrders
|
|
887
915
|
* @description watches information on multiple orders made by the user
|
|
888
916
|
* @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec53c8f-7773-11ed-9966-0242ac110003
|
|
917
|
+
* @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb89359-77b5-11ed-9966-195a208afe7
|
|
889
918
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
890
919
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
891
920
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -912,18 +941,31 @@ export default class htx extends htxRest {
|
|
|
912
941
|
subType = this.safeString(params, 'subType', subType);
|
|
913
942
|
params = this.omit(params, ['type', 'subType']);
|
|
914
943
|
}
|
|
944
|
+
const linear = (subType === 'linear');
|
|
945
|
+
const swap = (type === 'swap');
|
|
946
|
+
const future = (type === 'future');
|
|
947
|
+
const isV5Linear = (linear && (swap || future));
|
|
915
948
|
let messageHash = undefined;
|
|
916
949
|
let channel = undefined;
|
|
917
950
|
if (type === 'spot') {
|
|
918
951
|
messageHash = 'orders' + '#' + suffix;
|
|
919
952
|
channel = messageHash;
|
|
920
953
|
}
|
|
954
|
+
else if (isV5Linear) {
|
|
955
|
+
const channelAndMessageHashAndParams = this.getV5LinearChannelAndMessageHash('orders', market, params);
|
|
956
|
+
channel = this.safeString(channelAndMessageHashAndParams, 0);
|
|
957
|
+
messageHash = this.safeString(channelAndMessageHashAndParams, 1);
|
|
958
|
+
params = this.safeValue(channelAndMessageHashAndParams, 2, {});
|
|
959
|
+
}
|
|
921
960
|
else {
|
|
922
961
|
const channelAndMessageHash = this.getOrderChannelAndMessageHash(type, subType, market, params);
|
|
923
962
|
channel = this.safeString(channelAndMessageHash, 0);
|
|
924
963
|
messageHash = this.safeString(channelAndMessageHash, 1);
|
|
925
964
|
}
|
|
926
|
-
const
|
|
965
|
+
const subscriptionParams = {
|
|
966
|
+
'isV5': isV5Linear,
|
|
967
|
+
};
|
|
968
|
+
const orders = await this.subscribePrivate(channel, messageHash, type, subType, params, subscriptionParams);
|
|
927
969
|
if (this.newUpdates) {
|
|
928
970
|
limit = orders.getLimit(symbol, limit);
|
|
929
971
|
}
|
|
@@ -1050,11 +1092,60 @@ export default class htx extends htxRest {
|
|
|
1050
1092
|
// }
|
|
1051
1093
|
//
|
|
1052
1094
|
//
|
|
1095
|
+
// linear v5 watchOrders
|
|
1096
|
+
//
|
|
1097
|
+
// {
|
|
1098
|
+
// "op": "notify",
|
|
1099
|
+
// "topic": "orders",
|
|
1100
|
+
// "contract_code": "BTC-USDT",
|
|
1101
|
+
// "ts": 1782367563267,
|
|
1102
|
+
// "uid": "359305390",
|
|
1103
|
+
// "data": {
|
|
1104
|
+
// "side": "buy",
|
|
1105
|
+
// "type": "limit",
|
|
1106
|
+
// "price": "40000",
|
|
1107
|
+
// "volume": "1",
|
|
1108
|
+
// "state": "new",
|
|
1109
|
+
// "profit": "0",
|
|
1110
|
+
// "contract_code": "BTC-USDT",
|
|
1111
|
+
// "position_side": "both",
|
|
1112
|
+
// "price_match": null,
|
|
1113
|
+
// "order_id": "1519705236917489664",
|
|
1114
|
+
// "client_order_id": "1519705236917489664",
|
|
1115
|
+
// "margin_mode": "cross",
|
|
1116
|
+
// "lever_rate": 10,
|
|
1117
|
+
// "order_source": "api",
|
|
1118
|
+
// "reduce_only": false,
|
|
1119
|
+
// "time_in_force": "gtc",
|
|
1120
|
+
// "trade_avg_price": "0",
|
|
1121
|
+
// "trade_volume": "0",
|
|
1122
|
+
// "trade_turnover": "0",
|
|
1123
|
+
// "fee_currency": null,
|
|
1124
|
+
// "fee": "0",
|
|
1125
|
+
// "tp_trigger_price": "",
|
|
1126
|
+
// "tp_order_price": "",
|
|
1127
|
+
// "tp_type": "",
|
|
1128
|
+
// "tp_trigger_price_type": "",
|
|
1129
|
+
// "sl_trigger_price": "",
|
|
1130
|
+
// "sl_order_price": "",
|
|
1131
|
+
// "sl_type": "",
|
|
1132
|
+
// "sl_trigger_price_type": "",
|
|
1133
|
+
// "contract_type": "swap",
|
|
1134
|
+
// "cancel_reason": "",
|
|
1135
|
+
// "created_time": "1782367563239",
|
|
1136
|
+
// "updated_time": "1782367563239",
|
|
1137
|
+
// "self_match_prevent": "cancel_taker",
|
|
1138
|
+
// "amend_origin_volume": "",
|
|
1139
|
+
// "amend_source": "",
|
|
1140
|
+
// "amend_result": ""
|
|
1141
|
+
// }
|
|
1142
|
+
// }
|
|
1143
|
+
//
|
|
1053
1144
|
const messageHash = this.safeString2(message, 'ch', 'topic');
|
|
1054
1145
|
const data = this.safeValue(message, 'data');
|
|
1055
1146
|
let marketId = this.safeString(message, 'contract_code');
|
|
1056
1147
|
if (marketId === undefined) {
|
|
1057
|
-
marketId = this.
|
|
1148
|
+
marketId = this.safeString2(data, 'contract_code', 'symbol');
|
|
1058
1149
|
}
|
|
1059
1150
|
const market = this.safeMarket(marketId);
|
|
1060
1151
|
let parsedOrder = undefined;
|
|
@@ -1118,6 +1209,10 @@ export default class htx extends htxRest {
|
|
|
1118
1209
|
const cachedOrders = this.orders;
|
|
1119
1210
|
cachedOrders.append(parsedOrder);
|
|
1120
1211
|
client.resolve(this.orders, messageHash);
|
|
1212
|
+
if ((messageHash === 'orders') && (marketId !== undefined)) {
|
|
1213
|
+
const specificMessageHash = messageHash + '.' + marketId.toLowerCase();
|
|
1214
|
+
client.resolve(this.orders, specificMessageHash);
|
|
1215
|
+
}
|
|
1121
1216
|
// when we make a global subscription (for contracts only) our message hash can't have a symbol/currency attached
|
|
1122
1217
|
// so we're removing it here
|
|
1123
1218
|
let genericMessageHash = messageHash.replace('.' + market['lowercaseId'], '');
|
|
@@ -1239,22 +1334,64 @@ export default class htx extends htxRest {
|
|
|
1239
1334
|
// "real_profit": 0
|
|
1240
1335
|
// }
|
|
1241
1336
|
//
|
|
1242
|
-
|
|
1243
|
-
|
|
1337
|
+
// linear v5 watchOrders
|
|
1338
|
+
//
|
|
1339
|
+
// {
|
|
1340
|
+
// "side": "buy",
|
|
1341
|
+
// "type": "limit",
|
|
1342
|
+
// "price": "40000",
|
|
1343
|
+
// "volume": "1",
|
|
1344
|
+
// "state": "new",
|
|
1345
|
+
// "profit": "0",
|
|
1346
|
+
// "contract_code": "BTC-USDT",
|
|
1347
|
+
// "position_side": "both",
|
|
1348
|
+
// "price_match": null,
|
|
1349
|
+
// "order_id": "1519705236917489664",
|
|
1350
|
+
// "client_order_id": "1519705236917489664",
|
|
1351
|
+
// "margin_mode": "cross",
|
|
1352
|
+
// "lever_rate": 10,
|
|
1353
|
+
// "order_source": "api",
|
|
1354
|
+
// "reduce_only": false,
|
|
1355
|
+
// "time_in_force": "gtc",
|
|
1356
|
+
// "trade_avg_price": "0",
|
|
1357
|
+
// "trade_volume": "0",
|
|
1358
|
+
// "trade_turnover": "0",
|
|
1359
|
+
// "fee_currency": null,
|
|
1360
|
+
// "fee": "0",
|
|
1361
|
+
// "tp_trigger_price": "",
|
|
1362
|
+
// "tp_order_price": "",
|
|
1363
|
+
// "tp_type": "",
|
|
1364
|
+
// "tp_trigger_price_type": "",
|
|
1365
|
+
// "sl_trigger_price": "",
|
|
1366
|
+
// "sl_order_price": "",
|
|
1367
|
+
// "sl_type": "",
|
|
1368
|
+
// "sl_trigger_price_type": "",
|
|
1369
|
+
// "contract_type": "swap",
|
|
1370
|
+
// "cancel_reason": "",
|
|
1371
|
+
// "created_time": "1782367563239",
|
|
1372
|
+
// "updated_time": "1782367563239",
|
|
1373
|
+
// "self_match_prevent": "cancel_taker",
|
|
1374
|
+
// "amend_origin_volume": "",
|
|
1375
|
+
// "amend_source": "",
|
|
1376
|
+
// "amend_result": ""
|
|
1377
|
+
// }
|
|
1378
|
+
//
|
|
1379
|
+
const lastTradeTimestamp = this.safeIntegerN(order, ['lastActTime', 'updated_time', 'ts']);
|
|
1380
|
+
const created = this.safeInteger2(order, 'orderCreateTime', 'created_time');
|
|
1244
1381
|
const marketId = this.safeString2(order, 'contract_code', 'symbol');
|
|
1245
1382
|
market = this.safeMarket(marketId, market);
|
|
1246
1383
|
const symbol = this.safeSymbol(marketId, market);
|
|
1247
1384
|
const amount = this.safeString2(order, 'orderSize', 'volume');
|
|
1248
|
-
const status = this.parseOrderStatus(this.
|
|
1385
|
+
const status = this.parseOrderStatus(this.safeStringN(order, ['orderStatus', 'state', 'status']));
|
|
1249
1386
|
const id = this.safeString2(order, 'orderId', 'order_id');
|
|
1250
1387
|
const clientOrderId = this.safeString2(order, 'clientOrderId', 'client_order_id');
|
|
1251
1388
|
const price = this.safeString2(order, 'orderPrice', 'price');
|
|
1252
|
-
const filled = this.
|
|
1389
|
+
const filled = this.safeString2(order, 'execAmt', 'trade_volume');
|
|
1253
1390
|
const typeSide = this.safeString(order, 'type');
|
|
1254
1391
|
const feeCost = this.safeString(order, 'fee');
|
|
1255
1392
|
let fee = undefined;
|
|
1256
1393
|
if (feeCost !== undefined) {
|
|
1257
|
-
const feeCurrencyId = this.
|
|
1394
|
+
const feeCurrencyId = this.safeString2(order, 'fee_asset', 'fee_currency');
|
|
1258
1395
|
fee = {
|
|
1259
1396
|
'cost': feeCost,
|
|
1260
1397
|
'currency': this.safeCurrencyCode(feeCurrencyId),
|
|
@@ -1263,18 +1400,24 @@ export default class htx extends htxRest {
|
|
|
1263
1400
|
const avgPrice = this.safeString(order, 'trade_avg_price');
|
|
1264
1401
|
const rawTrades = this.safeValue(order, 'trade');
|
|
1265
1402
|
let typeSideParts = [];
|
|
1403
|
+
let type = undefined;
|
|
1266
1404
|
if (typeSide !== undefined) {
|
|
1267
|
-
|
|
1405
|
+
if (typeSide.indexOf('-') >= 0) {
|
|
1406
|
+
typeSideParts = typeSide.split('-');
|
|
1407
|
+
type = this.safeStringLower(typeSideParts, 1);
|
|
1408
|
+
}
|
|
1409
|
+
else {
|
|
1410
|
+
type = typeSide;
|
|
1411
|
+
}
|
|
1268
1412
|
}
|
|
1269
|
-
let type = this.safeStringLower(typeSideParts, 1);
|
|
1270
1413
|
if (type === undefined) {
|
|
1271
1414
|
type = this.safeString(order, 'order_price_type');
|
|
1272
1415
|
}
|
|
1273
1416
|
let side = this.safeStringLower(typeSideParts, 0);
|
|
1274
1417
|
if (side === undefined) {
|
|
1275
|
-
side = this.
|
|
1418
|
+
side = this.safeString2(order, 'direction', 'side');
|
|
1276
1419
|
}
|
|
1277
|
-
const cost = this.
|
|
1420
|
+
const cost = this.safeString2(order, 'orderValue', 'trade_turnover');
|
|
1278
1421
|
return this.safeOrder({
|
|
1279
1422
|
'info': order,
|
|
1280
1423
|
'id': id,
|
|
@@ -1285,7 +1428,7 @@ export default class htx extends htxRest {
|
|
|
1285
1428
|
'status': status,
|
|
1286
1429
|
'symbol': symbol,
|
|
1287
1430
|
'type': type,
|
|
1288
|
-
'timeInForce':
|
|
1431
|
+
'timeInForce': this.safeStringUpper(order, 'time_in_force'),
|
|
1289
1432
|
'postOnly': undefined,
|
|
1290
1433
|
'side': side,
|
|
1291
1434
|
'price': price,
|
|
@@ -1296,6 +1439,11 @@ export default class htx extends htxRest {
|
|
|
1296
1439
|
'fee': fee,
|
|
1297
1440
|
'average': avgPrice,
|
|
1298
1441
|
'trades': rawTrades,
|
|
1442
|
+
'reduceOnly': this.safeBool(order, 'reduce_only'),
|
|
1443
|
+
'stopPrice': undefined,
|
|
1444
|
+
'triggerPrice': undefined,
|
|
1445
|
+
'takeProfitPrice': this.safeString2(order, 'tp_trigger_price', 'tp_order_price'),
|
|
1446
|
+
'stopLossPrice': this.safeString2(order, 'sl_trigger_price', 'sl_order_price'),
|
|
1299
1447
|
}, market);
|
|
1300
1448
|
}
|
|
1301
1449
|
parseOrderTrade(trade, market = undefined) {
|
|
@@ -1357,11 +1505,10 @@ export default class htx extends htxRest {
|
|
|
1357
1505
|
/**
|
|
1358
1506
|
* @method
|
|
1359
1507
|
* @name htx#watchPositions
|
|
1360
|
-
* @
|
|
1361
|
-
* @see https://www.huobi.com/en-in/opend/newApiPages/?id=8cb7df0f-77b5-11ed-9966-0242ac110003
|
|
1508
|
+
* @description watch all open positions. Note: huobi has one channel for each marginMode and type
|
|
1362
1509
|
* @see https://www.huobi.com/en-in/opend/newApiPages/?id=28c34a7d-77ae-11ed-9966-0242ac110003
|
|
1363
1510
|
* @see https://www.huobi.com/en-in/opend/newApiPages/?id=5d5156b5-77b6-11ed-9966-0242ac110003
|
|
1364
|
-
* @
|
|
1511
|
+
* @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb89359-77b5-11ed-9966-195a35d6034
|
|
1365
1512
|
* @param {string[]} [symbols] list of unified market symbols
|
|
1366
1513
|
* @param {int} [since] timestamp in ms of the earliest position to fetch
|
|
1367
1514
|
* @param {int} [limit] the maximum number of positions to fetch
|
|
@@ -1392,11 +1539,26 @@ export default class htx extends htxRest {
|
|
|
1392
1539
|
symbols = this.marketSymbols(symbols);
|
|
1393
1540
|
let marginMode = undefined;
|
|
1394
1541
|
[marginMode, params] = this.handleMarginModeAndParams('watchPositions', params, 'cross');
|
|
1542
|
+
const linear = (subType === 'linear');
|
|
1543
|
+
const swap = (type === 'swap');
|
|
1544
|
+
const future = (type === 'future');
|
|
1545
|
+
const isV5Linear = (linear && (swap || future));
|
|
1395
1546
|
const isLinear = (subType === 'linear');
|
|
1396
|
-
const url = this.getUrlByMarketType(type, isLinear, true);
|
|
1547
|
+
const url = this.getUrlByMarketType(type, isLinear, true, false, isV5Linear);
|
|
1397
1548
|
messageHash = marginMode + ':positions' + messageHash;
|
|
1398
|
-
|
|
1399
|
-
|
|
1549
|
+
let channel = (marginMode === 'cross') ? 'positions_cross.*' : 'positions.*';
|
|
1550
|
+
if (isV5Linear) {
|
|
1551
|
+
const isOneMarket = (!this.isEmpty(symbols) && (symbols.length === 1));
|
|
1552
|
+
const v5Market = isOneMarket ? market : undefined;
|
|
1553
|
+
const channelAndMessageHashAndParams = this.getV5LinearChannelAndMessageHash('positions', v5Market, params);
|
|
1554
|
+
channel = this.safeString(channelAndMessageHashAndParams, 0);
|
|
1555
|
+
params = this.safeValue(channelAndMessageHashAndParams, 2, {});
|
|
1556
|
+
}
|
|
1557
|
+
const subscriptionParams = {
|
|
1558
|
+
'isV5': isV5Linear,
|
|
1559
|
+
'margin': marginMode,
|
|
1560
|
+
};
|
|
1561
|
+
const newPositions = await this.subscribePrivate(channel, messageHash, type, subType, params, subscriptionParams);
|
|
1400
1562
|
if (this.newUpdates) {
|
|
1401
1563
|
return newPositions;
|
|
1402
1564
|
}
|
|
@@ -1438,9 +1600,53 @@ export default class htx extends htxRest {
|
|
|
1438
1600
|
// ]
|
|
1439
1601
|
// }
|
|
1440
1602
|
//
|
|
1603
|
+
// watchPositions linear v5
|
|
1604
|
+
//
|
|
1605
|
+
// {
|
|
1606
|
+
// "op": "notify",
|
|
1607
|
+
// "topic": "positions",
|
|
1608
|
+
// "contract_code": "BTC-USDT",
|
|
1609
|
+
// "ts": 1782460576073,
|
|
1610
|
+
// "uid": "359305390",
|
|
1611
|
+
// "event": "snapshot",
|
|
1612
|
+
// "data": [
|
|
1613
|
+
// {
|
|
1614
|
+
// "contract_code": "BTC-USDT",
|
|
1615
|
+
// "symbol": "BTC",
|
|
1616
|
+
// "position_mode": "single_side",
|
|
1617
|
+
// "position_side": "both",
|
|
1618
|
+
// "direction": "buy",
|
|
1619
|
+
// "margin_mode": "cross",
|
|
1620
|
+
// "open_avg_price": "60547.9",
|
|
1621
|
+
// "volume": "1",
|
|
1622
|
+
// "available": "1",
|
|
1623
|
+
// "fee": "0.03632874",
|
|
1624
|
+
// "break_even_price": "60620.55748",
|
|
1625
|
+
// "total_trade_fee": "0.03632874",
|
|
1626
|
+
// "lever_rate": 10,
|
|
1627
|
+
// "adl_risk_percent": 4,
|
|
1628
|
+
// "liquidation_price": "-102094.847680676304309652",
|
|
1629
|
+
// "initial_margin": "6.05807",
|
|
1630
|
+
// "maintenance_margin": "0.20597438",
|
|
1631
|
+
// "profit_unreal": "0.0328",
|
|
1632
|
+
// "profit": "0",
|
|
1633
|
+
// "profit_rate": "0.0054",
|
|
1634
|
+
// "margin_rate": "0.0012",
|
|
1635
|
+
// "state": "normal",
|
|
1636
|
+
// "funding_fee": "0",
|
|
1637
|
+
// "mark_price": "60580.7",
|
|
1638
|
+
// "last_price": "60591.4",
|
|
1639
|
+
// "contract_type": "swap",
|
|
1640
|
+
// "version": 7,
|
|
1641
|
+
// "created_time": "1782460515119",
|
|
1642
|
+
// "updated_time": "1782460515119"
|
|
1643
|
+
// }
|
|
1644
|
+
// ]
|
|
1645
|
+
// }
|
|
1646
|
+
//
|
|
1441
1647
|
const url = client.url;
|
|
1442
1648
|
const topic = this.safeString(message, 'topic', '');
|
|
1443
|
-
const
|
|
1649
|
+
const defaultMarginMode = (topic === 'positions_cross') ? 'cross' : 'isolated';
|
|
1444
1650
|
if (this.positions === undefined) {
|
|
1445
1651
|
this.positions = {};
|
|
1446
1652
|
}
|
|
@@ -1448,43 +1654,64 @@ export default class htx extends htxRest {
|
|
|
1448
1654
|
if (clientPositions === undefined) {
|
|
1449
1655
|
this.positions[url] = {};
|
|
1450
1656
|
}
|
|
1451
|
-
const clientMarginModePositions = this.safeValue(clientPositions, marginMode);
|
|
1452
|
-
if (clientMarginModePositions === undefined) {
|
|
1453
|
-
this.positions[url][marginMode] = new ArrayCacheBySymbolBySide();
|
|
1454
|
-
}
|
|
1455
|
-
const cache = this.positions[url][marginMode];
|
|
1456
1657
|
const rawPositions = this.safeValue(message, 'data', []);
|
|
1658
|
+
if (this.isEmpty(rawPositions)) {
|
|
1659
|
+
const prefixes = ['cross:positions', 'isolated:positions'];
|
|
1660
|
+
for (let i = 0; i < prefixes.length; i++) {
|
|
1661
|
+
const messageHashes = this.findMessageHashes(client, prefixes[i]);
|
|
1662
|
+
for (let j = 0; j < messageHashes.length; j++) {
|
|
1663
|
+
client.resolve([], messageHashes[j]);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1457
1668
|
const newPositions = [];
|
|
1669
|
+
const positionsByMarginMode = {};
|
|
1458
1670
|
const timestamp = this.safeInteger(message, 'ts');
|
|
1459
1671
|
for (let i = 0; i < rawPositions.length; i++) {
|
|
1460
1672
|
const rawPosition = rawPositions[i];
|
|
1461
1673
|
const position = this.parsePosition(rawPosition);
|
|
1462
1674
|
position['timestamp'] = timestamp;
|
|
1463
1675
|
position['datetime'] = this.iso8601(timestamp);
|
|
1676
|
+
let marginMode = this.safeStringLower(position, 'marginMode', defaultMarginMode);
|
|
1677
|
+
if ((marginMode !== 'cross') && (marginMode !== 'isolated')) {
|
|
1678
|
+
marginMode = defaultMarginMode;
|
|
1679
|
+
}
|
|
1680
|
+
let cache = this.safeValue(this.positions[url], marginMode);
|
|
1681
|
+
if (cache === undefined) {
|
|
1682
|
+
cache = new ArrayCacheBySymbolBySide();
|
|
1683
|
+
this.positions[url][marginMode] = cache;
|
|
1684
|
+
}
|
|
1464
1685
|
newPositions.push(position);
|
|
1686
|
+
positionsByMarginMode[marginMode] = this.safeValue(positionsByMarginMode, marginMode, []);
|
|
1687
|
+
positionsByMarginMode[marginMode].push(position);
|
|
1465
1688
|
cache.append(position);
|
|
1466
1689
|
}
|
|
1467
|
-
const
|
|
1468
|
-
for (let i = 0; i <
|
|
1469
|
-
const
|
|
1470
|
-
const
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1690
|
+
const marginModes = Object.keys(positionsByMarginMode);
|
|
1691
|
+
for (let i = 0; i < marginModes.length; i++) {
|
|
1692
|
+
const marginMode = marginModes[i];
|
|
1693
|
+
const marginModePositions = this.safeValue(positionsByMarginMode, marginMode, []);
|
|
1694
|
+
const messageHashes = this.findMessageHashes(client, marginMode + ':positions::');
|
|
1695
|
+
for (let j = 0; j < messageHashes.length; j++) {
|
|
1696
|
+
const messageHash = messageHashes[j];
|
|
1697
|
+
const parts = messageHash.split('::');
|
|
1698
|
+
const symbolsString = parts[1];
|
|
1699
|
+
const symbols = symbolsString.split(',');
|
|
1700
|
+
const positions = this.filterByArray(marginModePositions, 'symbol', symbols, false);
|
|
1701
|
+
if (!this.isEmpty(positions)) {
|
|
1702
|
+
client.resolve(positions, messageHash);
|
|
1703
|
+
}
|
|
1476
1704
|
}
|
|
1705
|
+
client.resolve(marginModePositions, marginMode + ':positions');
|
|
1477
1706
|
}
|
|
1478
|
-
client.resolve(newPositions, marginMode + ':positions');
|
|
1479
1707
|
}
|
|
1480
1708
|
/**
|
|
1481
1709
|
* @method
|
|
1482
1710
|
* @name htx#watchBalance
|
|
1483
1711
|
* @description watch balance and get the amount of funds available for trading or funds locked in orders
|
|
1484
1712
|
* @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec52e28-7773-11ed-9966-0242ac110003
|
|
1485
|
-
* @see https://www.htx.com/en-us/opend/newApiPages/?id=10000084-77b7-11ed-9966-0242ac110003
|
|
1486
|
-
* @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb7dcca-77b5-11ed-9966-0242ac110003
|
|
1487
1713
|
* @see https://www.htx.com/en-us/opend/newApiPages/?id=28c34995-77ae-11ed-9966-0242ac110003
|
|
1714
|
+
* @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb89359-77b5-11ed-9966-195a6c94551
|
|
1488
1715
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1489
1716
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
|
|
1490
1717
|
*/
|
|
@@ -1499,12 +1726,22 @@ export default class htx extends htxRest {
|
|
|
1499
1726
|
let messageHash = undefined;
|
|
1500
1727
|
let channel = undefined;
|
|
1501
1728
|
let marginMode = undefined;
|
|
1729
|
+
const linear = (subType === 'linear');
|
|
1730
|
+
const swap = (type === 'swap');
|
|
1731
|
+
const future = (type === 'future');
|
|
1732
|
+
const isV5Linear = (linear && (swap || future));
|
|
1502
1733
|
if (type === 'spot') {
|
|
1503
1734
|
let mode = this.safeString2(this.options, 'watchBalance', 'mode', '2');
|
|
1504
1735
|
mode = this.safeString(params, 'mode', mode);
|
|
1505
1736
|
messageHash = 'accounts.update' + '#' + mode;
|
|
1506
1737
|
channel = messageHash;
|
|
1507
1738
|
}
|
|
1739
|
+
else if (isV5Linear) {
|
|
1740
|
+
marginMode = this.safeString(params, 'margin', 'cross');
|
|
1741
|
+
params = this.omit(params, ['currency', 'symbol', 'margin']);
|
|
1742
|
+
channel = 'account';
|
|
1743
|
+
messageHash = 'account';
|
|
1744
|
+
}
|
|
1508
1745
|
else {
|
|
1509
1746
|
const symbol = this.safeString(params, 'symbol');
|
|
1510
1747
|
const currency = this.safeString(params, 'currency');
|
|
@@ -1576,6 +1813,7 @@ export default class htx extends htxRest {
|
|
|
1576
1813
|
'type': type,
|
|
1577
1814
|
'subType': subType,
|
|
1578
1815
|
'margin': marginMode,
|
|
1816
|
+
'isV5': isV5Linear,
|
|
1579
1817
|
};
|
|
1580
1818
|
// we are differentiating the channel from the messageHash for global subscriptions (*)
|
|
1581
1819
|
// because huobi returns a different topic than the topic sent. Example: we send
|
|
@@ -1628,47 +1866,47 @@ export default class htx extends htxRest {
|
|
|
1628
1866
|
// "uid":"123456789"
|
|
1629
1867
|
// }
|
|
1630
1868
|
//
|
|
1631
|
-
//
|
|
1869
|
+
// watchBalance linear v5
|
|
1632
1870
|
//
|
|
1633
1871
|
// {
|
|
1634
|
-
// "op":"notify",
|
|
1635
|
-
// "topic":"
|
|
1636
|
-
// "
|
|
1637
|
-
// "
|
|
1638
|
-
// "
|
|
1639
|
-
//
|
|
1640
|
-
//
|
|
1641
|
-
//
|
|
1642
|
-
//
|
|
1643
|
-
//
|
|
1644
|
-
//
|
|
1645
|
-
//
|
|
1646
|
-
//
|
|
1647
|
-
//
|
|
1648
|
-
//
|
|
1649
|
-
//
|
|
1650
|
-
//
|
|
1651
|
-
//
|
|
1652
|
-
//
|
|
1653
|
-
//
|
|
1654
|
-
//
|
|
1655
|
-
//
|
|
1656
|
-
//
|
|
1657
|
-
//
|
|
1658
|
-
//
|
|
1659
|
-
//
|
|
1660
|
-
//
|
|
1661
|
-
//
|
|
1662
|
-
//
|
|
1663
|
-
//
|
|
1664
|
-
//
|
|
1665
|
-
//
|
|
1666
|
-
//
|
|
1667
|
-
//
|
|
1668
|
-
//
|
|
1669
|
-
//
|
|
1670
|
-
//
|
|
1671
|
-
//
|
|
1872
|
+
// "op": "notify",
|
|
1873
|
+
// "topic": "account",
|
|
1874
|
+
// "contract_code": "",
|
|
1875
|
+
// "ts": 1782459963509,
|
|
1876
|
+
// "uid": "359305390",
|
|
1877
|
+
// "event": "snapshot",
|
|
1878
|
+
// "data": {
|
|
1879
|
+
// "equity": "0",
|
|
1880
|
+
// "state": "normal",
|
|
1881
|
+
// "details": [
|
|
1882
|
+
// {
|
|
1883
|
+
// "currency": "USDT",
|
|
1884
|
+
// "equity": "162.331953938562004875",
|
|
1885
|
+
// "available": "162.331953938562004875",
|
|
1886
|
+
// "profit_unreal": "0",
|
|
1887
|
+
// "initial_margin": "0",
|
|
1888
|
+
// "maintenance_margin": "0",
|
|
1889
|
+
// "maintenance_margin_rate": "0",
|
|
1890
|
+
// "initial_margin_rate": "0",
|
|
1891
|
+
// "voucher": "0",
|
|
1892
|
+
// "voucher_value": "0",
|
|
1893
|
+
// "created_time": "1770293270932",
|
|
1894
|
+
// "updated_time": "1780329743956",
|
|
1895
|
+
// "isolated_equity": "0",
|
|
1896
|
+
// "isolated_profit_unreal": "0",
|
|
1897
|
+
// "withdraw_available": "162.331953938562004875"
|
|
1898
|
+
// }
|
|
1899
|
+
// ],
|
|
1900
|
+
// "initial_margin": "0",
|
|
1901
|
+
// "maintenance_margin": "0",
|
|
1902
|
+
// "maintenance_margin_rate": "0",
|
|
1903
|
+
// "profit_unreal": "0",
|
|
1904
|
+
// "available_margin": "0",
|
|
1905
|
+
// "created_time": "1770293268881",
|
|
1906
|
+
// "updated_time": "1780329743956",
|
|
1907
|
+
// "version": 5659,
|
|
1908
|
+
// "voucher_value": "0"
|
|
1909
|
+
// }
|
|
1672
1910
|
// }
|
|
1673
1911
|
//
|
|
1674
1912
|
// inverse future
|
|
@@ -1717,12 +1955,32 @@ export default class htx extends htxRest {
|
|
|
1717
1955
|
}
|
|
1718
1956
|
else {
|
|
1719
1957
|
// contract balance
|
|
1958
|
+
const topic = this.safeString(message, 'topic');
|
|
1959
|
+
if (topic === 'account') {
|
|
1960
|
+
const accountData = this.safeDict(message, 'data', {});
|
|
1961
|
+
const details = this.safeList(accountData, 'details', []);
|
|
1962
|
+
const detailsLength = details.length;
|
|
1963
|
+
for (let i = 0; i < detailsLength; i++) {
|
|
1964
|
+
const detail = details[i];
|
|
1965
|
+
const currencyId = this.safeString(detail, 'currency');
|
|
1966
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1967
|
+
if (code === undefined) {
|
|
1968
|
+
continue;
|
|
1969
|
+
}
|
|
1970
|
+
const account = this.account();
|
|
1971
|
+
account['free'] = this.safeString(detail, 'withdraw_available');
|
|
1972
|
+
account['total'] = this.safeString(detail, 'equity');
|
|
1973
|
+
this.balance[code] = account;
|
|
1974
|
+
}
|
|
1975
|
+
this.balance = this.safeBalance(this.balance);
|
|
1976
|
+
client.resolve(this.balance, 'account');
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1720
1979
|
const dataLength = data.length;
|
|
1721
1980
|
if (dataLength === 0) {
|
|
1722
1981
|
return;
|
|
1723
1982
|
}
|
|
1724
1983
|
const first = this.safeValue(data, 0, {});
|
|
1725
|
-
const topic = this.safeString(message, 'topic');
|
|
1726
1984
|
const splitTopic = topic.split('.');
|
|
1727
1985
|
let messageHash = this.safeString(splitTopic, 0);
|
|
1728
1986
|
let subscription = this.safeValue2(client.subscriptions, messageHash, messageHash + '.*');
|
|
@@ -2000,6 +2258,9 @@ export default class htx extends htxRest {
|
|
|
2000
2258
|
if (topic.indexOf('orders') >= 0) {
|
|
2001
2259
|
this.handleOrder(client, message);
|
|
2002
2260
|
}
|
|
2261
|
+
if (topic.indexOf('trade') >= 0) {
|
|
2262
|
+
this.handleMyTrade(client, message);
|
|
2263
|
+
}
|
|
2003
2264
|
if (topic.indexOf('account') >= 0) {
|
|
2004
2265
|
this.handleBalance(client, message);
|
|
2005
2266
|
}
|
|
@@ -2290,20 +2551,65 @@ export default class htx extends htxRest {
|
|
|
2290
2551
|
// ],
|
|
2291
2552
|
// }
|
|
2292
2553
|
//
|
|
2554
|
+
// linear v5 watchMyTrades
|
|
2555
|
+
//
|
|
2556
|
+
// {
|
|
2557
|
+
// "op": "notify",
|
|
2558
|
+
// "topic": "trade",
|
|
2559
|
+
// "contract_code": "BTC-USDT",
|
|
2560
|
+
// "ts": 1782367694387,
|
|
2561
|
+
// "uid": "359305390",
|
|
2562
|
+
// "data": [
|
|
2563
|
+
// {
|
|
2564
|
+
// "direction": "buy",
|
|
2565
|
+
// "id": "100121555172810-1519705786942156810-1",
|
|
2566
|
+
// "contract_code": "BTC-USDT",
|
|
2567
|
+
// "contract_type": "swap",
|
|
2568
|
+
// "order_id": "1519705786942156810",
|
|
2569
|
+
// "trade_id": "155233460",
|
|
2570
|
+
// "position_side": "both",
|
|
2571
|
+
// "trade_volume": "1",
|
|
2572
|
+
// "trade_price": "61629",
|
|
2573
|
+
// "trade_turnover": "61.629",
|
|
2574
|
+
// "role": "taker",
|
|
2575
|
+
// "client_order_id": "1519705786942156810",
|
|
2576
|
+
// "created_time": "1782367694375",
|
|
2577
|
+
// "updated_time": "1782367694385"
|
|
2578
|
+
// }
|
|
2579
|
+
// ]
|
|
2580
|
+
// }
|
|
2581
|
+
//
|
|
2293
2582
|
if (this.myTrades === undefined) {
|
|
2294
2583
|
const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
2295
2584
|
this.myTrades = new ArrayCacheBySymbolById(limit);
|
|
2296
2585
|
}
|
|
2297
2586
|
const cachedTrades = this.myTrades;
|
|
2298
|
-
const messageHash = this.
|
|
2587
|
+
const messageHash = this.safeString2(message, 'ch', 'topic');
|
|
2299
2588
|
if (messageHash !== undefined) {
|
|
2300
2589
|
const data = this.safeValue(message, 'data');
|
|
2301
2590
|
if (data !== undefined) {
|
|
2302
|
-
const
|
|
2303
|
-
const
|
|
2304
|
-
if (
|
|
2305
|
-
|
|
2306
|
-
|
|
2591
|
+
const contractCode = this.safeString(message, 'contract_code');
|
|
2592
|
+
const market = (contractCode !== undefined) ? this.safeMarket(contractCode) : undefined;
|
|
2593
|
+
if (Array.isArray(data)) {
|
|
2594
|
+
for (let i = 0; i < data.length; i++) {
|
|
2595
|
+
const parsed = this.parseWsTrade(data[i], market);
|
|
2596
|
+
const symbol = this.safeString(parsed, 'symbol');
|
|
2597
|
+
if (symbol !== undefined) {
|
|
2598
|
+
cachedTrades.append(parsed);
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
else {
|
|
2603
|
+
const parsed = this.parseWsTrade(data, market);
|
|
2604
|
+
const symbol = this.safeString(parsed, 'symbol');
|
|
2605
|
+
if (symbol !== undefined) {
|
|
2606
|
+
cachedTrades.append(parsed);
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
client.resolve(this.myTrades, messageHash);
|
|
2610
|
+
if ((messageHash === 'trade') && (contractCode !== undefined)) {
|
|
2611
|
+
const specificMessageHash = messageHash + '.' + contractCode.toLowerCase();
|
|
2612
|
+
client.resolve(this.myTrades, specificMessageHash);
|
|
2307
2613
|
}
|
|
2308
2614
|
}
|
|
2309
2615
|
else {
|
|
@@ -2361,31 +2667,54 @@ export default class htx extends htxRest {
|
|
|
2361
2667
|
// "feeDeductType":""
|
|
2362
2668
|
// }
|
|
2363
2669
|
//
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2670
|
+
// linear v5 watchMyTrades
|
|
2671
|
+
//
|
|
2672
|
+
// {
|
|
2673
|
+
// "direction": "buy",
|
|
2674
|
+
// "id": "100121555172810-1519705786942156810-1",
|
|
2675
|
+
// "contract_code": "BTC-USDT",
|
|
2676
|
+
// "contract_type": "swap",
|
|
2677
|
+
// "order_id": "1519705786942156810",
|
|
2678
|
+
// "trade_id": "155233460",
|
|
2679
|
+
// "position_side": "both",
|
|
2680
|
+
// "trade_volume": "1",
|
|
2681
|
+
// "trade_price": "61629",
|
|
2682
|
+
// "trade_turnover": "61.629",
|
|
2683
|
+
// "role": "taker",
|
|
2684
|
+
// "client_order_id": "1519705786942156810",
|
|
2685
|
+
// "created_time": "1782367694375",
|
|
2686
|
+
// "updated_time": "1782367694385"
|
|
2687
|
+
// }
|
|
2688
|
+
//
|
|
2689
|
+
const marketId = this.safeString2(trade, 'symbol', 'contract_code');
|
|
2690
|
+
market = this.safeMarket(marketId, market);
|
|
2691
|
+
const symbol = this.safeString(market, 'symbol');
|
|
2692
|
+
const side = this.safeStringN(trade, ['side', 'orderSide', 'direction']);
|
|
2693
|
+
const tradeId = this.safeStringN(trade, ['tradeId', 'trade_id', 'id']);
|
|
2694
|
+
const price = this.safeString2(trade, 'tradePrice', 'trade_price');
|
|
2695
|
+
const amount = this.safeString2(trade, 'tradeVolume', 'trade_volume');
|
|
2696
|
+
const order = this.safeString2(trade, 'orderId', 'order_id');
|
|
2697
|
+
const timestamp = this.safeIntegerN(trade, ['tradeTime', 'updated_time', 'created_time']);
|
|
2698
|
+
const orderType = this.safeString2(trade, 'orderType', 'type');
|
|
2373
2699
|
const aggressor = this.safeValue(trade, 'aggressor');
|
|
2374
2700
|
let takerOrMaker = undefined;
|
|
2375
2701
|
if (aggressor !== undefined) {
|
|
2376
2702
|
takerOrMaker = aggressor ? 'taker' : 'maker';
|
|
2377
2703
|
}
|
|
2704
|
+
else {
|
|
2705
|
+
takerOrMaker = this.safeStringLower(trade, 'role');
|
|
2706
|
+
}
|
|
2378
2707
|
let type = undefined;
|
|
2379
2708
|
let orderTypeParts = [];
|
|
2380
2709
|
if (orderType !== undefined) {
|
|
2381
2710
|
orderTypeParts = orderType.split('-');
|
|
2382
|
-
type = this.safeString(orderTypeParts, 1);
|
|
2711
|
+
type = this.safeString(orderTypeParts, 1, orderType);
|
|
2383
2712
|
}
|
|
2384
2713
|
let fee = undefined;
|
|
2385
|
-
const feeCurrency = this.safeCurrencyCode(this.
|
|
2714
|
+
const feeCurrency = this.safeCurrencyCode(this.safeStringN(trade, ['feeCurrency', 'fee_currency', 'fee_asset']));
|
|
2386
2715
|
if (feeCurrency !== undefined) {
|
|
2387
2716
|
fee = {
|
|
2388
|
-
'cost': this.
|
|
2717
|
+
'cost': this.safeStringN(trade, ['transactFee', 'fee', 'trade_fee']),
|
|
2389
2718
|
'currency': feeCurrency,
|
|
2390
2719
|
};
|
|
2391
2720
|
}
|
|
@@ -2405,7 +2734,7 @@ export default class htx extends htxRest {
|
|
|
2405
2734
|
'fee': fee,
|
|
2406
2735
|
}, market);
|
|
2407
2736
|
}
|
|
2408
|
-
getUrlByMarketType(type, isLinear = true, isPrivate = false, isFeed = false) {
|
|
2737
|
+
getUrlByMarketType(type, isLinear = true, isPrivate = false, isFeed = false, isV5 = false) {
|
|
2409
2738
|
const api = this.safeString(this.options, 'api', 'api');
|
|
2410
2739
|
const hostname = { 'hostname': this.hostname };
|
|
2411
2740
|
let hostnameURL = undefined;
|
|
@@ -2427,7 +2756,17 @@ export default class htx extends htxRest {
|
|
|
2427
2756
|
else {
|
|
2428
2757
|
const baseUrl = this.urls['api']['ws'][api][type];
|
|
2429
2758
|
const subTypeUrl = isLinear ? baseUrl['linear'] : baseUrl['inverse'];
|
|
2430
|
-
|
|
2759
|
+
if (isPrivate) {
|
|
2760
|
+
if (isV5 && isLinear) {
|
|
2761
|
+
url = this.safeString(subTypeUrl, 'privateV5', subTypeUrl['private']);
|
|
2762
|
+
}
|
|
2763
|
+
else {
|
|
2764
|
+
url = subTypeUrl['private'];
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
else {
|
|
2768
|
+
url = subTypeUrl['public'];
|
|
2769
|
+
}
|
|
2431
2770
|
}
|
|
2432
2771
|
return url;
|
|
2433
2772
|
}
|
|
@@ -2495,7 +2834,8 @@ export default class htx extends htxRest {
|
|
|
2495
2834
|
};
|
|
2496
2835
|
}
|
|
2497
2836
|
const isLinear = subtype === 'linear';
|
|
2498
|
-
const
|
|
2837
|
+
const isV5 = this.safeBool(subscriptionParams, 'isV5', false);
|
|
2838
|
+
const url = this.getUrlByMarketType(type, isLinear, true, false, isV5);
|
|
2499
2839
|
const hostname = (type === 'spot') ? this.urls['hostnames']['spot'] : this.urls['hostnames']['contract'];
|
|
2500
2840
|
const authParams = {
|
|
2501
2841
|
'type': type,
|