ccxt 4.4.12__py2.py3-none-any.whl → 4.4.13__py2.py3-none-any.whl
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.
- ccxt/__init__.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +4 -1
- ccxt/async_support/bigone.py +2 -0
- ccxt/async_support/binance.py +44 -1
- ccxt/async_support/bingx.py +69 -3
- ccxt/async_support/bitget.py +1 -0
- ccxt/async_support/bitmex.py +1 -0
- ccxt/async_support/bybit.py +2 -0
- ccxt/async_support/coinbaseinternational.py +2 -0
- ccxt/async_support/coinex.py +2 -0
- ccxt/async_support/delta.py +2 -0
- ccxt/async_support/deribit.py +2 -0
- ccxt/async_support/digifinex.py +2 -0
- ccxt/async_support/gate.py +2 -0
- ccxt/async_support/htx.py +2 -2
- ccxt/async_support/krakenfutures.py +2 -0
- ccxt/async_support/kucoinfutures.py +2 -0
- ccxt/async_support/okx.py +36 -0
- ccxt/async_support/oxfun.py +1 -0
- ccxt/async_support/paradex.py +1 -0
- ccxt/async_support/poloniex.py +1 -0
- ccxt/base/exchange.py +7 -1
- ccxt/base/types.py +2 -0
- ccxt/bigone.py +2 -0
- ccxt/binance.py +44 -1
- ccxt/bingx.py +69 -3
- ccxt/bitget.py +1 -0
- ccxt/bitmex.py +1 -0
- ccxt/bybit.py +2 -0
- ccxt/coinbaseinternational.py +2 -0
- ccxt/coinex.py +2 -0
- ccxt/delta.py +2 -0
- ccxt/deribit.py +2 -0
- ccxt/digifinex.py +2 -0
- ccxt/gate.py +2 -0
- ccxt/htx.py +2 -2
- ccxt/krakenfutures.py +2 -0
- ccxt/kucoinfutures.py +2 -0
- ccxt/okx.py +36 -0
- ccxt/oxfun.py +1 -0
- ccxt/paradex.py +1 -0
- ccxt/poloniex.py +1 -0
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +72 -5
- ccxt/pro/bitfinex.py +8 -8
- ccxt/pro/krakenfutures.py +2 -0
- ccxt/pro/phemex.py +2 -0
- ccxt/pro/woo.py +69 -0
- ccxt/test/tests_async.py +31 -3
- ccxt/test/tests_helpers.py +13 -36
- ccxt/test/tests_init.py +6 -2
- ccxt/test/tests_sync.py +31 -3
- {ccxt-4.4.12.dist-info → ccxt-4.4.13.dist-info}/METADATA +4 -5
- {ccxt-4.4.12.dist-info → ccxt-4.4.13.dist-info}/RECORD +58 -58
- {ccxt-4.4.12.dist-info → ccxt-4.4.13.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.12.dist-info → ccxt-4.4.13.dist-info}/WHEEL +0 -0
- {ccxt-4.4.12.dist-info → ccxt-4.4.13.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/async_support/__init__.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# -----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
__version__ = '4.4.
|
5
|
+
__version__ = '4.4.13'
|
6
6
|
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
@@ -1036,6 +1036,9 @@ class Exchange(BaseExchange):
|
|
1036
1036
|
async def fetch_tickers(self, symbols: Strings = None, params={}):
|
1037
1037
|
raise NotSupported(self.id + ' fetchTickers() is not supported yet')
|
1038
1038
|
|
1039
|
+
async def fetch_mark_prices(self, symbols: Strings = None, params={}):
|
1040
|
+
raise NotSupported(self.id + ' fetchMarkPrices() is not supported yet')
|
1041
|
+
|
1039
1042
|
async def fetch_tickers_ws(self, symbols: Strings = None, params={}):
|
1040
1043
|
raise NotSupported(self.id + ' fetchTickers() is not supported yet')
|
1041
1044
|
|
ccxt/async_support/bigone.py
CHANGED
@@ -724,6 +724,8 @@ class bigone(Exchange, ImplicitAPI):
|
|
724
724
|
'average': None,
|
725
725
|
'baseVolume': self.safe_string_2(ticker, 'volume', 'volume24h'),
|
726
726
|
'quoteVolume': self.safe_string(ticker, 'volume24hInUsd'),
|
727
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
728
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
727
729
|
'info': ticker,
|
728
730
|
}, market)
|
729
731
|
|
ccxt/async_support/binance.py
CHANGED
@@ -133,6 +133,7 @@ class binance(Exchange, ImplicitAPI):
|
|
133
133
|
'fetchMarketLeverageTiers': 'emulated',
|
134
134
|
'fetchMarkets': True,
|
135
135
|
'fetchMarkOHLCV': True,
|
136
|
+
'fetchMarkPrices': True,
|
136
137
|
'fetchMyLiquidations': True,
|
137
138
|
'fetchMySettlementHistory': True,
|
138
139
|
'fetchMyTrades': True,
|
@@ -1217,6 +1218,9 @@ class binance(Exchange, ImplicitAPI):
|
|
1217
1218
|
},
|
1218
1219
|
'option': {},
|
1219
1220
|
},
|
1221
|
+
'currencies': {
|
1222
|
+
'BNFCR': self.safe_currency_structure({'id': 'BNFCR', 'code': 'BNFCR', 'precision': self.parse_number('0.001')}),
|
1223
|
+
},
|
1220
1224
|
'commonCurrencies': {
|
1221
1225
|
'BCC': 'BCC', # kept for backward-compatibility https://github.com/ccxt/ccxt/issues/4848
|
1222
1226
|
'YOYO': 'YOYOW',
|
@@ -3715,6 +3719,18 @@ class binance(Exchange, ImplicitAPI):
|
|
3715
3719
|
return orderbook
|
3716
3720
|
|
3717
3721
|
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
3722
|
+
# markPrices
|
3723
|
+
#
|
3724
|
+
# {
|
3725
|
+
# "symbol": "BTCUSDT",
|
3726
|
+
# "markPrice": "11793.63104562", # mark price
|
3727
|
+
# "indexPrice": "11781.80495970", # index price
|
3728
|
+
# "estimatedSettlePrice": "11781.16138815", # Estimated Settle Price, only useful in the last hour before the settlement starts.
|
3729
|
+
# "lastFundingRate": "0.00038246", # This is the lastest estimated funding rate
|
3730
|
+
# "nextFundingTime": 1597392000000,
|
3731
|
+
# "interestRate": "0.00010000",
|
3732
|
+
# "time": 1597370495002
|
3733
|
+
# }
|
3718
3734
|
#
|
3719
3735
|
# {
|
3720
3736
|
# "symbol": "ETHBTC",
|
@@ -3818,7 +3834,7 @@ class binance(Exchange, ImplicitAPI):
|
|
3818
3834
|
# "time":"1673899278514"
|
3819
3835
|
# }
|
3820
3836
|
#
|
3821
|
-
timestamp = self.
|
3837
|
+
timestamp = self.safe_integer_2(ticker, 'closeTime', 'time')
|
3822
3838
|
marketType = None
|
3823
3839
|
if ('time' in ticker):
|
3824
3840
|
marketType = 'contract'
|
@@ -3858,6 +3874,8 @@ class binance(Exchange, ImplicitAPI):
|
|
3858
3874
|
'average': None,
|
3859
3875
|
'baseVolume': baseVolume,
|
3860
3876
|
'quoteVolume': quoteVolume,
|
3877
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
3878
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
3861
3879
|
'info': ticker,
|
3862
3880
|
}, market)
|
3863
3881
|
|
@@ -4088,6 +4106,31 @@ class binance(Exchange, ImplicitAPI):
|
|
4088
4106
|
raise NotSupported(self.id + ' fetchTickers() does not support ' + type + ' markets yet')
|
4089
4107
|
return self.parse_tickers(response, symbols)
|
4090
4108
|
|
4109
|
+
async def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
|
4110
|
+
"""
|
4111
|
+
fetches mark prices for multiple markets
|
4112
|
+
:see: https://binance-docs.github.io/apidocs/futures/en/#mark-price
|
4113
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
4114
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4115
|
+
:param str [params.subType]: "linear" or "inverse"
|
4116
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
4117
|
+
"""
|
4118
|
+
await self.load_markets()
|
4119
|
+
symbols = self.market_symbols(symbols, None, True, True, True)
|
4120
|
+
market = self.get_market_from_symbols(symbols)
|
4121
|
+
type = None
|
4122
|
+
type, params = self.handle_market_type_and_params('fetchTickers', market, params, 'swap')
|
4123
|
+
subType = None
|
4124
|
+
subType, params = self.handle_sub_type_and_params('fetchTickers', market, params, 'linear')
|
4125
|
+
response = None
|
4126
|
+
if self.is_linear(type, subType):
|
4127
|
+
response = await self.fapiPublicGetPremiumIndex(params)
|
4128
|
+
elif self.is_inverse(type, subType):
|
4129
|
+
response = await self.dapiPublicGetPremiumIndex(params)
|
4130
|
+
else:
|
4131
|
+
raise NotSupported(self.id + ' fetchMarkPrices() does not support ' + type + ' markets yet')
|
4132
|
+
return self.parse_tickers(response, symbols)
|
4133
|
+
|
4091
4134
|
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
4092
4135
|
# when api method = publicGetKlines or fapiPublicGetKlines or dapiPublicGetKlines
|
4093
4136
|
# [
|
ccxt/async_support/bingx.py
CHANGED
@@ -81,6 +81,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
81
81
|
'fetchMarginMode': True,
|
82
82
|
'fetchMarkets': True,
|
83
83
|
'fetchMarkOHLCV': True,
|
84
|
+
'fetchMarkPrices': True,
|
84
85
|
'fetchMyLiquidations': True,
|
85
86
|
'fetchOHLCV': True,
|
86
87
|
'fetchOpenInterest': True,
|
@@ -591,8 +592,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
591
592
|
networkList = self.safe_list(entry, 'networkList')
|
592
593
|
networks: dict = {}
|
593
594
|
fee = None
|
594
|
-
depositEnabled =
|
595
|
-
withdrawEnabled =
|
595
|
+
depositEnabled = False
|
596
|
+
withdrawEnabled = False
|
596
597
|
defaultLimits: dict = {}
|
597
598
|
for j in range(0, len(networkList)):
|
598
599
|
rawNetwork = networkList[j]
|
@@ -603,7 +604,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
603
604
|
if networkDepositEnabled:
|
604
605
|
depositEnabled = True
|
605
606
|
networkWithdrawEnabled = self.safe_bool(rawNetwork, 'withdrawEnable')
|
606
|
-
if
|
607
|
+
if networkWithdrawEnabled:
|
607
608
|
withdrawEnabled = True
|
608
609
|
limits: dict = {
|
609
610
|
'withdraw': {
|
@@ -1655,7 +1656,70 @@ class bingx(Exchange, ImplicitAPI):
|
|
1655
1656
|
tickers = self.safe_list(response, 'data')
|
1656
1657
|
return self.parse_tickers(tickers, symbols)
|
1657
1658
|
|
1659
|
+
async def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
|
1660
|
+
"""
|
1661
|
+
fetches mark prices for multiple markets
|
1662
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20and%20Funding%20Rate
|
1663
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1664
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1665
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1666
|
+
"""
|
1667
|
+
await self.load_markets()
|
1668
|
+
market = None
|
1669
|
+
if symbols is not None:
|
1670
|
+
symbols = self.market_symbols(symbols)
|
1671
|
+
firstSymbol = self.safe_string(symbols, 0)
|
1672
|
+
if firstSymbol is not None:
|
1673
|
+
market = self.market(firstSymbol)
|
1674
|
+
subType = None
|
1675
|
+
subType, params = self.handle_sub_type_and_params('fetchMarkPrices', market, params, 'linear')
|
1676
|
+
response = None
|
1677
|
+
if subType == 'inverse':
|
1678
|
+
response = await self.cswapV1PublicGetMarketPremiumIndex(params)
|
1679
|
+
else:
|
1680
|
+
response = await self.swapV2PublicGetQuotePremiumIndex(params)
|
1681
|
+
#
|
1682
|
+
# spot and swap
|
1683
|
+
#
|
1684
|
+
# {
|
1685
|
+
# "code": 0,
|
1686
|
+
# "msg": "",
|
1687
|
+
# "timestamp": 1720647285296,
|
1688
|
+
# "data": [
|
1689
|
+
# {
|
1690
|
+
# "symbol": "SOL-USD",
|
1691
|
+
# "priceChange": "-2.418",
|
1692
|
+
# "priceChangePercent": "-1.6900%",
|
1693
|
+
# "lastPrice": "140.574",
|
1694
|
+
# "lastQty": "1",
|
1695
|
+
# "highPrice": "146.190",
|
1696
|
+
# "lowPrice": "138.586",
|
1697
|
+
# "volume": "1464648.00",
|
1698
|
+
# "quoteVolume": "102928.12",
|
1699
|
+
# "openPrice": "142.994",
|
1700
|
+
# "closeTime": "1720647284976",
|
1701
|
+
# "bidPrice": "140.573",
|
1702
|
+
# "bidQty": "372",
|
1703
|
+
# "askPrice": "140.577",
|
1704
|
+
# "askQty": "58"
|
1705
|
+
# },
|
1706
|
+
# ...
|
1707
|
+
# ]
|
1708
|
+
# }
|
1709
|
+
#
|
1710
|
+
tickers = self.safe_list(response, 'data')
|
1711
|
+
return self.parse_tickers(tickers, symbols)
|
1712
|
+
|
1658
1713
|
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
1714
|
+
#
|
1715
|
+
# mark price
|
1716
|
+
# {
|
1717
|
+
# "symbol": "string",
|
1718
|
+
# "lastFundingRate": "string",
|
1719
|
+
# "markPrice": "string",
|
1720
|
+
# "indexPrice": "string",
|
1721
|
+
# "nextFundingTime": "int64"
|
1722
|
+
# }
|
1659
1723
|
#
|
1660
1724
|
# spot
|
1661
1725
|
# {
|
@@ -1741,6 +1805,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
1741
1805
|
'average': None,
|
1742
1806
|
'baseVolume': baseVolume,
|
1743
1807
|
'quoteVolume': quoteVolume,
|
1808
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
1809
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
1744
1810
|
'info': ticker,
|
1745
1811
|
}, market)
|
1746
1812
|
|
ccxt/async_support/bitget.py
CHANGED
@@ -2570,6 +2570,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2570
2570
|
'average': None,
|
2571
2571
|
'baseVolume': self.safe_string(ticker, 'baseVolume'),
|
2572
2572
|
'quoteVolume': self.safe_string(ticker, 'quoteVolume'),
|
2573
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
2573
2574
|
'info': ticker,
|
2574
2575
|
}, market)
|
2575
2576
|
|
ccxt/async_support/bitmex.py
CHANGED
@@ -1370,6 +1370,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1370
1370
|
'average': None,
|
1371
1371
|
'baseVolume': self.safe_string(ticker, 'homeNotional24h'),
|
1372
1372
|
'quoteVolume': self.safe_string(ticker, 'foreignNotional24h'),
|
1373
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
1373
1374
|
'info': ticker,
|
1374
1375
|
}, market)
|
1375
1376
|
|
ccxt/async_support/bybit.py
CHANGED
@@ -2054,6 +2054,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
2054
2054
|
'average': None,
|
2055
2055
|
'baseVolume': baseVolume,
|
2056
2056
|
'quoteVolume': quoteVolume,
|
2057
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
2058
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
2057
2059
|
'info': ticker,
|
2058
2060
|
}, market)
|
2059
2061
|
|
@@ -1426,6 +1426,8 @@ class coinbaseinternational(Exchange, ImplicitAPI):
|
|
1426
1426
|
'baseVolume': None,
|
1427
1427
|
'quoteVolume': None,
|
1428
1428
|
'previousClose': None,
|
1429
|
+
'markPrice': self.safe_number(ticker, 'mark_price'),
|
1430
|
+
'indexPrice': self.safe_number(ticker, 'index_price'),
|
1429
1431
|
})
|
1430
1432
|
|
1431
1433
|
async def fetch_balance(self, params={}) -> Balances:
|
ccxt/async_support/coinex.py
CHANGED
@@ -922,6 +922,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
922
922
|
'average': None,
|
923
923
|
'baseVolume': self.safe_string(ticker, 'volume'),
|
924
924
|
'quoteVolume': None,
|
925
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
926
|
+
'indexPrice': self.safe_string(ticker, 'index_price'),
|
925
927
|
'info': ticker,
|
926
928
|
}, market)
|
927
929
|
|
ccxt/async_support/delta.py
CHANGED
@@ -946,6 +946,8 @@ class delta(Exchange, ImplicitAPI):
|
|
946
946
|
'average': None,
|
947
947
|
'baseVolume': self.safe_number(ticker, 'volume'),
|
948
948
|
'quoteVolume': self.safe_number(ticker, 'turnover'),
|
949
|
+
'markPrice': self.safe_number(ticker, 'mark_price'),
|
950
|
+
'indexPrice': self.safe_number(ticker, 'spot_price'),
|
949
951
|
'info': ticker,
|
950
952
|
}, market)
|
951
953
|
|
ccxt/async_support/deribit.py
CHANGED
@@ -1133,6 +1133,8 @@ class deribit(Exchange, ImplicitAPI):
|
|
1133
1133
|
'average': None,
|
1134
1134
|
'baseVolume': None,
|
1135
1135
|
'quoteVolume': self.safe_string(stats, 'volume'),
|
1136
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
1137
|
+
'indexPrice': self.safe_string(ticker, 'index_price'),
|
1136
1138
|
'info': ticker,
|
1137
1139
|
}, market)
|
1138
1140
|
|
ccxt/async_support/digifinex.py
CHANGED
@@ -1164,6 +1164,8 @@ class digifinex(Exchange, ImplicitAPI):
|
|
1164
1164
|
'average': None,
|
1165
1165
|
'baseVolume': self.safe_string_2(ticker, 'vol', 'volume_24h'),
|
1166
1166
|
'quoteVolume': self.safe_string(ticker, 'base_vol'),
|
1167
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
1168
|
+
'indexPrice': indexPrice,
|
1167
1169
|
'info': ticker,
|
1168
1170
|
}, market)
|
1169
1171
|
|
ccxt/async_support/gate.py
CHANGED
@@ -2515,6 +2515,8 @@ class gate(Exchange, ImplicitAPI):
|
|
2515
2515
|
'average': None,
|
2516
2516
|
'baseVolume': baseVolume,
|
2517
2517
|
'quoteVolume': quoteVolume,
|
2518
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
2519
|
+
'indexPrice': self.safe_string(ticker, 'index_price'),
|
2518
2520
|
'info': ticker,
|
2519
2521
|
}, market)
|
2520
2522
|
|
ccxt/async_support/htx.py
CHANGED
@@ -4088,7 +4088,7 @@ class htx(Exchange, ImplicitAPI):
|
|
4088
4088
|
await self.load_accounts()
|
4089
4089
|
for i in range(0, len(self.accounts)):
|
4090
4090
|
account = self.accounts[i]
|
4091
|
-
if account
|
4091
|
+
if self.safe_string(account, 'type') == 'spot':
|
4092
4092
|
accountId = self.safe_string(account, 'id')
|
4093
4093
|
if accountId is not None:
|
4094
4094
|
break
|
@@ -4743,7 +4743,7 @@ class htx(Exchange, ImplicitAPI):
|
|
4743
4743
|
cost = self.safe_string(order, 'amount')
|
4744
4744
|
else:
|
4745
4745
|
amount = self.safe_string_2(order, 'volume', 'amount')
|
4746
|
-
cost = self.safe_string_n(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']) # same typo
|
4746
|
+
cost = self.safe_string_n(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']) # same typo here
|
4747
4747
|
filled = self.safe_string_n(order, ['filled-amount', 'field-amount', 'trade_volume']) # typo in their API, filled amount
|
4748
4748
|
price = self.safe_string_2(order, 'price', 'order_price')
|
4749
4749
|
feeCost = self.safe_string_2(order, 'filled-fees', 'field-fees') # typo in their API, filled feeSide
|
@@ -611,6 +611,8 @@ class krakenfutures(Exchange, ImplicitAPI):
|
|
611
611
|
'average': average,
|
612
612
|
'baseVolume': baseVolume,
|
613
613
|
'quoteVolume': quoteVolume,
|
614
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
615
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
614
616
|
'info': ticker,
|
615
617
|
})
|
616
618
|
|
@@ -944,6 +944,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
944
944
|
'average': None,
|
945
945
|
'baseVolume': self.safe_string(ticker, 'volumeOf24h'),
|
946
946
|
'quoteVolume': self.safe_string(ticker, 'turnoverOf24h'),
|
947
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
948
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
947
949
|
'info': ticker,
|
948
950
|
}, market)
|
949
951
|
|
ccxt/async_support/okx.py
CHANGED
@@ -121,6 +121,7 @@ class okx(Exchange, ImplicitAPI):
|
|
121
121
|
'fetchMarketLeverageTiers': True,
|
122
122
|
'fetchMarkets': True,
|
123
123
|
'fetchMarkOHLCV': True,
|
124
|
+
'fetchMarkPrices': True,
|
124
125
|
'fetchMySettlementHistory': False,
|
125
126
|
'fetchMyTrades': True,
|
126
127
|
'fetchOHLCV': True,
|
@@ -1785,6 +1786,13 @@ class okx(Exchange, ImplicitAPI):
|
|
1785
1786
|
return self.parse_order_book(first, symbol, timestamp)
|
1786
1787
|
|
1787
1788
|
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
1789
|
+
#
|
1790
|
+
# {
|
1791
|
+
# "instType":"SWAP",
|
1792
|
+
# "instId":"BTC-USDT-SWAP",
|
1793
|
+
# "markPx":"200",
|
1794
|
+
# "ts":"1597026383085"
|
1795
|
+
# }
|
1788
1796
|
#
|
1789
1797
|
# {
|
1790
1798
|
# "instType": "SPOT",
|
@@ -1836,6 +1844,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1836
1844
|
'average': None,
|
1837
1845
|
'baseVolume': baseVolume,
|
1838
1846
|
'quoteVolume': quoteVolume,
|
1847
|
+
'markPrice': self.safe_string(ticker, 'markPx'),
|
1839
1848
|
'info': ticker,
|
1840
1849
|
}, market)
|
1841
1850
|
|
@@ -1936,6 +1945,33 @@ class okx(Exchange, ImplicitAPI):
|
|
1936
1945
|
tickers = self.safe_list(response, 'data', [])
|
1937
1946
|
return self.parse_tickers(tickers, symbols)
|
1938
1947
|
|
1948
|
+
async def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
|
1949
|
+
"""
|
1950
|
+
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
1951
|
+
:see: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price
|
1952
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1953
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1954
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1955
|
+
"""
|
1956
|
+
await self.load_markets()
|
1957
|
+
symbols = self.market_symbols(symbols)
|
1958
|
+
market = self.get_market_from_symbols(symbols)
|
1959
|
+
marketType = None
|
1960
|
+
marketType, params = self.handle_market_type_and_params('fetchTickers', market, params, 'swap')
|
1961
|
+
request: dict = {
|
1962
|
+
'instType': self.convert_to_instrument_type(marketType),
|
1963
|
+
}
|
1964
|
+
if marketType == 'option':
|
1965
|
+
defaultUnderlying = self.safe_string(self.options, 'defaultUnderlying', 'BTC-USD')
|
1966
|
+
currencyId = self.safe_string_2(params, 'uly', 'marketId', defaultUnderlying)
|
1967
|
+
if currencyId is None:
|
1968
|
+
raise ArgumentsRequired(self.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets')
|
1969
|
+
else:
|
1970
|
+
request['uly'] = currencyId
|
1971
|
+
response = await self.publicGetPublicMarkPrice(self.extend(request, params))
|
1972
|
+
tickers = self.safe_list(response, 'data', [])
|
1973
|
+
return self.parse_tickers(tickers, symbols)
|
1974
|
+
|
1939
1975
|
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1940
1976
|
#
|
1941
1977
|
# public fetchTrades
|
ccxt/async_support/oxfun.py
CHANGED
@@ -859,6 +859,7 @@ class oxfun(Exchange, ImplicitAPI):
|
|
859
859
|
'average': None,
|
860
860
|
'baseVolume': self.safe_string(ticker, 'currencyVolume24h'),
|
861
861
|
'quoteVolume': None, # the exchange returns cost in OX
|
862
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
862
863
|
'info': ticker,
|
863
864
|
}, market)
|
864
865
|
|
ccxt/async_support/paradex.py
CHANGED
ccxt/async_support/poloniex.py
CHANGED
@@ -633,6 +633,7 @@ class poloniex(Exchange, ImplicitAPI):
|
|
633
633
|
'average': None,
|
634
634
|
'baseVolume': self.safe_string(ticker, 'quantity'),
|
635
635
|
'quoteVolume': self.safe_string(ticker, 'amount'),
|
636
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
636
637
|
'info': ticker,
|
637
638
|
}, market)
|
638
639
|
|
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.4.
|
7
|
+
__version__ = '4.4.13'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -1952,6 +1952,7 @@ class Exchange(object):
|
|
1952
1952
|
'fetchTicker': True,
|
1953
1953
|
'fetchTickerWs': None,
|
1954
1954
|
'fetchTickers': None,
|
1955
|
+
'fetchMarkPrices': None,
|
1955
1956
|
'fetchTickersWs': None,
|
1956
1957
|
'fetchTime': None,
|
1957
1958
|
'fetchTrades': True,
|
@@ -3478,6 +3479,8 @@ class Exchange(object):
|
|
3478
3479
|
'baseVolume': self.parse_number(baseVolume),
|
3479
3480
|
'quoteVolume': self.parse_number(quoteVolume),
|
3480
3481
|
'previousClose': self.safe_number(ticker, 'previousClose'),
|
3482
|
+
'indexPrice': self.safe_number(ticker, 'indexPrice'),
|
3483
|
+
'markPrice': self.safe_number(ticker, 'markPrice'),
|
3481
3484
|
})
|
3482
3485
|
|
3483
3486
|
def fetch_borrow_rate(self, code: str, amount, params={}):
|
@@ -4508,6 +4511,9 @@ class Exchange(object):
|
|
4508
4511
|
def fetch_tickers(self, symbols: Strings = None, params={}):
|
4509
4512
|
raise NotSupported(self.id + ' fetchTickers() is not supported yet')
|
4510
4513
|
|
4514
|
+
def fetch_mark_prices(self, symbols: Strings = None, params={}):
|
4515
|
+
raise NotSupported(self.id + ' fetchMarkPrices() is not supported yet')
|
4516
|
+
|
4511
4517
|
def fetch_tickers_ws(self, symbols: Strings = None, params={}):
|
4512
4518
|
raise NotSupported(self.id + ' fetchTickers() is not supported yet')
|
4513
4519
|
|
ccxt/base/types.py
CHANGED
ccxt/bigone.py
CHANGED
@@ -723,6 +723,8 @@ class bigone(Exchange, ImplicitAPI):
|
|
723
723
|
'average': None,
|
724
724
|
'baseVolume': self.safe_string_2(ticker, 'volume', 'volume24h'),
|
725
725
|
'quoteVolume': self.safe_string(ticker, 'volume24hInUsd'),
|
726
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
727
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
726
728
|
'info': ticker,
|
727
729
|
}, market)
|
728
730
|
|
ccxt/binance.py
CHANGED
@@ -132,6 +132,7 @@ class binance(Exchange, ImplicitAPI):
|
|
132
132
|
'fetchMarketLeverageTiers': 'emulated',
|
133
133
|
'fetchMarkets': True,
|
134
134
|
'fetchMarkOHLCV': True,
|
135
|
+
'fetchMarkPrices': True,
|
135
136
|
'fetchMyLiquidations': True,
|
136
137
|
'fetchMySettlementHistory': True,
|
137
138
|
'fetchMyTrades': True,
|
@@ -1216,6 +1217,9 @@ class binance(Exchange, ImplicitAPI):
|
|
1216
1217
|
},
|
1217
1218
|
'option': {},
|
1218
1219
|
},
|
1220
|
+
'currencies': {
|
1221
|
+
'BNFCR': self.safe_currency_structure({'id': 'BNFCR', 'code': 'BNFCR', 'precision': self.parse_number('0.001')}),
|
1222
|
+
},
|
1219
1223
|
'commonCurrencies': {
|
1220
1224
|
'BCC': 'BCC', # kept for backward-compatibility https://github.com/ccxt/ccxt/issues/4848
|
1221
1225
|
'YOYO': 'YOYOW',
|
@@ -3714,6 +3718,18 @@ class binance(Exchange, ImplicitAPI):
|
|
3714
3718
|
return orderbook
|
3715
3719
|
|
3716
3720
|
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
3721
|
+
# markPrices
|
3722
|
+
#
|
3723
|
+
# {
|
3724
|
+
# "symbol": "BTCUSDT",
|
3725
|
+
# "markPrice": "11793.63104562", # mark price
|
3726
|
+
# "indexPrice": "11781.80495970", # index price
|
3727
|
+
# "estimatedSettlePrice": "11781.16138815", # Estimated Settle Price, only useful in the last hour before the settlement starts.
|
3728
|
+
# "lastFundingRate": "0.00038246", # This is the lastest estimated funding rate
|
3729
|
+
# "nextFundingTime": 1597392000000,
|
3730
|
+
# "interestRate": "0.00010000",
|
3731
|
+
# "time": 1597370495002
|
3732
|
+
# }
|
3717
3733
|
#
|
3718
3734
|
# {
|
3719
3735
|
# "symbol": "ETHBTC",
|
@@ -3817,7 +3833,7 @@ class binance(Exchange, ImplicitAPI):
|
|
3817
3833
|
# "time":"1673899278514"
|
3818
3834
|
# }
|
3819
3835
|
#
|
3820
|
-
timestamp = self.
|
3836
|
+
timestamp = self.safe_integer_2(ticker, 'closeTime', 'time')
|
3821
3837
|
marketType = None
|
3822
3838
|
if ('time' in ticker):
|
3823
3839
|
marketType = 'contract'
|
@@ -3857,6 +3873,8 @@ class binance(Exchange, ImplicitAPI):
|
|
3857
3873
|
'average': None,
|
3858
3874
|
'baseVolume': baseVolume,
|
3859
3875
|
'quoteVolume': quoteVolume,
|
3876
|
+
'markPrice': self.safe_string(ticker, 'markPrice'),
|
3877
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
3860
3878
|
'info': ticker,
|
3861
3879
|
}, market)
|
3862
3880
|
|
@@ -4087,6 +4105,31 @@ class binance(Exchange, ImplicitAPI):
|
|
4087
4105
|
raise NotSupported(self.id + ' fetchTickers() does not support ' + type + ' markets yet')
|
4088
4106
|
return self.parse_tickers(response, symbols)
|
4089
4107
|
|
4108
|
+
def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
|
4109
|
+
"""
|
4110
|
+
fetches mark prices for multiple markets
|
4111
|
+
:see: https://binance-docs.github.io/apidocs/futures/en/#mark-price
|
4112
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
4113
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4114
|
+
:param str [params.subType]: "linear" or "inverse"
|
4115
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
4116
|
+
"""
|
4117
|
+
self.load_markets()
|
4118
|
+
symbols = self.market_symbols(symbols, None, True, True, True)
|
4119
|
+
market = self.get_market_from_symbols(symbols)
|
4120
|
+
type = None
|
4121
|
+
type, params = self.handle_market_type_and_params('fetchTickers', market, params, 'swap')
|
4122
|
+
subType = None
|
4123
|
+
subType, params = self.handle_sub_type_and_params('fetchTickers', market, params, 'linear')
|
4124
|
+
response = None
|
4125
|
+
if self.is_linear(type, subType):
|
4126
|
+
response = self.fapiPublicGetPremiumIndex(params)
|
4127
|
+
elif self.is_inverse(type, subType):
|
4128
|
+
response = self.dapiPublicGetPremiumIndex(params)
|
4129
|
+
else:
|
4130
|
+
raise NotSupported(self.id + ' fetchMarkPrices() does not support ' + type + ' markets yet')
|
4131
|
+
return self.parse_tickers(response, symbols)
|
4132
|
+
|
4090
4133
|
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
4091
4134
|
# when api method = publicGetKlines or fapiPublicGetKlines or dapiPublicGetKlines
|
4092
4135
|
# [
|