ccxt 4.4.13__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 +34 -1
- ccxt/async_support/binance.py +69 -11
- ccxt/async_support/bitget.py +101 -3
- ccxt/async_support/bitrue.py +1 -7
- ccxt/async_support/bitvavo.py +1 -3
- ccxt/async_support/coinex.py +13 -1
- ccxt/async_support/cryptocom.py +1 -0
- ccxt/async_support/digifinex.py +13 -1
- ccxt/async_support/huobijp.py +1 -3
- ccxt/async_support/kucoin.py +36 -1
- ccxt/async_support/kucoinfutures.py +55 -4
- ccxt/async_support/mexc.py +52 -8
- ccxt/async_support/okx.py +12 -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 +38 -2
- ccxt/binance.py +69 -11
- ccxt/bitget.py +101 -3
- ccxt/bitrue.py +1 -7
- ccxt/bitvavo.py +1 -3
- ccxt/coinex.py +13 -1
- ccxt/cryptocom.py +1 -0
- ccxt/digifinex.py +13 -1
- ccxt/huobijp.py +1 -3
- ccxt/kucoin.py +36 -1
- ccxt/kucoinfutures.py +55 -4
- ccxt/mexc.py +52 -8
- ccxt/okx.py +12 -0
- ccxt/poloniexfutures.py +35 -11
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/okx.py +38 -0
- ccxt/test/tests_async.py +53 -53
- ccxt/test/tests_helpers.py +14 -0
- ccxt/test/tests_sync.py +53 -53
- ccxt/woo.py +12 -0
- ccxt/woofipro.py +12 -0
- ccxt/xt.py +12 -0
- {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/METADATA +4 -4
- {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/RECORD +51 -51
- {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/WHEEL +0 -0
- {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/top_level.txt +0 -0
@@ -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,7 +972,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
944
972
|
'average': None,
|
945
973
|
'baseVolume': self.safe_string(ticker, 'volumeOf24h'),
|
946
974
|
'quoteVolume': self.safe_string(ticker, 'turnoverOf24h'),
|
947
|
-
'markPrice': self.
|
975
|
+
'markPrice': self.safe_string_2(ticker, 'markPrice', 'value'),
|
948
976
|
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
949
977
|
'info': ticker,
|
950
978
|
}, market)
|
@@ -2074,12 +2102,35 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2074
2102
|
# },
|
2075
2103
|
# }
|
2076
2104
|
#
|
2077
|
-
data = self.
|
2078
|
-
fundingTimestamp = self.safe_integer(data, 'timePoint')
|
2105
|
+
data = self.safe_dict(response, 'data', {})
|
2079
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')
|
2080
2131
|
return {
|
2081
2132
|
'info': data,
|
2082
|
-
'symbol': market
|
2133
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
2083
2134
|
'markPrice': None,
|
2084
2135
|
'indexPrice': None,
|
2085
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,
|
@@ -5726,6 +5728,16 @@ class okx(Exchange, ImplicitAPI):
|
|
5726
5728
|
}
|
5727
5729
|
return self.safe_string(intervals, interval, interval)
|
5728
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
|
+
|
5729
5741
|
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
5730
5742
|
"""
|
5731
5743
|
fetch the current funding rate
|
@@ -48,6 +48,8 @@ class poloniexfutures(Exchange, ImplicitAPI):
|
|
48
48
|
'fetchDepositAddress': False,
|
49
49
|
'fetchDepositAddresses': False,
|
50
50
|
'fetchDepositAddressesByNetwork': False,
|
51
|
+
'fetchFundingInterval': True,
|
52
|
+
'fetchFundingIntervals': False,
|
51
53
|
'fetchFundingRate': True,
|
52
54
|
'fetchFundingRateHistory': False,
|
53
55
|
'fetchL3OrderBook': True,
|
@@ -1550,28 +1552,50 @@ class poloniexfutures(Exchange, ImplicitAPI):
|
|
1550
1552
|
# "predictedValue": 0.00375
|
1551
1553
|
# }
|
1552
1554
|
#
|
1553
|
-
data = self.
|
1555
|
+
data = self.safe_dict(response, 'data', {})
|
1556
|
+
return self.parse_funding_rate(data, market)
|
1557
|
+
|
1558
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
1559
|
+
"""
|
1560
|
+
fetch the current funding rate interval
|
1561
|
+
:see: https://api-docs.poloniex.com/futures/api/futures-index#get-premium-index
|
1562
|
+
:param str symbol: unified market symbol
|
1563
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1564
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
1565
|
+
"""
|
1566
|
+
return await self.fetch_funding_rate(symbol, params)
|
1567
|
+
|
1568
|
+
def parse_funding_rate(self, data, market: Market = None) -> FundingRate:
|
1569
|
+
#
|
1570
|
+
# {
|
1571
|
+
# "symbol": ".ETHUSDTMFPI8H",
|
1572
|
+
# "granularity": 28800000,
|
1573
|
+
# "timePoint": 1637380800000,
|
1574
|
+
# "value": 0.0001,
|
1575
|
+
# "predictedValue": 0.0001,
|
1576
|
+
# }
|
1577
|
+
#
|
1554
1578
|
fundingTimestamp = self.safe_integer(data, 'timePoint')
|
1555
|
-
|
1579
|
+
marketId = self.safe_string(data, 'symbol')
|
1556
1580
|
return {
|
1557
1581
|
'info': data,
|
1558
|
-
'symbol': market
|
1582
|
+
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
1559
1583
|
'markPrice': None,
|
1560
1584
|
'indexPrice': None,
|
1561
1585
|
'interestRate': None,
|
1562
1586
|
'estimatedSettlePrice': None,
|
1563
1587
|
'timestamp': None,
|
1564
1588
|
'datetime': None,
|
1565
|
-
'fundingRate': self.safe_number(data, '
|
1566
|
-
'fundingTimestamp':
|
1567
|
-
'fundingDatetime':
|
1568
|
-
'nextFundingRate':
|
1589
|
+
'fundingRate': self.safe_number(data, 'value'),
|
1590
|
+
'fundingTimestamp': fundingTimestamp,
|
1591
|
+
'fundingDatetime': self.iso8601(fundingTimestamp),
|
1592
|
+
'nextFundingRate': self.safe_number(data, 'predictedValue'),
|
1569
1593
|
'nextFundingTimestamp': None,
|
1570
1594
|
'nextFundingDatetime': None,
|
1571
|
-
'previousFundingRate':
|
1572
|
-
'previousFundingTimestamp':
|
1573
|
-
'previousFundingDatetime':
|
1574
|
-
'interval': self.parse_funding_interval(self.safe_string(data, '
|
1595
|
+
'previousFundingRate': None,
|
1596
|
+
'previousFundingTimestamp': None,
|
1597
|
+
'previousFundingDatetime': None,
|
1598
|
+
'interval': self.parse_funding_interval(self.safe_string(data, 'granularity')),
|
1575
1599
|
}
|
1576
1600
|
|
1577
1601
|
def parse_funding_interval(self, interval):
|
ccxt/async_support/woo.py
CHANGED
@@ -79,6 +79,8 @@ class woo(Exchange, ImplicitAPI):
|
|
79
79
|
'fetchDeposits': True,
|
80
80
|
'fetchDepositsWithdrawals': True,
|
81
81
|
'fetchFundingHistory': True,
|
82
|
+
'fetchFundingInterval': True,
|
83
|
+
'fetchFundingIntervals': False,
|
82
84
|
'fetchFundingRate': True,
|
83
85
|
'fetchFundingRateHistory': True,
|
84
86
|
'fetchFundingRates': True,
|
@@ -2590,6 +2592,16 @@ class woo(Exchange, ImplicitAPI):
|
|
2590
2592
|
'interval': intervalString + 'h',
|
2591
2593
|
}
|
2592
2594
|
|
2595
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
2596
|
+
"""
|
2597
|
+
fetch the current funding rate interval
|
2598
|
+
:see: https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public
|
2599
|
+
:param str symbol: unified market symbol
|
2600
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2601
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2602
|
+
"""
|
2603
|
+
return await self.fetch_funding_rate(symbol, params)
|
2604
|
+
|
2593
2605
|
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2594
2606
|
"""
|
2595
2607
|
fetch the current funding rate
|
ccxt/async_support/woofipro.py
CHANGED
@@ -77,6 +77,8 @@ class woofipro(Exchange, ImplicitAPI):
|
|
77
77
|
'fetchDeposits': True,
|
78
78
|
'fetchDepositsWithdrawals': True,
|
79
79
|
'fetchFundingHistory': True,
|
80
|
+
'fetchFundingInterval': True,
|
81
|
+
'fetchFundingIntervals': False,
|
80
82
|
'fetchFundingRate': True,
|
81
83
|
'fetchFundingRateHistory': True,
|
82
84
|
'fetchFundingRates': True,
|
@@ -787,6 +789,16 @@ class woofipro(Exchange, ImplicitAPI):
|
|
787
789
|
}
|
788
790
|
return self.safe_string(intervals, interval, interval)
|
789
791
|
|
792
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
793
|
+
"""
|
794
|
+
fetch the current funding rate interval
|
795
|
+
:see: https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-predicted-funding-rate-for-one-market
|
796
|
+
:param str symbol: unified market symbol
|
797
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
798
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
799
|
+
"""
|
800
|
+
return await self.fetch_funding_rate(symbol, params)
|
801
|
+
|
790
802
|
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
791
803
|
"""
|
792
804
|
fetch the current funding rate
|
ccxt/async_support/xt.py
CHANGED
@@ -78,6 +78,8 @@ class xt(Exchange, ImplicitAPI):
|
|
78
78
|
'fetchDepositWithdrawFee': False,
|
79
79
|
'fetchDepositWithdrawFees': False,
|
80
80
|
'fetchFundingHistory': True,
|
81
|
+
'fetchFundingInterval': True,
|
82
|
+
'fetchFundingIntervals': False,
|
81
83
|
'fetchFundingRate': True,
|
82
84
|
'fetchFundingRateHistory': True,
|
83
85
|
'fetchFundingRates': False,
|
@@ -4030,6 +4032,16 @@ class xt(Exchange, ImplicitAPI):
|
|
4030
4032
|
sorted = self.sort_by(rates, 'timestamp')
|
4031
4033
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
4032
4034
|
|
4035
|
+
async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
|
4036
|
+
"""
|
4037
|
+
fetch the current funding rate interval
|
4038
|
+
:see: https://doc.xt.com/#futures_quotesgetFundingRate
|
4039
|
+
:param str symbol: unified market symbol
|
4040
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4041
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
4042
|
+
"""
|
4043
|
+
return await self.fetch_funding_rate(symbol, params)
|
4044
|
+
|
4033
4045
|
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
4034
4046
|
"""
|
4035
4047
|
fetch the current funding rate
|
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.4.
|
7
|
+
__version__ = '4.4.14'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -1892,6 +1892,8 @@ class Exchange(object):
|
|
1892
1892
|
'fetchFundingHistory': None,
|
1893
1893
|
'fetchFundingRate': None,
|
1894
1894
|
'fetchFundingRateHistory': None,
|
1895
|
+
'fetchFundingInterval': None,
|
1896
|
+
'fetchFundingIntervals': None,
|
1895
1897
|
'fetchFundingRates': None,
|
1896
1898
|
'fetchGreeks': None,
|
1897
1899
|
'fetchIndexOHLCV': None,
|
@@ -2561,6 +2563,9 @@ class Exchange(object):
|
|
2561
2563
|
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2562
2564
|
raise NotSupported(self.id + ' fetchFundingRates() is not supported yet')
|
2563
2565
|
|
2566
|
+
def fetch_funding_intervals(self, symbols: Strings = None, params={}):
|
2567
|
+
raise NotSupported(self.id + ' fetchFundingIntervals() is not supported yet')
|
2568
|
+
|
2564
2569
|
def watch_funding_rate(self, symbol: str, params={}):
|
2565
2570
|
raise NotSupported(self.id + ' watchFundingRate() is not supported yet')
|
2566
2571
|
|
@@ -4491,6 +4496,20 @@ class Exchange(object):
|
|
4491
4496
|
else:
|
4492
4497
|
raise NotSupported(self.id + ' fetchTicker() is not supported yet')
|
4493
4498
|
|
4499
|
+
def fetch_mark_price(self, symbol: str, params={}):
|
4500
|
+
if self.has['fetchMarkPrices']:
|
4501
|
+
self.load_markets()
|
4502
|
+
market = self.market(symbol)
|
4503
|
+
symbol = market['symbol']
|
4504
|
+
tickers = self.fetch_mark_prices([symbol], params)
|
4505
|
+
ticker = self.safe_dict(tickers, symbol)
|
4506
|
+
if ticker is None:
|
4507
|
+
raise NullResponse(self.id + ' fetchMarkPrices() could not find a ticker for ' + symbol)
|
4508
|
+
else:
|
4509
|
+
return ticker
|
4510
|
+
else:
|
4511
|
+
raise NotSupported(self.id + ' fetchMarkPrices() is not supported yet')
|
4512
|
+
|
4494
4513
|
def fetch_ticker_ws(self, symbol: str, params={}):
|
4495
4514
|
if self.has['fetchTickersWs']:
|
4496
4515
|
self.load_markets()
|
@@ -5166,7 +5185,8 @@ class Exchange(object):
|
|
5166
5185
|
if precision is None:
|
5167
5186
|
return self.force_string(fee)
|
5168
5187
|
else:
|
5169
|
-
|
5188
|
+
roundingMode = self.safe_integer(self.options, 'currencyToPrecisionRoundingMode', ROUND)
|
5189
|
+
return self.decimal_to_precision(fee, roundingMode, precision, self.precisionMode, self.paddingMode)
|
5170
5190
|
|
5171
5191
|
def force_string(self, value):
|
5172
5192
|
if not isinstance(value, str):
|
@@ -5553,6 +5573,22 @@ class Exchange(object):
|
|
5553
5573
|
else:
|
5554
5574
|
raise NotSupported(self.id + ' fetchFundingRate() is not supported yet')
|
5555
5575
|
|
5576
|
+
def fetch_funding_interval(self, symbol: str, params={}):
|
5577
|
+
if self.has['fetchFundingIntervals']:
|
5578
|
+
self.load_markets()
|
5579
|
+
market = self.market(symbol)
|
5580
|
+
symbol = market['symbol']
|
5581
|
+
if not market['contract']:
|
5582
|
+
raise BadSymbol(self.id + ' fetchFundingInterval() supports contract markets only')
|
5583
|
+
rates = self.fetch_funding_intervals([symbol], params)
|
5584
|
+
rate = self.safe_value(rates, symbol)
|
5585
|
+
if rate is None:
|
5586
|
+
raise NullResponse(self.id + ' fetchFundingInterval() returned no data for ' + symbol)
|
5587
|
+
else:
|
5588
|
+
return rate
|
5589
|
+
else:
|
5590
|
+
raise NotSupported(self.id + ' fetchFundingInterval() is not supported yet')
|
5591
|
+
|
5556
5592
|
def fetch_mark_ohlcv(self, symbol, timeframe='1m', since: Int = None, limit: Int = None, params={}):
|
5557
5593
|
"""
|
5558
5594
|
fetches historical mark price candlestick data containing the open, high, low, and close price of a market
|
ccxt/binance.py
CHANGED
@@ -111,6 +111,8 @@ class binance(Exchange, ImplicitAPI):
|
|
111
111
|
'fetchDepositWithdrawFee': 'emulated',
|
112
112
|
'fetchDepositWithdrawFees': True,
|
113
113
|
'fetchFundingHistory': True,
|
114
|
+
'fetchFundingInterval': 'emulated',
|
115
|
+
'fetchFundingIntervals': True,
|
114
116
|
'fetchFundingRate': True,
|
115
117
|
'fetchFundingRateHistory': True,
|
116
118
|
'fetchFundingRates': True,
|
@@ -734,6 +736,7 @@ class binance(Exchange, ImplicitAPI):
|
|
734
736
|
'ticker/bookTicker': {'cost': 2, 'noSymbol': 5},
|
735
737
|
'constituents': 2,
|
736
738
|
'openInterest': 1,
|
739
|
+
'fundingInfo': 1,
|
737
740
|
},
|
738
741
|
},
|
739
742
|
'dapiData': {
|
@@ -8828,16 +8831,28 @@ class binance(Exchange, ImplicitAPI):
|
|
8828
8831
|
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
8829
8832
|
# ensure it matches with https://www.binance.com/en/futures/funding-history/0
|
8830
8833
|
#
|
8831
|
-
#
|
8832
|
-
#
|
8833
|
-
#
|
8834
|
-
#
|
8835
|
-
#
|
8836
|
-
#
|
8837
|
-
#
|
8838
|
-
#
|
8839
|
-
#
|
8840
|
-
#
|
8834
|
+
# fetchFundingRate, fetchFundingRates
|
8835
|
+
#
|
8836
|
+
# {
|
8837
|
+
# "symbol": "BTCUSDT",
|
8838
|
+
# "markPrice": "45802.81129892",
|
8839
|
+
# "indexPrice": "45745.47701915",
|
8840
|
+
# "estimatedSettlePrice": "45133.91753671",
|
8841
|
+
# "lastFundingRate": "0.00063521",
|
8842
|
+
# "interestRate": "0.00010000",
|
8843
|
+
# "nextFundingTime": "1621267200000",
|
8844
|
+
# "time": "1621252344001"
|
8845
|
+
# }
|
8846
|
+
#
|
8847
|
+
# fetchFundingInterval, fetchFundingIntervals
|
8848
|
+
#
|
8849
|
+
# {
|
8850
|
+
# "symbol": "BLZUSDT",
|
8851
|
+
# "adjustedFundingRateCap": "0.03000000",
|
8852
|
+
# "adjustedFundingRateFloor": "-0.03000000",
|
8853
|
+
# "fundingIntervalHours": 4,
|
8854
|
+
# "disclaimer": False
|
8855
|
+
# }
|
8841
8856
|
#
|
8842
8857
|
timestamp = self.safe_integer(contract, 'time')
|
8843
8858
|
marketId = self.safe_string(contract, 'symbol')
|
@@ -8848,6 +8863,10 @@ class binance(Exchange, ImplicitAPI):
|
|
8848
8863
|
estimatedSettlePrice = self.safe_number(contract, 'estimatedSettlePrice')
|
8849
8864
|
fundingRate = self.safe_number(contract, 'lastFundingRate')
|
8850
8865
|
fundingTime = self.safe_integer(contract, 'nextFundingTime')
|
8866
|
+
interval = self.safe_string(contract, 'fundingIntervalHours')
|
8867
|
+
intervalString = None
|
8868
|
+
if interval is not None:
|
8869
|
+
intervalString = interval + 'h'
|
8851
8870
|
return {
|
8852
8871
|
'info': contract,
|
8853
8872
|
'symbol': symbol,
|
@@ -8866,7 +8885,7 @@ class binance(Exchange, ImplicitAPI):
|
|
8866
8885
|
'previousFundingRate': None,
|
8867
8886
|
'previousFundingTimestamp': None,
|
8868
8887
|
'previousFundingDatetime': None,
|
8869
|
-
'interval':
|
8888
|
+
'interval': intervalString,
|
8870
8889
|
}
|
8871
8890
|
|
8872
8891
|
def parse_account_positions(self, account, filterClosed=False):
|
@@ -12580,3 +12599,42 @@ class binance(Exchange, ImplicitAPI):
|
|
12580
12599
|
'price': None,
|
12581
12600
|
'fee': None,
|
12582
12601
|
}
|
12602
|
+
|
12603
|
+
def fetch_funding_intervals(self, symbols: Strings = None, params={}) -> FundingRates:
|
12604
|
+
"""
|
12605
|
+
fetch the funding rate interval for multiple markets
|
12606
|
+
:see: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Info
|
12607
|
+
:see: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Get-Funding-Info
|
12608
|
+
:param str[] [symbols]: list of unified market symbols
|
12609
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
12610
|
+
:param str [params.subType]: "linear" or "inverse"
|
12611
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
12612
|
+
"""
|
12613
|
+
self.load_markets()
|
12614
|
+
market = None
|
12615
|
+
if symbols is not None:
|
12616
|
+
symbols = self.market_symbols(symbols)
|
12617
|
+
market = self.market(symbols[0])
|
12618
|
+
type = 'swap'
|
12619
|
+
subType = None
|
12620
|
+
subType, params = self.handle_sub_type_and_params('fetchFundingIntervals', market, params, 'linear')
|
12621
|
+
response = None
|
12622
|
+
if self.is_linear(type, subType):
|
12623
|
+
response = self.fapiPublicGetFundingInfo(params)
|
12624
|
+
elif self.is_inverse(type, subType):
|
12625
|
+
response = self.dapiPublicGetFundingInfo(params)
|
12626
|
+
else:
|
12627
|
+
raise NotSupported(self.id + ' fetchFundingIntervals() supports linear and inverse swap contracts only')
|
12628
|
+
#
|
12629
|
+
# [
|
12630
|
+
# {
|
12631
|
+
# "symbol": "BLZUSDT",
|
12632
|
+
# "adjustedFundingRateCap": "0.03000000",
|
12633
|
+
# "adjustedFundingRateFloor": "-0.03000000",
|
12634
|
+
# "fundingIntervalHours": 4,
|
12635
|
+
# "disclaimer": False
|
12636
|
+
# },
|
12637
|
+
# ]
|
12638
|
+
#
|
12639
|
+
result = self.parse_funding_rates(response, market)
|
12640
|
+
return self.filter_by_array(result, 'symbol', symbols)
|