ccxt 4.1.89 → 4.1.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.js +936 -358
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +2 -2
- package/dist/cjs/src/binance.js +61 -0
- package/dist/cjs/src/bitforex.js +2 -0
- package/dist/cjs/src/bitget.js +11 -4
- package/dist/cjs/src/bitmex.js +2 -0
- package/dist/cjs/src/blockchaincom.js +0 -41
- package/dist/cjs/src/bybit.js +29 -14
- package/dist/cjs/src/coinlist.js +2 -0
- package/dist/cjs/src/coinsph.js +2 -0
- package/dist/cjs/src/cryptocom.js +2 -0
- package/dist/cjs/src/gate.js +276 -11
- package/dist/cjs/src/htx.js +264 -219
- package/dist/cjs/src/kucoin.js +1 -0
- package/dist/cjs/src/kucoinfutures.js +37 -0
- package/dist/cjs/src/kuna.js +2 -0
- package/dist/cjs/src/mexc.js +2 -0
- package/dist/cjs/src/okcoin.js +4 -1
- package/dist/cjs/src/phemex.js +160 -26
- package/dist/cjs/src/poloniex.js +28 -2
- package/dist/cjs/src/pro/binance.js +6 -6
- package/dist/cjs/src/pro/bitmart.js +19 -18
- package/dist/cjs/src/pro/poloniex.js +15 -10
- package/dist/cjs/src/tokocrypto.js +2 -0
- package/dist/cjs/src/wazirx.js +2 -0
- package/dist/cjs/src/whitebit.js +2 -0
- package/dist/cjs/src/zaif.js +2 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.js +2 -2
- package/js/src/binance.d.ts +3 -0
- package/js/src/binance.js +61 -0
- package/js/src/bitforex.js +2 -0
- package/js/src/bitget.js +11 -4
- package/js/src/bitmex.js +2 -0
- package/js/src/blockchaincom.d.ts +0 -2
- package/js/src/blockchaincom.js +0 -41
- package/js/src/bybit.js +29 -14
- package/js/src/coinlist.js +2 -0
- package/js/src/coinsph.js +2 -0
- package/js/src/cryptocom.js +2 -0
- package/js/src/gate.d.ts +47 -0
- package/js/src/gate.js +276 -11
- package/js/src/htx.js +264 -219
- package/js/src/kucoin.js +1 -0
- package/js/src/kucoinfutures.d.ts +1 -0
- package/js/src/kucoinfutures.js +37 -0
- package/js/src/kuna.js +2 -0
- package/js/src/mexc.js +2 -0
- package/js/src/okcoin.js +4 -1
- package/js/src/phemex.d.ts +1 -0
- package/js/src/phemex.js +160 -26
- package/js/src/poloniex.js +28 -2
- package/js/src/pro/binance.js +6 -6
- package/js/src/pro/bitmart.d.ts +1 -1
- package/js/src/pro/bitmart.js +19 -18
- package/js/src/pro/poloniex.js +16 -11
- package/js/src/tokocrypto.js +2 -0
- package/js/src/wazirx.js +2 -0
- package/js/src/whitebit.js +2 -0
- package/js/src/zaif.js +2 -3
- package/package.json +1 -1
package/js/src/htx.js
CHANGED
|
@@ -1227,30 +1227,32 @@ export default class htx extends Exchange {
|
|
|
1227
1227
|
await this.loadMarkets();
|
|
1228
1228
|
let marketType = undefined;
|
|
1229
1229
|
[marketType, params] = this.handleMarketTypeAndParams('fetchMyTrades', undefined, params);
|
|
1230
|
-
let
|
|
1230
|
+
let response = undefined;
|
|
1231
1231
|
if (marketType !== 'spot') {
|
|
1232
1232
|
const subType = this.safeString(params, 'subType', this.options['defaultSubType']);
|
|
1233
1233
|
if (marketType === 'swap') {
|
|
1234
1234
|
if (subType === 'linear') {
|
|
1235
|
-
|
|
1235
|
+
response = await this.statusPublicSwapLinearGetApiV2SummaryJson();
|
|
1236
1236
|
}
|
|
1237
1237
|
else if (subType === 'inverse') {
|
|
1238
|
-
|
|
1238
|
+
response = await this.statusPublicSwapInverseGetApiV2SummaryJson();
|
|
1239
1239
|
}
|
|
1240
1240
|
}
|
|
1241
1241
|
else if (marketType === 'future') {
|
|
1242
1242
|
if (subType === 'linear') {
|
|
1243
|
-
|
|
1243
|
+
response = await this.statusPublicFutureLinearGetApiV2SummaryJson();
|
|
1244
1244
|
}
|
|
1245
1245
|
else if (subType === 'inverse') {
|
|
1246
|
-
|
|
1246
|
+
response = await this.statusPublicFutureInverseGetApiV2SummaryJson();
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
1249
|
else if (marketType === 'contract') {
|
|
1250
|
-
|
|
1250
|
+
response = await this.contractPublicGetHeartbeat();
|
|
1251
1251
|
}
|
|
1252
1252
|
}
|
|
1253
|
-
|
|
1253
|
+
else {
|
|
1254
|
+
response = await this.statusPublicSpotGetApiV2SummaryJson();
|
|
1255
|
+
}
|
|
1254
1256
|
//
|
|
1255
1257
|
// statusPublicSpotGetApiV2SummaryJson, statusPublicSwapInverseGetApiV2SummaryJson, statusPublicFutureLinearGetApiV2SummaryJson, statusPublicFutureInverseGetApiV2SummaryJson
|
|
1256
1258
|
//
|
|
@@ -1415,7 +1417,7 @@ export default class htx extends Exchange {
|
|
|
1415
1417
|
let status = undefined;
|
|
1416
1418
|
let updated = undefined;
|
|
1417
1419
|
let url = undefined;
|
|
1418
|
-
if (
|
|
1420
|
+
if (marketType === 'contract') {
|
|
1419
1421
|
const statusRaw = this.safeString(response, 'status');
|
|
1420
1422
|
status = (statusRaw === 'ok') ? 'ok' : 'maintenance'; // 'ok', 'error'
|
|
1421
1423
|
updated = this.safeString(response, 'ts');
|
|
@@ -1449,11 +1451,13 @@ export default class htx extends Exchange {
|
|
|
1449
1451
|
const defaultType = this.safeString(this.options, 'defaultType', 'spot');
|
|
1450
1452
|
let type = this.safeString(options, 'type', defaultType);
|
|
1451
1453
|
type = this.safeString(params, 'type', type);
|
|
1452
|
-
let
|
|
1454
|
+
let response = undefined;
|
|
1453
1455
|
if ((type === 'future') || (type === 'swap')) {
|
|
1454
|
-
|
|
1456
|
+
response = await this.contractPublicGetApiV1Timestamp(params);
|
|
1457
|
+
}
|
|
1458
|
+
else {
|
|
1459
|
+
response = await this.spotPublicGetV1CommonTimestamp(params);
|
|
1455
1460
|
}
|
|
1456
|
-
const response = await this[method](params);
|
|
1457
1461
|
//
|
|
1458
1462
|
// spot
|
|
1459
1463
|
//
|
|
@@ -1621,7 +1625,6 @@ export default class htx extends Exchange {
|
|
|
1621
1625
|
return allMarkets;
|
|
1622
1626
|
}
|
|
1623
1627
|
async fetchMarketsByTypeAndSubType(type, subType, params = {}) {
|
|
1624
|
-
let method = 'spotPublicGetV1CommonSymbols';
|
|
1625
1628
|
const query = this.omit(params, ['type', 'subType']);
|
|
1626
1629
|
const spot = (type === 'spot');
|
|
1627
1630
|
const contract = (type !== 'spot');
|
|
@@ -1630,25 +1633,28 @@ export default class htx extends Exchange {
|
|
|
1630
1633
|
let linear = undefined;
|
|
1631
1634
|
let inverse = undefined;
|
|
1632
1635
|
const request = {};
|
|
1636
|
+
let response = undefined;
|
|
1633
1637
|
if (contract) {
|
|
1634
1638
|
linear = (subType === 'linear');
|
|
1635
1639
|
inverse = (subType === 'inverse');
|
|
1636
1640
|
if (linear) {
|
|
1637
|
-
method = 'contractPublicGetLinearSwapApiV1SwapContractInfo';
|
|
1638
1641
|
if (future) {
|
|
1639
1642
|
request['business_type'] = 'futures';
|
|
1640
1643
|
}
|
|
1644
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapContractInfo(this.extend(request, query));
|
|
1641
1645
|
}
|
|
1642
1646
|
else if (inverse) {
|
|
1643
1647
|
if (future) {
|
|
1644
|
-
|
|
1648
|
+
response = await this.contractPublicGetApiV1ContractContractInfo(this.extend(request, query));
|
|
1645
1649
|
}
|
|
1646
1650
|
else if (swap) {
|
|
1647
|
-
|
|
1651
|
+
response = await this.contractPublicGetSwapApiV1SwapContractInfo(this.extend(request, query));
|
|
1648
1652
|
}
|
|
1649
1653
|
}
|
|
1650
1654
|
}
|
|
1651
|
-
|
|
1655
|
+
else {
|
|
1656
|
+
response = await this.spotPublicGetV1CommonSymbols(this.extend(request, query));
|
|
1657
|
+
}
|
|
1652
1658
|
//
|
|
1653
1659
|
// spot
|
|
1654
1660
|
//
|
|
@@ -2035,23 +2041,25 @@ export default class htx extends Exchange {
|
|
|
2035
2041
|
await this.loadMarkets();
|
|
2036
2042
|
const market = this.market(symbol);
|
|
2037
2043
|
const request = {};
|
|
2038
|
-
let
|
|
2039
|
-
let method = 'spotPublicGetMarketDetailMerged';
|
|
2044
|
+
let response = undefined;
|
|
2040
2045
|
if (market['linear']) {
|
|
2041
|
-
|
|
2042
|
-
|
|
2046
|
+
request['contract_code'] = market['id'];
|
|
2047
|
+
response = await this.contractPublicGetLinearSwapExMarketDetailMerged(this.extend(request, params));
|
|
2043
2048
|
}
|
|
2044
2049
|
else if (market['inverse']) {
|
|
2045
2050
|
if (market['future']) {
|
|
2046
|
-
|
|
2051
|
+
request['symbol'] = market['id'];
|
|
2052
|
+
response = await this.contractPublicGetMarketDetailMerged(this.extend(request, params));
|
|
2047
2053
|
}
|
|
2048
2054
|
else if (market['swap']) {
|
|
2049
|
-
|
|
2050
|
-
|
|
2055
|
+
request['contract_code'] = market['id'];
|
|
2056
|
+
response = await this.contractPublicGetSwapExMarketDetailMerged(this.extend(request, params));
|
|
2051
2057
|
}
|
|
2052
2058
|
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2059
|
+
else {
|
|
2060
|
+
request['symbol'] = market['id'];
|
|
2061
|
+
response = await this.spotPublicGetMarketDetailMerged(this.extend(request, params));
|
|
2062
|
+
}
|
|
2055
2063
|
//
|
|
2056
2064
|
// spot
|
|
2057
2065
|
//
|
|
@@ -2124,7 +2132,6 @@ export default class htx extends Exchange {
|
|
|
2124
2132
|
}
|
|
2125
2133
|
let type = undefined;
|
|
2126
2134
|
let subType = undefined;
|
|
2127
|
-
let method = 'spotPublicGetMarketTickers';
|
|
2128
2135
|
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
2129
2136
|
[subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
|
|
2130
2137
|
const request = {};
|
|
@@ -2132,24 +2139,27 @@ export default class htx extends Exchange {
|
|
|
2132
2139
|
const swap = (type === 'swap');
|
|
2133
2140
|
const linear = (subType === 'linear');
|
|
2134
2141
|
const inverse = (subType === 'inverse');
|
|
2142
|
+
params = this.omit(params, ['type', 'subType']);
|
|
2143
|
+
let response = undefined;
|
|
2135
2144
|
if (future || swap) {
|
|
2136
2145
|
if (linear) {
|
|
2137
|
-
method = 'contractPublicGetLinearSwapExMarketDetailBatchMerged';
|
|
2138
2146
|
if (future) {
|
|
2139
2147
|
request['business_type'] = 'futures';
|
|
2140
2148
|
}
|
|
2149
|
+
response = await this.contractPublicGetLinearSwapExMarketDetailBatchMerged(this.extend(request, params));
|
|
2141
2150
|
}
|
|
2142
2151
|
else if (inverse) {
|
|
2143
2152
|
if (future) {
|
|
2144
|
-
|
|
2153
|
+
response = await this.contractPublicGetMarketDetailBatchMerged(this.extend(request, params));
|
|
2145
2154
|
}
|
|
2146
2155
|
else if (swap) {
|
|
2147
|
-
|
|
2156
|
+
response = await this.contractPublicGetSwapExMarketDetailBatchMerged(this.extend(request, params));
|
|
2148
2157
|
}
|
|
2149
2158
|
}
|
|
2150
2159
|
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2160
|
+
else {
|
|
2161
|
+
response = await this.spotPublicGetMarketTickers(this.extend(request, params));
|
|
2162
|
+
}
|
|
2153
2163
|
//
|
|
2154
2164
|
// spot
|
|
2155
2165
|
//
|
|
@@ -2282,19 +2292,19 @@ export default class htx extends Exchange {
|
|
|
2282
2292
|
// 'symbol': market['id'], // spot, future
|
|
2283
2293
|
// 'contract_code': market['id'], // swap
|
|
2284
2294
|
};
|
|
2285
|
-
let
|
|
2286
|
-
let method = 'spotPublicGetMarketDepth';
|
|
2295
|
+
let response = undefined;
|
|
2287
2296
|
if (market['linear']) {
|
|
2288
|
-
|
|
2289
|
-
|
|
2297
|
+
request['contract_code'] = market['id'];
|
|
2298
|
+
response = await this.contractPublicGetLinearSwapExMarketDepth(this.extend(request, params));
|
|
2290
2299
|
}
|
|
2291
2300
|
else if (market['inverse']) {
|
|
2292
2301
|
if (market['future']) {
|
|
2293
|
-
|
|
2302
|
+
request['symbol'] = market['id'];
|
|
2303
|
+
response = await this.contractPublicGetMarketDepth(this.extend(request, params));
|
|
2294
2304
|
}
|
|
2295
2305
|
else if (market['swap']) {
|
|
2296
|
-
|
|
2297
|
-
|
|
2306
|
+
request['contract_code'] = market['id'];
|
|
2307
|
+
response = await this.contractPublicGetSwapExMarketDepth(this.extend(request, params));
|
|
2298
2308
|
}
|
|
2299
2309
|
}
|
|
2300
2310
|
else {
|
|
@@ -2310,9 +2320,9 @@ export default class htx extends Exchange {
|
|
|
2310
2320
|
request['depth'] = limit;
|
|
2311
2321
|
}
|
|
2312
2322
|
}
|
|
2323
|
+
request['symbol'] = market['id'];
|
|
2324
|
+
response = await this.spotPublicGetMarketDepth(this.extend(request, params));
|
|
2313
2325
|
}
|
|
2314
|
-
request[fieldName] = market['id'];
|
|
2315
|
-
const response = await this[method](this.extend(request, params));
|
|
2316
2326
|
//
|
|
2317
2327
|
// spot, future, swap
|
|
2318
2328
|
//
|
|
@@ -2563,7 +2573,7 @@ export default class htx extends Exchange {
|
|
|
2563
2573
|
// 'direct': 'prev', // next, prev
|
|
2564
2574
|
// 'size': limit, // default 20, max 50
|
|
2565
2575
|
};
|
|
2566
|
-
let
|
|
2576
|
+
let response = undefined;
|
|
2567
2577
|
if (marketType === 'spot') {
|
|
2568
2578
|
if (symbol !== undefined) {
|
|
2569
2579
|
market = this.market(symbol);
|
|
@@ -2577,7 +2587,7 @@ export default class htx extends Exchange {
|
|
|
2577
2587
|
// request['end-time'] = this.sum (since, 172800000); // 48 hours window
|
|
2578
2588
|
}
|
|
2579
2589
|
[request, params] = this.handleUntilOption('end-time', request, params);
|
|
2580
|
-
|
|
2590
|
+
response = await this.spotPrivateGetV1OrderMatchresults(this.extend(request, params));
|
|
2581
2591
|
}
|
|
2582
2592
|
else {
|
|
2583
2593
|
if (symbol === undefined) {
|
|
@@ -2598,26 +2608,25 @@ export default class htx extends Exchange {
|
|
|
2598
2608
|
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
2599
2609
|
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
2600
2610
|
if (marginMode === 'isolated') {
|
|
2601
|
-
|
|
2611
|
+
response = await this.contractPrivatePostLinearSwapApiV3SwapMatchresultsExact(this.extend(request, params));
|
|
2602
2612
|
}
|
|
2603
2613
|
else if (marginMode === 'cross') {
|
|
2604
|
-
|
|
2614
|
+
response = await this.contractPrivatePostLinearSwapApiV3SwapCrossMatchresultsExact(this.extend(request, params));
|
|
2605
2615
|
}
|
|
2606
2616
|
}
|
|
2607
2617
|
else if (market['inverse']) {
|
|
2608
2618
|
if (marketType === 'future') {
|
|
2609
|
-
method = 'contractPrivatePostApiV3ContractMatchresultsExact';
|
|
2610
2619
|
request['symbol'] = market['settleId'];
|
|
2620
|
+
response = await this.contractPrivatePostApiV3ContractMatchresultsExact(this.extend(request, params));
|
|
2611
2621
|
}
|
|
2612
2622
|
else if (marketType === 'swap') {
|
|
2613
|
-
|
|
2623
|
+
response = await this.contractPrivatePostSwapApiV3SwapMatchresultsExact(this.extend(request, params));
|
|
2614
2624
|
}
|
|
2615
2625
|
else {
|
|
2616
2626
|
throw new NotSupported(this.id + ' fetchMyTrades() does not support ' + marketType + ' markets');
|
|
2617
2627
|
}
|
|
2618
2628
|
}
|
|
2619
2629
|
}
|
|
2620
|
-
const response = await this[method](this.extend(request, params));
|
|
2621
2630
|
//
|
|
2622
2631
|
// spot
|
|
2623
2632
|
//
|
|
@@ -2711,31 +2720,33 @@ export default class htx extends Exchange {
|
|
|
2711
2720
|
// 'symbol': market['id'], // spot, future
|
|
2712
2721
|
// 'contract_code': market['id'], // swap
|
|
2713
2722
|
};
|
|
2714
|
-
|
|
2715
|
-
|
|
2723
|
+
if (limit !== undefined) {
|
|
2724
|
+
request['size'] = Math.min(limit, 2000); // max 2000
|
|
2725
|
+
}
|
|
2726
|
+
let response = undefined;
|
|
2716
2727
|
if (market['future']) {
|
|
2717
2728
|
if (market['inverse']) {
|
|
2718
|
-
|
|
2729
|
+
request['symbol'] = market['id'];
|
|
2730
|
+
response = await this.contractPublicGetMarketHistoryTrade(this.extend(request, params));
|
|
2719
2731
|
}
|
|
2720
2732
|
else if (market['linear']) {
|
|
2721
|
-
|
|
2722
|
-
|
|
2733
|
+
request['contract_code'] = market['id'];
|
|
2734
|
+
response = await this.contractPublicGetLinearSwapExMarketHistoryTrade(this.extend(request, params));
|
|
2723
2735
|
}
|
|
2724
2736
|
}
|
|
2725
2737
|
else if (market['swap']) {
|
|
2738
|
+
request['contract_code'] = market['id'];
|
|
2726
2739
|
if (market['inverse']) {
|
|
2727
|
-
|
|
2740
|
+
response = await this.contractPublicGetSwapExMarketHistoryTrade(this.extend(request, params));
|
|
2728
2741
|
}
|
|
2729
2742
|
else if (market['linear']) {
|
|
2730
|
-
|
|
2743
|
+
response = await this.contractPublicGetLinearSwapExMarketHistoryTrade(this.extend(request, params));
|
|
2731
2744
|
}
|
|
2732
|
-
fieldName = 'contract_code';
|
|
2733
2745
|
}
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2746
|
+
else {
|
|
2747
|
+
request['symbol'] = market['id'];
|
|
2748
|
+
response = await this.spotPublicGetMarketHistoryTrade(this.extend(request, params));
|
|
2737
2749
|
}
|
|
2738
|
-
const response = await this[method](this.extend(request, params));
|
|
2739
2750
|
//
|
|
2740
2751
|
// {
|
|
2741
2752
|
// "status": "ok",
|
|
@@ -2826,109 +2837,111 @@ export default class htx extends Exchange {
|
|
|
2826
2837
|
// 'from': parseInt ((since / 1000).toString ()), spot only
|
|
2827
2838
|
// 'to': this.seconds (), spot only
|
|
2828
2839
|
};
|
|
2829
|
-
let fieldName = 'symbol';
|
|
2830
2840
|
const price = this.safeString(params, 'price');
|
|
2831
2841
|
params = this.omit(params, 'price');
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
//
|
|
2836
|
-
// https://github.com/ccxt/ccxt/issues/18006
|
|
2837
|
-
method = 'spotPublicGetMarketHistoryKline';
|
|
2842
|
+
if (market['contract']) {
|
|
2843
|
+
if (limit !== undefined) {
|
|
2844
|
+
request['size'] = limit; // when using limit from and to are ignored
|
|
2845
|
+
// https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
|
|
2838
2846
|
}
|
|
2839
|
-
|
|
2840
|
-
|
|
2847
|
+
else {
|
|
2848
|
+
limit = 2000; // only used for from/to calculation
|
|
2841
2849
|
}
|
|
2842
|
-
if (
|
|
2843
|
-
|
|
2850
|
+
if (price === undefined) {
|
|
2851
|
+
const duration = this.parseTimeframe(timeframe);
|
|
2852
|
+
if (since === undefined) {
|
|
2853
|
+
const now = this.seconds();
|
|
2854
|
+
request['from'] = now - duration * (limit - 1);
|
|
2855
|
+
request['to'] = now;
|
|
2856
|
+
}
|
|
2857
|
+
else {
|
|
2858
|
+
const start = this.parseToInt(since / 1000);
|
|
2859
|
+
request['from'] = start;
|
|
2860
|
+
request['to'] = this.sum(start, duration * (limit - 1));
|
|
2861
|
+
}
|
|
2844
2862
|
}
|
|
2845
2863
|
}
|
|
2846
|
-
|
|
2864
|
+
let response = undefined;
|
|
2865
|
+
if (market['future']) {
|
|
2847
2866
|
if (market['inverse']) {
|
|
2867
|
+
request['symbol'] = market['id'];
|
|
2848
2868
|
if (price === 'mark') {
|
|
2849
|
-
|
|
2869
|
+
response = await this.contractPublicGetIndexMarketHistoryMarkPriceKline(this.extend(request, params));
|
|
2850
2870
|
}
|
|
2851
2871
|
else if (price === 'index') {
|
|
2852
|
-
|
|
2872
|
+
response = await this.contractPublicGetIndexMarketHistoryIndex(this.extend(request, params));
|
|
2853
2873
|
}
|
|
2854
2874
|
else if (price === 'premiumIndex') {
|
|
2855
2875
|
throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
|
|
2856
2876
|
}
|
|
2857
2877
|
else {
|
|
2858
|
-
|
|
2878
|
+
response = await this.contractPublicGetMarketHistoryKline(this.extend(request, params));
|
|
2859
2879
|
}
|
|
2860
2880
|
}
|
|
2861
2881
|
else if (market['linear']) {
|
|
2882
|
+
request['contract_code'] = market['id'];
|
|
2862
2883
|
if (price === 'mark') {
|
|
2863
|
-
|
|
2884
|
+
response = await this.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(this.extend(request, params));
|
|
2864
2885
|
}
|
|
2865
2886
|
else if (price === 'index') {
|
|
2866
2887
|
throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
|
|
2867
2888
|
}
|
|
2868
2889
|
else if (price === 'premiumIndex') {
|
|
2869
|
-
|
|
2890
|
+
response = await this.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(this.extend(request, params));
|
|
2870
2891
|
}
|
|
2871
2892
|
else {
|
|
2872
|
-
|
|
2893
|
+
response = await this.contractPublicGetLinearSwapExMarketHistoryKline(this.extend(request, params));
|
|
2873
2894
|
}
|
|
2874
|
-
fieldName = 'contract_code';
|
|
2875
2895
|
}
|
|
2876
2896
|
}
|
|
2877
2897
|
else if (market['swap']) {
|
|
2898
|
+
request['contract_code'] = market['id'];
|
|
2878
2899
|
if (market['inverse']) {
|
|
2879
2900
|
if (price === 'mark') {
|
|
2880
|
-
|
|
2901
|
+
response = await this.contractPublicGetIndexMarketHistorySwapMarkPriceKline(this.extend(request, params));
|
|
2881
2902
|
}
|
|
2882
2903
|
else if (price === 'index') {
|
|
2883
2904
|
throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
|
|
2884
2905
|
}
|
|
2885
2906
|
else if (price === 'premiumIndex') {
|
|
2886
|
-
|
|
2907
|
+
response = await this.contractPublicGetIndexMarketHistorySwapPremiumIndexKline(this.extend(request, params));
|
|
2887
2908
|
}
|
|
2888
2909
|
else {
|
|
2889
|
-
|
|
2910
|
+
response = await this.contractPublicGetSwapExMarketHistoryKline(this.extend(request, params));
|
|
2890
2911
|
}
|
|
2891
2912
|
}
|
|
2892
2913
|
else if (market['linear']) {
|
|
2893
2914
|
if (price === 'mark') {
|
|
2894
|
-
|
|
2915
|
+
response = await this.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(this.extend(request, params));
|
|
2895
2916
|
}
|
|
2896
2917
|
else if (price === 'index') {
|
|
2897
2918
|
throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
|
|
2898
2919
|
}
|
|
2899
2920
|
else if (price === 'premiumIndex') {
|
|
2900
|
-
|
|
2921
|
+
response = await this.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(this.extend(request, params));
|
|
2901
2922
|
}
|
|
2902
2923
|
else {
|
|
2903
|
-
|
|
2924
|
+
response = await this.contractPublicGetLinearSwapExMarketHistoryKline(this.extend(request, params));
|
|
2904
2925
|
}
|
|
2905
2926
|
}
|
|
2906
|
-
fieldName = 'contract_code';
|
|
2907
2927
|
}
|
|
2908
|
-
|
|
2928
|
+
else {
|
|
2929
|
+
if (since !== undefined) {
|
|
2930
|
+
request['from'] = this.parseToInt(since / 1000);
|
|
2931
|
+
}
|
|
2909
2932
|
if (limit !== undefined) {
|
|
2910
|
-
request['size'] = limit; //
|
|
2911
|
-
// https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
|
|
2933
|
+
request['size'] = limit; // max 2000
|
|
2912
2934
|
}
|
|
2913
|
-
|
|
2914
|
-
|
|
2935
|
+
request['symbol'] = market['id'];
|
|
2936
|
+
if (timeframe === '1M' || timeframe === '1y') {
|
|
2937
|
+
// for some reason 1M and 1Y does not work with the regular endpoint
|
|
2938
|
+
// https://github.com/ccxt/ccxt/issues/18006
|
|
2939
|
+
response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
|
|
2915
2940
|
}
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
if (since === undefined) {
|
|
2919
|
-
const now = this.seconds();
|
|
2920
|
-
request['from'] = now - duration * (limit - 1);
|
|
2921
|
-
request['to'] = now;
|
|
2922
|
-
}
|
|
2923
|
-
else {
|
|
2924
|
-
const start = this.parseToInt(since / 1000);
|
|
2925
|
-
request['from'] = start;
|
|
2926
|
-
request['to'] = this.sum(start, duration * (limit - 1));
|
|
2927
|
-
}
|
|
2941
|
+
else {
|
|
2942
|
+
response = await this.spotPublicGetMarketHistoryCandles(this.extend(request, params));
|
|
2928
2943
|
}
|
|
2929
2944
|
}
|
|
2930
|
-
request[fieldName] = market['id'];
|
|
2931
|
-
const response = await this[method](this.extend(request, params));
|
|
2932
2945
|
//
|
|
2933
2946
|
// {
|
|
2934
2947
|
// "status":"ok",
|
|
@@ -3545,58 +3558,57 @@ export default class htx extends Exchange {
|
|
|
3545
3558
|
// 'pair': 'BTC-USDT',
|
|
3546
3559
|
// 'contract_type': 'this_week', // swap, this_week, next_week, quarter, next_ quarter
|
|
3547
3560
|
};
|
|
3548
|
-
let
|
|
3561
|
+
let response = undefined;
|
|
3549
3562
|
if (marketType === 'spot') {
|
|
3550
3563
|
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
3551
|
-
method = 'spotPrivateGetV1OrderOrdersOrderId';
|
|
3552
3564
|
if (clientOrderId !== undefined) {
|
|
3553
|
-
method = 'spotPrivateGetV1OrderOrdersGetClientOrder';
|
|
3554
3565
|
// will be filled below in extend ()
|
|
3555
3566
|
// they expect clientOrderId instead of client-order-id
|
|
3556
3567
|
// request['clientOrderId'] = clientOrderId;
|
|
3568
|
+
response = await this.spotPrivateGetV1OrderOrdersGetClientOrder(this.extend(request, params));
|
|
3557
3569
|
}
|
|
3558
3570
|
else {
|
|
3559
3571
|
request['order-id'] = id;
|
|
3572
|
+
response = await this.spotPrivateGetV1OrderOrdersOrderId(this.extend(request, params));
|
|
3560
3573
|
}
|
|
3561
3574
|
}
|
|
3562
3575
|
else {
|
|
3563
3576
|
if (symbol === undefined) {
|
|
3564
3577
|
throw new ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
3565
3578
|
}
|
|
3579
|
+
const clientOrderId = this.safeString2(params, 'client_order_id', 'clientOrderId');
|
|
3580
|
+
if (clientOrderId === undefined) {
|
|
3581
|
+
request['order_id'] = id;
|
|
3582
|
+
}
|
|
3583
|
+
else {
|
|
3584
|
+
request['client_order_id'] = clientOrderId;
|
|
3585
|
+
params = this.omit(params, ['client_order_id', 'clientOrderId']);
|
|
3586
|
+
}
|
|
3566
3587
|
request['contract_code'] = market['id'];
|
|
3567
3588
|
if (market['linear']) {
|
|
3568
3589
|
let marginMode = undefined;
|
|
3569
3590
|
[marginMode, params] = this.handleMarginModeAndParams('fetchOrder', params);
|
|
3570
3591
|
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
3571
3592
|
if (marginMode === 'isolated') {
|
|
3572
|
-
|
|
3593
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapOrderInfo(this.extend(request, params));
|
|
3573
3594
|
}
|
|
3574
3595
|
else if (marginMode === 'cross') {
|
|
3575
|
-
|
|
3596
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrderInfo(this.extend(request, params));
|
|
3576
3597
|
}
|
|
3577
3598
|
}
|
|
3578
3599
|
else if (market['inverse']) {
|
|
3579
3600
|
if (marketType === 'future') {
|
|
3580
|
-
method = 'contractPrivatePostApiV1ContractOrderInfo';
|
|
3581
3601
|
request['symbol'] = market['settleId'];
|
|
3602
|
+
response = await this.contractPrivatePostApiV1ContractOrderInfo(this.extend(request, params));
|
|
3582
3603
|
}
|
|
3583
3604
|
else if (marketType === 'swap') {
|
|
3584
|
-
|
|
3605
|
+
response = await this.contractPrivatePostSwapApiV1SwapOrderInfo(this.extend(request, params));
|
|
3585
3606
|
}
|
|
3586
3607
|
else {
|
|
3587
3608
|
throw new NotSupported(this.id + ' fetchOrder() does not support ' + marketType + ' markets');
|
|
3588
3609
|
}
|
|
3589
3610
|
}
|
|
3590
|
-
const clientOrderId = this.safeString2(params, 'client_order_id', 'clientOrderId');
|
|
3591
|
-
if (clientOrderId === undefined) {
|
|
3592
|
-
request['order_id'] = id;
|
|
3593
|
-
}
|
|
3594
|
-
else {
|
|
3595
|
-
request['client_order_id'] = clientOrderId;
|
|
3596
|
-
params = this.omit(params, ['client_order_id', 'clientOrderId']);
|
|
3597
|
-
}
|
|
3598
3611
|
}
|
|
3599
|
-
const response = await this[method](this.extend(request, params));
|
|
3600
3612
|
//
|
|
3601
3613
|
// spot
|
|
3602
3614
|
//
|
|
@@ -6295,7 +6307,6 @@ export default class htx extends Exchange {
|
|
|
6295
6307
|
};
|
|
6296
6308
|
let subType = undefined;
|
|
6297
6309
|
[subType, params] = this.handleSubTypeAndParams('transfer', undefined, params);
|
|
6298
|
-
let method = undefined;
|
|
6299
6310
|
let fromAccountId = this.convertTypeToAccount(fromAccount);
|
|
6300
6311
|
let toAccountId = this.convertTypeToAccount(toAccount);
|
|
6301
6312
|
const toCross = toAccountId === 'cross';
|
|
@@ -6308,28 +6319,28 @@ export default class htx extends Exchange {
|
|
|
6308
6319
|
throw new BadRequest(this.id + ' transfer () cannot make a transfer between ' + fromAccount + ' and ' + toAccount);
|
|
6309
6320
|
}
|
|
6310
6321
|
const fromOrToFuturesAccount = (fromAccountId === 'futures') || (toAccountId === 'futures');
|
|
6322
|
+
let response = undefined;
|
|
6311
6323
|
if (fromOrToFuturesAccount) {
|
|
6312
6324
|
let type = fromAccountId + '-to-' + toAccountId;
|
|
6313
6325
|
type = this.safeString(params, 'type', type);
|
|
6314
6326
|
request['type'] = type;
|
|
6315
|
-
|
|
6327
|
+
response = await this.spotPrivatePostV1FuturesTransfer(this.extend(request, params));
|
|
6316
6328
|
}
|
|
6317
6329
|
else if (fromSpot && toCross) {
|
|
6318
|
-
|
|
6330
|
+
response = await this.privatePostCrossMarginTransferIn(this.extend(request, params));
|
|
6319
6331
|
}
|
|
6320
6332
|
else if (fromCross && toSpot) {
|
|
6321
|
-
|
|
6333
|
+
response = await this.privatePostCrossMarginTransferOut(this.extend(request, params));
|
|
6322
6334
|
}
|
|
6323
6335
|
else if (fromSpot && toIsolated) {
|
|
6324
6336
|
request['symbol'] = toAccountId;
|
|
6325
|
-
|
|
6337
|
+
response = await this.privatePostDwTransferInMargin(this.extend(request, params));
|
|
6326
6338
|
}
|
|
6327
6339
|
else if (fromIsolated && toSpot) {
|
|
6328
6340
|
request['symbol'] = fromAccountId;
|
|
6329
|
-
|
|
6341
|
+
response = await this.privatePostDwTransferOutMargin(this.extend(request, params));
|
|
6330
6342
|
}
|
|
6331
6343
|
else {
|
|
6332
|
-
method = 'v2PrivatePostAccountTransfer';
|
|
6333
6344
|
if (subType === 'linear') {
|
|
6334
6345
|
if ((fromAccountId === 'swap') || (fromAccount === 'linear-swap')) {
|
|
6335
6346
|
fromAccountId = 'linear-swap';
|
|
@@ -6350,8 +6361,8 @@ export default class htx extends Exchange {
|
|
|
6350
6361
|
}
|
|
6351
6362
|
request['from'] = fromSpot ? 'spot' : fromAccountId;
|
|
6352
6363
|
request['to'] = toSpot ? 'spot' : toAccountId;
|
|
6364
|
+
response = await this.v2PrivatePostAccountTransfer(this.extend(request, params));
|
|
6353
6365
|
}
|
|
6354
|
-
const response = await this[method](this.extend(request, params));
|
|
6355
6366
|
//
|
|
6356
6367
|
// {
|
|
6357
6368
|
// "code": "200",
|
|
@@ -6478,17 +6489,16 @@ export default class htx extends Exchange {
|
|
|
6478
6489
|
const request = {
|
|
6479
6490
|
'contract_code': market['id'],
|
|
6480
6491
|
};
|
|
6481
|
-
let
|
|
6492
|
+
let response = undefined;
|
|
6482
6493
|
if (market['inverse']) {
|
|
6483
|
-
|
|
6494
|
+
response = await this.contractPublicGetSwapApiV1SwapHistoricalFundingRate(this.extend(request, params));
|
|
6484
6495
|
}
|
|
6485
6496
|
else if (market['linear']) {
|
|
6486
|
-
|
|
6497
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapHistoricalFundingRate(this.extend(request, params));
|
|
6487
6498
|
}
|
|
6488
6499
|
else {
|
|
6489
6500
|
throw new NotSupported(this.id + ' fetchFundingRateHistory() supports inverse and linear swaps only');
|
|
6490
6501
|
}
|
|
6491
|
-
const response = await this[method](this.extend(request, params));
|
|
6492
6502
|
//
|
|
6493
6503
|
// {
|
|
6494
6504
|
// "status": "ok",
|
|
@@ -6584,20 +6594,19 @@ export default class htx extends Exchange {
|
|
|
6584
6594
|
*/
|
|
6585
6595
|
await this.loadMarkets();
|
|
6586
6596
|
const market = this.market(symbol);
|
|
6587
|
-
|
|
6597
|
+
const request = {
|
|
6598
|
+
'contract_code': market['id'],
|
|
6599
|
+
};
|
|
6600
|
+
let response = undefined;
|
|
6588
6601
|
if (market['inverse']) {
|
|
6589
|
-
|
|
6602
|
+
response = await this.contractPublicGetSwapApiV1SwapFundingRate(this.extend(request, params));
|
|
6590
6603
|
}
|
|
6591
6604
|
else if (market['linear']) {
|
|
6592
|
-
|
|
6605
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapFundingRate(this.extend(request, params));
|
|
6593
6606
|
}
|
|
6594
6607
|
else {
|
|
6595
6608
|
throw new NotSupported(this.id + ' fetchFundingRate() supports inverse and linear swaps only');
|
|
6596
6609
|
}
|
|
6597
|
-
const request = {
|
|
6598
|
-
'contract_code': market['id'],
|
|
6599
|
-
};
|
|
6600
|
-
const response = await this[method](this.extend(request, params));
|
|
6601
6610
|
//
|
|
6602
6611
|
// {
|
|
6603
6612
|
// "status": "ok",
|
|
@@ -6634,12 +6643,17 @@ export default class htx extends Exchange {
|
|
|
6634
6643
|
const request = {
|
|
6635
6644
|
// 'contract_code': market['id'],
|
|
6636
6645
|
};
|
|
6637
|
-
const method = this.getSupportedMapping(subType, {
|
|
6638
|
-
'linear': 'contractPublicGetLinearSwapApiV1SwapBatchFundingRate',
|
|
6639
|
-
'inverse': 'contractPublicGetSwapApiV1SwapBatchFundingRate',
|
|
6640
|
-
});
|
|
6641
6646
|
params = this.omit(params, 'subType');
|
|
6642
|
-
|
|
6647
|
+
let response = undefined;
|
|
6648
|
+
if (subType === 'linear') {
|
|
6649
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapBatchFundingRate(this.extend(request, params));
|
|
6650
|
+
}
|
|
6651
|
+
else if (subType === 'inverse') {
|
|
6652
|
+
response = await this.contractPublicGetSwapApiV1SwapBatchFundingRate(this.extend(request, params));
|
|
6653
|
+
}
|
|
6654
|
+
else {
|
|
6655
|
+
throw new NotSupported(this.id + ' fetchFundingRates() not support this market type');
|
|
6656
|
+
}
|
|
6643
6657
|
//
|
|
6644
6658
|
// {
|
|
6645
6659
|
// "status": "ok",
|
|
@@ -6686,22 +6700,21 @@ export default class htx extends Exchange {
|
|
|
6686
6700
|
request['size'] = limit;
|
|
6687
6701
|
}
|
|
6688
6702
|
let market = undefined;
|
|
6689
|
-
let
|
|
6703
|
+
let response = undefined;
|
|
6690
6704
|
if (marginMode === 'isolated') {
|
|
6691
|
-
method = 'privateGetMarginLoanOrders';
|
|
6692
6705
|
if (symbol !== undefined) {
|
|
6693
6706
|
market = this.market(symbol);
|
|
6694
6707
|
request['symbol'] = market['id'];
|
|
6695
6708
|
}
|
|
6709
|
+
response = await this.privateGetMarginLoanOrders(this.extend(request, params));
|
|
6696
6710
|
}
|
|
6697
6711
|
else { // Cross
|
|
6698
|
-
method = 'privateGetCrossMarginLoanOrders';
|
|
6699
6712
|
if (code !== undefined) {
|
|
6700
6713
|
const currency = this.currency(code);
|
|
6701
6714
|
request['currency'] = currency['id'];
|
|
6702
6715
|
}
|
|
6716
|
+
response = await this.privateGetCrossMarginLoanOrders(this.extend(request, params));
|
|
6703
6717
|
}
|
|
6704
|
-
const response = await this[method](this.extend(request, params));
|
|
6705
6718
|
//
|
|
6706
6719
|
// {
|
|
6707
6720
|
// "status":"ok",
|
|
@@ -6964,17 +6977,16 @@ export default class htx extends Exchange {
|
|
|
6964
6977
|
await this.loadMarkets();
|
|
6965
6978
|
const market = this.market(symbol);
|
|
6966
6979
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchFundingHistory', market, params);
|
|
6967
|
-
let method = undefined;
|
|
6968
6980
|
const request = {
|
|
6969
6981
|
'type': '30,31',
|
|
6970
6982
|
};
|
|
6971
6983
|
if (since !== undefined) {
|
|
6972
6984
|
request['start_date'] = since;
|
|
6973
6985
|
}
|
|
6986
|
+
let response = undefined;
|
|
6974
6987
|
if (marketType === 'swap') {
|
|
6975
6988
|
request['contract'] = market['id'];
|
|
6976
6989
|
if (market['linear']) {
|
|
6977
|
-
method = 'contractPrivatePostLinearSwapApiV3SwapFinancialRecordExact';
|
|
6978
6990
|
//
|
|
6979
6991
|
// {
|
|
6980
6992
|
// "status": "ok",
|
|
@@ -7006,9 +7018,9 @@ export default class htx extends Exchange {
|
|
|
7006
7018
|
else {
|
|
7007
7019
|
request['mar_acct'] = market['quoteId'];
|
|
7008
7020
|
}
|
|
7021
|
+
response = await this.contractPrivatePostLinearSwapApiV3SwapFinancialRecordExact(this.extend(request, query));
|
|
7009
7022
|
}
|
|
7010
7023
|
else {
|
|
7011
|
-
method = 'contractPrivatePostSwapApiV3SwapFinancialRecordExact';
|
|
7012
7024
|
//
|
|
7013
7025
|
// {
|
|
7014
7026
|
// "code": 200,
|
|
@@ -7029,13 +7041,13 @@ export default class htx extends Exchange {
|
|
|
7029
7041
|
// "ts": 1604312615051
|
|
7030
7042
|
// }
|
|
7031
7043
|
//
|
|
7044
|
+
response = await this.contractPrivatePostSwapApiV3SwapFinancialRecordExact(this.extend(request, query));
|
|
7032
7045
|
}
|
|
7033
7046
|
}
|
|
7034
7047
|
else {
|
|
7035
|
-
method = 'contractPrivatePostApiV3ContractFinancialRecordExact';
|
|
7036
7048
|
request['symbol'] = market['id'];
|
|
7049
|
+
response = await this.contractPrivatePostApiV3ContractFinancialRecordExact(this.extend(request, query));
|
|
7037
7050
|
}
|
|
7038
|
-
const response = await this[method](this.extend(request, query));
|
|
7039
7051
|
const data = this.safeValue(response, 'data', []);
|
|
7040
7052
|
return this.parseIncomes(data, market, since, limit);
|
|
7041
7053
|
}
|
|
@@ -7055,15 +7067,29 @@ export default class htx extends Exchange {
|
|
|
7055
7067
|
await this.loadMarkets();
|
|
7056
7068
|
const market = this.market(symbol);
|
|
7057
7069
|
const [marketType, query] = this.handleMarketTypeAndParams('setLeverage', market, params);
|
|
7058
|
-
|
|
7070
|
+
const request = {
|
|
7071
|
+
'lever_rate': leverage,
|
|
7072
|
+
};
|
|
7073
|
+
if (marketType === 'future' && market['inverse']) {
|
|
7074
|
+
request['symbol'] = market['settleId'];
|
|
7075
|
+
}
|
|
7076
|
+
else {
|
|
7077
|
+
request['contract_code'] = market['id'];
|
|
7078
|
+
}
|
|
7079
|
+
let response = undefined;
|
|
7059
7080
|
if (market['linear']) {
|
|
7060
7081
|
let marginMode = undefined;
|
|
7061
7082
|
[marginMode, params] = this.handleMarginModeAndParams('setLeverage', params);
|
|
7062
7083
|
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7084
|
+
if (marginMode === 'isolated') {
|
|
7085
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapSwitchLeverRate(this.extend(request, query));
|
|
7086
|
+
}
|
|
7087
|
+
else if (marginMode === 'cross') {
|
|
7088
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossSwitchLeverRate(this.extend(request, query));
|
|
7089
|
+
}
|
|
7090
|
+
else {
|
|
7091
|
+
throw new NotSupported(this.id + ' setLeverage() not support this market type');
|
|
7092
|
+
}
|
|
7067
7093
|
//
|
|
7068
7094
|
// {
|
|
7069
7095
|
// "status": "ok",
|
|
@@ -7077,10 +7103,15 @@ export default class htx extends Exchange {
|
|
|
7077
7103
|
//
|
|
7078
7104
|
}
|
|
7079
7105
|
else {
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7106
|
+
if (marketType === 'future') {
|
|
7107
|
+
response = await this.contractPrivatePostApiV1ContractSwitchLeverRate(this.extend(request, query));
|
|
7108
|
+
}
|
|
7109
|
+
else if (marketType === 'swap') {
|
|
7110
|
+
response = await this.contractPrivatePostSwapApiV1SwapSwitchLeverRate(this.extend(request, query));
|
|
7111
|
+
}
|
|
7112
|
+
else {
|
|
7113
|
+
throw new NotSupported(this.id + ' setLeverage() not support this market type');
|
|
7114
|
+
}
|
|
7084
7115
|
//
|
|
7085
7116
|
// future
|
|
7086
7117
|
// {
|
|
@@ -7098,16 +7129,6 @@ export default class htx extends Exchange {
|
|
|
7098
7129
|
// }
|
|
7099
7130
|
//
|
|
7100
7131
|
}
|
|
7101
|
-
const request = {
|
|
7102
|
-
'lever_rate': leverage,
|
|
7103
|
-
};
|
|
7104
|
-
if (marketType === 'future' && market['inverse']) {
|
|
7105
|
-
request['symbol'] = market['settleId'];
|
|
7106
|
-
}
|
|
7107
|
-
else {
|
|
7108
|
-
request['contract_code'] = market['id'];
|
|
7109
|
-
}
|
|
7110
|
-
const response = await this[method](this.extend(request, query));
|
|
7111
7132
|
return response;
|
|
7112
7133
|
}
|
|
7113
7134
|
parseIncome(income, market = undefined) {
|
|
@@ -7255,12 +7276,17 @@ export default class htx extends Exchange {
|
|
|
7255
7276
|
if (marketType === 'spot') {
|
|
7256
7277
|
marketType = 'future';
|
|
7257
7278
|
}
|
|
7258
|
-
let
|
|
7279
|
+
let response = undefined;
|
|
7259
7280
|
if (subType === 'linear') {
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7281
|
+
if (marginMode === 'isolated') {
|
|
7282
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapPositionInfo(params);
|
|
7283
|
+
}
|
|
7284
|
+
else if (marginMode === 'cross') {
|
|
7285
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossPositionInfo(params);
|
|
7286
|
+
}
|
|
7287
|
+
else {
|
|
7288
|
+
throw new NotSupported(this.id + ' fetchPositions() not support this market type');
|
|
7289
|
+
}
|
|
7264
7290
|
//
|
|
7265
7291
|
// {
|
|
7266
7292
|
// "status": "ok",
|
|
@@ -7290,10 +7316,15 @@ export default class htx extends Exchange {
|
|
|
7290
7316
|
//
|
|
7291
7317
|
}
|
|
7292
7318
|
else {
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7319
|
+
if (marketType === 'future') {
|
|
7320
|
+
response = await this.contractPrivatePostApiV1ContractPositionInfo(params);
|
|
7321
|
+
}
|
|
7322
|
+
else if (marketType === 'swap') {
|
|
7323
|
+
response = await this.contractPrivatePostSwapApiV1SwapPositionInfo(params);
|
|
7324
|
+
}
|
|
7325
|
+
else {
|
|
7326
|
+
throw new NotSupported(this.id + ' fetchPositions() not support this market type');
|
|
7327
|
+
}
|
|
7297
7328
|
//
|
|
7298
7329
|
// future
|
|
7299
7330
|
// {
|
|
@@ -7345,7 +7376,6 @@ export default class htx extends Exchange {
|
|
|
7345
7376
|
// }
|
|
7346
7377
|
//
|
|
7347
7378
|
}
|
|
7348
|
-
const response = await this[method](params);
|
|
7349
7379
|
const data = this.safeValue(response, 'data', []);
|
|
7350
7380
|
const timestamp = this.safeInteger(response, 'ts');
|
|
7351
7381
|
const result = [];
|
|
@@ -7374,12 +7404,27 @@ export default class htx extends Exchange {
|
|
|
7374
7404
|
[marginMode, params] = this.handleMarginModeAndParams('fetchPosition', params);
|
|
7375
7405
|
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
7376
7406
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchPosition', market, params);
|
|
7377
|
-
|
|
7407
|
+
const request = {};
|
|
7408
|
+
if (market['future'] && market['inverse']) {
|
|
7409
|
+
request['symbol'] = market['settleId'];
|
|
7410
|
+
}
|
|
7411
|
+
else {
|
|
7412
|
+
if (marginMode === 'cross') {
|
|
7413
|
+
request['margin_account'] = 'USDT'; // only allowed value
|
|
7414
|
+
}
|
|
7415
|
+
request['contract_code'] = market['id'];
|
|
7416
|
+
}
|
|
7417
|
+
let response = undefined;
|
|
7378
7418
|
if (market['linear']) {
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7419
|
+
if (marginMode === 'isolated') {
|
|
7420
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapAccountPositionInfo(this.extend(request, query));
|
|
7421
|
+
}
|
|
7422
|
+
else if (marginMode === 'cross') {
|
|
7423
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossAccountPositionInfo(this.extend(request, query));
|
|
7424
|
+
}
|
|
7425
|
+
else {
|
|
7426
|
+
throw new NotSupported(this.id + ' fetchPosition() not support this market type');
|
|
7427
|
+
}
|
|
7383
7428
|
//
|
|
7384
7429
|
// isolated
|
|
7385
7430
|
//
|
|
@@ -7499,10 +7544,15 @@ export default class htx extends Exchange {
|
|
|
7499
7544
|
//
|
|
7500
7545
|
}
|
|
7501
7546
|
else {
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7547
|
+
if (marketType === 'future') {
|
|
7548
|
+
response = await this.contractPrivatePostApiV1ContractAccountPositionInfo(this.extend(request, query));
|
|
7549
|
+
}
|
|
7550
|
+
else if (marketType === 'swap') {
|
|
7551
|
+
response = await this.contractPrivatePostSwapApiV1SwapAccountPositionInfo(this.extend(request, query));
|
|
7552
|
+
}
|
|
7553
|
+
else {
|
|
7554
|
+
throw new NotSupported(this.id + ' setLeverage() not support this market type');
|
|
7555
|
+
}
|
|
7506
7556
|
//
|
|
7507
7557
|
// future, swap
|
|
7508
7558
|
//
|
|
@@ -7573,17 +7623,6 @@ export default class htx extends Exchange {
|
|
|
7573
7623
|
// }
|
|
7574
7624
|
//
|
|
7575
7625
|
}
|
|
7576
|
-
const request = {};
|
|
7577
|
-
if (market['future'] && market['inverse']) {
|
|
7578
|
-
request['symbol'] = market['settleId'];
|
|
7579
|
-
}
|
|
7580
|
-
else {
|
|
7581
|
-
if (marginMode === 'cross') {
|
|
7582
|
-
request['margin_account'] = 'USDT'; // only allowed value
|
|
7583
|
-
}
|
|
7584
|
-
request['contract_code'] = market['id'];
|
|
7585
|
-
}
|
|
7586
|
-
const response = await this[method](this.extend(request, query));
|
|
7587
7626
|
const data = this.safeValue(response, 'data');
|
|
7588
7627
|
let account = undefined;
|
|
7589
7628
|
if (marginMode === 'cross') {
|
|
@@ -7914,26 +7953,28 @@ export default class htx extends Exchange {
|
|
|
7914
7953
|
'period': timeframes[timeframe],
|
|
7915
7954
|
'amount_type': amountType,
|
|
7916
7955
|
};
|
|
7917
|
-
|
|
7956
|
+
if (limit !== undefined) {
|
|
7957
|
+
request['size'] = limit;
|
|
7958
|
+
}
|
|
7959
|
+
let response = undefined;
|
|
7918
7960
|
if (market['future']) {
|
|
7919
7961
|
request['contract_type'] = this.safeString(market['info'], 'contract_type');
|
|
7920
7962
|
request['symbol'] = market['baseId']; // currency code on coin-m futures
|
|
7921
|
-
|
|
7963
|
+
// coin-m futures
|
|
7964
|
+
response = await this.contractPublicGetApiV1ContractHisOpenInterest(this.extend(request, params));
|
|
7922
7965
|
}
|
|
7923
7966
|
else if (market['linear']) {
|
|
7924
7967
|
request['contract_type'] = 'swap';
|
|
7925
7968
|
request['contract_code'] = market['id'];
|
|
7926
7969
|
request['contract_code'] = market['id'];
|
|
7927
|
-
|
|
7970
|
+
// USDT-M
|
|
7971
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapHisOpenInterest(this.extend(request, params));
|
|
7928
7972
|
}
|
|
7929
7973
|
else {
|
|
7930
7974
|
request['contract_code'] = market['id'];
|
|
7931
|
-
|
|
7975
|
+
// coin-m swaps
|
|
7976
|
+
response = await this.contractPublicGetSwapApiV1SwapHisOpenInterest(this.extend(request, params));
|
|
7932
7977
|
}
|
|
7933
|
-
if (limit !== undefined) {
|
|
7934
|
-
request['size'] = limit;
|
|
7935
|
-
}
|
|
7936
|
-
const response = await this[method](this.extend(request, params));
|
|
7937
7978
|
//
|
|
7938
7979
|
// contractPublicGetlinearSwapApiV1SwapHisOpenInterest
|
|
7939
7980
|
// {
|
|
@@ -8021,20 +8062,22 @@ export default class htx extends Exchange {
|
|
|
8021
8062
|
const request = {
|
|
8022
8063
|
'contract_code': market['id'],
|
|
8023
8064
|
};
|
|
8024
|
-
let
|
|
8065
|
+
let response = undefined;
|
|
8025
8066
|
if (market['future']) {
|
|
8026
8067
|
request['contract_type'] = this.safeString(market['info'], 'contract_type');
|
|
8027
8068
|
request['symbol'] = market['baseId'];
|
|
8028
|
-
|
|
8069
|
+
// COIN-M futures
|
|
8070
|
+
response = await this.contractPublicGetApiV1ContractOpenInterest(this.extend(request, params));
|
|
8029
8071
|
}
|
|
8030
8072
|
else if (market['linear']) {
|
|
8031
8073
|
request['contract_type'] = 'swap';
|
|
8032
|
-
|
|
8074
|
+
// USDT-M
|
|
8075
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapOpenInterest(this.extend(request, params));
|
|
8033
8076
|
}
|
|
8034
8077
|
else {
|
|
8035
|
-
|
|
8078
|
+
// COIN-M swaps
|
|
8079
|
+
response = await this.contractPublicGetSwapApiV1SwapOpenInterest(this.extend(request, params));
|
|
8036
8080
|
}
|
|
8037
|
-
const response = await this[method](this.extend(request, params));
|
|
8038
8081
|
//
|
|
8039
8082
|
// USDT-M contractPublicGetLinearSwapApiV1SwapOpenInterest
|
|
8040
8083
|
//
|
|
@@ -8384,16 +8427,18 @@ export default class htx extends Exchange {
|
|
|
8384
8427
|
if (until !== undefined) {
|
|
8385
8428
|
request['end_at'] = until;
|
|
8386
8429
|
}
|
|
8387
|
-
let
|
|
8430
|
+
let response = undefined;
|
|
8388
8431
|
if (market['swap']) {
|
|
8389
8432
|
if (market['linear']) {
|
|
8390
|
-
|
|
8433
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapSettlementRecords(this.extend(request, params));
|
|
8391
8434
|
}
|
|
8392
8435
|
else {
|
|
8393
|
-
|
|
8436
|
+
response = await this.contractPublicGetSwapApiV1SwapSettlementRecords(this.extend(request, params));
|
|
8394
8437
|
}
|
|
8395
8438
|
}
|
|
8396
|
-
|
|
8439
|
+
else {
|
|
8440
|
+
response = await this.contractPublicGetApiV1ContractSettlementRecords(this.extend(request, params));
|
|
8441
|
+
}
|
|
8397
8442
|
//
|
|
8398
8443
|
// linear swap, coin-m swap
|
|
8399
8444
|
//
|