ccxt 4.2.76 → 4.2.78
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 +1181 -643
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +6 -0
- package/dist/cjs/src/binance.js +502 -443
- package/dist/cjs/src/bingx.js +1 -1
- package/dist/cjs/src/blofin.js +14 -2
- package/dist/cjs/src/bybit.js +106 -60
- package/dist/cjs/src/coinbase.js +23 -10
- package/dist/cjs/src/delta.js +66 -49
- package/dist/cjs/src/gate.js +1 -0
- package/dist/cjs/src/htx.js +36 -27
- package/dist/cjs/src/hyperliquid.js +7 -5
- package/dist/cjs/src/kraken.js +8 -8
- package/dist/cjs/src/kucoin.js +204 -5
- package/dist/cjs/src/okcoin.js +27 -1
- package/dist/cjs/src/okx.js +18 -0
- package/dist/cjs/src/pro/ascendex.js +1 -1
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/coinex.js +20 -14
- package/dist/cjs/src/pro/deribit.js +1 -1
- package/dist/cjs/src/pro/exmo.js +1 -1
- package/dist/cjs/src/pro/krakenfutures.js +1 -1
- package/dist/cjs/src/pro/phemex.js +1 -1
- package/dist/cjs/src/pro/poloniex.js +1 -1
- package/dist/cjs/src/pro/probit.js +1 -1
- package/dist/cjs/src/pro/woo.js +61 -6
- package/dist/cjs/src/woo.js +72 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +3 -3
- package/js/src/base/Exchange.js +6 -0
- package/js/src/base/types.d.ts +3 -3
- package/js/src/binance.d.ts +2 -2
- package/js/src/binance.js +502 -443
- package/js/src/bingx.js +1 -1
- package/js/src/bitflyer.d.ts +2 -2
- package/js/src/bithumb.d.ts +2 -2
- package/js/src/blofin.js +14 -2
- package/js/src/bybit.d.ts +1 -1
- package/js/src/bybit.js +106 -60
- package/js/src/coinbase.d.ts +2 -2
- package/js/src/coinbase.js +23 -10
- package/js/src/delta.d.ts +2 -1
- package/js/src/delta.js +66 -49
- package/js/src/deribit.d.ts +1 -1
- package/js/src/gate.d.ts +1 -1
- package/js/src/gate.js +1 -0
- package/js/src/htx.js +36 -27
- package/js/src/hyperliquid.js +7 -5
- package/js/src/kraken.js +8 -8
- package/js/src/kucoin.d.ts +4 -1
- package/js/src/kucoin.js +204 -5
- package/js/src/okcoin.js +27 -1
- package/js/src/okx.d.ts +1 -1
- package/js/src/okx.js +18 -0
- package/js/src/pro/ascendex.js +1 -1
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/coinex.js +20 -14
- package/js/src/pro/deribit.js +1 -1
- package/js/src/pro/exmo.js +1 -1
- package/js/src/pro/krakenfutures.js +1 -1
- package/js/src/pro/phemex.js +1 -1
- package/js/src/pro/poloniex.js +1 -1
- package/js/src/pro/probit.js +1 -1
- package/js/src/pro/woo.d.ts +1 -0
- package/js/src/pro/woo.js +61 -6
- package/js/src/woo.d.ts +2 -0
- package/js/src/woo.js +72 -3
- package/package.json +1 -1
- package/skip-tests.json +6 -3
package/dist/cjs/src/delta.js
CHANGED
|
@@ -334,7 +334,7 @@ class delta extends delta$1 {
|
|
|
334
334
|
*/
|
|
335
335
|
const response = await this.publicGetSettings(params);
|
|
336
336
|
// full response sample under `fetchStatus`
|
|
337
|
-
const result = this.
|
|
337
|
+
const result = this.safeDict(response, 'result', {});
|
|
338
338
|
return this.safeIntegerProduct(result, 'server_time', 0.001);
|
|
339
339
|
}
|
|
340
340
|
async fetchStatus(params = {}) {
|
|
@@ -399,7 +399,7 @@ class delta extends delta$1 {
|
|
|
399
399
|
// "success": true
|
|
400
400
|
// }
|
|
401
401
|
//
|
|
402
|
-
const result = this.
|
|
402
|
+
const result = this.safeDict(response, 'result', {});
|
|
403
403
|
const underMaintenance = this.safeString(result, 'under_maintenance');
|
|
404
404
|
const status = (underMaintenance === 'true') ? 'maintenance' : 'ok';
|
|
405
405
|
const updated = this.safeIntegerProduct(result, 'server_time', 0.001, this.milliseconds());
|
|
@@ -451,7 +451,7 @@ class delta extends delta$1 {
|
|
|
451
451
|
// "success":true
|
|
452
452
|
// }
|
|
453
453
|
//
|
|
454
|
-
const currencies = this.
|
|
454
|
+
const currencies = this.safeList(response, 'result', []);
|
|
455
455
|
const result = {};
|
|
456
456
|
for (let i = 0; i < currencies.length; i++) {
|
|
457
457
|
const currency = currencies[i];
|
|
@@ -488,16 +488,33 @@ class delta extends delta$1 {
|
|
|
488
488
|
}
|
|
489
489
|
async loadMarkets(reload = false, params = {}) {
|
|
490
490
|
const markets = await super.loadMarkets(reload, params);
|
|
491
|
-
const currenciesByNumericId = this.
|
|
491
|
+
const currenciesByNumericId = this.safeDict(this.options, 'currenciesByNumericId');
|
|
492
492
|
if ((currenciesByNumericId === undefined) || reload) {
|
|
493
|
-
this.options['currenciesByNumericId'] = this.
|
|
493
|
+
this.options['currenciesByNumericId'] = this.indexByStringifiedNumericId(this.currencies);
|
|
494
494
|
}
|
|
495
|
-
const marketsByNumericId = this.
|
|
495
|
+
const marketsByNumericId = this.safeDict(this.options, 'marketsByNumericId');
|
|
496
496
|
if ((marketsByNumericId === undefined) || reload) {
|
|
497
|
-
this.options['marketsByNumericId'] = this.
|
|
497
|
+
this.options['marketsByNumericId'] = this.indexByStringifiedNumericId(this.markets);
|
|
498
498
|
}
|
|
499
499
|
return markets;
|
|
500
500
|
}
|
|
501
|
+
indexByStringifiedNumericId(input) {
|
|
502
|
+
const result = {};
|
|
503
|
+
if (input === undefined) {
|
|
504
|
+
return undefined;
|
|
505
|
+
}
|
|
506
|
+
const keys = Object.keys(input);
|
|
507
|
+
for (let i = 0; i < keys.length; i++) {
|
|
508
|
+
const key = keys[i];
|
|
509
|
+
const item = input[key];
|
|
510
|
+
const numericIdString = this.safeString(item, 'numericId');
|
|
511
|
+
if (numericIdString === undefined) {
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
result[numericIdString] = item;
|
|
515
|
+
}
|
|
516
|
+
return result;
|
|
517
|
+
}
|
|
501
518
|
async fetchMarkets(params = {}) {
|
|
502
519
|
/**
|
|
503
520
|
* @method
|
|
@@ -686,7 +703,7 @@ class delta extends delta$1 {
|
|
|
686
703
|
// "success":true
|
|
687
704
|
// }
|
|
688
705
|
//
|
|
689
|
-
const markets = this.
|
|
706
|
+
const markets = this.safeList(response, 'result', []);
|
|
690
707
|
const result = [];
|
|
691
708
|
for (let i = 0; i < markets.length; i++) {
|
|
692
709
|
const market = markets[i];
|
|
@@ -695,10 +712,10 @@ class delta extends delta$1 {
|
|
|
695
712
|
continue;
|
|
696
713
|
}
|
|
697
714
|
// const settlingAsset = this.safeValue (market, 'settling_asset', {});
|
|
698
|
-
const quotingAsset = this.
|
|
699
|
-
const underlyingAsset = this.
|
|
700
|
-
const settlingAsset = this.
|
|
701
|
-
const productSpecs = this.
|
|
715
|
+
const quotingAsset = this.safeDict(market, 'quoting_asset', {});
|
|
716
|
+
const underlyingAsset = this.safeDict(market, 'underlying_asset', {});
|
|
717
|
+
const settlingAsset = this.safeDict(market, 'settling_asset');
|
|
718
|
+
const productSpecs = this.safeDict(market, 'product_specs', {});
|
|
702
719
|
const baseId = this.safeString(underlyingAsset, 'symbol');
|
|
703
720
|
const quoteId = this.safeString(quotingAsset, 'symbol');
|
|
704
721
|
const settleId = this.safeString(settlingAsset, 'symbol');
|
|
@@ -931,7 +948,7 @@ class delta extends delta$1 {
|
|
|
931
948
|
const marketId = this.safeString(ticker, 'symbol');
|
|
932
949
|
const symbol = this.safeSymbol(marketId, market);
|
|
933
950
|
const last = this.safeString(ticker, 'close');
|
|
934
|
-
const quotes = this.
|
|
951
|
+
const quotes = this.safeDict(ticker, 'quotes', {});
|
|
935
952
|
return this.safeTicker({
|
|
936
953
|
'symbol': symbol,
|
|
937
954
|
'timestamp': timestamp,
|
|
@@ -1095,7 +1112,7 @@ class delta extends delta$1 {
|
|
|
1095
1112
|
// "success": true
|
|
1096
1113
|
// }
|
|
1097
1114
|
//
|
|
1098
|
-
const result = this.
|
|
1115
|
+
const result = this.safeDict(response, 'result', {});
|
|
1099
1116
|
return this.parseTicker(result, market);
|
|
1100
1117
|
}
|
|
1101
1118
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
@@ -1241,7 +1258,7 @@ class delta extends delta$1 {
|
|
|
1241
1258
|
// "success":true
|
|
1242
1259
|
// }
|
|
1243
1260
|
//
|
|
1244
|
-
const tickers = this.
|
|
1261
|
+
const tickers = this.safeList(response, 'result', []);
|
|
1245
1262
|
const result = {};
|
|
1246
1263
|
for (let i = 0; i < tickers.length; i++) {
|
|
1247
1264
|
const ticker = this.parseTicker(tickers[i]);
|
|
@@ -1288,7 +1305,7 @@ class delta extends delta$1 {
|
|
|
1288
1305
|
// "success":true
|
|
1289
1306
|
// }
|
|
1290
1307
|
//
|
|
1291
|
-
const result = this.
|
|
1308
|
+
const result = this.safeDict(response, 'result', {});
|
|
1292
1309
|
return this.parseOrderBook(result, market['symbol'], undefined, 'buy', 'sell', 'price', 'size');
|
|
1293
1310
|
}
|
|
1294
1311
|
parseTrade(trade, market = undefined) {
|
|
@@ -1345,7 +1362,7 @@ class delta extends delta$1 {
|
|
|
1345
1362
|
timestamp = this.safeIntegerProduct(trade, 'timestamp', 0.001, timestamp);
|
|
1346
1363
|
const priceString = this.safeString(trade, 'price');
|
|
1347
1364
|
const amountString = this.safeString(trade, 'size');
|
|
1348
|
-
const product = this.
|
|
1365
|
+
const product = this.safeDict(trade, 'product', {});
|
|
1349
1366
|
const marketId = this.safeString(product, 'symbol');
|
|
1350
1367
|
const symbol = this.safeSymbol(marketId, market);
|
|
1351
1368
|
const sellerRole = this.safeString(trade, 'seller_role');
|
|
@@ -1359,7 +1376,7 @@ class delta extends delta$1 {
|
|
|
1359
1376
|
}
|
|
1360
1377
|
}
|
|
1361
1378
|
const takerOrMaker = this.safeString(trade, 'role');
|
|
1362
|
-
const metaData = this.
|
|
1379
|
+
const metaData = this.safeDict(trade, 'meta_data', {});
|
|
1363
1380
|
let type = this.safeString(metaData, 'order_type');
|
|
1364
1381
|
if (type !== undefined) {
|
|
1365
1382
|
type = type.replace('_order', '');
|
|
@@ -1367,7 +1384,7 @@ class delta extends delta$1 {
|
|
|
1367
1384
|
const feeCostString = this.safeString(trade, 'commission');
|
|
1368
1385
|
let fee = undefined;
|
|
1369
1386
|
if (feeCostString !== undefined) {
|
|
1370
|
-
const settlingAsset = this.
|
|
1387
|
+
const settlingAsset = this.safeDict(product, 'settling_asset', {});
|
|
1371
1388
|
const feeCurrencyId = this.safeString(settlingAsset, 'symbol');
|
|
1372
1389
|
const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
1373
1390
|
fee = {
|
|
@@ -1424,7 +1441,7 @@ class delta extends delta$1 {
|
|
|
1424
1441
|
// "success":true
|
|
1425
1442
|
// }
|
|
1426
1443
|
//
|
|
1427
|
-
const result = this.
|
|
1444
|
+
const result = this.safeList(response, 'result', []);
|
|
1428
1445
|
return this.parseTrades(result, market, since, limit);
|
|
1429
1446
|
}
|
|
1430
1447
|
parseOHLCV(ohlcv, market = undefined) {
|
|
@@ -1499,17 +1516,17 @@ class delta extends delta$1 {
|
|
|
1499
1516
|
// ]
|
|
1500
1517
|
// }
|
|
1501
1518
|
//
|
|
1502
|
-
const result = this.
|
|
1519
|
+
const result = this.safeList(response, 'result', []);
|
|
1503
1520
|
return this.parseOHLCVs(result, market, timeframe, since, limit);
|
|
1504
1521
|
}
|
|
1505
1522
|
parseBalance(response) {
|
|
1506
|
-
const balances = this.
|
|
1523
|
+
const balances = this.safeList(response, 'result', []);
|
|
1507
1524
|
const result = { 'info': response };
|
|
1508
|
-
const currenciesByNumericId = this.
|
|
1525
|
+
const currenciesByNumericId = this.safeDict(this.options, 'currenciesByNumericId', {});
|
|
1509
1526
|
for (let i = 0; i < balances.length; i++) {
|
|
1510
1527
|
const balance = balances[i];
|
|
1511
1528
|
const currencyId = this.safeString(balance, 'asset_id');
|
|
1512
|
-
const currency = this.
|
|
1529
|
+
const currency = this.safeDict(currenciesByNumericId, currencyId);
|
|
1513
1530
|
const code = (currency === undefined) ? currencyId : currency['code'];
|
|
1514
1531
|
const account = this.account();
|
|
1515
1532
|
account['total'] = this.safeString(balance, 'balance');
|
|
@@ -1578,7 +1595,7 @@ class delta extends delta$1 {
|
|
|
1578
1595
|
// "success":true
|
|
1579
1596
|
// }
|
|
1580
1597
|
//
|
|
1581
|
-
const result = this.
|
|
1598
|
+
const result = this.safeDict(response, 'result', {});
|
|
1582
1599
|
return this.parsePosition(result, market);
|
|
1583
1600
|
}
|
|
1584
1601
|
async fetchPositions(symbols = undefined, params = {}) {
|
|
@@ -1614,7 +1631,7 @@ class delta extends delta$1 {
|
|
|
1614
1631
|
// ]
|
|
1615
1632
|
// }
|
|
1616
1633
|
//
|
|
1617
|
-
const result = this.
|
|
1634
|
+
const result = this.safeList(response, 'result', []);
|
|
1618
1635
|
return this.parsePositions(result, symbols);
|
|
1619
1636
|
}
|
|
1620
1637
|
parsePosition(position, market = undefined) {
|
|
@@ -1736,7 +1753,7 @@ class delta extends delta$1 {
|
|
|
1736
1753
|
const clientOrderId = this.safeString(order, 'client_order_id');
|
|
1737
1754
|
const timestamp = this.parse8601(this.safeString(order, 'created_at'));
|
|
1738
1755
|
const marketId = this.safeString(order, 'product_id');
|
|
1739
|
-
const marketsByNumericId = this.
|
|
1756
|
+
const marketsByNumericId = this.safeDict(this.options, 'marketsByNumericId', {});
|
|
1740
1757
|
market = this.safeValue(marketsByNumericId, marketId, market);
|
|
1741
1758
|
const symbol = (market === undefined) ? marketId : market['symbol'];
|
|
1742
1759
|
const status = this.parseOrderStatus(this.safeString(order, 'state'));
|
|
@@ -1752,7 +1769,7 @@ class delta extends delta$1 {
|
|
|
1752
1769
|
if (feeCostString !== undefined) {
|
|
1753
1770
|
let feeCurrencyCode = undefined;
|
|
1754
1771
|
if (market !== undefined) {
|
|
1755
|
-
const settlingAsset = this.
|
|
1772
|
+
const settlingAsset = this.safeDict(market['info'], 'settling_asset', {});
|
|
1756
1773
|
const feeCurrencyId = this.safeString(settlingAsset, 'symbol');
|
|
1757
1774
|
feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
1758
1775
|
}
|
|
@@ -1819,7 +1836,7 @@ class delta extends delta$1 {
|
|
|
1819
1836
|
if (clientOrderId !== undefined) {
|
|
1820
1837
|
request['client_order_id'] = clientOrderId;
|
|
1821
1838
|
}
|
|
1822
|
-
const reduceOnly = this.
|
|
1839
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly');
|
|
1823
1840
|
if (reduceOnly) {
|
|
1824
1841
|
request['reduce_only'] = reduceOnly;
|
|
1825
1842
|
params = this.omit(params, 'reduceOnly');
|
|
@@ -1861,7 +1878,7 @@ class delta extends delta$1 {
|
|
|
1861
1878
|
// "success":true
|
|
1862
1879
|
// }
|
|
1863
1880
|
//
|
|
1864
|
-
const result = this.
|
|
1881
|
+
const result = this.safeDict(response, 'result', {});
|
|
1865
1882
|
return this.parseOrder(result, market);
|
|
1866
1883
|
}
|
|
1867
1884
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
@@ -1911,7 +1928,7 @@ class delta extends delta$1 {
|
|
|
1911
1928
|
// }
|
|
1912
1929
|
// }
|
|
1913
1930
|
//
|
|
1914
|
-
const result = this.
|
|
1931
|
+
const result = this.safeDict(response, 'result');
|
|
1915
1932
|
return this.parseOrder(result, market);
|
|
1916
1933
|
}
|
|
1917
1934
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
@@ -1971,7 +1988,7 @@ class delta extends delta$1 {
|
|
|
1971
1988
|
// "success":true
|
|
1972
1989
|
// }
|
|
1973
1990
|
//
|
|
1974
|
-
const result = this.
|
|
1991
|
+
const result = this.safeDict(response, 'result');
|
|
1975
1992
|
return this.parseOrder(result, market);
|
|
1976
1993
|
}
|
|
1977
1994
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
@@ -2084,7 +2101,7 @@ class delta extends delta$1 {
|
|
|
2084
2101
|
// }
|
|
2085
2102
|
// }
|
|
2086
2103
|
//
|
|
2087
|
-
const result = this.
|
|
2104
|
+
const result = this.safeList(response, 'result', []);
|
|
2088
2105
|
return this.parseOrders(result, market, since, limit);
|
|
2089
2106
|
}
|
|
2090
2107
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2166,7 +2183,7 @@ class delta extends delta$1 {
|
|
|
2166
2183
|
// "success":true
|
|
2167
2184
|
// }
|
|
2168
2185
|
//
|
|
2169
|
-
const result = this.
|
|
2186
|
+
const result = this.safeList(response, 'result', []);
|
|
2170
2187
|
return this.parseTrades(result, market, since, limit);
|
|
2171
2188
|
}
|
|
2172
2189
|
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -2219,7 +2236,7 @@ class delta extends delta$1 {
|
|
|
2219
2236
|
// "success":true
|
|
2220
2237
|
// }
|
|
2221
2238
|
//
|
|
2222
|
-
const result = this.
|
|
2239
|
+
const result = this.safeList(response, 'result', []);
|
|
2223
2240
|
return this.parseLedger(result, currency, since, limit);
|
|
2224
2241
|
}
|
|
2225
2242
|
parseLedgerEntryType(type) {
|
|
@@ -2256,7 +2273,7 @@ class delta extends delta$1 {
|
|
|
2256
2273
|
const id = this.safeString(item, 'uuid');
|
|
2257
2274
|
let direction = undefined;
|
|
2258
2275
|
const account = undefined;
|
|
2259
|
-
const metaData = this.
|
|
2276
|
+
const metaData = this.safeDict(item, 'meta_data', {});
|
|
2260
2277
|
const referenceId = this.safeString(metaData, 'transaction_id');
|
|
2261
2278
|
const referenceAccount = undefined;
|
|
2262
2279
|
let type = this.safeString(item, 'transaction_type');
|
|
@@ -2267,8 +2284,8 @@ class delta extends delta$1 {
|
|
|
2267
2284
|
direction = 'out';
|
|
2268
2285
|
}
|
|
2269
2286
|
type = this.parseLedgerEntryType(type);
|
|
2270
|
-
const currencyId = this.
|
|
2271
|
-
const currenciesByNumericId = this.
|
|
2287
|
+
const currencyId = this.safeString(item, 'asset_id');
|
|
2288
|
+
const currenciesByNumericId = this.safeDict(this.options, 'currenciesByNumericId');
|
|
2272
2289
|
currency = this.safeValue(currenciesByNumericId, currencyId, currency);
|
|
2273
2290
|
const code = (currency === undefined) ? undefined : currency['code'];
|
|
2274
2291
|
const amount = this.safeString(item, 'amount');
|
|
@@ -2332,7 +2349,7 @@ class delta extends delta$1 {
|
|
|
2332
2349
|
// }
|
|
2333
2350
|
// }
|
|
2334
2351
|
//
|
|
2335
|
-
const result = this.
|
|
2352
|
+
const result = this.safeDict(response, 'result', {});
|
|
2336
2353
|
return this.parseDepositAddress(result, currency);
|
|
2337
2354
|
}
|
|
2338
2355
|
parseDepositAddress(depositAddress, currency = undefined) {
|
|
@@ -2426,7 +2443,7 @@ class delta extends delta$1 {
|
|
|
2426
2443
|
// "success": true
|
|
2427
2444
|
// }
|
|
2428
2445
|
//
|
|
2429
|
-
const result = this.
|
|
2446
|
+
const result = this.safeDict(response, 'result', {});
|
|
2430
2447
|
return this.parseFundingRate(result, market);
|
|
2431
2448
|
}
|
|
2432
2449
|
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
@@ -2492,7 +2509,7 @@ class delta extends delta$1 {
|
|
|
2492
2509
|
// "success":true
|
|
2493
2510
|
// }
|
|
2494
2511
|
//
|
|
2495
|
-
const rates = this.
|
|
2512
|
+
const rates = this.safeList(response, 'result', []);
|
|
2496
2513
|
const result = this.parseFundingRates(rates);
|
|
2497
2514
|
return this.filterByArray(result, 'symbol', symbols);
|
|
2498
2515
|
}
|
|
@@ -2624,7 +2641,7 @@ class delta extends delta$1 {
|
|
|
2624
2641
|
// "success": true
|
|
2625
2642
|
// }
|
|
2626
2643
|
//
|
|
2627
|
-
const result = this.
|
|
2644
|
+
const result = this.safeDict(response, 'result', {});
|
|
2628
2645
|
return this.parseMarginModification(result, market);
|
|
2629
2646
|
}
|
|
2630
2647
|
parseMarginModification(data, market = undefined) {
|
|
@@ -2731,7 +2748,7 @@ class delta extends delta$1 {
|
|
|
2731
2748
|
// "success": true
|
|
2732
2749
|
// }
|
|
2733
2750
|
//
|
|
2734
|
-
const result = this.
|
|
2751
|
+
const result = this.safeDict(response, 'result', {});
|
|
2735
2752
|
return this.parseOpenInterest(result, market);
|
|
2736
2753
|
}
|
|
2737
2754
|
parseOpenInterest(interest, market = undefined) {
|
|
@@ -2955,7 +2972,7 @@ class delta extends delta$1 {
|
|
|
2955
2972
|
// "success": true
|
|
2956
2973
|
// }
|
|
2957
2974
|
//
|
|
2958
|
-
const result = this.
|
|
2975
|
+
const result = this.safeList(response, 'result', []);
|
|
2959
2976
|
const settlements = this.parseSettlements(result, market);
|
|
2960
2977
|
const sorted = this.sortBy(settlements, 'timestamp');
|
|
2961
2978
|
return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
|
|
@@ -3099,7 +3116,7 @@ class delta extends delta$1 {
|
|
|
3099
3116
|
// "success": true
|
|
3100
3117
|
// }
|
|
3101
3118
|
//
|
|
3102
|
-
const result = this.
|
|
3119
|
+
const result = this.safeDict(response, 'result', {});
|
|
3103
3120
|
return this.parseGreeks(result, market);
|
|
3104
3121
|
}
|
|
3105
3122
|
parseGreeks(greeks, market = undefined) {
|
|
@@ -3155,8 +3172,8 @@ class delta extends delta$1 {
|
|
|
3155
3172
|
const timestamp = this.safeIntegerProduct(greeks, 'timestamp', 0.001);
|
|
3156
3173
|
const marketId = this.safeString(greeks, 'symbol');
|
|
3157
3174
|
const symbol = this.safeSymbol(marketId, market);
|
|
3158
|
-
const stats = this.
|
|
3159
|
-
const quotes = this.
|
|
3175
|
+
const stats = this.safeDict(greeks, 'greeks', {});
|
|
3176
|
+
const quotes = this.safeDict(greeks, 'quotes', {});
|
|
3160
3177
|
return {
|
|
3161
3178
|
'symbol': symbol,
|
|
3162
3179
|
'timestamp': timestamp,
|
|
@@ -3199,7 +3216,7 @@ class delta extends delta$1 {
|
|
|
3199
3216
|
//
|
|
3200
3217
|
// {"result":{},"success":true}
|
|
3201
3218
|
//
|
|
3202
|
-
const position = this.parsePosition(this.
|
|
3219
|
+
const position = this.parsePosition(this.safeDict(response, 'result', {}));
|
|
3203
3220
|
return [position];
|
|
3204
3221
|
}
|
|
3205
3222
|
async fetchMarginMode(symbol, params = {}) {
|
|
@@ -3336,7 +3353,7 @@ class delta extends delta$1 {
|
|
|
3336
3353
|
//
|
|
3337
3354
|
// {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false}
|
|
3338
3355
|
//
|
|
3339
|
-
const error = this.
|
|
3356
|
+
const error = this.safeDict(response, 'error', {});
|
|
3340
3357
|
const errorCode = this.safeString(error, 'code');
|
|
3341
3358
|
if (errorCode !== undefined) {
|
|
3342
3359
|
const feedback = this.id + ' ' + body;
|
package/dist/cjs/src/gate.js
CHANGED
package/dist/cjs/src/htx.js
CHANGED
|
@@ -2977,42 +2977,47 @@ class htx extends htx$1 {
|
|
|
2977
2977
|
// 'from': parseInt ((since / 1000).toString ()), spot only
|
|
2978
2978
|
// 'to': this.seconds (), spot only
|
|
2979
2979
|
};
|
|
2980
|
-
const
|
|
2981
|
-
params = this.omit(params, 'price');
|
|
2980
|
+
const priceType = this.safeStringN(params, ['priceType', 'price']);
|
|
2981
|
+
params = this.omit(params, ['priceType', 'price']);
|
|
2982
|
+
let until = undefined;
|
|
2983
|
+
[until, params] = this.handleParamInteger(params, 'until');
|
|
2984
|
+
const untilSeconds = (until !== undefined) ? this.parseToInt(until / 1000) : undefined;
|
|
2982
2985
|
if (market['contract']) {
|
|
2983
2986
|
if (limit !== undefined) {
|
|
2984
|
-
request['size'] = limit; // when using limit from
|
|
2987
|
+
request['size'] = limit; // when using limit: from & to are ignored
|
|
2985
2988
|
// https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
|
|
2986
2989
|
}
|
|
2987
2990
|
else {
|
|
2988
2991
|
limit = 2000; // only used for from/to calculation
|
|
2989
2992
|
}
|
|
2990
|
-
if (
|
|
2993
|
+
if (priceType === undefined) {
|
|
2991
2994
|
const duration = this.parseTimeframe(timeframe);
|
|
2995
|
+
let calcualtedEnd = undefined;
|
|
2992
2996
|
if (since === undefined) {
|
|
2993
2997
|
const now = this.seconds();
|
|
2994
2998
|
request['from'] = now - duration * (limit - 1);
|
|
2995
|
-
|
|
2999
|
+
calcualtedEnd = now;
|
|
2996
3000
|
}
|
|
2997
3001
|
else {
|
|
2998
3002
|
const start = this.parseToInt(since / 1000);
|
|
2999
3003
|
request['from'] = start;
|
|
3000
|
-
|
|
3004
|
+
calcualtedEnd = this.sum(start, duration * (limit - 1));
|
|
3001
3005
|
}
|
|
3006
|
+
request['to'] = (untilSeconds !== undefined) ? untilSeconds : calcualtedEnd;
|
|
3002
3007
|
}
|
|
3003
3008
|
}
|
|
3004
3009
|
let response = undefined;
|
|
3005
3010
|
if (market['future']) {
|
|
3006
3011
|
if (market['inverse']) {
|
|
3007
3012
|
request['symbol'] = market['id'];
|
|
3008
|
-
if (
|
|
3013
|
+
if (priceType === 'mark') {
|
|
3009
3014
|
response = await this.contractPublicGetIndexMarketHistoryMarkPriceKline(this.extend(request, params));
|
|
3010
3015
|
}
|
|
3011
|
-
else if (
|
|
3016
|
+
else if (priceType === 'index') {
|
|
3012
3017
|
response = await this.contractPublicGetIndexMarketHistoryIndex(this.extend(request, params));
|
|
3013
3018
|
}
|
|
3014
|
-
else if (
|
|
3015
|
-
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' +
|
|
3019
|
+
else if (priceType === 'premiumIndex') {
|
|
3020
|
+
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data');
|
|
3016
3021
|
}
|
|
3017
3022
|
else {
|
|
3018
3023
|
response = await this.contractPublicGetMarketHistoryKline(this.extend(request, params));
|
|
@@ -3020,13 +3025,13 @@ class htx extends htx$1 {
|
|
|
3020
3025
|
}
|
|
3021
3026
|
else if (market['linear']) {
|
|
3022
3027
|
request['contract_code'] = market['id'];
|
|
3023
|
-
if (
|
|
3028
|
+
if (priceType === 'mark') {
|
|
3024
3029
|
response = await this.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(this.extend(request, params));
|
|
3025
3030
|
}
|
|
3026
|
-
else if (
|
|
3027
|
-
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' +
|
|
3031
|
+
else if (priceType === 'index') {
|
|
3032
|
+
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data');
|
|
3028
3033
|
}
|
|
3029
|
-
else if (
|
|
3034
|
+
else if (priceType === 'premiumIndex') {
|
|
3030
3035
|
response = await this.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(this.extend(request, params));
|
|
3031
3036
|
}
|
|
3032
3037
|
else {
|
|
@@ -3037,13 +3042,13 @@ class htx extends htx$1 {
|
|
|
3037
3042
|
else if (market['swap']) {
|
|
3038
3043
|
request['contract_code'] = market['id'];
|
|
3039
3044
|
if (market['inverse']) {
|
|
3040
|
-
if (
|
|
3045
|
+
if (priceType === 'mark') {
|
|
3041
3046
|
response = await this.contractPublicGetIndexMarketHistorySwapMarkPriceKline(this.extend(request, params));
|
|
3042
3047
|
}
|
|
3043
|
-
else if (
|
|
3044
|
-
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' +
|
|
3048
|
+
else if (priceType === 'index') {
|
|
3049
|
+
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data');
|
|
3045
3050
|
}
|
|
3046
|
-
else if (
|
|
3051
|
+
else if (priceType === 'premiumIndex') {
|
|
3047
3052
|
response = await this.contractPublicGetIndexMarketHistorySwapPremiumIndexKline(this.extend(request, params));
|
|
3048
3053
|
}
|
|
3049
3054
|
else {
|
|
@@ -3051,13 +3056,13 @@ class htx extends htx$1 {
|
|
|
3051
3056
|
}
|
|
3052
3057
|
}
|
|
3053
3058
|
else if (market['linear']) {
|
|
3054
|
-
if (
|
|
3059
|
+
if (priceType === 'mark') {
|
|
3055
3060
|
response = await this.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(this.extend(request, params));
|
|
3056
3061
|
}
|
|
3057
|
-
else if (
|
|
3058
|
-
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' +
|
|
3062
|
+
else if (priceType === 'index') {
|
|
3063
|
+
throw new errors.BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data');
|
|
3059
3064
|
}
|
|
3060
|
-
else if (
|
|
3065
|
+
else if (priceType === 'premiumIndex') {
|
|
3061
3066
|
response = await this.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(this.extend(request, params));
|
|
3062
3067
|
}
|
|
3063
3068
|
else {
|
|
@@ -3070,18 +3075,22 @@ class htx extends htx$1 {
|
|
|
3070
3075
|
let useHistorical = undefined;
|
|
3071
3076
|
[useHistorical, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', true);
|
|
3072
3077
|
if (!useHistorical) {
|
|
3073
|
-
// `limit` only available for the this endpoint
|
|
3074
3078
|
if (limit !== undefined) {
|
|
3075
|
-
request['size'] = limit; // max 2000
|
|
3079
|
+
request['size'] = Math.min(2000, limit); // max 2000
|
|
3076
3080
|
}
|
|
3077
3081
|
response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
|
|
3078
3082
|
}
|
|
3079
3083
|
else {
|
|
3080
|
-
//
|
|
3084
|
+
// "from & to" only available for the this endpoint
|
|
3081
3085
|
if (since !== undefined) {
|
|
3082
|
-
// default 150 bars
|
|
3083
3086
|
request['from'] = this.parseToInt(since / 1000);
|
|
3084
3087
|
}
|
|
3088
|
+
if (untilSeconds !== undefined) {
|
|
3089
|
+
request['to'] = untilSeconds;
|
|
3090
|
+
}
|
|
3091
|
+
if (limit !== undefined) {
|
|
3092
|
+
request['size'] = Math.min(1000, limit); // max 1000, otherwise default returns 150
|
|
3093
|
+
}
|
|
3085
3094
|
response = await this.spotPublicGetMarketHistoryCandles(this.extend(request, params));
|
|
3086
3095
|
}
|
|
3087
3096
|
}
|
|
@@ -3097,7 +3106,7 @@ class htx extends htx$1 {
|
|
|
3097
3106
|
// ]
|
|
3098
3107
|
// }
|
|
3099
3108
|
//
|
|
3100
|
-
const data = this.
|
|
3109
|
+
const data = this.safeList(response, 'data', []);
|
|
3101
3110
|
return this.parseOHLCVs(data, market, timeframe, since, limit);
|
|
3102
3111
|
}
|
|
3103
3112
|
async fetchAccounts(params = {}) {
|
|
@@ -555,7 +555,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
555
555
|
// }
|
|
556
556
|
//
|
|
557
557
|
return [
|
|
558
|
-
this.safeInteger(ohlcv, '
|
|
558
|
+
this.safeInteger(ohlcv, 't'),
|
|
559
559
|
this.safeNumber(ohlcv, 'o'),
|
|
560
560
|
this.safeNumber(ohlcv, 'h'),
|
|
561
561
|
this.safeNumber(ohlcv, 'l'),
|
|
@@ -761,8 +761,9 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
761
761
|
* @param {bool} [params.postOnly] true or false whether the order is post-only
|
|
762
762
|
* @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
|
|
763
763
|
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
764
|
-
* @param {string} [params.clientOrderId] client order id, optional 128 bit hex string
|
|
764
|
+
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
765
765
|
* @param {string} [params.slippage] the slippage for market order
|
|
766
|
+
* @param {string} [params.vaultAddress] the vault address for order
|
|
766
767
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
767
768
|
*/
|
|
768
769
|
await this.loadMarkets();
|
|
@@ -812,7 +813,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
812
813
|
}
|
|
813
814
|
}
|
|
814
815
|
}
|
|
815
|
-
params = this.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
816
|
+
params = this.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce']);
|
|
816
817
|
const nonce = this.milliseconds();
|
|
817
818
|
const orderReq = [];
|
|
818
819
|
for (let i = 0; i < orders.length; i++) {
|
|
@@ -939,7 +940,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
939
940
|
* @param {string} id order id
|
|
940
941
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
941
942
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
942
|
-
* @param {string} [params.clientOrderId] client order id (
|
|
943
|
+
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
943
944
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
944
945
|
*/
|
|
945
946
|
return await this.cancelOrders([id], symbol, params);
|
|
@@ -954,7 +955,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
954
955
|
* @param {string[]} ids order ids
|
|
955
956
|
* @param {string} [symbol] unified market symbol
|
|
956
957
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
957
|
-
* @param {string|string[]} [params.clientOrderId] client order ids (
|
|
958
|
+
* @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
958
959
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
959
960
|
*/
|
|
960
961
|
this.checkRequiredCredentials();
|
|
@@ -1037,6 +1038,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
1037
1038
|
* @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
|
|
1038
1039
|
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
1039
1040
|
* @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
|
1041
|
+
* @param {string} [params.vaultAddress] the vault address for order
|
|
1040
1042
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1041
1043
|
*/
|
|
1042
1044
|
this.checkRequiredCredentials();
|