ccxt 4.4.12__py2.py3-none-any.whl → 4.4.14__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/abstract/binance.py +1 -0
- ccxt/abstract/binancecoinm.py +1 -0
- ccxt/abstract/binanceus.py +1 -0
- ccxt/abstract/binanceusdm.py +1 -0
- ccxt/abstract/cryptocom.py +1 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +37 -1
- ccxt/async_support/bigone.py +2 -0
- ccxt/async_support/binance.py +113 -12
- ccxt/async_support/bingx.py +69 -3
- ccxt/async_support/bitget.py +102 -3
- ccxt/async_support/bitmex.py +1 -0
- ccxt/async_support/bitrue.py +1 -7
- ccxt/async_support/bitvavo.py +1 -3
- ccxt/async_support/bybit.py +2 -0
- ccxt/async_support/coinbaseinternational.py +2 -0
- ccxt/async_support/coinex.py +15 -1
- ccxt/async_support/cryptocom.py +1 -0
- ccxt/async_support/delta.py +2 -0
- ccxt/async_support/deribit.py +2 -0
- ccxt/async_support/digifinex.py +15 -1
- ccxt/async_support/gate.py +2 -0
- ccxt/async_support/htx.py +2 -2
- ccxt/async_support/huobijp.py +1 -3
- ccxt/async_support/krakenfutures.py +2 -0
- ccxt/async_support/kucoin.py +36 -1
- ccxt/async_support/kucoinfutures.py +56 -3
- ccxt/async_support/mexc.py +52 -8
- ccxt/async_support/okx.py +48 -0
- ccxt/async_support/oxfun.py +1 -0
- ccxt/async_support/paradex.py +1 -0
- ccxt/async_support/poloniex.py +1 -0
- ccxt/async_support/poloniexfutures.py +35 -11
- ccxt/async_support/woo.py +12 -0
- ccxt/async_support/woofipro.py +12 -0
- ccxt/async_support/xt.py +12 -0
- ccxt/base/exchange.py +44 -2
- ccxt/base/types.py +2 -0
- ccxt/bigone.py +2 -0
- ccxt/binance.py +113 -12
- ccxt/bingx.py +69 -3
- ccxt/bitget.py +102 -3
- ccxt/bitmex.py +1 -0
- ccxt/bitrue.py +1 -7
- ccxt/bitvavo.py +1 -3
- ccxt/bybit.py +2 -0
- ccxt/coinbaseinternational.py +2 -0
- ccxt/coinex.py +15 -1
- ccxt/cryptocom.py +1 -0
- ccxt/delta.py +2 -0
- ccxt/deribit.py +2 -0
- ccxt/digifinex.py +15 -1
- ccxt/gate.py +2 -0
- ccxt/htx.py +2 -2
- ccxt/huobijp.py +1 -3
- ccxt/krakenfutures.py +2 -0
- ccxt/kucoin.py +36 -1
- ccxt/kucoinfutures.py +56 -3
- ccxt/mexc.py +52 -8
- ccxt/okx.py +48 -0
- ccxt/oxfun.py +1 -0
- ccxt/paradex.py +1 -0
- ccxt/poloniex.py +1 -0
- ccxt/poloniexfutures.py +35 -11
- 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/okx.py +38 -0
- ccxt/pro/phemex.py +2 -0
- ccxt/pro/woo.py +69 -0
- ccxt/test/tests_async.py +76 -48
- ccxt/test/tests_helpers.py +27 -36
- ccxt/test/tests_init.py +6 -2
- ccxt/test/tests_sync.py +76 -48
- ccxt/woo.py +12 -0
- ccxt/woofipro.py +12 -0
- ccxt/xt.py +12 -0
- {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/METADATA +4 -5
- {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/RECORD +84 -84
- {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/WHEEL +0 -0
- {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/top_level.txt +0 -0
ccxt/async_support/bitrue.py
CHANGED
@@ -345,6 +345,7 @@ class bitrue(Exchange, ImplicitAPI):
|
|
345
345
|
# 'fetchTradesMethod': 'publicGetAggTrades', # publicGetTrades, publicGetHistoricalTrades
|
346
346
|
'fetchMyTradesMethod': 'v2PrivateGetMyTrades', # spotV1PrivateGetMyTrades
|
347
347
|
'hasAlreadyAuthenticatedSuccessfully': False,
|
348
|
+
'currencyToPrecisionRoundingMode': TRUNCATE,
|
348
349
|
'recvWindow': 5 * 1000, # 5 sec, binance default
|
349
350
|
'timeDifference': 0, # the difference between system clock and Binance clock
|
350
351
|
'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
|
@@ -534,13 +535,6 @@ class bitrue(Exchange, ImplicitAPI):
|
|
534
535
|
},
|
535
536
|
})
|
536
537
|
|
537
|
-
def currency_to_precision(self, code, fee, networkCode=None):
|
538
|
-
# info is available in currencies only if the user has configured his api keys
|
539
|
-
if self.safe_value(self.currencies[code], 'precision') is not None:
|
540
|
-
return self.decimal_to_precision(fee, TRUNCATE, self.currencies[code]['precision'], self.precisionMode, self.paddingMode)
|
541
|
-
else:
|
542
|
-
return self.number_to_string(fee)
|
543
|
-
|
544
538
|
def nonce(self):
|
545
539
|
return self.milliseconds() - self.options['timeDifference']
|
546
540
|
|
ccxt/async_support/bitvavo.py
CHANGED
@@ -284,6 +284,7 @@ class bitvavo(Exchange, ImplicitAPI):
|
|
284
284
|
},
|
285
285
|
},
|
286
286
|
'options': {
|
287
|
+
'currencyToPrecisionRoundingMode': TRUNCATE,
|
287
288
|
'BITVAVO-ACCESS-WINDOW': 10000, # default 10 sec
|
288
289
|
'networks': {
|
289
290
|
'ERC20': 'ETH',
|
@@ -296,9 +297,6 @@ class bitvavo(Exchange, ImplicitAPI):
|
|
296
297
|
},
|
297
298
|
})
|
298
299
|
|
299
|
-
def currency_to_precision(self, code, fee, networkCode=None):
|
300
|
-
return self.decimal_to_precision(fee, 0, self.currencies[code]['precision'], DECIMAL_PLACES)
|
301
|
-
|
302
300
|
def amount_to_precision(self, symbol, amount):
|
303
301
|
# https://docs.bitfinex.com/docs/introduction#amount-precision
|
304
302
|
# The amount field allows up to 8 decimals.
|
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
@@ -85,6 +85,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
85
85
|
'fetchDepositWithdrawFee': True,
|
86
86
|
'fetchDepositWithdrawFees': False,
|
87
87
|
'fetchFundingHistory': True,
|
88
|
+
'fetchFundingInterval': True,
|
89
|
+
'fetchFundingIntervals': False,
|
88
90
|
'fetchFundingRate': True,
|
89
91
|
'fetchFundingRateHistory': True,
|
90
92
|
'fetchFundingRates': True,
|
@@ -922,6 +924,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
922
924
|
'average': None,
|
923
925
|
'baseVolume': self.safe_string(ticker, 'volume'),
|
924
926
|
'quoteVolume': None,
|
927
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
928
|
+
'indexPrice': self.safe_string(ticker, 'index_price'),
|
925
929
|
'info': ticker,
|
926
930
|
}, market)
|
927
931
|
|
@@ -4292,9 +4296,19 @@ class coinex(Exchange, ImplicitAPI):
|
|
4292
4296
|
first = self.safe_dict(data, 0, {})
|
4293
4297
|
return self.parse_funding_rate(first, market)
|
4294
4298
|
|
4299
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
4300
|
+
"""
|
4301
|
+
fetch the current funding rate interval
|
4302
|
+
:see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
4303
|
+
:param str symbol: unified market symbol
|
4304
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4305
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
4306
|
+
"""
|
4307
|
+
return await self.fetch_funding_rate(symbol, params)
|
4308
|
+
|
4295
4309
|
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
4296
4310
|
#
|
4297
|
-
# fetchFundingRate, fetchFundingRates
|
4311
|
+
# fetchFundingRate, fetchFundingRates, fetchFundingInterval
|
4298
4312
|
#
|
4299
4313
|
# {
|
4300
4314
|
# "latest_funding_rate": "0",
|
ccxt/async_support/cryptocom.py
CHANGED
@@ -178,6 +178,7 @@ class cryptocom(Exchange, ImplicitAPI):
|
|
178
178
|
'public/get-valuations': 1,
|
179
179
|
'public/get-expired-settlement-price': 10 / 3,
|
180
180
|
'public/get-insurance': 1,
|
181
|
+
'public/get-risk-parameters': 1,
|
181
182
|
},
|
182
183
|
'post': {
|
183
184
|
'public/staking/get-conversion-rate': 2,
|
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
@@ -72,6 +72,8 @@ class digifinex(Exchange, ImplicitAPI):
|
|
72
72
|
'fetchDepositWithdrawFee': 'emulated',
|
73
73
|
'fetchDepositWithdrawFees': True,
|
74
74
|
'fetchFundingHistory': True,
|
75
|
+
'fetchFundingInterval': True,
|
76
|
+
'fetchFundingIntervals': False,
|
75
77
|
'fetchFundingRate': True,
|
76
78
|
'fetchFundingRateHistory': True,
|
77
79
|
'fetchFundingRates': False,
|
@@ -1164,6 +1166,8 @@ class digifinex(Exchange, ImplicitAPI):
|
|
1164
1166
|
'average': None,
|
1165
1167
|
'baseVolume': self.safe_string_2(ticker, 'vol', 'volume_24h'),
|
1166
1168
|
'quoteVolume': self.safe_string(ticker, 'base_vol'),
|
1169
|
+
'markPrice': self.safe_string(ticker, 'mark_price'),
|
1170
|
+
'indexPrice': indexPrice,
|
1167
1171
|
'info': ticker,
|
1168
1172
|
}, market)
|
1169
1173
|
|
@@ -3009,9 +3013,19 @@ class digifinex(Exchange, ImplicitAPI):
|
|
3009
3013
|
# }
|
3010
3014
|
# }
|
3011
3015
|
#
|
3012
|
-
data = self.
|
3016
|
+
data = self.safe_dict(response, 'data', {})
|
3013
3017
|
return self.parse_funding_rate(data, market)
|
3014
3018
|
|
3019
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
3020
|
+
"""
|
3021
|
+
fetch the current funding rate interval
|
3022
|
+
:see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
|
3023
|
+
:param str symbol: unified market symbol
|
3024
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3025
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
3026
|
+
"""
|
3027
|
+
return await self.fetch_funding_rate(symbol, params)
|
3028
|
+
|
3015
3029
|
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
3016
3030
|
#
|
3017
3031
|
# {
|
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
|
ccxt/async_support/huobijp.py
CHANGED
@@ -323,6 +323,7 @@ class huobijp(Exchange, ImplicitAPI):
|
|
323
323
|
'fetchMarketsMethod': 'publicGetCommonSymbols',
|
324
324
|
'fetchBalanceMethod': 'privateGetAccountAccountsIdBalance',
|
325
325
|
'createOrderMethod': 'privatePostOrderOrdersPlace',
|
326
|
+
'currencyToPrecisionRoundingMode': TRUNCATE,
|
326
327
|
'language': 'en-US',
|
327
328
|
'broker': {
|
328
329
|
'id': 'AA03022abc',
|
@@ -1561,9 +1562,6 @@ class huobijp(Exchange, ImplicitAPI):
|
|
1561
1562
|
}),
|
1562
1563
|
]
|
1563
1564
|
|
1564
|
-
def currency_to_precision(self, code, fee, networkCode=None):
|
1565
|
-
return self.decimal_to_precision(fee, 0, self.currencies[code]['precision'], self.precisionMode)
|
1566
|
-
|
1567
1565
|
def parse_deposit_address(self, depositAddress, currency: Currency = None):
|
1568
1566
|
#
|
1569
1567
|
# {
|
@@ -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
|
|
ccxt/async_support/kucoin.py
CHANGED
@@ -98,6 +98,8 @@ class kucoin(Exchange, ImplicitAPI):
|
|
98
98
|
'fetchMarketLeverageTiers': False,
|
99
99
|
'fetchMarkets': True,
|
100
100
|
'fetchMarkOHLCV': False,
|
101
|
+
'fetchMarkPrice': True,
|
102
|
+
'fetchMarkPrices': True,
|
101
103
|
'fetchMyTrades': True,
|
102
104
|
'fetchOHLCV': True,
|
103
105
|
'fetchOpenInterest': False,
|
@@ -1644,7 +1646,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1644
1646
|
symbol = market['symbol']
|
1645
1647
|
baseVolume = self.safe_string(ticker, 'vol')
|
1646
1648
|
quoteVolume = self.safe_string(ticker, 'volValue')
|
1647
|
-
timestamp = self.
|
1649
|
+
timestamp = self.safe_integer_n(ticker, ['time', 'datetime', 'timePoint'])
|
1648
1650
|
return self.safe_ticker({
|
1649
1651
|
'symbol': symbol,
|
1650
1652
|
'timestamp': timestamp,
|
@@ -1665,6 +1667,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1665
1667
|
'average': self.safe_string(ticker, 'averagePrice'),
|
1666
1668
|
'baseVolume': baseVolume,
|
1667
1669
|
'quoteVolume': quoteVolume,
|
1670
|
+
'markPrice': self.safe_string(ticker, 'value'),
|
1668
1671
|
'info': ticker,
|
1669
1672
|
}, market)
|
1670
1673
|
|
@@ -1719,6 +1722,20 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1719
1722
|
result[symbol] = ticker
|
1720
1723
|
return self.filter_by_array_tickers(result, 'symbol', symbols)
|
1721
1724
|
|
1725
|
+
async def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
|
1726
|
+
"""
|
1727
|
+
fetches the mark price for multiple markets
|
1728
|
+
:see: https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-all-margin-trading-pairs-mark-prices
|
1729
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1730
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1731
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1732
|
+
"""
|
1733
|
+
await self.load_markets()
|
1734
|
+
symbols = self.market_symbols(symbols)
|
1735
|
+
response = await self.publicGetMarkPriceAllSymbols(params)
|
1736
|
+
data = self.safe_list(response, 'data', [])
|
1737
|
+
return self.parse_tickers(data)
|
1738
|
+
|
1722
1739
|
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
1723
1740
|
"""
|
1724
1741
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
@@ -1759,6 +1776,24 @@ class kucoin(Exchange, ImplicitAPI):
|
|
1759
1776
|
data = self.safe_dict(response, 'data', {})
|
1760
1777
|
return self.parse_ticker(data, market)
|
1761
1778
|
|
1779
|
+
async def fetch_mark_price(self, symbol: str, params={}) -> Ticker:
|
1780
|
+
"""
|
1781
|
+
fetches the mark price for a specific market
|
1782
|
+
:see: https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-mark-price
|
1783
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
1784
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1785
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1786
|
+
"""
|
1787
|
+
await self.load_markets()
|
1788
|
+
market = self.market(symbol)
|
1789
|
+
request: dict = {
|
1790
|
+
'symbol': market['id'],
|
1791
|
+
}
|
1792
|
+
response = await self.publicGetMarkPriceSymbolCurrent(self.extend(request, params))
|
1793
|
+
#
|
1794
|
+
data = self.safe_dict(response, 'data', {})
|
1795
|
+
return self.parse_ticker(data, market)
|
1796
|
+
|
1762
1797
|
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
1763
1798
|
#
|
1764
1799
|
# [
|
@@ -73,6 +73,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
73
73
|
'fetchDepositWithdrawFee': False,
|
74
74
|
'fetchDepositWithdrawFees': False,
|
75
75
|
'fetchFundingHistory': True,
|
76
|
+
'fetchFundingInterval': True,
|
77
|
+
'fetchFundingIntervals': False,
|
76
78
|
'fetchFundingRate': True,
|
77
79
|
'fetchFundingRateHistory': True,
|
78
80
|
'fetchIndexOHLCV': False,
|
@@ -87,6 +89,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
87
89
|
'fetchMarketLeverageTiers': True,
|
88
90
|
'fetchMarkets': True,
|
89
91
|
'fetchMarkOHLCV': False,
|
92
|
+
'fetchMarkPrice': True,
|
90
93
|
'fetchMyTrades': True,
|
91
94
|
'fetchOHLCV': True,
|
92
95
|
'fetchOpenOrders': True,
|
@@ -757,6 +760,23 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
757
760
|
#
|
758
761
|
return self.parse_ticker(response['data'], market)
|
759
762
|
|
763
|
+
async def fetch_mark_price(self, symbol: str, params={}) -> Ticker:
|
764
|
+
"""
|
765
|
+
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
766
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/market-data/get-current-mark-price
|
767
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
768
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
769
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
770
|
+
"""
|
771
|
+
await self.load_markets()
|
772
|
+
market = self.market(symbol)
|
773
|
+
request: dict = {
|
774
|
+
'symbol': market['id'],
|
775
|
+
}
|
776
|
+
response = await self.futuresPublicGetMarkPriceSymbolCurrent(self.extend(request, params))
|
777
|
+
#
|
778
|
+
return self.parse_ticker(response['data'], market)
|
779
|
+
|
760
780
|
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
761
781
|
"""
|
762
782
|
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
@@ -842,6 +862,14 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
842
862
|
return self.filter_by_array_tickers(tickers, 'symbol', symbols)
|
843
863
|
|
844
864
|
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
865
|
+
#
|
866
|
+
# {
|
867
|
+
# "symbol": "LTCUSDTM",
|
868
|
+
# "granularity": 1000,
|
869
|
+
# "timePoint": 1727967339000,
|
870
|
+
# "value": 62.37, mark price
|
871
|
+
# "indexPrice": 62.37
|
872
|
+
# }
|
845
873
|
#
|
846
874
|
# {
|
847
875
|
# "code": "200000",
|
@@ -944,6 +972,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
944
972
|
'average': None,
|
945
973
|
'baseVolume': self.safe_string(ticker, 'volumeOf24h'),
|
946
974
|
'quoteVolume': self.safe_string(ticker, 'turnoverOf24h'),
|
975
|
+
'markPrice': self.safe_string_2(ticker, 'markPrice', 'value'),
|
976
|
+
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
947
977
|
'info': ticker,
|
948
978
|
}, market)
|
949
979
|
|
@@ -2072,12 +2102,35 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2072
2102
|
# },
|
2073
2103
|
# }
|
2074
2104
|
#
|
2075
|
-
data = self.
|
2076
|
-
fundingTimestamp = self.safe_integer(data, 'timePoint')
|
2105
|
+
data = self.safe_dict(response, 'data', {})
|
2077
2106
|
# the website displayes the previous funding rate as "funding rate"
|
2107
|
+
return self.parse_funding_rate(data, market)
|
2108
|
+
|
2109
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
2110
|
+
"""
|
2111
|
+
fetch the current funding rate interval
|
2112
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-current-funding-rate
|
2113
|
+
:param str symbol: unified market symbol
|
2114
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2115
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2116
|
+
"""
|
2117
|
+
return await self.fetch_funding_rate(symbol, params)
|
2118
|
+
|
2119
|
+
def parse_funding_rate(self, data, market: Market = None) -> FundingRate:
|
2120
|
+
#
|
2121
|
+
# {
|
2122
|
+
# "symbol": ".ETHUSDTMFPI8H",
|
2123
|
+
# "granularity": 28800000,
|
2124
|
+
# "timePoint": 1637380800000,
|
2125
|
+
# "value": 0.0001,
|
2126
|
+
# "predictedValue": 0.0001,
|
2127
|
+
# }
|
2128
|
+
#
|
2129
|
+
fundingTimestamp = self.safe_integer(data, 'timePoint')
|
2130
|
+
marketId = self.safe_string(data, 'symbol')
|
2078
2131
|
return {
|
2079
2132
|
'info': data,
|
2080
|
-
'symbol': market
|
2133
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
2081
2134
|
'markPrice': None,
|
2082
2135
|
'indexPrice': None,
|
2083
2136
|
'interestRate': None,
|
ccxt/async_support/mexc.py
CHANGED
@@ -90,6 +90,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
90
90
|
'fetchDepositWithdrawFee': 'emulated',
|
91
91
|
'fetchDepositWithdrawFees': True,
|
92
92
|
'fetchFundingHistory': True,
|
93
|
+
'fetchFundingInterval': True,
|
94
|
+
'fetchFundingIntervals': False,
|
93
95
|
'fetchFundingRate': True,
|
94
96
|
'fetchFundingRateHistory': True,
|
95
97
|
'fetchFundingRates': None,
|
@@ -2469,6 +2471,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
2469
2471
|
:param int [since]: the earliest time in ms to fetch orders for
|
2470
2472
|
:param int [limit]: the maximum number of order structures to retrieve
|
2471
2473
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2474
|
+
:param int [params.until]: the latest time in ms to fetch orders for
|
2472
2475
|
:param str [params.marginMode]: only 'isolated' is supported, for spot-margin trading
|
2473
2476
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2474
2477
|
"""
|
@@ -2478,6 +2481,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
2478
2481
|
if symbol is not None:
|
2479
2482
|
market = self.market(symbol)
|
2480
2483
|
request['symbol'] = market['id']
|
2484
|
+
until = self.safe_integer(params, 'until')
|
2485
|
+
params = self.omit(params, 'until')
|
2481
2486
|
marketType, query = self.handle_market_type_and_params('fetchOrders', market, params)
|
2482
2487
|
if marketType == 'spot':
|
2483
2488
|
if symbol is None:
|
@@ -2485,6 +2490,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
2485
2490
|
marginMode, queryInner = self.handle_margin_mode_and_params('fetchOrders', params)
|
2486
2491
|
if since is not None:
|
2487
2492
|
request['startTime'] = since
|
2493
|
+
if until is not None:
|
2494
|
+
request['endTime'] = until
|
2488
2495
|
if limit is not None:
|
2489
2496
|
request['limit'] = limit
|
2490
2497
|
response = None
|
@@ -2546,9 +2553,17 @@ class mexc(Exchange, ImplicitAPI):
|
|
2546
2553
|
else:
|
2547
2554
|
if since is not None:
|
2548
2555
|
request['start_time'] = since
|
2549
|
-
end = self.safe_integer(params, 'end_time')
|
2556
|
+
end = self.safe_integer(params, 'end_time', until)
|
2550
2557
|
if end is None:
|
2551
2558
|
request['end_time'] = self.sum(since, self.options['maxTimeTillEnd'])
|
2559
|
+
else:
|
2560
|
+
if (end - since) > self.options['maxTimeTillEnd']:
|
2561
|
+
raise BadRequest(self.id + ' end is invalid, i.e. exceeds allowed 90 days.')
|
2562
|
+
else:
|
2563
|
+
request['end_time'] = until
|
2564
|
+
elif until is not None:
|
2565
|
+
request['start_time'] = self.sum(until, self.options['maxTimeTillEnd'] * -1)
|
2566
|
+
request['end_time'] = until
|
2552
2567
|
if limit is not None:
|
2553
2568
|
request['page_size'] = limit
|
2554
2569
|
method = self.safe_string(self.options, 'fetchOrders', 'contractPrivateGetOrderListHistoryOrders')
|
@@ -3938,9 +3953,12 @@ class mexc(Exchange, ImplicitAPI):
|
|
3938
3953
|
nextFundingRate = self.safe_number(contract, 'fundingRate')
|
3939
3954
|
nextFundingTimestamp = self.safe_integer(contract, 'nextSettleTime')
|
3940
3955
|
marketId = self.safe_string(contract, 'symbol')
|
3941
|
-
symbol = self.safe_symbol(marketId, market)
|
3956
|
+
symbol = self.safe_symbol(marketId, market, None, 'contract')
|
3942
3957
|
timestamp = self.safe_integer(contract, 'timestamp')
|
3943
|
-
|
3958
|
+
interval = self.safe_string(contract, 'collectCycle')
|
3959
|
+
intervalString = None
|
3960
|
+
if interval is not None:
|
3961
|
+
intervalString = interval + 'h'
|
3944
3962
|
return {
|
3945
3963
|
'info': contract,
|
3946
3964
|
'symbol': symbol,
|
@@ -3949,7 +3967,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3949
3967
|
'interestRate': None,
|
3950
3968
|
'estimatedSettlePrice': None,
|
3951
3969
|
'timestamp': timestamp,
|
3952
|
-
'datetime':
|
3970
|
+
'datetime': self.iso8601(timestamp),
|
3953
3971
|
'fundingRate': nextFundingRate,
|
3954
3972
|
'fundingTimestamp': nextFundingTimestamp,
|
3955
3973
|
'fundingDatetime': self.iso8601(nextFundingTimestamp),
|
@@ -3959,9 +3977,19 @@ class mexc(Exchange, ImplicitAPI):
|
|
3959
3977
|
'previousFundingRate': None,
|
3960
3978
|
'previousFundingTimestamp': None,
|
3961
3979
|
'previousFundingDatetime': None,
|
3962
|
-
'interval':
|
3980
|
+
'interval': intervalString,
|
3963
3981
|
}
|
3964
3982
|
|
3983
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
3984
|
+
"""
|
3985
|
+
fetch the current funding rate interval
|
3986
|
+
:see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
|
3987
|
+
:param str symbol: unified market symbol
|
3988
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3989
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
3990
|
+
"""
|
3991
|
+
return await self.fetch_funding_rate(symbol, params)
|
3992
|
+
|
3965
3993
|
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
3966
3994
|
"""
|
3967
3995
|
fetch the current funding rate
|
@@ -4230,7 +4258,15 @@ class mexc(Exchange, ImplicitAPI):
|
|
4230
4258
|
networkCode = self.safe_string(params, 'network')
|
4231
4259
|
networkId = None
|
4232
4260
|
if networkCode is not None:
|
4233
|
-
|
4261
|
+
# createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
|
4262
|
+
networkUnified = self.network_id_to_code(networkCode, code)
|
4263
|
+
networks = self.safe_dict(currency, 'networks', {})
|
4264
|
+
if networkUnified in networks:
|
4265
|
+
network = self.safe_dict(networks, networkUnified, {})
|
4266
|
+
networkInfo = self.safe_value(network, 'info', {})
|
4267
|
+
networkId = self.safe_string(networkInfo, 'network')
|
4268
|
+
else:
|
4269
|
+
networkId = self.network_code_to_id(networkCode, code)
|
4234
4270
|
if networkId is not None:
|
4235
4271
|
request['network'] = networkId
|
4236
4272
|
params = self.omit(params, 'network')
|
@@ -4266,7 +4302,16 @@ class mexc(Exchange, ImplicitAPI):
|
|
4266
4302
|
networkCode = self.safe_string(params, 'network')
|
4267
4303
|
if networkCode is None:
|
4268
4304
|
raise ArgumentsRequired(self.id + ' createDepositAddress requires a `network` parameter')
|
4269
|
-
|
4305
|
+
# createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
|
4306
|
+
networkId = None
|
4307
|
+
networkUnified = self.network_id_to_code(networkCode, code)
|
4308
|
+
networks = self.safe_dict(currency, 'networks', {})
|
4309
|
+
if networkUnified in networks:
|
4310
|
+
network = self.safe_dict(networks, networkUnified, {})
|
4311
|
+
networkInfo = self.safe_value(network, 'info', {})
|
4312
|
+
networkId = self.safe_string(networkInfo, 'network')
|
4313
|
+
else:
|
4314
|
+
networkId = self.network_code_to_id(networkCode, code)
|
4270
4315
|
if networkId is not None:
|
4271
4316
|
request['network'] = networkId
|
4272
4317
|
params = self.omit(params, 'network')
|
@@ -4289,7 +4334,6 @@ class mexc(Exchange, ImplicitAPI):
|
|
4289
4334
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
4290
4335
|
"""
|
4291
4336
|
network = self.safe_string(params, 'network')
|
4292
|
-
params = self.omit(params, ['network'])
|
4293
4337
|
addressStructures = await self.fetch_deposit_addresses_by_network(code, params)
|
4294
4338
|
result = None
|
4295
4339
|
if network is not None:
|
ccxt/async_support/okx.py
CHANGED
@@ -105,6 +105,8 @@ class okx(Exchange, ImplicitAPI):
|
|
105
105
|
'fetchDepositWithdrawFee': 'emulated',
|
106
106
|
'fetchDepositWithdrawFees': True,
|
107
107
|
'fetchFundingHistory': True,
|
108
|
+
'fetchFundingInterval': True,
|
109
|
+
'fetchFundingIntervals': False,
|
108
110
|
'fetchFundingRate': True,
|
109
111
|
'fetchFundingRateHistory': True,
|
110
112
|
'fetchFundingRates': False,
|
@@ -121,6 +123,7 @@ class okx(Exchange, ImplicitAPI):
|
|
121
123
|
'fetchMarketLeverageTiers': True,
|
122
124
|
'fetchMarkets': True,
|
123
125
|
'fetchMarkOHLCV': True,
|
126
|
+
'fetchMarkPrices': True,
|
124
127
|
'fetchMySettlementHistory': False,
|
125
128
|
'fetchMyTrades': True,
|
126
129
|
'fetchOHLCV': True,
|
@@ -1785,6 +1788,13 @@ class okx(Exchange, ImplicitAPI):
|
|
1785
1788
|
return self.parse_order_book(first, symbol, timestamp)
|
1786
1789
|
|
1787
1790
|
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
1791
|
+
#
|
1792
|
+
# {
|
1793
|
+
# "instType":"SWAP",
|
1794
|
+
# "instId":"BTC-USDT-SWAP",
|
1795
|
+
# "markPx":"200",
|
1796
|
+
# "ts":"1597026383085"
|
1797
|
+
# }
|
1788
1798
|
#
|
1789
1799
|
# {
|
1790
1800
|
# "instType": "SPOT",
|
@@ -1836,6 +1846,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1836
1846
|
'average': None,
|
1837
1847
|
'baseVolume': baseVolume,
|
1838
1848
|
'quoteVolume': quoteVolume,
|
1849
|
+
'markPrice': self.safe_string(ticker, 'markPx'),
|
1839
1850
|
'info': ticker,
|
1840
1851
|
}, market)
|
1841
1852
|
|
@@ -1936,6 +1947,33 @@ class okx(Exchange, ImplicitAPI):
|
|
1936
1947
|
tickers = self.safe_list(response, 'data', [])
|
1937
1948
|
return self.parse_tickers(tickers, symbols)
|
1938
1949
|
|
1950
|
+
async def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
|
1951
|
+
"""
|
1952
|
+
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
1953
|
+
:see: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price
|
1954
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1955
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1956
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
1957
|
+
"""
|
1958
|
+
await self.load_markets()
|
1959
|
+
symbols = self.market_symbols(symbols)
|
1960
|
+
market = self.get_market_from_symbols(symbols)
|
1961
|
+
marketType = None
|
1962
|
+
marketType, params = self.handle_market_type_and_params('fetchTickers', market, params, 'swap')
|
1963
|
+
request: dict = {
|
1964
|
+
'instType': self.convert_to_instrument_type(marketType),
|
1965
|
+
}
|
1966
|
+
if marketType == 'option':
|
1967
|
+
defaultUnderlying = self.safe_string(self.options, 'defaultUnderlying', 'BTC-USD')
|
1968
|
+
currencyId = self.safe_string_2(params, 'uly', 'marketId', defaultUnderlying)
|
1969
|
+
if currencyId is None:
|
1970
|
+
raise ArgumentsRequired(self.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets')
|
1971
|
+
else:
|
1972
|
+
request['uly'] = currencyId
|
1973
|
+
response = await self.publicGetPublicMarkPrice(self.extend(request, params))
|
1974
|
+
tickers = self.safe_list(response, 'data', [])
|
1975
|
+
return self.parse_tickers(tickers, symbols)
|
1976
|
+
|
1939
1977
|
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1940
1978
|
#
|
1941
1979
|
# public fetchTrades
|
@@ -5690,6 +5728,16 @@ class okx(Exchange, ImplicitAPI):
|
|
5690
5728
|
}
|
5691
5729
|
return self.safe_string(intervals, interval, interval)
|
5692
5730
|
|
5731
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
5732
|
+
"""
|
5733
|
+
fetch the current funding rate interval
|
5734
|
+
:see: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
|
5735
|
+
:param str symbol: unified market symbol
|
5736
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5737
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
5738
|
+
"""
|
5739
|
+
return await self.fetch_funding_rate(symbol, params)
|
5740
|
+
|
5693
5741
|
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
5694
5742
|
"""
|
5695
5743
|
fetch the current funding rate
|
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