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/dist/cjs/src/htx.js
CHANGED
|
@@ -1224,30 +1224,32 @@ class htx extends htx$1 {
|
|
|
1224
1224
|
await this.loadMarkets();
|
|
1225
1225
|
let marketType = undefined;
|
|
1226
1226
|
[marketType, params] = this.handleMarketTypeAndParams('fetchMyTrades', undefined, params);
|
|
1227
|
-
let
|
|
1227
|
+
let response = undefined;
|
|
1228
1228
|
if (marketType !== 'spot') {
|
|
1229
1229
|
const subType = this.safeString(params, 'subType', this.options['defaultSubType']);
|
|
1230
1230
|
if (marketType === 'swap') {
|
|
1231
1231
|
if (subType === 'linear') {
|
|
1232
|
-
|
|
1232
|
+
response = await this.statusPublicSwapLinearGetApiV2SummaryJson();
|
|
1233
1233
|
}
|
|
1234
1234
|
else if (subType === 'inverse') {
|
|
1235
|
-
|
|
1235
|
+
response = await this.statusPublicSwapInverseGetApiV2SummaryJson();
|
|
1236
1236
|
}
|
|
1237
1237
|
}
|
|
1238
1238
|
else if (marketType === 'future') {
|
|
1239
1239
|
if (subType === 'linear') {
|
|
1240
|
-
|
|
1240
|
+
response = await this.statusPublicFutureLinearGetApiV2SummaryJson();
|
|
1241
1241
|
}
|
|
1242
1242
|
else if (subType === 'inverse') {
|
|
1243
|
-
|
|
1243
|
+
response = await this.statusPublicFutureInverseGetApiV2SummaryJson();
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
|
1246
1246
|
else if (marketType === 'contract') {
|
|
1247
|
-
|
|
1247
|
+
response = await this.contractPublicGetHeartbeat();
|
|
1248
1248
|
}
|
|
1249
1249
|
}
|
|
1250
|
-
|
|
1250
|
+
else {
|
|
1251
|
+
response = await this.statusPublicSpotGetApiV2SummaryJson();
|
|
1252
|
+
}
|
|
1251
1253
|
//
|
|
1252
1254
|
// statusPublicSpotGetApiV2SummaryJson, statusPublicSwapInverseGetApiV2SummaryJson, statusPublicFutureLinearGetApiV2SummaryJson, statusPublicFutureInverseGetApiV2SummaryJson
|
|
1253
1255
|
//
|
|
@@ -1412,7 +1414,7 @@ class htx extends htx$1 {
|
|
|
1412
1414
|
let status = undefined;
|
|
1413
1415
|
let updated = undefined;
|
|
1414
1416
|
let url = undefined;
|
|
1415
|
-
if (
|
|
1417
|
+
if (marketType === 'contract') {
|
|
1416
1418
|
const statusRaw = this.safeString(response, 'status');
|
|
1417
1419
|
status = (statusRaw === 'ok') ? 'ok' : 'maintenance'; // 'ok', 'error'
|
|
1418
1420
|
updated = this.safeString(response, 'ts');
|
|
@@ -1446,11 +1448,13 @@ class htx extends htx$1 {
|
|
|
1446
1448
|
const defaultType = this.safeString(this.options, 'defaultType', 'spot');
|
|
1447
1449
|
let type = this.safeString(options, 'type', defaultType);
|
|
1448
1450
|
type = this.safeString(params, 'type', type);
|
|
1449
|
-
let
|
|
1451
|
+
let response = undefined;
|
|
1450
1452
|
if ((type === 'future') || (type === 'swap')) {
|
|
1451
|
-
|
|
1453
|
+
response = await this.contractPublicGetApiV1Timestamp(params);
|
|
1454
|
+
}
|
|
1455
|
+
else {
|
|
1456
|
+
response = await this.spotPublicGetV1CommonTimestamp(params);
|
|
1452
1457
|
}
|
|
1453
|
-
const response = await this[method](params);
|
|
1454
1458
|
//
|
|
1455
1459
|
// spot
|
|
1456
1460
|
//
|
|
@@ -1618,7 +1622,6 @@ class htx extends htx$1 {
|
|
|
1618
1622
|
return allMarkets;
|
|
1619
1623
|
}
|
|
1620
1624
|
async fetchMarketsByTypeAndSubType(type, subType, params = {}) {
|
|
1621
|
-
let method = 'spotPublicGetV1CommonSymbols';
|
|
1622
1625
|
const query = this.omit(params, ['type', 'subType']);
|
|
1623
1626
|
const spot = (type === 'spot');
|
|
1624
1627
|
const contract = (type !== 'spot');
|
|
@@ -1627,25 +1630,28 @@ class htx extends htx$1 {
|
|
|
1627
1630
|
let linear = undefined;
|
|
1628
1631
|
let inverse = undefined;
|
|
1629
1632
|
const request = {};
|
|
1633
|
+
let response = undefined;
|
|
1630
1634
|
if (contract) {
|
|
1631
1635
|
linear = (subType === 'linear');
|
|
1632
1636
|
inverse = (subType === 'inverse');
|
|
1633
1637
|
if (linear) {
|
|
1634
|
-
method = 'contractPublicGetLinearSwapApiV1SwapContractInfo';
|
|
1635
1638
|
if (future) {
|
|
1636
1639
|
request['business_type'] = 'futures';
|
|
1637
1640
|
}
|
|
1641
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapContractInfo(this.extend(request, query));
|
|
1638
1642
|
}
|
|
1639
1643
|
else if (inverse) {
|
|
1640
1644
|
if (future) {
|
|
1641
|
-
|
|
1645
|
+
response = await this.contractPublicGetApiV1ContractContractInfo(this.extend(request, query));
|
|
1642
1646
|
}
|
|
1643
1647
|
else if (swap) {
|
|
1644
|
-
|
|
1648
|
+
response = await this.contractPublicGetSwapApiV1SwapContractInfo(this.extend(request, query));
|
|
1645
1649
|
}
|
|
1646
1650
|
}
|
|
1647
1651
|
}
|
|
1648
|
-
|
|
1652
|
+
else {
|
|
1653
|
+
response = await this.spotPublicGetV1CommonSymbols(this.extend(request, query));
|
|
1654
|
+
}
|
|
1649
1655
|
//
|
|
1650
1656
|
// spot
|
|
1651
1657
|
//
|
|
@@ -2032,23 +2038,25 @@ class htx extends htx$1 {
|
|
|
2032
2038
|
await this.loadMarkets();
|
|
2033
2039
|
const market = this.market(symbol);
|
|
2034
2040
|
const request = {};
|
|
2035
|
-
let
|
|
2036
|
-
let method = 'spotPublicGetMarketDetailMerged';
|
|
2041
|
+
let response = undefined;
|
|
2037
2042
|
if (market['linear']) {
|
|
2038
|
-
|
|
2039
|
-
|
|
2043
|
+
request['contract_code'] = market['id'];
|
|
2044
|
+
response = await this.contractPublicGetLinearSwapExMarketDetailMerged(this.extend(request, params));
|
|
2040
2045
|
}
|
|
2041
2046
|
else if (market['inverse']) {
|
|
2042
2047
|
if (market['future']) {
|
|
2043
|
-
|
|
2048
|
+
request['symbol'] = market['id'];
|
|
2049
|
+
response = await this.contractPublicGetMarketDetailMerged(this.extend(request, params));
|
|
2044
2050
|
}
|
|
2045
2051
|
else if (market['swap']) {
|
|
2046
|
-
|
|
2047
|
-
|
|
2052
|
+
request['contract_code'] = market['id'];
|
|
2053
|
+
response = await this.contractPublicGetSwapExMarketDetailMerged(this.extend(request, params));
|
|
2048
2054
|
}
|
|
2049
2055
|
}
|
|
2050
|
-
|
|
2051
|
-
|
|
2056
|
+
else {
|
|
2057
|
+
request['symbol'] = market['id'];
|
|
2058
|
+
response = await this.spotPublicGetMarketDetailMerged(this.extend(request, params));
|
|
2059
|
+
}
|
|
2052
2060
|
//
|
|
2053
2061
|
// spot
|
|
2054
2062
|
//
|
|
@@ -2121,7 +2129,6 @@ class htx extends htx$1 {
|
|
|
2121
2129
|
}
|
|
2122
2130
|
let type = undefined;
|
|
2123
2131
|
let subType = undefined;
|
|
2124
|
-
let method = 'spotPublicGetMarketTickers';
|
|
2125
2132
|
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
2126
2133
|
[subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
|
|
2127
2134
|
const request = {};
|
|
@@ -2129,24 +2136,27 @@ class htx extends htx$1 {
|
|
|
2129
2136
|
const swap = (type === 'swap');
|
|
2130
2137
|
const linear = (subType === 'linear');
|
|
2131
2138
|
const inverse = (subType === 'inverse');
|
|
2139
|
+
params = this.omit(params, ['type', 'subType']);
|
|
2140
|
+
let response = undefined;
|
|
2132
2141
|
if (future || swap) {
|
|
2133
2142
|
if (linear) {
|
|
2134
|
-
method = 'contractPublicGetLinearSwapExMarketDetailBatchMerged';
|
|
2135
2143
|
if (future) {
|
|
2136
2144
|
request['business_type'] = 'futures';
|
|
2137
2145
|
}
|
|
2146
|
+
response = await this.contractPublicGetLinearSwapExMarketDetailBatchMerged(this.extend(request, params));
|
|
2138
2147
|
}
|
|
2139
2148
|
else if (inverse) {
|
|
2140
2149
|
if (future) {
|
|
2141
|
-
|
|
2150
|
+
response = await this.contractPublicGetMarketDetailBatchMerged(this.extend(request, params));
|
|
2142
2151
|
}
|
|
2143
2152
|
else if (swap) {
|
|
2144
|
-
|
|
2153
|
+
response = await this.contractPublicGetSwapExMarketDetailBatchMerged(this.extend(request, params));
|
|
2145
2154
|
}
|
|
2146
2155
|
}
|
|
2147
2156
|
}
|
|
2148
|
-
|
|
2149
|
-
|
|
2157
|
+
else {
|
|
2158
|
+
response = await this.spotPublicGetMarketTickers(this.extend(request, params));
|
|
2159
|
+
}
|
|
2150
2160
|
//
|
|
2151
2161
|
// spot
|
|
2152
2162
|
//
|
|
@@ -2279,19 +2289,19 @@ class htx extends htx$1 {
|
|
|
2279
2289
|
// 'symbol': market['id'], // spot, future
|
|
2280
2290
|
// 'contract_code': market['id'], // swap
|
|
2281
2291
|
};
|
|
2282
|
-
let
|
|
2283
|
-
let method = 'spotPublicGetMarketDepth';
|
|
2292
|
+
let response = undefined;
|
|
2284
2293
|
if (market['linear']) {
|
|
2285
|
-
|
|
2286
|
-
|
|
2294
|
+
request['contract_code'] = market['id'];
|
|
2295
|
+
response = await this.contractPublicGetLinearSwapExMarketDepth(this.extend(request, params));
|
|
2287
2296
|
}
|
|
2288
2297
|
else if (market['inverse']) {
|
|
2289
2298
|
if (market['future']) {
|
|
2290
|
-
|
|
2299
|
+
request['symbol'] = market['id'];
|
|
2300
|
+
response = await this.contractPublicGetMarketDepth(this.extend(request, params));
|
|
2291
2301
|
}
|
|
2292
2302
|
else if (market['swap']) {
|
|
2293
|
-
|
|
2294
|
-
|
|
2303
|
+
request['contract_code'] = market['id'];
|
|
2304
|
+
response = await this.contractPublicGetSwapExMarketDepth(this.extend(request, params));
|
|
2295
2305
|
}
|
|
2296
2306
|
}
|
|
2297
2307
|
else {
|
|
@@ -2307,9 +2317,9 @@ class htx extends htx$1 {
|
|
|
2307
2317
|
request['depth'] = limit;
|
|
2308
2318
|
}
|
|
2309
2319
|
}
|
|
2320
|
+
request['symbol'] = market['id'];
|
|
2321
|
+
response = await this.spotPublicGetMarketDepth(this.extend(request, params));
|
|
2310
2322
|
}
|
|
2311
|
-
request[fieldName] = market['id'];
|
|
2312
|
-
const response = await this[method](this.extend(request, params));
|
|
2313
2323
|
//
|
|
2314
2324
|
// spot, future, swap
|
|
2315
2325
|
//
|
|
@@ -2560,7 +2570,7 @@ class htx extends htx$1 {
|
|
|
2560
2570
|
// 'direct': 'prev', // next, prev
|
|
2561
2571
|
// 'size': limit, // default 20, max 50
|
|
2562
2572
|
};
|
|
2563
|
-
let
|
|
2573
|
+
let response = undefined;
|
|
2564
2574
|
if (marketType === 'spot') {
|
|
2565
2575
|
if (symbol !== undefined) {
|
|
2566
2576
|
market = this.market(symbol);
|
|
@@ -2574,7 +2584,7 @@ class htx extends htx$1 {
|
|
|
2574
2584
|
// request['end-time'] = this.sum (since, 172800000); // 48 hours window
|
|
2575
2585
|
}
|
|
2576
2586
|
[request, params] = this.handleUntilOption('end-time', request, params);
|
|
2577
|
-
|
|
2587
|
+
response = await this.spotPrivateGetV1OrderMatchresults(this.extend(request, params));
|
|
2578
2588
|
}
|
|
2579
2589
|
else {
|
|
2580
2590
|
if (symbol === undefined) {
|
|
@@ -2595,26 +2605,25 @@ class htx extends htx$1 {
|
|
|
2595
2605
|
[marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
2596
2606
|
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
2597
2607
|
if (marginMode === 'isolated') {
|
|
2598
|
-
|
|
2608
|
+
response = await this.contractPrivatePostLinearSwapApiV3SwapMatchresultsExact(this.extend(request, params));
|
|
2599
2609
|
}
|
|
2600
2610
|
else if (marginMode === 'cross') {
|
|
2601
|
-
|
|
2611
|
+
response = await this.contractPrivatePostLinearSwapApiV3SwapCrossMatchresultsExact(this.extend(request, params));
|
|
2602
2612
|
}
|
|
2603
2613
|
}
|
|
2604
2614
|
else if (market['inverse']) {
|
|
2605
2615
|
if (marketType === 'future') {
|
|
2606
|
-
method = 'contractPrivatePostApiV3ContractMatchresultsExact';
|
|
2607
2616
|
request['symbol'] = market['settleId'];
|
|
2617
|
+
response = await this.contractPrivatePostApiV3ContractMatchresultsExact(this.extend(request, params));
|
|
2608
2618
|
}
|
|
2609
2619
|
else if (marketType === 'swap') {
|
|
2610
|
-
|
|
2620
|
+
response = await this.contractPrivatePostSwapApiV3SwapMatchresultsExact(this.extend(request, params));
|
|
2611
2621
|
}
|
|
2612
2622
|
else {
|
|
2613
2623
|
throw new errors.NotSupported(this.id + ' fetchMyTrades() does not support ' + marketType + ' markets');
|
|
2614
2624
|
}
|
|
2615
2625
|
}
|
|
2616
2626
|
}
|
|
2617
|
-
const response = await this[method](this.extend(request, params));
|
|
2618
2627
|
//
|
|
2619
2628
|
// spot
|
|
2620
2629
|
//
|
|
@@ -2708,31 +2717,33 @@ class htx extends htx$1 {
|
|
|
2708
2717
|
// 'symbol': market['id'], // spot, future
|
|
2709
2718
|
// 'contract_code': market['id'], // swap
|
|
2710
2719
|
};
|
|
2711
|
-
|
|
2712
|
-
|
|
2720
|
+
if (limit !== undefined) {
|
|
2721
|
+
request['size'] = Math.min(limit, 2000); // max 2000
|
|
2722
|
+
}
|
|
2723
|
+
let response = undefined;
|
|
2713
2724
|
if (market['future']) {
|
|
2714
2725
|
if (market['inverse']) {
|
|
2715
|
-
|
|
2726
|
+
request['symbol'] = market['id'];
|
|
2727
|
+
response = await this.contractPublicGetMarketHistoryTrade(this.extend(request, params));
|
|
2716
2728
|
}
|
|
2717
2729
|
else if (market['linear']) {
|
|
2718
|
-
|
|
2719
|
-
|
|
2730
|
+
request['contract_code'] = market['id'];
|
|
2731
|
+
response = await this.contractPublicGetLinearSwapExMarketHistoryTrade(this.extend(request, params));
|
|
2720
2732
|
}
|
|
2721
2733
|
}
|
|
2722
2734
|
else if (market['swap']) {
|
|
2735
|
+
request['contract_code'] = market['id'];
|
|
2723
2736
|
if (market['inverse']) {
|
|
2724
|
-
|
|
2737
|
+
response = await this.contractPublicGetSwapExMarketHistoryTrade(this.extend(request, params));
|
|
2725
2738
|
}
|
|
2726
2739
|
else if (market['linear']) {
|
|
2727
|
-
|
|
2740
|
+
response = await this.contractPublicGetLinearSwapExMarketHistoryTrade(this.extend(request, params));
|
|
2728
2741
|
}
|
|
2729
|
-
fieldName = 'contract_code';
|
|
2730
2742
|
}
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2743
|
+
else {
|
|
2744
|
+
request['symbol'] = market['id'];
|
|
2745
|
+
response = await this.spotPublicGetMarketHistoryTrade(this.extend(request, params));
|
|
2734
2746
|
}
|
|
2735
|
-
const response = await this[method](this.extend(request, params));
|
|
2736
2747
|
//
|
|
2737
2748
|
// {
|
|
2738
2749
|
// "status": "ok",
|
|
@@ -2823,109 +2834,111 @@ class htx extends htx$1 {
|
|
|
2823
2834
|
// 'from': parseInt ((since / 1000).toString ()), spot only
|
|
2824
2835
|
// 'to': this.seconds (), spot only
|
|
2825
2836
|
};
|
|
2826
|
-
let fieldName = 'symbol';
|
|
2827
2837
|
const price = this.safeString(params, 'price');
|
|
2828
2838
|
params = this.omit(params, 'price');
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
//
|
|
2833
|
-
// https://github.com/ccxt/ccxt/issues/18006
|
|
2834
|
-
method = 'spotPublicGetMarketHistoryKline';
|
|
2839
|
+
if (market['contract']) {
|
|
2840
|
+
if (limit !== undefined) {
|
|
2841
|
+
request['size'] = limit; // when using limit from and to are ignored
|
|
2842
|
+
// https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
|
|
2835
2843
|
}
|
|
2836
|
-
|
|
2837
|
-
|
|
2844
|
+
else {
|
|
2845
|
+
limit = 2000; // only used for from/to calculation
|
|
2838
2846
|
}
|
|
2839
|
-
if (
|
|
2840
|
-
|
|
2847
|
+
if (price === undefined) {
|
|
2848
|
+
const duration = this.parseTimeframe(timeframe);
|
|
2849
|
+
if (since === undefined) {
|
|
2850
|
+
const now = this.seconds();
|
|
2851
|
+
request['from'] = now - duration * (limit - 1);
|
|
2852
|
+
request['to'] = now;
|
|
2853
|
+
}
|
|
2854
|
+
else {
|
|
2855
|
+
const start = this.parseToInt(since / 1000);
|
|
2856
|
+
request['from'] = start;
|
|
2857
|
+
request['to'] = this.sum(start, duration * (limit - 1));
|
|
2858
|
+
}
|
|
2841
2859
|
}
|
|
2842
2860
|
}
|
|
2843
|
-
|
|
2861
|
+
let response = undefined;
|
|
2862
|
+
if (market['future']) {
|
|
2844
2863
|
if (market['inverse']) {
|
|
2864
|
+
request['symbol'] = market['id'];
|
|
2845
2865
|
if (price === 'mark') {
|
|
2846
|
-
|
|
2866
|
+
response = await this.contractPublicGetIndexMarketHistoryMarkPriceKline(this.extend(request, params));
|
|
2847
2867
|
}
|
|
2848
2868
|
else if (price === 'index') {
|
|
2849
|
-
|
|
2869
|
+
response = await this.contractPublicGetIndexMarketHistoryIndex(this.extend(request, params));
|
|
2850
2870
|
}
|
|
2851
2871
|
else if (price === 'premiumIndex') {
|
|
2852
2872
|
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
|
|
2853
2873
|
}
|
|
2854
2874
|
else {
|
|
2855
|
-
|
|
2875
|
+
response = await this.contractPublicGetMarketHistoryKline(this.extend(request, params));
|
|
2856
2876
|
}
|
|
2857
2877
|
}
|
|
2858
2878
|
else if (market['linear']) {
|
|
2879
|
+
request['contract_code'] = market['id'];
|
|
2859
2880
|
if (price === 'mark') {
|
|
2860
|
-
|
|
2881
|
+
response = await this.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(this.extend(request, params));
|
|
2861
2882
|
}
|
|
2862
2883
|
else if (price === 'index') {
|
|
2863
2884
|
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
|
|
2864
2885
|
}
|
|
2865
2886
|
else if (price === 'premiumIndex') {
|
|
2866
|
-
|
|
2887
|
+
response = await this.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(this.extend(request, params));
|
|
2867
2888
|
}
|
|
2868
2889
|
else {
|
|
2869
|
-
|
|
2890
|
+
response = await this.contractPublicGetLinearSwapExMarketHistoryKline(this.extend(request, params));
|
|
2870
2891
|
}
|
|
2871
|
-
fieldName = 'contract_code';
|
|
2872
2892
|
}
|
|
2873
2893
|
}
|
|
2874
2894
|
else if (market['swap']) {
|
|
2895
|
+
request['contract_code'] = market['id'];
|
|
2875
2896
|
if (market['inverse']) {
|
|
2876
2897
|
if (price === 'mark') {
|
|
2877
|
-
|
|
2898
|
+
response = await this.contractPublicGetIndexMarketHistorySwapMarkPriceKline(this.extend(request, params));
|
|
2878
2899
|
}
|
|
2879
2900
|
else if (price === 'index') {
|
|
2880
2901
|
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
|
|
2881
2902
|
}
|
|
2882
2903
|
else if (price === 'premiumIndex') {
|
|
2883
|
-
|
|
2904
|
+
response = await this.contractPublicGetIndexMarketHistorySwapPremiumIndexKline(this.extend(request, params));
|
|
2884
2905
|
}
|
|
2885
2906
|
else {
|
|
2886
|
-
|
|
2907
|
+
response = await this.contractPublicGetSwapExMarketHistoryKline(this.extend(request, params));
|
|
2887
2908
|
}
|
|
2888
2909
|
}
|
|
2889
2910
|
else if (market['linear']) {
|
|
2890
2911
|
if (price === 'mark') {
|
|
2891
|
-
|
|
2912
|
+
response = await this.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(this.extend(request, params));
|
|
2892
2913
|
}
|
|
2893
2914
|
else if (price === 'index') {
|
|
2894
2915
|
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
|
|
2895
2916
|
}
|
|
2896
2917
|
else if (price === 'premiumIndex') {
|
|
2897
|
-
|
|
2918
|
+
response = await this.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(this.extend(request, params));
|
|
2898
2919
|
}
|
|
2899
2920
|
else {
|
|
2900
|
-
|
|
2921
|
+
response = await this.contractPublicGetLinearSwapExMarketHistoryKline(this.extend(request, params));
|
|
2901
2922
|
}
|
|
2902
2923
|
}
|
|
2903
|
-
fieldName = 'contract_code';
|
|
2904
2924
|
}
|
|
2905
|
-
|
|
2925
|
+
else {
|
|
2926
|
+
if (since !== undefined) {
|
|
2927
|
+
request['from'] = this.parseToInt(since / 1000);
|
|
2928
|
+
}
|
|
2906
2929
|
if (limit !== undefined) {
|
|
2907
|
-
request['size'] = limit; //
|
|
2908
|
-
// https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
|
|
2930
|
+
request['size'] = limit; // max 2000
|
|
2909
2931
|
}
|
|
2910
|
-
|
|
2911
|
-
|
|
2932
|
+
request['symbol'] = market['id'];
|
|
2933
|
+
if (timeframe === '1M' || timeframe === '1y') {
|
|
2934
|
+
// for some reason 1M and 1Y does not work with the regular endpoint
|
|
2935
|
+
// https://github.com/ccxt/ccxt/issues/18006
|
|
2936
|
+
response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
|
|
2912
2937
|
}
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
if (since === undefined) {
|
|
2916
|
-
const now = this.seconds();
|
|
2917
|
-
request['from'] = now - duration * (limit - 1);
|
|
2918
|
-
request['to'] = now;
|
|
2919
|
-
}
|
|
2920
|
-
else {
|
|
2921
|
-
const start = this.parseToInt(since / 1000);
|
|
2922
|
-
request['from'] = start;
|
|
2923
|
-
request['to'] = this.sum(start, duration * (limit - 1));
|
|
2924
|
-
}
|
|
2938
|
+
else {
|
|
2939
|
+
response = await this.spotPublicGetMarketHistoryCandles(this.extend(request, params));
|
|
2925
2940
|
}
|
|
2926
2941
|
}
|
|
2927
|
-
request[fieldName] = market['id'];
|
|
2928
|
-
const response = await this[method](this.extend(request, params));
|
|
2929
2942
|
//
|
|
2930
2943
|
// {
|
|
2931
2944
|
// "status":"ok",
|
|
@@ -3542,58 +3555,57 @@ class htx extends htx$1 {
|
|
|
3542
3555
|
// 'pair': 'BTC-USDT',
|
|
3543
3556
|
// 'contract_type': 'this_week', // swap, this_week, next_week, quarter, next_ quarter
|
|
3544
3557
|
};
|
|
3545
|
-
let
|
|
3558
|
+
let response = undefined;
|
|
3546
3559
|
if (marketType === 'spot') {
|
|
3547
3560
|
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
3548
|
-
method = 'spotPrivateGetV1OrderOrdersOrderId';
|
|
3549
3561
|
if (clientOrderId !== undefined) {
|
|
3550
|
-
method = 'spotPrivateGetV1OrderOrdersGetClientOrder';
|
|
3551
3562
|
// will be filled below in extend ()
|
|
3552
3563
|
// they expect clientOrderId instead of client-order-id
|
|
3553
3564
|
// request['clientOrderId'] = clientOrderId;
|
|
3565
|
+
response = await this.spotPrivateGetV1OrderOrdersGetClientOrder(this.extend(request, params));
|
|
3554
3566
|
}
|
|
3555
3567
|
else {
|
|
3556
3568
|
request['order-id'] = id;
|
|
3569
|
+
response = await this.spotPrivateGetV1OrderOrdersOrderId(this.extend(request, params));
|
|
3557
3570
|
}
|
|
3558
3571
|
}
|
|
3559
3572
|
else {
|
|
3560
3573
|
if (symbol === undefined) {
|
|
3561
3574
|
throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
3562
3575
|
}
|
|
3576
|
+
const clientOrderId = this.safeString2(params, 'client_order_id', 'clientOrderId');
|
|
3577
|
+
if (clientOrderId === undefined) {
|
|
3578
|
+
request['order_id'] = id;
|
|
3579
|
+
}
|
|
3580
|
+
else {
|
|
3581
|
+
request['client_order_id'] = clientOrderId;
|
|
3582
|
+
params = this.omit(params, ['client_order_id', 'clientOrderId']);
|
|
3583
|
+
}
|
|
3563
3584
|
request['contract_code'] = market['id'];
|
|
3564
3585
|
if (market['linear']) {
|
|
3565
3586
|
let marginMode = undefined;
|
|
3566
3587
|
[marginMode, params] = this.handleMarginModeAndParams('fetchOrder', params);
|
|
3567
3588
|
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
3568
3589
|
if (marginMode === 'isolated') {
|
|
3569
|
-
|
|
3590
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapOrderInfo(this.extend(request, params));
|
|
3570
3591
|
}
|
|
3571
3592
|
else if (marginMode === 'cross') {
|
|
3572
|
-
|
|
3593
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrderInfo(this.extend(request, params));
|
|
3573
3594
|
}
|
|
3574
3595
|
}
|
|
3575
3596
|
else if (market['inverse']) {
|
|
3576
3597
|
if (marketType === 'future') {
|
|
3577
|
-
method = 'contractPrivatePostApiV1ContractOrderInfo';
|
|
3578
3598
|
request['symbol'] = market['settleId'];
|
|
3599
|
+
response = await this.contractPrivatePostApiV1ContractOrderInfo(this.extend(request, params));
|
|
3579
3600
|
}
|
|
3580
3601
|
else if (marketType === 'swap') {
|
|
3581
|
-
|
|
3602
|
+
response = await this.contractPrivatePostSwapApiV1SwapOrderInfo(this.extend(request, params));
|
|
3582
3603
|
}
|
|
3583
3604
|
else {
|
|
3584
3605
|
throw new errors.NotSupported(this.id + ' fetchOrder() does not support ' + marketType + ' markets');
|
|
3585
3606
|
}
|
|
3586
3607
|
}
|
|
3587
|
-
const clientOrderId = this.safeString2(params, 'client_order_id', 'clientOrderId');
|
|
3588
|
-
if (clientOrderId === undefined) {
|
|
3589
|
-
request['order_id'] = id;
|
|
3590
|
-
}
|
|
3591
|
-
else {
|
|
3592
|
-
request['client_order_id'] = clientOrderId;
|
|
3593
|
-
params = this.omit(params, ['client_order_id', 'clientOrderId']);
|
|
3594
|
-
}
|
|
3595
3608
|
}
|
|
3596
|
-
const response = await this[method](this.extend(request, params));
|
|
3597
3609
|
//
|
|
3598
3610
|
// spot
|
|
3599
3611
|
//
|
|
@@ -6292,7 +6304,6 @@ class htx extends htx$1 {
|
|
|
6292
6304
|
};
|
|
6293
6305
|
let subType = undefined;
|
|
6294
6306
|
[subType, params] = this.handleSubTypeAndParams('transfer', undefined, params);
|
|
6295
|
-
let method = undefined;
|
|
6296
6307
|
let fromAccountId = this.convertTypeToAccount(fromAccount);
|
|
6297
6308
|
let toAccountId = this.convertTypeToAccount(toAccount);
|
|
6298
6309
|
const toCross = toAccountId === 'cross';
|
|
@@ -6305,28 +6316,28 @@ class htx extends htx$1 {
|
|
|
6305
6316
|
throw new errors.BadRequest(this.id + ' transfer () cannot make a transfer between ' + fromAccount + ' and ' + toAccount);
|
|
6306
6317
|
}
|
|
6307
6318
|
const fromOrToFuturesAccount = (fromAccountId === 'futures') || (toAccountId === 'futures');
|
|
6319
|
+
let response = undefined;
|
|
6308
6320
|
if (fromOrToFuturesAccount) {
|
|
6309
6321
|
let type = fromAccountId + '-to-' + toAccountId;
|
|
6310
6322
|
type = this.safeString(params, 'type', type);
|
|
6311
6323
|
request['type'] = type;
|
|
6312
|
-
|
|
6324
|
+
response = await this.spotPrivatePostV1FuturesTransfer(this.extend(request, params));
|
|
6313
6325
|
}
|
|
6314
6326
|
else if (fromSpot && toCross) {
|
|
6315
|
-
|
|
6327
|
+
response = await this.privatePostCrossMarginTransferIn(this.extend(request, params));
|
|
6316
6328
|
}
|
|
6317
6329
|
else if (fromCross && toSpot) {
|
|
6318
|
-
|
|
6330
|
+
response = await this.privatePostCrossMarginTransferOut(this.extend(request, params));
|
|
6319
6331
|
}
|
|
6320
6332
|
else if (fromSpot && toIsolated) {
|
|
6321
6333
|
request['symbol'] = toAccountId;
|
|
6322
|
-
|
|
6334
|
+
response = await this.privatePostDwTransferInMargin(this.extend(request, params));
|
|
6323
6335
|
}
|
|
6324
6336
|
else if (fromIsolated && toSpot) {
|
|
6325
6337
|
request['symbol'] = fromAccountId;
|
|
6326
|
-
|
|
6338
|
+
response = await this.privatePostDwTransferOutMargin(this.extend(request, params));
|
|
6327
6339
|
}
|
|
6328
6340
|
else {
|
|
6329
|
-
method = 'v2PrivatePostAccountTransfer';
|
|
6330
6341
|
if (subType === 'linear') {
|
|
6331
6342
|
if ((fromAccountId === 'swap') || (fromAccount === 'linear-swap')) {
|
|
6332
6343
|
fromAccountId = 'linear-swap';
|
|
@@ -6347,8 +6358,8 @@ class htx extends htx$1 {
|
|
|
6347
6358
|
}
|
|
6348
6359
|
request['from'] = fromSpot ? 'spot' : fromAccountId;
|
|
6349
6360
|
request['to'] = toSpot ? 'spot' : toAccountId;
|
|
6361
|
+
response = await this.v2PrivatePostAccountTransfer(this.extend(request, params));
|
|
6350
6362
|
}
|
|
6351
|
-
const response = await this[method](this.extend(request, params));
|
|
6352
6363
|
//
|
|
6353
6364
|
// {
|
|
6354
6365
|
// "code": "200",
|
|
@@ -6475,17 +6486,16 @@ class htx extends htx$1 {
|
|
|
6475
6486
|
const request = {
|
|
6476
6487
|
'contract_code': market['id'],
|
|
6477
6488
|
};
|
|
6478
|
-
let
|
|
6489
|
+
let response = undefined;
|
|
6479
6490
|
if (market['inverse']) {
|
|
6480
|
-
|
|
6491
|
+
response = await this.contractPublicGetSwapApiV1SwapHistoricalFundingRate(this.extend(request, params));
|
|
6481
6492
|
}
|
|
6482
6493
|
else if (market['linear']) {
|
|
6483
|
-
|
|
6494
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapHistoricalFundingRate(this.extend(request, params));
|
|
6484
6495
|
}
|
|
6485
6496
|
else {
|
|
6486
6497
|
throw new errors.NotSupported(this.id + ' fetchFundingRateHistory() supports inverse and linear swaps only');
|
|
6487
6498
|
}
|
|
6488
|
-
const response = await this[method](this.extend(request, params));
|
|
6489
6499
|
//
|
|
6490
6500
|
// {
|
|
6491
6501
|
// "status": "ok",
|
|
@@ -6581,20 +6591,19 @@ class htx extends htx$1 {
|
|
|
6581
6591
|
*/
|
|
6582
6592
|
await this.loadMarkets();
|
|
6583
6593
|
const market = this.market(symbol);
|
|
6584
|
-
|
|
6594
|
+
const request = {
|
|
6595
|
+
'contract_code': market['id'],
|
|
6596
|
+
};
|
|
6597
|
+
let response = undefined;
|
|
6585
6598
|
if (market['inverse']) {
|
|
6586
|
-
|
|
6599
|
+
response = await this.contractPublicGetSwapApiV1SwapFundingRate(this.extend(request, params));
|
|
6587
6600
|
}
|
|
6588
6601
|
else if (market['linear']) {
|
|
6589
|
-
|
|
6602
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapFundingRate(this.extend(request, params));
|
|
6590
6603
|
}
|
|
6591
6604
|
else {
|
|
6592
6605
|
throw new errors.NotSupported(this.id + ' fetchFundingRate() supports inverse and linear swaps only');
|
|
6593
6606
|
}
|
|
6594
|
-
const request = {
|
|
6595
|
-
'contract_code': market['id'],
|
|
6596
|
-
};
|
|
6597
|
-
const response = await this[method](this.extend(request, params));
|
|
6598
6607
|
//
|
|
6599
6608
|
// {
|
|
6600
6609
|
// "status": "ok",
|
|
@@ -6631,12 +6640,17 @@ class htx extends htx$1 {
|
|
|
6631
6640
|
const request = {
|
|
6632
6641
|
// 'contract_code': market['id'],
|
|
6633
6642
|
};
|
|
6634
|
-
const method = this.getSupportedMapping(subType, {
|
|
6635
|
-
'linear': 'contractPublicGetLinearSwapApiV1SwapBatchFundingRate',
|
|
6636
|
-
'inverse': 'contractPublicGetSwapApiV1SwapBatchFundingRate',
|
|
6637
|
-
});
|
|
6638
6643
|
params = this.omit(params, 'subType');
|
|
6639
|
-
|
|
6644
|
+
let response = undefined;
|
|
6645
|
+
if (subType === 'linear') {
|
|
6646
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapBatchFundingRate(this.extend(request, params));
|
|
6647
|
+
}
|
|
6648
|
+
else if (subType === 'inverse') {
|
|
6649
|
+
response = await this.contractPublicGetSwapApiV1SwapBatchFundingRate(this.extend(request, params));
|
|
6650
|
+
}
|
|
6651
|
+
else {
|
|
6652
|
+
throw new errors.NotSupported(this.id + ' fetchFundingRates() not support this market type');
|
|
6653
|
+
}
|
|
6640
6654
|
//
|
|
6641
6655
|
// {
|
|
6642
6656
|
// "status": "ok",
|
|
@@ -6683,22 +6697,21 @@ class htx extends htx$1 {
|
|
|
6683
6697
|
request['size'] = limit;
|
|
6684
6698
|
}
|
|
6685
6699
|
let market = undefined;
|
|
6686
|
-
let
|
|
6700
|
+
let response = undefined;
|
|
6687
6701
|
if (marginMode === 'isolated') {
|
|
6688
|
-
method = 'privateGetMarginLoanOrders';
|
|
6689
6702
|
if (symbol !== undefined) {
|
|
6690
6703
|
market = this.market(symbol);
|
|
6691
6704
|
request['symbol'] = market['id'];
|
|
6692
6705
|
}
|
|
6706
|
+
response = await this.privateGetMarginLoanOrders(this.extend(request, params));
|
|
6693
6707
|
}
|
|
6694
6708
|
else { // Cross
|
|
6695
|
-
method = 'privateGetCrossMarginLoanOrders';
|
|
6696
6709
|
if (code !== undefined) {
|
|
6697
6710
|
const currency = this.currency(code);
|
|
6698
6711
|
request['currency'] = currency['id'];
|
|
6699
6712
|
}
|
|
6713
|
+
response = await this.privateGetCrossMarginLoanOrders(this.extend(request, params));
|
|
6700
6714
|
}
|
|
6701
|
-
const response = await this[method](this.extend(request, params));
|
|
6702
6715
|
//
|
|
6703
6716
|
// {
|
|
6704
6717
|
// "status":"ok",
|
|
@@ -6961,17 +6974,16 @@ class htx extends htx$1 {
|
|
|
6961
6974
|
await this.loadMarkets();
|
|
6962
6975
|
const market = this.market(symbol);
|
|
6963
6976
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchFundingHistory', market, params);
|
|
6964
|
-
let method = undefined;
|
|
6965
6977
|
const request = {
|
|
6966
6978
|
'type': '30,31',
|
|
6967
6979
|
};
|
|
6968
6980
|
if (since !== undefined) {
|
|
6969
6981
|
request['start_date'] = since;
|
|
6970
6982
|
}
|
|
6983
|
+
let response = undefined;
|
|
6971
6984
|
if (marketType === 'swap') {
|
|
6972
6985
|
request['contract'] = market['id'];
|
|
6973
6986
|
if (market['linear']) {
|
|
6974
|
-
method = 'contractPrivatePostLinearSwapApiV3SwapFinancialRecordExact';
|
|
6975
6987
|
//
|
|
6976
6988
|
// {
|
|
6977
6989
|
// "status": "ok",
|
|
@@ -7003,9 +7015,9 @@ class htx extends htx$1 {
|
|
|
7003
7015
|
else {
|
|
7004
7016
|
request['mar_acct'] = market['quoteId'];
|
|
7005
7017
|
}
|
|
7018
|
+
response = await this.contractPrivatePostLinearSwapApiV3SwapFinancialRecordExact(this.extend(request, query));
|
|
7006
7019
|
}
|
|
7007
7020
|
else {
|
|
7008
|
-
method = 'contractPrivatePostSwapApiV3SwapFinancialRecordExact';
|
|
7009
7021
|
//
|
|
7010
7022
|
// {
|
|
7011
7023
|
// "code": 200,
|
|
@@ -7026,13 +7038,13 @@ class htx extends htx$1 {
|
|
|
7026
7038
|
// "ts": 1604312615051
|
|
7027
7039
|
// }
|
|
7028
7040
|
//
|
|
7041
|
+
response = await this.contractPrivatePostSwapApiV3SwapFinancialRecordExact(this.extend(request, query));
|
|
7029
7042
|
}
|
|
7030
7043
|
}
|
|
7031
7044
|
else {
|
|
7032
|
-
method = 'contractPrivatePostApiV3ContractFinancialRecordExact';
|
|
7033
7045
|
request['symbol'] = market['id'];
|
|
7046
|
+
response = await this.contractPrivatePostApiV3ContractFinancialRecordExact(this.extend(request, query));
|
|
7034
7047
|
}
|
|
7035
|
-
const response = await this[method](this.extend(request, query));
|
|
7036
7048
|
const data = this.safeValue(response, 'data', []);
|
|
7037
7049
|
return this.parseIncomes(data, market, since, limit);
|
|
7038
7050
|
}
|
|
@@ -7052,15 +7064,29 @@ class htx extends htx$1 {
|
|
|
7052
7064
|
await this.loadMarkets();
|
|
7053
7065
|
const market = this.market(symbol);
|
|
7054
7066
|
const [marketType, query] = this.handleMarketTypeAndParams('setLeverage', market, params);
|
|
7055
|
-
|
|
7067
|
+
const request = {
|
|
7068
|
+
'lever_rate': leverage,
|
|
7069
|
+
};
|
|
7070
|
+
if (marketType === 'future' && market['inverse']) {
|
|
7071
|
+
request['symbol'] = market['settleId'];
|
|
7072
|
+
}
|
|
7073
|
+
else {
|
|
7074
|
+
request['contract_code'] = market['id'];
|
|
7075
|
+
}
|
|
7076
|
+
let response = undefined;
|
|
7056
7077
|
if (market['linear']) {
|
|
7057
7078
|
let marginMode = undefined;
|
|
7058
7079
|
[marginMode, params] = this.handleMarginModeAndParams('setLeverage', params);
|
|
7059
7080
|
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7081
|
+
if (marginMode === 'isolated') {
|
|
7082
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapSwitchLeverRate(this.extend(request, query));
|
|
7083
|
+
}
|
|
7084
|
+
else if (marginMode === 'cross') {
|
|
7085
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossSwitchLeverRate(this.extend(request, query));
|
|
7086
|
+
}
|
|
7087
|
+
else {
|
|
7088
|
+
throw new errors.NotSupported(this.id + ' setLeverage() not support this market type');
|
|
7089
|
+
}
|
|
7064
7090
|
//
|
|
7065
7091
|
// {
|
|
7066
7092
|
// "status": "ok",
|
|
@@ -7074,10 +7100,15 @@ class htx extends htx$1 {
|
|
|
7074
7100
|
//
|
|
7075
7101
|
}
|
|
7076
7102
|
else {
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7103
|
+
if (marketType === 'future') {
|
|
7104
|
+
response = await this.contractPrivatePostApiV1ContractSwitchLeverRate(this.extend(request, query));
|
|
7105
|
+
}
|
|
7106
|
+
else if (marketType === 'swap') {
|
|
7107
|
+
response = await this.contractPrivatePostSwapApiV1SwapSwitchLeverRate(this.extend(request, query));
|
|
7108
|
+
}
|
|
7109
|
+
else {
|
|
7110
|
+
throw new errors.NotSupported(this.id + ' setLeverage() not support this market type');
|
|
7111
|
+
}
|
|
7081
7112
|
//
|
|
7082
7113
|
// future
|
|
7083
7114
|
// {
|
|
@@ -7095,16 +7126,6 @@ class htx extends htx$1 {
|
|
|
7095
7126
|
// }
|
|
7096
7127
|
//
|
|
7097
7128
|
}
|
|
7098
|
-
const request = {
|
|
7099
|
-
'lever_rate': leverage,
|
|
7100
|
-
};
|
|
7101
|
-
if (marketType === 'future' && market['inverse']) {
|
|
7102
|
-
request['symbol'] = market['settleId'];
|
|
7103
|
-
}
|
|
7104
|
-
else {
|
|
7105
|
-
request['contract_code'] = market['id'];
|
|
7106
|
-
}
|
|
7107
|
-
const response = await this[method](this.extend(request, query));
|
|
7108
7129
|
return response;
|
|
7109
7130
|
}
|
|
7110
7131
|
parseIncome(income, market = undefined) {
|
|
@@ -7252,12 +7273,17 @@ class htx extends htx$1 {
|
|
|
7252
7273
|
if (marketType === 'spot') {
|
|
7253
7274
|
marketType = 'future';
|
|
7254
7275
|
}
|
|
7255
|
-
let
|
|
7276
|
+
let response = undefined;
|
|
7256
7277
|
if (subType === 'linear') {
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7278
|
+
if (marginMode === 'isolated') {
|
|
7279
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapPositionInfo(params);
|
|
7280
|
+
}
|
|
7281
|
+
else if (marginMode === 'cross') {
|
|
7282
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossPositionInfo(params);
|
|
7283
|
+
}
|
|
7284
|
+
else {
|
|
7285
|
+
throw new errors.NotSupported(this.id + ' fetchPositions() not support this market type');
|
|
7286
|
+
}
|
|
7261
7287
|
//
|
|
7262
7288
|
// {
|
|
7263
7289
|
// "status": "ok",
|
|
@@ -7287,10 +7313,15 @@ class htx extends htx$1 {
|
|
|
7287
7313
|
//
|
|
7288
7314
|
}
|
|
7289
7315
|
else {
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7316
|
+
if (marketType === 'future') {
|
|
7317
|
+
response = await this.contractPrivatePostApiV1ContractPositionInfo(params);
|
|
7318
|
+
}
|
|
7319
|
+
else if (marketType === 'swap') {
|
|
7320
|
+
response = await this.contractPrivatePostSwapApiV1SwapPositionInfo(params);
|
|
7321
|
+
}
|
|
7322
|
+
else {
|
|
7323
|
+
throw new errors.NotSupported(this.id + ' fetchPositions() not support this market type');
|
|
7324
|
+
}
|
|
7294
7325
|
//
|
|
7295
7326
|
// future
|
|
7296
7327
|
// {
|
|
@@ -7342,7 +7373,6 @@ class htx extends htx$1 {
|
|
|
7342
7373
|
// }
|
|
7343
7374
|
//
|
|
7344
7375
|
}
|
|
7345
|
-
const response = await this[method](params);
|
|
7346
7376
|
const data = this.safeValue(response, 'data', []);
|
|
7347
7377
|
const timestamp = this.safeInteger(response, 'ts');
|
|
7348
7378
|
const result = [];
|
|
@@ -7371,12 +7401,27 @@ class htx extends htx$1 {
|
|
|
7371
7401
|
[marginMode, params] = this.handleMarginModeAndParams('fetchPosition', params);
|
|
7372
7402
|
marginMode = (marginMode === undefined) ? 'cross' : marginMode;
|
|
7373
7403
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchPosition', market, params);
|
|
7374
|
-
|
|
7404
|
+
const request = {};
|
|
7405
|
+
if (market['future'] && market['inverse']) {
|
|
7406
|
+
request['symbol'] = market['settleId'];
|
|
7407
|
+
}
|
|
7408
|
+
else {
|
|
7409
|
+
if (marginMode === 'cross') {
|
|
7410
|
+
request['margin_account'] = 'USDT'; // only allowed value
|
|
7411
|
+
}
|
|
7412
|
+
request['contract_code'] = market['id'];
|
|
7413
|
+
}
|
|
7414
|
+
let response = undefined;
|
|
7375
7415
|
if (market['linear']) {
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7416
|
+
if (marginMode === 'isolated') {
|
|
7417
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapAccountPositionInfo(this.extend(request, query));
|
|
7418
|
+
}
|
|
7419
|
+
else if (marginMode === 'cross') {
|
|
7420
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossAccountPositionInfo(this.extend(request, query));
|
|
7421
|
+
}
|
|
7422
|
+
else {
|
|
7423
|
+
throw new errors.NotSupported(this.id + ' fetchPosition() not support this market type');
|
|
7424
|
+
}
|
|
7380
7425
|
//
|
|
7381
7426
|
// isolated
|
|
7382
7427
|
//
|
|
@@ -7496,10 +7541,15 @@ class htx extends htx$1 {
|
|
|
7496
7541
|
//
|
|
7497
7542
|
}
|
|
7498
7543
|
else {
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7544
|
+
if (marketType === 'future') {
|
|
7545
|
+
response = await this.contractPrivatePostApiV1ContractAccountPositionInfo(this.extend(request, query));
|
|
7546
|
+
}
|
|
7547
|
+
else if (marketType === 'swap') {
|
|
7548
|
+
response = await this.contractPrivatePostSwapApiV1SwapAccountPositionInfo(this.extend(request, query));
|
|
7549
|
+
}
|
|
7550
|
+
else {
|
|
7551
|
+
throw new errors.NotSupported(this.id + ' setLeverage() not support this market type');
|
|
7552
|
+
}
|
|
7503
7553
|
//
|
|
7504
7554
|
// future, swap
|
|
7505
7555
|
//
|
|
@@ -7570,17 +7620,6 @@ class htx extends htx$1 {
|
|
|
7570
7620
|
// }
|
|
7571
7621
|
//
|
|
7572
7622
|
}
|
|
7573
|
-
const request = {};
|
|
7574
|
-
if (market['future'] && market['inverse']) {
|
|
7575
|
-
request['symbol'] = market['settleId'];
|
|
7576
|
-
}
|
|
7577
|
-
else {
|
|
7578
|
-
if (marginMode === 'cross') {
|
|
7579
|
-
request['margin_account'] = 'USDT'; // only allowed value
|
|
7580
|
-
}
|
|
7581
|
-
request['contract_code'] = market['id'];
|
|
7582
|
-
}
|
|
7583
|
-
const response = await this[method](this.extend(request, query));
|
|
7584
7623
|
const data = this.safeValue(response, 'data');
|
|
7585
7624
|
let account = undefined;
|
|
7586
7625
|
if (marginMode === 'cross') {
|
|
@@ -7911,26 +7950,28 @@ class htx extends htx$1 {
|
|
|
7911
7950
|
'period': timeframes[timeframe],
|
|
7912
7951
|
'amount_type': amountType,
|
|
7913
7952
|
};
|
|
7914
|
-
|
|
7953
|
+
if (limit !== undefined) {
|
|
7954
|
+
request['size'] = limit;
|
|
7955
|
+
}
|
|
7956
|
+
let response = undefined;
|
|
7915
7957
|
if (market['future']) {
|
|
7916
7958
|
request['contract_type'] = this.safeString(market['info'], 'contract_type');
|
|
7917
7959
|
request['symbol'] = market['baseId']; // currency code on coin-m futures
|
|
7918
|
-
|
|
7960
|
+
// coin-m futures
|
|
7961
|
+
response = await this.contractPublicGetApiV1ContractHisOpenInterest(this.extend(request, params));
|
|
7919
7962
|
}
|
|
7920
7963
|
else if (market['linear']) {
|
|
7921
7964
|
request['contract_type'] = 'swap';
|
|
7922
7965
|
request['contract_code'] = market['id'];
|
|
7923
7966
|
request['contract_code'] = market['id'];
|
|
7924
|
-
|
|
7967
|
+
// USDT-M
|
|
7968
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapHisOpenInterest(this.extend(request, params));
|
|
7925
7969
|
}
|
|
7926
7970
|
else {
|
|
7927
7971
|
request['contract_code'] = market['id'];
|
|
7928
|
-
|
|
7972
|
+
// coin-m swaps
|
|
7973
|
+
response = await this.contractPublicGetSwapApiV1SwapHisOpenInterest(this.extend(request, params));
|
|
7929
7974
|
}
|
|
7930
|
-
if (limit !== undefined) {
|
|
7931
|
-
request['size'] = limit;
|
|
7932
|
-
}
|
|
7933
|
-
const response = await this[method](this.extend(request, params));
|
|
7934
7975
|
//
|
|
7935
7976
|
// contractPublicGetlinearSwapApiV1SwapHisOpenInterest
|
|
7936
7977
|
// {
|
|
@@ -8018,20 +8059,22 @@ class htx extends htx$1 {
|
|
|
8018
8059
|
const request = {
|
|
8019
8060
|
'contract_code': market['id'],
|
|
8020
8061
|
};
|
|
8021
|
-
let
|
|
8062
|
+
let response = undefined;
|
|
8022
8063
|
if (market['future']) {
|
|
8023
8064
|
request['contract_type'] = this.safeString(market['info'], 'contract_type');
|
|
8024
8065
|
request['symbol'] = market['baseId'];
|
|
8025
|
-
|
|
8066
|
+
// COIN-M futures
|
|
8067
|
+
response = await this.contractPublicGetApiV1ContractOpenInterest(this.extend(request, params));
|
|
8026
8068
|
}
|
|
8027
8069
|
else if (market['linear']) {
|
|
8028
8070
|
request['contract_type'] = 'swap';
|
|
8029
|
-
|
|
8071
|
+
// USDT-M
|
|
8072
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapOpenInterest(this.extend(request, params));
|
|
8030
8073
|
}
|
|
8031
8074
|
else {
|
|
8032
|
-
|
|
8075
|
+
// COIN-M swaps
|
|
8076
|
+
response = await this.contractPublicGetSwapApiV1SwapOpenInterest(this.extend(request, params));
|
|
8033
8077
|
}
|
|
8034
|
-
const response = await this[method](this.extend(request, params));
|
|
8035
8078
|
//
|
|
8036
8079
|
// USDT-M contractPublicGetLinearSwapApiV1SwapOpenInterest
|
|
8037
8080
|
//
|
|
@@ -8381,16 +8424,18 @@ class htx extends htx$1 {
|
|
|
8381
8424
|
if (until !== undefined) {
|
|
8382
8425
|
request['end_at'] = until;
|
|
8383
8426
|
}
|
|
8384
|
-
let
|
|
8427
|
+
let response = undefined;
|
|
8385
8428
|
if (market['swap']) {
|
|
8386
8429
|
if (market['linear']) {
|
|
8387
|
-
|
|
8430
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapSettlementRecords(this.extend(request, params));
|
|
8388
8431
|
}
|
|
8389
8432
|
else {
|
|
8390
|
-
|
|
8433
|
+
response = await this.contractPublicGetSwapApiV1SwapSettlementRecords(this.extend(request, params));
|
|
8391
8434
|
}
|
|
8392
8435
|
}
|
|
8393
|
-
|
|
8436
|
+
else {
|
|
8437
|
+
response = await this.contractPublicGetApiV1ContractSettlementRecords(this.extend(request, params));
|
|
8438
|
+
}
|
|
8394
8439
|
//
|
|
8395
8440
|
// linear swap, coin-m swap
|
|
8396
8441
|
//
|