ccxt 4.4.12 → 4.4.13
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 -4
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +6 -0
- package/dist/cjs/src/bigone.js +2 -0
- package/dist/cjs/src/binance.js +49 -1
- package/dist/cjs/src/bingx.js +75 -3
- package/dist/cjs/src/bitget.js +1 -0
- package/dist/cjs/src/bitmex.js +1 -0
- package/dist/cjs/src/bybit.js +2 -0
- package/dist/cjs/src/coinbaseinternational.js +2 -0
- package/dist/cjs/src/coinex.js +2 -0
- package/dist/cjs/src/delta.js +2 -0
- package/dist/cjs/src/deribit.js +2 -0
- package/dist/cjs/src/digifinex.js +2 -0
- package/dist/cjs/src/gate.js +2 -0
- package/dist/cjs/src/htx.js +2 -2
- package/dist/cjs/src/krakenfutures.js +2 -0
- package/dist/cjs/src/kucoinfutures.js +2 -0
- package/dist/cjs/src/okx.js +41 -0
- package/dist/cjs/src/oxfun.js +1 -0
- package/dist/cjs/src/paradex.js +1 -0
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/binance.js +80 -5
- package/dist/cjs/src/pro/bitfinex.js +8 -8
- package/dist/cjs/src/pro/krakenfutures.js +2 -0
- package/dist/cjs/src/pro/phemex.js +2 -0
- package/dist/cjs/src/pro/woo.js +73 -0
- package/examples/README.md +4 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +6 -0
- package/js/src/base/types.d.ts +18 -16
- package/js/src/bigone.js +2 -0
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +49 -1
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +75 -3
- package/js/src/bitget.js +1 -0
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.js +2 -0
- package/js/src/coinbaseinternational.js +2 -0
- package/js/src/coinex.js +2 -0
- package/js/src/delta.js +2 -0
- package/js/src/deribit.js +2 -0
- package/js/src/digifinex.js +2 -0
- package/js/src/gate.js +2 -0
- package/js/src/htx.js +2 -2
- package/js/src/krakenfutures.js +2 -0
- package/js/src/kucoinfutures.js +2 -0
- package/js/src/okx.d.ts +1 -0
- package/js/src/okx.js +41 -0
- package/js/src/oxfun.js +1 -0
- package/js/src/paradex.js +1 -0
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/binance.d.ts +5 -0
- package/js/src/pro/binance.js +80 -5
- package/js/src/pro/bitfinex.js +8 -8
- package/js/src/pro/krakenfutures.js +2 -0
- package/js/src/pro/phemex.js +2 -0
- package/js/src/pro/woo.d.ts +3 -0
- package/js/src/pro/woo.js +73 -0
- package/package.json +2 -2
package/dist/cjs/ccxt.js
CHANGED
|
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
194
194
|
|
|
195
195
|
//-----------------------------------------------------------------------------
|
|
196
196
|
// this is updated by vss.js when building
|
|
197
|
-
const version = '4.4.
|
|
197
|
+
const version = '4.4.13';
|
|
198
198
|
Exchange["default"].ccxtVersion = version;
|
|
199
199
|
const exchanges = {
|
|
200
200
|
'ace': ace,
|
|
@@ -1460,6 +1460,7 @@ class Exchange {
|
|
|
1460
1460
|
'fetchTicker': true,
|
|
1461
1461
|
'fetchTickerWs': undefined,
|
|
1462
1462
|
'fetchTickers': undefined,
|
|
1463
|
+
'fetchMarkPrices': undefined,
|
|
1463
1464
|
'fetchTickersWs': undefined,
|
|
1464
1465
|
'fetchTime': undefined,
|
|
1465
1466
|
'fetchTrades': true,
|
|
@@ -3214,6 +3215,8 @@ class Exchange {
|
|
|
3214
3215
|
'baseVolume': this.parseNumber(baseVolume),
|
|
3215
3216
|
'quoteVolume': this.parseNumber(quoteVolume),
|
|
3216
3217
|
'previousClose': this.safeNumber(ticker, 'previousClose'),
|
|
3218
|
+
'indexPrice': this.safeNumber(ticker, 'indexPrice'),
|
|
3219
|
+
'markPrice': this.safeNumber(ticker, 'markPrice'),
|
|
3217
3220
|
});
|
|
3218
3221
|
}
|
|
3219
3222
|
async fetchBorrowRate(code, amount, params = {}) {
|
|
@@ -4438,6 +4441,9 @@ class Exchange {
|
|
|
4438
4441
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
4439
4442
|
throw new errors.NotSupported(this.id + ' fetchTickers() is not supported yet');
|
|
4440
4443
|
}
|
|
4444
|
+
async fetchMarkPrices(symbols = undefined, params = {}) {
|
|
4445
|
+
throw new errors.NotSupported(this.id + ' fetchMarkPrices() is not supported yet');
|
|
4446
|
+
}
|
|
4441
4447
|
async fetchTickersWs(symbols = undefined, params = {}) {
|
|
4442
4448
|
throw new errors.NotSupported(this.id + ' fetchTickers() is not supported yet');
|
|
4443
4449
|
}
|
package/dist/cjs/src/bigone.js
CHANGED
|
@@ -722,6 +722,8 @@ class bigone extends bigone$1 {
|
|
|
722
722
|
'average': undefined,
|
|
723
723
|
'baseVolume': this.safeString2(ticker, 'volume', 'volume24h'),
|
|
724
724
|
'quoteVolume': this.safeString(ticker, 'volume24hInUsd'),
|
|
725
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
726
|
+
'indexPrice': this.safeString(ticker, 'indexPrice'),
|
|
725
727
|
'info': ticker,
|
|
726
728
|
}, market);
|
|
727
729
|
}
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -109,6 +109,7 @@ class binance extends binance$1 {
|
|
|
109
109
|
'fetchMarketLeverageTiers': 'emulated',
|
|
110
110
|
'fetchMarkets': true,
|
|
111
111
|
'fetchMarkOHLCV': true,
|
|
112
|
+
'fetchMarkPrices': true,
|
|
112
113
|
'fetchMyLiquidations': true,
|
|
113
114
|
'fetchMySettlementHistory': true,
|
|
114
115
|
'fetchMyTrades': true,
|
|
@@ -1193,6 +1194,9 @@ class binance extends binance$1 {
|
|
|
1193
1194
|
},
|
|
1194
1195
|
'option': {},
|
|
1195
1196
|
},
|
|
1197
|
+
'currencies': {
|
|
1198
|
+
'BNFCR': this.safeCurrencyStructure({ 'id': 'BNFCR', 'code': 'BNFCR', 'precision': this.parseNumber('0.001') }),
|
|
1199
|
+
},
|
|
1196
1200
|
'commonCurrencies': {
|
|
1197
1201
|
'BCC': 'BCC',
|
|
1198
1202
|
'YOYO': 'YOYOW',
|
|
@@ -3811,6 +3815,18 @@ class binance extends binance$1 {
|
|
|
3811
3815
|
return orderbook;
|
|
3812
3816
|
}
|
|
3813
3817
|
parseTicker(ticker, market = undefined) {
|
|
3818
|
+
// markPrices
|
|
3819
|
+
//
|
|
3820
|
+
// {
|
|
3821
|
+
// "symbol": "BTCUSDT",
|
|
3822
|
+
// "markPrice": "11793.63104562", // mark price
|
|
3823
|
+
// "indexPrice": "11781.80495970", // index price
|
|
3824
|
+
// "estimatedSettlePrice": "11781.16138815", // Estimated Settle Price, only useful in the last hour before the settlement starts.
|
|
3825
|
+
// "lastFundingRate": "0.00038246", // This is the lastest estimated funding rate
|
|
3826
|
+
// "nextFundingTime": 1597392000000,
|
|
3827
|
+
// "interestRate": "0.00010000",
|
|
3828
|
+
// "time": 1597370495002
|
|
3829
|
+
// }
|
|
3814
3830
|
//
|
|
3815
3831
|
// {
|
|
3816
3832
|
// "symbol": "ETHBTC",
|
|
@@ -3914,7 +3930,7 @@ class binance extends binance$1 {
|
|
|
3914
3930
|
// "time":"1673899278514"
|
|
3915
3931
|
// }
|
|
3916
3932
|
//
|
|
3917
|
-
const timestamp = this.
|
|
3933
|
+
const timestamp = this.safeInteger2(ticker, 'closeTime', 'time');
|
|
3918
3934
|
let marketType = undefined;
|
|
3919
3935
|
if (('time' in ticker)) {
|
|
3920
3936
|
marketType = 'contract';
|
|
@@ -3958,6 +3974,8 @@ class binance extends binance$1 {
|
|
|
3958
3974
|
'average': undefined,
|
|
3959
3975
|
'baseVolume': baseVolume,
|
|
3960
3976
|
'quoteVolume': quoteVolume,
|
|
3977
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
3978
|
+
'indexPrice': this.safeString(ticker, 'indexPrice'),
|
|
3961
3979
|
'info': ticker,
|
|
3962
3980
|
}, market);
|
|
3963
3981
|
}
|
|
@@ -4220,6 +4238,36 @@ class binance extends binance$1 {
|
|
|
4220
4238
|
}
|
|
4221
4239
|
return this.parseTickers(response, symbols);
|
|
4222
4240
|
}
|
|
4241
|
+
async fetchMarkPrices(symbols = undefined, params = {}) {
|
|
4242
|
+
/**
|
|
4243
|
+
* @method
|
|
4244
|
+
* @name binance#fetchMarkPrices
|
|
4245
|
+
* @description fetches mark prices for multiple markets
|
|
4246
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#mark-price
|
|
4247
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
4248
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4249
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
4250
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
4251
|
+
*/
|
|
4252
|
+
await this.loadMarkets();
|
|
4253
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
4254
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
4255
|
+
let type = undefined;
|
|
4256
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params, 'swap');
|
|
4257
|
+
let subType = undefined;
|
|
4258
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params, 'linear');
|
|
4259
|
+
let response = undefined;
|
|
4260
|
+
if (this.isLinear(type, subType)) {
|
|
4261
|
+
response = await this.fapiPublicGetPremiumIndex(params);
|
|
4262
|
+
}
|
|
4263
|
+
else if (this.isInverse(type, subType)) {
|
|
4264
|
+
response = await this.dapiPublicGetPremiumIndex(params);
|
|
4265
|
+
}
|
|
4266
|
+
else {
|
|
4267
|
+
throw new errors.NotSupported(this.id + ' fetchMarkPrices() does not support ' + type + ' markets yet');
|
|
4268
|
+
}
|
|
4269
|
+
return this.parseTickers(response, symbols);
|
|
4270
|
+
}
|
|
4223
4271
|
parseOHLCV(ohlcv, market = undefined) {
|
|
4224
4272
|
// when api method = publicGetKlines || fapiPublicGetKlines || dapiPublicGetKlines
|
|
4225
4273
|
// [
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -65,6 +65,7 @@ class bingx extends bingx$1 {
|
|
|
65
65
|
'fetchMarginMode': true,
|
|
66
66
|
'fetchMarkets': true,
|
|
67
67
|
'fetchMarkOHLCV': true,
|
|
68
|
+
'fetchMarkPrices': true,
|
|
68
69
|
'fetchMyLiquidations': true,
|
|
69
70
|
'fetchOHLCV': true,
|
|
70
71
|
'fetchOpenInterest': true,
|
|
@@ -581,8 +582,8 @@ class bingx extends bingx$1 {
|
|
|
581
582
|
const networkList = this.safeList(entry, 'networkList');
|
|
582
583
|
const networks = {};
|
|
583
584
|
let fee = undefined;
|
|
584
|
-
let depositEnabled =
|
|
585
|
-
let withdrawEnabled =
|
|
585
|
+
let depositEnabled = false;
|
|
586
|
+
let withdrawEnabled = false;
|
|
586
587
|
let defaultLimits = {};
|
|
587
588
|
for (let j = 0; j < networkList.length; j++) {
|
|
588
589
|
const rawNetwork = networkList[j];
|
|
@@ -594,7 +595,7 @@ class bingx extends bingx$1 {
|
|
|
594
595
|
depositEnabled = true;
|
|
595
596
|
}
|
|
596
597
|
const networkWithdrawEnabled = this.safeBool(rawNetwork, 'withdrawEnable');
|
|
597
|
-
if (
|
|
598
|
+
if (networkWithdrawEnabled) {
|
|
598
599
|
withdrawEnabled = true;
|
|
599
600
|
}
|
|
600
601
|
const limits = {
|
|
@@ -1729,7 +1730,76 @@ class bingx extends bingx$1 {
|
|
|
1729
1730
|
const tickers = this.safeList(response, 'data');
|
|
1730
1731
|
return this.parseTickers(tickers, symbols);
|
|
1731
1732
|
}
|
|
1733
|
+
async fetchMarkPrices(symbols = undefined, params = {}) {
|
|
1734
|
+
/**
|
|
1735
|
+
* @method
|
|
1736
|
+
* @name bingx#fetchMarkPrices
|
|
1737
|
+
* @description fetches mark prices for multiple markets
|
|
1738
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20and%20Funding%20Rate
|
|
1739
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1740
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1741
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1742
|
+
*/
|
|
1743
|
+
await this.loadMarkets();
|
|
1744
|
+
let market = undefined;
|
|
1745
|
+
if (symbols !== undefined) {
|
|
1746
|
+
symbols = this.marketSymbols(symbols);
|
|
1747
|
+
const firstSymbol = this.safeString(symbols, 0);
|
|
1748
|
+
if (firstSymbol !== undefined) {
|
|
1749
|
+
market = this.market(firstSymbol);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
let subType = undefined;
|
|
1753
|
+
[subType, params] = this.handleSubTypeAndParams('fetchMarkPrices', market, params, 'linear');
|
|
1754
|
+
let response = undefined;
|
|
1755
|
+
if (subType === 'inverse') {
|
|
1756
|
+
response = await this.cswapV1PublicGetMarketPremiumIndex(params);
|
|
1757
|
+
}
|
|
1758
|
+
else {
|
|
1759
|
+
response = await this.swapV2PublicGetQuotePremiumIndex(params);
|
|
1760
|
+
}
|
|
1761
|
+
//
|
|
1762
|
+
// spot and swap
|
|
1763
|
+
//
|
|
1764
|
+
// {
|
|
1765
|
+
// "code": 0,
|
|
1766
|
+
// "msg": "",
|
|
1767
|
+
// "timestamp": 1720647285296,
|
|
1768
|
+
// "data": [
|
|
1769
|
+
// {
|
|
1770
|
+
// "symbol": "SOL-USD",
|
|
1771
|
+
// "priceChange": "-2.418",
|
|
1772
|
+
// "priceChangePercent": "-1.6900%",
|
|
1773
|
+
// "lastPrice": "140.574",
|
|
1774
|
+
// "lastQty": "1",
|
|
1775
|
+
// "highPrice": "146.190",
|
|
1776
|
+
// "lowPrice": "138.586",
|
|
1777
|
+
// "volume": "1464648.00",
|
|
1778
|
+
// "quoteVolume": "102928.12",
|
|
1779
|
+
// "openPrice": "142.994",
|
|
1780
|
+
// "closeTime": "1720647284976",
|
|
1781
|
+
// "bidPrice": "140.573",
|
|
1782
|
+
// "bidQty": "372",
|
|
1783
|
+
// "askPrice": "140.577",
|
|
1784
|
+
// "askQty": "58"
|
|
1785
|
+
// },
|
|
1786
|
+
// ...
|
|
1787
|
+
// ]
|
|
1788
|
+
// }
|
|
1789
|
+
//
|
|
1790
|
+
const tickers = this.safeList(response, 'data');
|
|
1791
|
+
return this.parseTickers(tickers, symbols);
|
|
1792
|
+
}
|
|
1732
1793
|
parseTicker(ticker, market = undefined) {
|
|
1794
|
+
//
|
|
1795
|
+
// mark price
|
|
1796
|
+
// {
|
|
1797
|
+
// "symbol": "string",
|
|
1798
|
+
// "lastFundingRate": "string",
|
|
1799
|
+
// "markPrice": "string",
|
|
1800
|
+
// "indexPrice": "string",
|
|
1801
|
+
// "nextFundingTime": "int64"
|
|
1802
|
+
// }
|
|
1733
1803
|
//
|
|
1734
1804
|
// spot
|
|
1735
1805
|
// {
|
|
@@ -1817,6 +1887,8 @@ class bingx extends bingx$1 {
|
|
|
1817
1887
|
'average': undefined,
|
|
1818
1888
|
'baseVolume': baseVolume,
|
|
1819
1889
|
'quoteVolume': quoteVolume,
|
|
1890
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
1891
|
+
'indexPrice': this.safeString(ticker, 'indexPrice'),
|
|
1820
1892
|
'info': ticker,
|
|
1821
1893
|
}, market);
|
|
1822
1894
|
}
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -2640,6 +2640,7 @@ class bitget extends bitget$1 {
|
|
|
2640
2640
|
'average': undefined,
|
|
2641
2641
|
'baseVolume': this.safeString(ticker, 'baseVolume'),
|
|
2642
2642
|
'quoteVolume': this.safeString(ticker, 'quoteVolume'),
|
|
2643
|
+
'indexPrice': this.safeString(ticker, 'indexPrice'),
|
|
2643
2644
|
'info': ticker,
|
|
2644
2645
|
}, market);
|
|
2645
2646
|
}
|
package/dist/cjs/src/bitmex.js
CHANGED
|
@@ -1437,6 +1437,7 @@ class bitmex extends bitmex$1 {
|
|
|
1437
1437
|
'average': undefined,
|
|
1438
1438
|
'baseVolume': this.safeString(ticker, 'homeNotional24h'),
|
|
1439
1439
|
'quoteVolume': this.safeString(ticker, 'foreignNotional24h'),
|
|
1440
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
1440
1441
|
'info': ticker,
|
|
1441
1442
|
}, market);
|
|
1442
1443
|
}
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -2108,6 +2108,8 @@ class bybit extends bybit$1 {
|
|
|
2108
2108
|
'average': undefined,
|
|
2109
2109
|
'baseVolume': baseVolume,
|
|
2110
2110
|
'quoteVolume': quoteVolume,
|
|
2111
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
2112
|
+
'indexPrice': this.safeString(ticker, 'indexPrice'),
|
|
2111
2113
|
'info': ticker,
|
|
2112
2114
|
}, market);
|
|
2113
2115
|
}
|
|
@@ -1505,6 +1505,8 @@ class coinbaseinternational extends coinbaseinternational$1 {
|
|
|
1505
1505
|
'baseVolume': undefined,
|
|
1506
1506
|
'quoteVolume': undefined,
|
|
1507
1507
|
'previousClose': undefined,
|
|
1508
|
+
'markPrice': this.safeNumber(ticker, 'mark_price'),
|
|
1509
|
+
'indexPrice': this.safeNumber(ticker, 'index_price'),
|
|
1508
1510
|
});
|
|
1509
1511
|
}
|
|
1510
1512
|
async fetchBalance(params = {}) {
|
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -917,6 +917,8 @@ class coinex extends coinex$1 {
|
|
|
917
917
|
'average': undefined,
|
|
918
918
|
'baseVolume': this.safeString(ticker, 'volume'),
|
|
919
919
|
'quoteVolume': undefined,
|
|
920
|
+
'markPrice': this.safeString(ticker, 'mark_price'),
|
|
921
|
+
'indexPrice': this.safeString(ticker, 'index_price'),
|
|
920
922
|
'info': ticker,
|
|
921
923
|
}, market);
|
|
922
924
|
}
|
package/dist/cjs/src/delta.js
CHANGED
|
@@ -963,6 +963,8 @@ class delta extends delta$1 {
|
|
|
963
963
|
'average': undefined,
|
|
964
964
|
'baseVolume': this.safeNumber(ticker, 'volume'),
|
|
965
965
|
'quoteVolume': this.safeNumber(ticker, 'turnover'),
|
|
966
|
+
'markPrice': this.safeNumber(ticker, 'mark_price'),
|
|
967
|
+
'indexPrice': this.safeNumber(ticker, 'spot_price'),
|
|
966
968
|
'info': ticker,
|
|
967
969
|
}, market);
|
|
968
970
|
}
|
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -1157,6 +1157,8 @@ class deribit extends deribit$1 {
|
|
|
1157
1157
|
'average': undefined,
|
|
1158
1158
|
'baseVolume': undefined,
|
|
1159
1159
|
'quoteVolume': this.safeString(stats, 'volume'),
|
|
1160
|
+
'markPrice': this.safeString(ticker, 'mark_price'),
|
|
1161
|
+
'indexPrice': this.safeString(ticker, 'index_price'),
|
|
1160
1162
|
'info': ticker,
|
|
1161
1163
|
}, market);
|
|
1162
1164
|
}
|
|
@@ -1192,6 +1192,8 @@ class digifinex extends digifinex$1 {
|
|
|
1192
1192
|
'average': undefined,
|
|
1193
1193
|
'baseVolume': this.safeString2(ticker, 'vol', 'volume_24h'),
|
|
1194
1194
|
'quoteVolume': this.safeString(ticker, 'base_vol'),
|
|
1195
|
+
'markPrice': this.safeString(ticker, 'mark_price'),
|
|
1196
|
+
'indexPrice': indexPrice,
|
|
1195
1197
|
'info': ticker,
|
|
1196
1198
|
}, market);
|
|
1197
1199
|
}
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -2610,6 +2610,8 @@ class gate extends gate$1 {
|
|
|
2610
2610
|
'average': undefined,
|
|
2611
2611
|
'baseVolume': baseVolume,
|
|
2612
2612
|
'quoteVolume': quoteVolume,
|
|
2613
|
+
'markPrice': this.safeString(ticker, 'mark_price'),
|
|
2614
|
+
'indexPrice': this.safeString(ticker, 'index_price'),
|
|
2613
2615
|
'info': ticker,
|
|
2614
2616
|
}, market);
|
|
2615
2617
|
}
|
package/dist/cjs/src/htx.js
CHANGED
|
@@ -4379,7 +4379,7 @@ class htx extends htx$1 {
|
|
|
4379
4379
|
await this.loadAccounts();
|
|
4380
4380
|
for (let i = 0; i < this.accounts.length; i++) {
|
|
4381
4381
|
const account = this.accounts[i];
|
|
4382
|
-
if (account
|
|
4382
|
+
if (this.safeString(account, 'type') === 'spot') {
|
|
4383
4383
|
accountId = this.safeString(account, 'id');
|
|
4384
4384
|
if (accountId !== undefined) {
|
|
4385
4385
|
break;
|
|
@@ -5071,7 +5071,7 @@ class htx extends htx$1 {
|
|
|
5071
5071
|
}
|
|
5072
5072
|
else {
|
|
5073
5073
|
amount = this.safeString2(order, 'volume', 'amount');
|
|
5074
|
-
cost = this.safeStringN(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']); // same typo
|
|
5074
|
+
cost = this.safeStringN(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']); // same typo here
|
|
5075
5075
|
}
|
|
5076
5076
|
const filled = this.safeStringN(order, ['filled-amount', 'field-amount', 'trade_volume']); // typo in their API, filled amount
|
|
5077
5077
|
const price = this.safeString2(order, 'price', 'order_price');
|
|
@@ -613,6 +613,8 @@ class krakenfutures extends krakenfutures$1 {
|
|
|
613
613
|
'average': average,
|
|
614
614
|
'baseVolume': baseVolume,
|
|
615
615
|
'quoteVolume': quoteVolume,
|
|
616
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
617
|
+
'indexPrice': this.safeString(ticker, 'indexPrice'),
|
|
616
618
|
'info': ticker,
|
|
617
619
|
});
|
|
618
620
|
}
|
|
@@ -966,6 +966,8 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
966
966
|
'average': undefined,
|
|
967
967
|
'baseVolume': this.safeString(ticker, 'volumeOf24h'),
|
|
968
968
|
'quoteVolume': this.safeString(ticker, 'turnoverOf24h'),
|
|
969
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
970
|
+
'indexPrice': this.safeString(ticker, 'indexPrice'),
|
|
969
971
|
'info': ticker,
|
|
970
972
|
}, market);
|
|
971
973
|
}
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -95,6 +95,7 @@ class okx extends okx$1 {
|
|
|
95
95
|
'fetchMarketLeverageTiers': true,
|
|
96
96
|
'fetchMarkets': true,
|
|
97
97
|
'fetchMarkOHLCV': true,
|
|
98
|
+
'fetchMarkPrices': true,
|
|
98
99
|
'fetchMySettlementHistory': false,
|
|
99
100
|
'fetchMyTrades': true,
|
|
100
101
|
'fetchOHLCV': true,
|
|
@@ -1801,6 +1802,13 @@ class okx extends okx$1 {
|
|
|
1801
1802
|
return this.parseOrderBook(first, symbol, timestamp);
|
|
1802
1803
|
}
|
|
1803
1804
|
parseTicker(ticker, market = undefined) {
|
|
1805
|
+
//
|
|
1806
|
+
// {
|
|
1807
|
+
// "instType":"SWAP",
|
|
1808
|
+
// "instId":"BTC-USDT-SWAP",
|
|
1809
|
+
// "markPx":"200",
|
|
1810
|
+
// "ts":"1597026383085"
|
|
1811
|
+
// }
|
|
1804
1812
|
//
|
|
1805
1813
|
// {
|
|
1806
1814
|
// "instType": "SPOT",
|
|
@@ -1852,6 +1860,7 @@ class okx extends okx$1 {
|
|
|
1852
1860
|
'average': undefined,
|
|
1853
1861
|
'baseVolume': baseVolume,
|
|
1854
1862
|
'quoteVolume': quoteVolume,
|
|
1863
|
+
'markPrice': this.safeString(ticker, 'markPx'),
|
|
1855
1864
|
'info': ticker,
|
|
1856
1865
|
}, market);
|
|
1857
1866
|
}
|
|
@@ -1959,6 +1968,38 @@ class okx extends okx$1 {
|
|
|
1959
1968
|
const tickers = this.safeList(response, 'data', []);
|
|
1960
1969
|
return this.parseTickers(tickers, symbols);
|
|
1961
1970
|
}
|
|
1971
|
+
async fetchMarkPrices(symbols = undefined, params = {}) {
|
|
1972
|
+
/**
|
|
1973
|
+
* @method
|
|
1974
|
+
* @name okx#fetchMarkPrices
|
|
1975
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1976
|
+
* @see https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price
|
|
1977
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1978
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1979
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1980
|
+
*/
|
|
1981
|
+
await this.loadMarkets();
|
|
1982
|
+
symbols = this.marketSymbols(symbols);
|
|
1983
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
1984
|
+
let marketType = undefined;
|
|
1985
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params, 'swap');
|
|
1986
|
+
const request = {
|
|
1987
|
+
'instType': this.convertToInstrumentType(marketType),
|
|
1988
|
+
};
|
|
1989
|
+
if (marketType === 'option') {
|
|
1990
|
+
const defaultUnderlying = this.safeString(this.options, 'defaultUnderlying', 'BTC-USD');
|
|
1991
|
+
const currencyId = this.safeString2(params, 'uly', 'marketId', defaultUnderlying);
|
|
1992
|
+
if (currencyId === undefined) {
|
|
1993
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets');
|
|
1994
|
+
}
|
|
1995
|
+
else {
|
|
1996
|
+
request['uly'] = currencyId;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
const response = await this.publicGetPublicMarkPrice(this.extend(request, params));
|
|
2000
|
+
const tickers = this.safeList(response, 'data', []);
|
|
2001
|
+
return this.parseTickers(tickers, symbols);
|
|
2002
|
+
}
|
|
1962
2003
|
parseTrade(trade, market = undefined) {
|
|
1963
2004
|
//
|
|
1964
2005
|
// public fetchTrades
|
package/dist/cjs/src/oxfun.js
CHANGED
package/dist/cjs/src/paradex.js
CHANGED
package/dist/cjs/src/poloniex.js
CHANGED
|
@@ -627,6 +627,7 @@ class poloniex extends poloniex$1 {
|
|
|
627
627
|
'average': undefined,
|
|
628
628
|
'baseVolume': this.safeString(ticker, 'quantity'),
|
|
629
629
|
'quoteVolume': this.safeString(ticker, 'amount'),
|
|
630
|
+
'markPrice': this.safeString(ticker, 'markPrice'),
|
|
630
631
|
'info': ticker,
|
|
631
632
|
}, market);
|
|
632
633
|
}
|
|
@@ -36,6 +36,8 @@ class binance extends binance$1 {
|
|
|
36
36
|
'watchPositions': true,
|
|
37
37
|
'watchTicker': true,
|
|
38
38
|
'watchTickers': true,
|
|
39
|
+
'watchMarkPrices': true,
|
|
40
|
+
'watchMarkPrice': true,
|
|
39
41
|
'watchTrades': true,
|
|
40
42
|
'watchTradesForSymbols': true,
|
|
41
43
|
'createOrderWs': true,
|
|
@@ -152,6 +154,7 @@ class binance extends binance$1 {
|
|
|
152
154
|
'tickerChannelsMap': {
|
|
153
155
|
'24hrTicker': 'ticker',
|
|
154
156
|
'24hrMiniTicker': 'miniTicker',
|
|
157
|
+
'markPriceUpdate': 'markPrice',
|
|
155
158
|
// rolling window tickers
|
|
156
159
|
'1hTicker': 'ticker_1h',
|
|
157
160
|
'4hTicker': 'ticker_4h',
|
|
@@ -1767,6 +1770,44 @@ class binance extends binance$1 {
|
|
|
1767
1770
|
const tickers = await this.watchTickers([symbol], this.extend(params, { 'callerMethodName': 'watchTicker' }));
|
|
1768
1771
|
return tickers[symbol];
|
|
1769
1772
|
}
|
|
1773
|
+
async watchMarkPrice(symbol, params = {}) {
|
|
1774
|
+
/**
|
|
1775
|
+
* @method
|
|
1776
|
+
* @name binance#watchMarkPrice
|
|
1777
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/websocket-market-streams/Mark-Price-Stream
|
|
1778
|
+
* @description watches a mark price for a specific market
|
|
1779
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1780
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1781
|
+
* @param {boolean} [params.use1sFreq] *default is true* if set to true, the mark price will be updated every second, otherwise every 3 seconds
|
|
1782
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1783
|
+
*/
|
|
1784
|
+
await this.loadMarkets();
|
|
1785
|
+
symbol = this.symbol(symbol);
|
|
1786
|
+
const tickers = await this.watchMarkPrices([symbol], this.extend(params, { 'callerMethodName': 'watchMarkPrice' }));
|
|
1787
|
+
return tickers[symbol];
|
|
1788
|
+
}
|
|
1789
|
+
async watchMarkPrices(symbols = undefined, params = {}) {
|
|
1790
|
+
/**
|
|
1791
|
+
* @method
|
|
1792
|
+
* @name binance#watchMarkPrices
|
|
1793
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/websocket-market-streams/Mark-Price-Stream-for-All-market
|
|
1794
|
+
* @description watches the mark price for all markets
|
|
1795
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
1796
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1797
|
+
* @param {boolean} [params.use1sFreq] *default is true* if set to true, the mark price will be updated every second, otherwise every 3 seconds
|
|
1798
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1799
|
+
*/
|
|
1800
|
+
let channelName = undefined;
|
|
1801
|
+
// for now watchmarkPrice uses the same messageHash as watchTicker
|
|
1802
|
+
// so it's impossible to watch both at the same time
|
|
1803
|
+
// refactor this to use different messageHashes
|
|
1804
|
+
[channelName, params] = this.handleOptionAndParams(params, 'watchMarkPrices', 'name', 'markPrice');
|
|
1805
|
+
const newTickers = await this.watchMultiTickerHelper('watchMarkPrices', channelName, symbols, params);
|
|
1806
|
+
if (this.newUpdates) {
|
|
1807
|
+
return newTickers;
|
|
1808
|
+
}
|
|
1809
|
+
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
1810
|
+
}
|
|
1770
1811
|
async watchTickers(symbols = undefined, params = {}) {
|
|
1771
1812
|
/**
|
|
1772
1813
|
* @method
|
|
@@ -1922,13 +1963,17 @@ class binance extends binance$1 {
|
|
|
1922
1963
|
async watchMultiTickerHelper(methodName, channelName, symbols = undefined, params = {}) {
|
|
1923
1964
|
await this.loadMarkets();
|
|
1924
1965
|
symbols = this.marketSymbols(symbols, undefined, true, false, true);
|
|
1966
|
+
const isBidAsk = (channelName === 'bookTicker');
|
|
1967
|
+
const isMarkPrice = (channelName === 'markPrice');
|
|
1968
|
+
const use1sFreq = this.safeBool(params, 'use1sFreq', true);
|
|
1925
1969
|
let firstMarket = undefined;
|
|
1926
1970
|
let marketType = undefined;
|
|
1927
1971
|
const symbolsDefined = (symbols !== undefined);
|
|
1928
1972
|
if (symbolsDefined) {
|
|
1929
1973
|
firstMarket = this.market(symbols[0]);
|
|
1930
1974
|
}
|
|
1931
|
-
|
|
1975
|
+
const defaultMarket = (isMarkPrice) ? 'swap' : 'spot';
|
|
1976
|
+
[marketType, params] = this.handleMarketTypeAndParams(methodName, firstMarket, params, defaultMarket);
|
|
1932
1977
|
let subType = undefined;
|
|
1933
1978
|
[subType, params] = this.handleSubTypeAndParams(methodName, firstMarket, params);
|
|
1934
1979
|
let rawMarketType = undefined;
|
|
@@ -1944,14 +1989,17 @@ class binance extends binance$1 {
|
|
|
1944
1989
|
else {
|
|
1945
1990
|
throw new errors.NotSupported(this.id + ' ' + methodName + '() does not support options markets');
|
|
1946
1991
|
}
|
|
1947
|
-
const isBidAsk = (channelName === 'bookTicker');
|
|
1948
1992
|
const subscriptionArgs = [];
|
|
1949
1993
|
const messageHashes = [];
|
|
1994
|
+
let suffix = '';
|
|
1995
|
+
if (isMarkPrice) {
|
|
1996
|
+
suffix = (use1sFreq) ? '@1s' : '';
|
|
1997
|
+
}
|
|
1950
1998
|
if (symbolsDefined) {
|
|
1951
1999
|
for (let i = 0; i < symbols.length; i++) {
|
|
1952
2000
|
const symbol = symbols[i];
|
|
1953
2001
|
const market = this.market(symbol);
|
|
1954
|
-
subscriptionArgs.push(market['lowercaseId'] + '@' + channelName);
|
|
2002
|
+
subscriptionArgs.push(market['lowercaseId'] + '@' + channelName + suffix);
|
|
1955
2003
|
messageHashes.push(this.getMessageHash(channelName, market['symbol'], isBidAsk));
|
|
1956
2004
|
}
|
|
1957
2005
|
}
|
|
@@ -1962,6 +2010,9 @@ class binance extends binance$1 {
|
|
|
1962
2010
|
}
|
|
1963
2011
|
subscriptionArgs.push('!' + channelName);
|
|
1964
2012
|
}
|
|
2013
|
+
else if (isMarkPrice) {
|
|
2014
|
+
subscriptionArgs.push('!' + channelName + '@arr' + suffix);
|
|
2015
|
+
}
|
|
1965
2016
|
else {
|
|
1966
2017
|
subscriptionArgs.push('!' + channelName + '@arr');
|
|
1967
2018
|
}
|
|
@@ -1994,6 +2045,17 @@ class binance extends binance$1 {
|
|
|
1994
2045
|
}
|
|
1995
2046
|
}
|
|
1996
2047
|
parseWsTicker(message, marketType) {
|
|
2048
|
+
// markPrice
|
|
2049
|
+
// {
|
|
2050
|
+
// "e": "markPriceUpdate", // Event type
|
|
2051
|
+
// "E": 1562305380000, // Event time
|
|
2052
|
+
// "s": "BTCUSDT", // Symbol
|
|
2053
|
+
// "p": "11794.15000000", // Mark price
|
|
2054
|
+
// "i": "11784.62659091", // Index price
|
|
2055
|
+
// "P": "11784.25641265", // Estimated Settle Price, only useful in the last hour before the settlement starts
|
|
2056
|
+
// "r": "0.00038167", // Funding rate
|
|
2057
|
+
// "T": 1562306400000 // Next funding time
|
|
2058
|
+
// }
|
|
1997
2059
|
//
|
|
1998
2060
|
// ticker
|
|
1999
2061
|
// {
|
|
@@ -2051,10 +2113,23 @@ class binance extends binance$1 {
|
|
|
2051
2113
|
// "time":1589437530011,
|
|
2052
2114
|
// }
|
|
2053
2115
|
//
|
|
2116
|
+
const marketId = this.safeString2(message, 's', 'symbol');
|
|
2117
|
+
const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
|
|
2054
2118
|
let event = this.safeString(message, 'e', 'bookTicker');
|
|
2055
2119
|
if (event === '24hrTicker') {
|
|
2056
2120
|
event = 'ticker';
|
|
2057
2121
|
}
|
|
2122
|
+
if (event === 'markPriceUpdate') {
|
|
2123
|
+
// handle this separately because some fields clash with the ticker fields
|
|
2124
|
+
return this.safeTicker({
|
|
2125
|
+
'symbol': symbol,
|
|
2126
|
+
'timestamp': this.safeInteger(message, 'E'),
|
|
2127
|
+
'datetime': this.iso8601(this.safeInteger(message, 'E')),
|
|
2128
|
+
'info': message,
|
|
2129
|
+
'markPrice': this.safeString(message, 'p'),
|
|
2130
|
+
'indexPrice': this.safeString(message, 'i'),
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2058
2133
|
let timestamp = undefined;
|
|
2059
2134
|
if (event === 'bookTicker') {
|
|
2060
2135
|
// take the event timestamp, if available, for spot tickers it is not
|
|
@@ -2064,8 +2139,6 @@ class binance extends binance$1 {
|
|
|
2064
2139
|
// take the timestamp of the closing price for candlestick streams
|
|
2065
2140
|
timestamp = this.safeIntegerN(message, ['C', 'E', 'time']);
|
|
2066
2141
|
}
|
|
2067
|
-
const marketId = this.safeString2(message, 's', 'symbol');
|
|
2068
|
-
const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
|
|
2069
2142
|
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
2070
2143
|
const last = this.safeString2(message, 'c', 'price');
|
|
2071
2144
|
return this.safeTicker({
|
|
@@ -4234,6 +4307,8 @@ class binance extends binance$1 {
|
|
|
4234
4307
|
'1dTicker': this.handleTickers,
|
|
4235
4308
|
'24hrTicker': this.handleTickers,
|
|
4236
4309
|
'24hrMiniTicker': this.handleTickers,
|
|
4310
|
+
'markPriceUpdate': this.handleTickers,
|
|
4311
|
+
'markPriceUpdate@arr': this.handleTickers,
|
|
4237
4312
|
'bookTicker': this.handleBidsAsks,
|
|
4238
4313
|
'outboundAccountPosition': this.handleBalance,
|
|
4239
4314
|
'balanceUpdate': this.handleBalance,
|