ccxt 4.4.8__py2.py3-none-any.whl → 4.4.10__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/bigone.py +1 -1
- ccxt/abstract/kucoinfutures.py +5 -0
- ccxt/abstract/oceanex.py +5 -0
- ccxt/ascendex.py +5 -4
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ascendex.py +5 -4
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bigone.py +35 -86
- ccxt/async_support/binance.py +8 -11
- ccxt/async_support/bingx.py +27 -23
- ccxt/async_support/bitfinex2.py +7 -16
- ccxt/async_support/bitget.py +10 -6
- ccxt/async_support/bitmart.py +4 -3
- ccxt/async_support/bitmex.py +7 -6
- ccxt/async_support/blofin.py +7 -16
- ccxt/async_support/bybit.py +22 -17
- ccxt/async_support/coinex.py +19 -5
- ccxt/async_support/delta.py +6 -5
- ccxt/async_support/deribit.py +4 -3
- ccxt/async_support/digifinex.py +18 -4
- ccxt/async_support/gate.py +61 -13
- ccxt/async_support/hashkey.py +6 -6
- ccxt/async_support/hitbtc.py +6 -5
- ccxt/async_support/htx.py +25 -6
- ccxt/async_support/hyperliquid.py +6 -1
- ccxt/async_support/krakenfutures.py +6 -5
- ccxt/async_support/kucoin.py +1 -0
- ccxt/async_support/kucoinfutures.py +164 -4
- ccxt/async_support/mexc.py +4 -3
- ccxt/async_support/oceanex.py +80 -4
- ccxt/async_support/okx.py +17 -3
- ccxt/async_support/oxfun.py +7 -7
- ccxt/async_support/phemex.py +4 -3
- ccxt/async_support/poloniexfutures.py +13 -2
- ccxt/async_support/vertex.py +6 -5
- ccxt/async_support/whitebit.py +14 -13
- ccxt/async_support/woo.py +42 -21
- ccxt/async_support/woofipro.py +19 -6
- ccxt/async_support/xt.py +5 -3
- ccxt/base/exchange.py +1 -1
- ccxt/base/types.py +1 -0
- ccxt/bigone.py +35 -86
- ccxt/binance.py +8 -11
- ccxt/bingx.py +27 -23
- ccxt/bitfinex2.py +7 -16
- ccxt/bitget.py +10 -6
- ccxt/bitmart.py +4 -3
- ccxt/bitmex.py +7 -6
- ccxt/blofin.py +7 -16
- ccxt/bybit.py +22 -17
- ccxt/coinex.py +19 -5
- ccxt/delta.py +6 -5
- ccxt/deribit.py +4 -3
- ccxt/digifinex.py +18 -4
- ccxt/gate.py +61 -13
- ccxt/hashkey.py +6 -6
- ccxt/hitbtc.py +6 -5
- ccxt/htx.py +25 -6
- ccxt/hyperliquid.py +6 -1
- ccxt/krakenfutures.py +6 -5
- ccxt/kucoin.py +1 -0
- ccxt/kucoinfutures.py +164 -4
- ccxt/mexc.py +4 -3
- ccxt/oceanex.py +80 -4
- ccxt/okx.py +17 -3
- ccxt/oxfun.py +7 -7
- ccxt/phemex.py +4 -3
- ccxt/poloniexfutures.py +13 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +3 -3
- ccxt/pro/deribit.py +39 -2
- ccxt/pro/gate.py +1 -1
- ccxt/pro/hitbtc.py +112 -44
- ccxt/pro/hollaex.py +5 -0
- ccxt/pro/okx.py +12 -1
- ccxt/pro/p2b.py +33 -2
- ccxt/pro/whitebit.py +29 -1
- ccxt/vertex.py +6 -5
- ccxt/whitebit.py +14 -13
- ccxt/woo.py +42 -21
- ccxt/woofipro.py +19 -6
- ccxt/xt.py +5 -3
- ccxt-4.4.10.dist-info/METADATA +636 -0
- {ccxt-4.4.8.dist-info → ccxt-4.4.10.dist-info}/RECORD +88 -88
- ccxt-4.4.8.dist-info/METADATA +0 -636
- {ccxt-4.4.8.dist-info → ccxt-4.4.10.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.8.dist-info → ccxt-4.4.10.dist-info}/WHEEL +0 -0
- {ccxt-4.4.8.dist-info → ccxt-4.4.10.dist-info}/top_level.txt +0 -0
ccxt/async_support/hashkey.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.hashkey import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LastPrice, LastPrices, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LastPrice, LastPrices, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -3491,7 +3491,7 @@ class hashkey(Exchange, ImplicitAPI):
|
|
3491
3491
|
}
|
3492
3492
|
return self.safe_string(types, type, type)
|
3493
3493
|
|
3494
|
-
async def fetch_funding_rate(self, symbol: str, params={}):
|
3494
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
3495
3495
|
"""
|
3496
3496
|
fetch the current funding rate
|
3497
3497
|
:see: https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate
|
@@ -3514,13 +3514,13 @@ class hashkey(Exchange, ImplicitAPI):
|
|
3514
3514
|
rate = self.safe_dict(response, 0, {})
|
3515
3515
|
return self.parse_funding_rate(rate, market)
|
3516
3516
|
|
3517
|
-
async def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
3517
|
+
async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
3518
3518
|
"""
|
3519
3519
|
fetch the funding rate for multiple markets
|
3520
3520
|
:see: https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate
|
3521
3521
|
:param str[]|None symbols: list of unified market symbols
|
3522
3522
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3523
|
-
:returns dict: a
|
3523
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
3524
3524
|
"""
|
3525
3525
|
await self.load_markets()
|
3526
3526
|
symbols = self.market_symbols(symbols)
|
@@ -3537,9 +3537,8 @@ class hashkey(Exchange, ImplicitAPI):
|
|
3537
3537
|
fundingRates = self.parse_funding_rates(response)
|
3538
3538
|
return self.filter_by_array(fundingRates, 'symbol', symbols)
|
3539
3539
|
|
3540
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
3540
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
3541
3541
|
#
|
3542
|
-
# fetchFundingRates
|
3543
3542
|
# {
|
3544
3543
|
# "symbol": "ETHUSDT-PERPETUAL",
|
3545
3544
|
# "rate": "0.0001",
|
@@ -3568,6 +3567,7 @@ class hashkey(Exchange, ImplicitAPI):
|
|
3568
3567
|
'previousFundingRate': None,
|
3569
3568
|
'previousFundingTimestamp': None,
|
3570
3569
|
'previousFundingDatetime': None,
|
3570
|
+
'interval': None,
|
3571
3571
|
}
|
3572
3572
|
|
3573
3573
|
async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
ccxt/async_support/hitbtc.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.hitbtc import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -2536,13 +2536,13 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
2536
2536
|
#
|
2537
2537
|
return self.parse_transaction(response, currency)
|
2538
2538
|
|
2539
|
-
async def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2539
|
+
async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
2540
2540
|
"""
|
2541
2541
|
fetches funding rates for multiple markets
|
2542
2542
|
:see: https://api.hitbtc.com/#futures-info
|
2543
2543
|
:param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
|
2544
2544
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2545
|
-
:returns dict:
|
2545
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2546
2546
|
"""
|
2547
2547
|
await self.load_markets()
|
2548
2548
|
market = None
|
@@ -2934,7 +2934,7 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
2934
2934
|
#
|
2935
2935
|
return self.parse_open_interest(response, market)
|
2936
2936
|
|
2937
|
-
async def fetch_funding_rate(self, symbol: str, params={}):
|
2937
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2938
2938
|
"""
|
2939
2939
|
fetch the current funding rate
|
2940
2940
|
:see: https://api.hitbtc.com/#futures-info
|
@@ -2967,7 +2967,7 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
2967
2967
|
#
|
2968
2968
|
return self.parse_funding_rate(response, market)
|
2969
2969
|
|
2970
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
2970
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2971
2971
|
#
|
2972
2972
|
# {
|
2973
2973
|
# "contract_type": "perpetual",
|
@@ -3003,6 +3003,7 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
3003
3003
|
'previousFundingRate': None,
|
3004
3004
|
'previousFundingTimestamp': None,
|
3005
3005
|
'previousFundingDatetime': None,
|
3006
|
+
'interval': None,
|
3006
3007
|
}
|
3007
3008
|
|
3008
3009
|
async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
|
ccxt/async_support/htx.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.htx import ImplicitAPI
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
|
-
from ccxt.base.types import Account, Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Account, Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import AuthenticationError
|
@@ -203,7 +203,7 @@ class htx(Exchange, ImplicitAPI):
|
|
203
203
|
},
|
204
204
|
'www': 'https://www.huobi.com',
|
205
205
|
'referral': {
|
206
|
-
'url': 'https://www.
|
206
|
+
'url': 'https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223',
|
207
207
|
'discount': 0.15,
|
208
208
|
},
|
209
209
|
'doc': [
|
@@ -2956,6 +2956,7 @@ class htx(Exchange, ImplicitAPI):
|
|
2956
2956
|
async def fetch_accounts(self, params={}) -> List[Account]:
|
2957
2957
|
"""
|
2958
2958
|
fetch all the accounts associated with a profile
|
2959
|
+
:see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
|
2959
2960
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2960
2961
|
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
2961
2962
|
"""
|
@@ -3019,6 +3020,7 @@ class htx(Exchange, ImplicitAPI):
|
|
3019
3020
|
async def fetch_currencies(self, params={}) -> Currencies:
|
3020
3021
|
"""
|
3021
3022
|
fetches all available currencies on an exchange
|
3023
|
+
:see: https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains
|
3022
3024
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3023
3025
|
:returns dict: an associative dictionary of currencies
|
3024
3026
|
"""
|
@@ -6381,7 +6383,7 @@ class htx(Exchange, ImplicitAPI):
|
|
6381
6383
|
sorted = self.sort_by(rates, 'timestamp')
|
6382
6384
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
6383
6385
|
|
6384
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
6386
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
6385
6387
|
#
|
6386
6388
|
# {
|
6387
6389
|
# "status": "ok",
|
@@ -6400,6 +6402,9 @@ class htx(Exchange, ImplicitAPI):
|
|
6400
6402
|
nextFundingRate = self.safe_number(contract, 'estimated_rate')
|
6401
6403
|
fundingTimestamp = self.safe_integer(contract, 'funding_time')
|
6402
6404
|
nextFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
|
6405
|
+
fundingTimeString = self.safe_string(contract, 'funding_time')
|
6406
|
+
nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
|
6407
|
+
millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
|
6403
6408
|
marketId = self.safe_string(contract, 'contract_code')
|
6404
6409
|
symbol = self.safe_symbol(marketId, market)
|
6405
6410
|
return {
|
@@ -6420,9 +6425,20 @@ class htx(Exchange, ImplicitAPI):
|
|
6420
6425
|
'previousFundingRate': None,
|
6421
6426
|
'previousFundingTimestamp': None,
|
6422
6427
|
'previousFundingDatetime': None,
|
6428
|
+
'interval': self.parse_funding_interval(millisecondsInterval),
|
6423
6429
|
}
|
6424
6430
|
|
6425
|
-
|
6431
|
+
def parse_funding_interval(self, interval):
|
6432
|
+
intervals: dict = {
|
6433
|
+
'3600000': '1h',
|
6434
|
+
'14400000': '4h',
|
6435
|
+
'28800000': '8h',
|
6436
|
+
'57600000': '16h',
|
6437
|
+
'86400000': '24h',
|
6438
|
+
}
|
6439
|
+
return self.safe_string(intervals, interval, interval)
|
6440
|
+
|
6441
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
6426
6442
|
"""
|
6427
6443
|
fetch the current funding rate
|
6428
6444
|
:param str symbol: unified market symbol
|
@@ -6459,12 +6475,12 @@ class htx(Exchange, ImplicitAPI):
|
|
6459
6475
|
result = self.safe_value(response, 'data', {})
|
6460
6476
|
return self.parse_funding_rate(result, market)
|
6461
6477
|
|
6462
|
-
async def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
6478
|
+
async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
6463
6479
|
"""
|
6464
6480
|
fetch the funding rate for multiple markets
|
6465
6481
|
:param str[]|None symbols: list of unified market symbols
|
6466
6482
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6467
|
-
:returns dict: a
|
6483
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
6468
6484
|
"""
|
6469
6485
|
await self.load_markets()
|
6470
6486
|
symbols = self.market_symbols(symbols)
|
@@ -8095,6 +8111,9 @@ class htx(Exchange, ImplicitAPI):
|
|
8095
8111
|
async def fetch_settlement_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
8096
8112
|
"""
|
8097
8113
|
Fetches historical settlement records
|
8114
|
+
:see: https://huobiapi.github.io/docs/dm/v1/en/#query-historical-settlement-records-of-the-platform-interface
|
8115
|
+
:see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-settlement-records-of-the-platform-interface
|
8116
|
+
:see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-settlement-records-of-the-platform-interface
|
8098
8117
|
:param str symbol: unified symbol of the market to fetch the settlement history for
|
8099
8118
|
:param int [since]: timestamp in ms, value range = current time - 90 days,default = current time - 90 days
|
8100
8119
|
:param int [limit]: page items, default 20, shall not exceed 50
|
@@ -1927,6 +1927,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1927
1927
|
# "crossed": True,
|
1928
1928
|
# "dir": "Close Long",
|
1929
1929
|
# "fee": "0.050062",
|
1930
|
+
# "feeToken": "USDC",
|
1930
1931
|
# "hash": "0x09d77c96791e98b5775a04092584ab010d009445119c71e4005c0d634ea322bc",
|
1931
1932
|
# "liquidationMarkPx": null,
|
1932
1933
|
# "oid": 3929354691,
|
@@ -1985,7 +1986,11 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1985
1986
|
'price': price,
|
1986
1987
|
'amount': amount,
|
1987
1988
|
'cost': None,
|
1988
|
-
'fee': {
|
1989
|
+
'fee': {
|
1990
|
+
'cost': fee,
|
1991
|
+
'currency': self.safe_string(trade, 'feeToken'),
|
1992
|
+
'rate': None,
|
1993
|
+
},
|
1989
1994
|
}, market)
|
1990
1995
|
|
1991
1996
|
async def fetch_position(self, symbol: str, params={}):
|
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.krakenfutures import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -2030,10 +2030,10 @@ class krakenfutures(Exchange, ImplicitAPI):
|
|
2030
2030
|
result[code] = account
|
2031
2031
|
return self.safe_balance(result)
|
2032
2032
|
|
2033
|
-
async def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2033
|
+
async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
2034
2034
|
"""
|
2035
|
+
fetch the current funding rates for multiple markets
|
2035
2036
|
:see: https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-tickers
|
2036
|
-
fetch the current funding rates
|
2037
2037
|
:param str[] symbols: unified market symbols
|
2038
2038
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2039
2039
|
:returns Order[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
@@ -2041,7 +2041,7 @@ class krakenfutures(Exchange, ImplicitAPI):
|
|
2041
2041
|
await self.load_markets()
|
2042
2042
|
marketIds = self.market_ids(symbols)
|
2043
2043
|
response = await self.publicGetTickers(params)
|
2044
|
-
tickers = self.
|
2044
|
+
tickers = self.safe_list(response, 'tickers', [])
|
2045
2045
|
fundingRates = []
|
2046
2046
|
for i in range(0, len(tickers)):
|
2047
2047
|
entry = tickers[i]
|
@@ -2054,7 +2054,7 @@ class krakenfutures(Exchange, ImplicitAPI):
|
|
2054
2054
|
fundingRates.append(parsed)
|
2055
2055
|
return self.index_by(fundingRates, 'symbol')
|
2056
2056
|
|
2057
|
-
def parse_funding_rate(self, ticker, market: Market = None):
|
2057
|
+
def parse_funding_rate(self, ticker, market: Market = None) -> FundingRate:
|
2058
2058
|
#
|
2059
2059
|
# {"ask": 26.283,
|
2060
2060
|
# "askSize": 4.6,
|
@@ -2108,6 +2108,7 @@ class krakenfutures(Exchange, ImplicitAPI):
|
|
2108
2108
|
'previousFundingRate': None,
|
2109
2109
|
'previousFundingTimestamp': None,
|
2110
2110
|
'previousFundingDatetime': None,
|
2111
|
+
'interval': None,
|
2111
2112
|
}
|
2112
2113
|
|
2113
2114
|
async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
ccxt/async_support/kucoin.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.async_support.kucoin import kucoin
|
7
7
|
from ccxt.abstract.kucoinfutures import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Currency, Int, LeverageTier, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
8
|
+
from ccxt.base.types import Balances, Currency, Int, Leverage, LeverageTier, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import AuthenticationError
|
11
11
|
from ccxt.base.errors import PermissionDenied
|
@@ -80,9 +80,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
80
80
|
'fetchIsolatedBorrowRates': False,
|
81
81
|
'fetchL3OrderBook': True,
|
82
82
|
'fetchLedger': True,
|
83
|
+
'fetchLeverage': True,
|
83
84
|
'fetchLeverageTiers': False,
|
84
85
|
'fetchMarginAdjustmentHistory': False,
|
85
|
-
'fetchMarginMode':
|
86
|
+
'fetchMarginMode': True,
|
86
87
|
'fetchMarketLeverageTiers': True,
|
87
88
|
'fetchMarkets': True,
|
88
89
|
'fetchMarkOHLCV': False,
|
@@ -106,7 +107,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
106
107
|
'fetchTransactionFee': False,
|
107
108
|
'fetchWithdrawals': True,
|
108
109
|
'setLeverage': False,
|
109
|
-
'setMarginMode':
|
110
|
+
'setMarginMode': True,
|
110
111
|
'transfer': True,
|
111
112
|
'withdraw': None,
|
112
113
|
},
|
@@ -183,12 +184,15 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
183
184
|
'trade-fees': 1,
|
184
185
|
'history-positions': 1,
|
185
186
|
'getMaxOpenSize': 1,
|
187
|
+
'getCrossUserLeverage': 1,
|
188
|
+
'position/getMarginMode': 1,
|
186
189
|
},
|
187
190
|
'post': {
|
188
191
|
'withdrawals': 1,
|
189
192
|
'transfer-out': 1, # v2
|
190
193
|
'transfer-in': 1,
|
191
194
|
'orders': 1.33,
|
195
|
+
'st-orders': 1.33,
|
192
196
|
'orders/test': 1.33,
|
193
197
|
'position/margin/auto-deposit-status': 1,
|
194
198
|
'position/margin/deposit-margin': 1,
|
@@ -196,6 +200,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
196
200
|
'bullet-private': 1,
|
197
201
|
'sub/api-key': 1,
|
198
202
|
'sub/api-key/update': 1,
|
203
|
+
'changeCrossUserLeverage': 1,
|
204
|
+
'position/changeMarginMode': 1,
|
199
205
|
},
|
200
206
|
'delete': {
|
201
207
|
'withdrawals/{withdrawalId}': 1,
|
@@ -330,9 +336,13 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
330
336
|
'futuresPrivate': {
|
331
337
|
'GET': {
|
332
338
|
'getMaxOpenSize': 'v2',
|
339
|
+
'getCrossUserLeverage': 'v2',
|
340
|
+
'position/getMarginMode': 'v2',
|
333
341
|
},
|
334
342
|
'POST': {
|
335
343
|
'transfer-out': 'v2',
|
344
|
+
'changeCrossUserLeverage': 'v2',
|
345
|
+
'position/changeMarginMode': 'v2',
|
336
346
|
},
|
337
347
|
},
|
338
348
|
'futuresPublic': {
|
@@ -2036,7 +2046,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2036
2046
|
'trades': None,
|
2037
2047
|
}, market)
|
2038
2048
|
|
2039
|
-
async def fetch_funding_rate(self, symbol: str, params={}):
|
2049
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2040
2050
|
"""
|
2041
2051
|
fetch the current funding rate
|
2042
2052
|
:see: https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-current-funding-rate
|
@@ -2083,8 +2093,19 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2083
2093
|
'previousFundingRate': None,
|
2084
2094
|
'previousFundingTimestamp': None,
|
2085
2095
|
'previousFundingDatetime': None,
|
2096
|
+
'interval': self.parse_funding_interval(self.safe_string(data, 'granularity')),
|
2086
2097
|
}
|
2087
2098
|
|
2099
|
+
def parse_funding_interval(self, interval):
|
2100
|
+
intervals: dict = {
|
2101
|
+
'3600000': '1h',
|
2102
|
+
'14400000': '4h',
|
2103
|
+
'28800000': '8h',
|
2104
|
+
'57600000': '16h',
|
2105
|
+
'86400000': '24h',
|
2106
|
+
}
|
2107
|
+
return self.safe_string(intervals, interval, interval)
|
2108
|
+
|
2088
2109
|
def parse_balance(self, response) -> Balances:
|
2089
2110
|
result: dict = {
|
2090
2111
|
'info': response,
|
@@ -2721,3 +2742,142 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2721
2742
|
'percentage': True,
|
2722
2743
|
'tierBased': True,
|
2723
2744
|
}
|
2745
|
+
|
2746
|
+
async def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
|
2747
|
+
"""
|
2748
|
+
fetches the margin mode of a trading pair
|
2749
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/get-margin-mode
|
2750
|
+
:param str symbol: unified symbol of the market to fetch the margin mode for
|
2751
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2752
|
+
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
2753
|
+
"""
|
2754
|
+
await self.load_markets()
|
2755
|
+
market = self.market(symbol)
|
2756
|
+
request: dict = {
|
2757
|
+
'symbol': market['id'],
|
2758
|
+
}
|
2759
|
+
response = await self.futuresPrivateGetPositionGetMarginMode(self.extend(request, params))
|
2760
|
+
#
|
2761
|
+
# {
|
2762
|
+
# "code": "200000",
|
2763
|
+
# "data": {
|
2764
|
+
# "symbol": "XBTUSDTM",
|
2765
|
+
# "marginMode": "ISOLATED"
|
2766
|
+
# }
|
2767
|
+
# }
|
2768
|
+
#
|
2769
|
+
data = self.safe_dict(response, 'data', {})
|
2770
|
+
return self.parse_margin_mode(data, market)
|
2771
|
+
|
2772
|
+
def parse_margin_mode(self, marginMode: dict, market=None) -> MarginMode:
|
2773
|
+
marginType = self.safe_string(marginMode, 'marginMode')
|
2774
|
+
marginType = 'isolated' if (marginType == 'ISOLATED') else 'cross'
|
2775
|
+
return {
|
2776
|
+
'info': marginMode,
|
2777
|
+
'symbol': market['symbol'],
|
2778
|
+
'marginMode': marginType,
|
2779
|
+
}
|
2780
|
+
|
2781
|
+
async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
2782
|
+
"""
|
2783
|
+
set margin mode to 'cross' or 'isolated'
|
2784
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/modify-margin-mode
|
2785
|
+
:param str marginMode: 'cross' or 'isolated'
|
2786
|
+
:param str symbol: unified market symbol
|
2787
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2788
|
+
:returns dict: response from the exchange
|
2789
|
+
"""
|
2790
|
+
if symbol is None:
|
2791
|
+
raise ArgumentsRequired(self.id + ' setMarginMode() requires a symbol argument')
|
2792
|
+
self.check_required_argument('setMarginMode', marginMode, 'marginMode', ['cross', 'isolated'])
|
2793
|
+
await self.load_markets()
|
2794
|
+
market = self.market(symbol)
|
2795
|
+
request: dict = {
|
2796
|
+
'symbol': market['id'],
|
2797
|
+
'marginMode': marginMode.upper(),
|
2798
|
+
}
|
2799
|
+
response = await self.futuresPrivatePostPositionChangeMarginMode(self.extend(request, params))
|
2800
|
+
#
|
2801
|
+
# {
|
2802
|
+
# "code": "200000",
|
2803
|
+
# "data": {
|
2804
|
+
# "symbol": "XBTUSDTM",
|
2805
|
+
# "marginMode": "ISOLATED"
|
2806
|
+
# }
|
2807
|
+
# }
|
2808
|
+
#
|
2809
|
+
data = self.safe_dict(response, 'data', {})
|
2810
|
+
return self.parse_margin_mode(data, market)
|
2811
|
+
|
2812
|
+
async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
2813
|
+
"""
|
2814
|
+
fetch the set leverage for a market
|
2815
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/get-cross-margin-leverage
|
2816
|
+
:param str symbol: unified market symbol
|
2817
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2818
|
+
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
2819
|
+
"""
|
2820
|
+
marginMode = None
|
2821
|
+
marginMode, params = self.handle_margin_mode_and_params(symbol, params)
|
2822
|
+
if marginMode != 'cross':
|
2823
|
+
raise NotSupported(self.id + ' fetchLeverage() currently supports only params["marginMode"] = "cross"')
|
2824
|
+
await self.load_markets()
|
2825
|
+
market = self.market(symbol)
|
2826
|
+
request: dict = {
|
2827
|
+
'symbol': market['id'],
|
2828
|
+
}
|
2829
|
+
response = await self.futuresPrivateGetGetCrossUserLeverage(self.extend(request, params))
|
2830
|
+
#
|
2831
|
+
# {
|
2832
|
+
# "code": "200000",
|
2833
|
+
# "data": {
|
2834
|
+
# "symbol": "XBTUSDTM",
|
2835
|
+
# "leverage": "3"
|
2836
|
+
# }
|
2837
|
+
# }
|
2838
|
+
#
|
2839
|
+
data = self.safe_dict(response, 'data', {})
|
2840
|
+
parsed = self.parse_leverage(data, market)
|
2841
|
+
return self.extend(parsed, {
|
2842
|
+
'marginMode': marginMode,
|
2843
|
+
})
|
2844
|
+
|
2845
|
+
async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
|
2846
|
+
"""
|
2847
|
+
set the level of leverage for a market
|
2848
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/modify-cross-margin-leverage
|
2849
|
+
:param float leverage: the rate of leverage
|
2850
|
+
:param str symbol: unified market symbol
|
2851
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2852
|
+
:returns dict: response from the exchange
|
2853
|
+
"""
|
2854
|
+
marginMode = None
|
2855
|
+
marginMode, params = self.handle_margin_mode_and_params(symbol, params)
|
2856
|
+
if marginMode != 'cross':
|
2857
|
+
raise NotSupported(self.id + ' setLeverage() currently supports only params["marginMode"] = "cross"')
|
2858
|
+
await self.load_markets()
|
2859
|
+
market = self.market(symbol)
|
2860
|
+
request: dict = {
|
2861
|
+
'symbol': market['id'],
|
2862
|
+
'leverage': str(leverage),
|
2863
|
+
}
|
2864
|
+
response = await self.futuresPrivatePostChangeCrossUserLeverage(self.extend(request, params))
|
2865
|
+
#
|
2866
|
+
# {
|
2867
|
+
# "code": "200000",
|
2868
|
+
# "data": True
|
2869
|
+
# }
|
2870
|
+
#
|
2871
|
+
return self.parse_leverage(response, market)
|
2872
|
+
|
2873
|
+
def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
|
2874
|
+
marketId = self.safe_string(leverage, 'symbol')
|
2875
|
+
market = self.safe_market(marketId, market)
|
2876
|
+
leverageNum = self.safe_integer(leverage, 'leverage')
|
2877
|
+
return {
|
2878
|
+
'info': leverage,
|
2879
|
+
'symbol': market['symbol'],
|
2880
|
+
'marginMode': None,
|
2881
|
+
'longLeverage': leverageNum,
|
2882
|
+
'shortLeverage': leverageNum,
|
2883
|
+
}
|
ccxt/async_support/mexc.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.mexc import ImplicitAPI
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
|
-
from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import AuthenticationError
|
@@ -3905,7 +3905,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3905
3905
|
})
|
3906
3906
|
return result
|
3907
3907
|
|
3908
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
3908
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
3909
3909
|
#
|
3910
3910
|
# {
|
3911
3911
|
# "symbol": "BTC_USDT",
|
@@ -3941,9 +3941,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
3941
3941
|
'previousFundingRate': None,
|
3942
3942
|
'previousFundingTimestamp': None,
|
3943
3943
|
'previousFundingDatetime': None,
|
3944
|
+
'interval': None,
|
3944
3945
|
}
|
3945
3946
|
|
3946
|
-
async def fetch_funding_rate(self, symbol: str, params={}):
|
3947
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
3947
3948
|
"""
|
3948
3949
|
fetch the current funding rate
|
3949
3950
|
:see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
|
ccxt/async_support/oceanex.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.oceanex import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees
|
8
|
+
from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import ExchangeError
|
11
11
|
from ccxt.base.errors import AuthenticationError
|
@@ -54,9 +54,9 @@ class oceanex(Exchange, ImplicitAPI):
|
|
54
54
|
'fetchClosedOrders': True,
|
55
55
|
'fetchCrossBorrowRate': False,
|
56
56
|
'fetchCrossBorrowRates': False,
|
57
|
-
'fetchDepositAddress':
|
58
|
-
'fetchDepositAddresses':
|
59
|
-
'fetchDepositAddressesByNetwork':
|
57
|
+
'fetchDepositAddress': 'emulated',
|
58
|
+
'fetchDepositAddresses': None,
|
59
|
+
'fetchDepositAddressesByNetwork': True,
|
60
60
|
'fetchIsolatedBorrowRate': False,
|
61
61
|
'fetchIsolatedBorrowRates': False,
|
62
62
|
'fetchMarkets': True,
|
@@ -117,6 +117,11 @@ class oceanex(Exchange, ImplicitAPI):
|
|
117
117
|
'order/delete',
|
118
118
|
'order/delete/multi',
|
119
119
|
'orders/clear',
|
120
|
+
'/withdraws/special/new',
|
121
|
+
'/deposit_address',
|
122
|
+
'/deposit_addresses',
|
123
|
+
'/deposit_history',
|
124
|
+
'/withdraw_history',
|
120
125
|
],
|
121
126
|
},
|
122
127
|
},
|
@@ -858,6 +863,77 @@ class oceanex(Exchange, ImplicitAPI):
|
|
858
863
|
data = self.safe_list(response, 'data')
|
859
864
|
return self.parse_orders(data)
|
860
865
|
|
866
|
+
async def fetch_deposit_addresses_by_network(self, code: str, params={}):
|
867
|
+
"""
|
868
|
+
fetch the deposit addresses for a currency associated with self account
|
869
|
+
:see: https://api.oceanex.pro/doc/v1/#deposit-addresses-post
|
870
|
+
:param str code: unified currency code
|
871
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
872
|
+
:returns dict: a dictionary `address structures <https://docs.ccxt.com/#/?id=address-structure>`, indexed by the network
|
873
|
+
"""
|
874
|
+
await self.load_markets()
|
875
|
+
currency = self.currency(code)
|
876
|
+
request: dict = {
|
877
|
+
'currency': currency['id'],
|
878
|
+
}
|
879
|
+
response = await self.privatePostDepositAddresses(self.extend(request, params))
|
880
|
+
#
|
881
|
+
# {
|
882
|
+
# code: '0',
|
883
|
+
# message: 'Operation successful',
|
884
|
+
# data: {
|
885
|
+
# data: {
|
886
|
+
# currency_id: 'usdt',
|
887
|
+
# display_name: 'USDT',
|
888
|
+
# num_of_resources: '3',
|
889
|
+
# resources: [
|
890
|
+
# {
|
891
|
+
# chain_name: 'TRC20',
|
892
|
+
# currency_id: 'usdt',
|
893
|
+
# address: 'TPcS7VgKMFmpRrWY82GbJzDeMnemWxEbpg',
|
894
|
+
# memo: '',
|
895
|
+
# deposit_status: 'enabled'
|
896
|
+
# },
|
897
|
+
# ...
|
898
|
+
# ]
|
899
|
+
# }
|
900
|
+
# }
|
901
|
+
# }
|
902
|
+
#
|
903
|
+
data = self.safe_dict(response, 'data', {})
|
904
|
+
data2 = self.safe_dict(data, 'data', {})
|
905
|
+
resources = self.safe_list(data2, 'resources', [])
|
906
|
+
result = {}
|
907
|
+
for i in range(0, len(resources)):
|
908
|
+
resource = resources[i]
|
909
|
+
enabled = self.safe_string(resource, 'deposit_status')
|
910
|
+
if enabled == 'enabled':
|
911
|
+
parsedAddress = self.parse_deposit_address(resource, currency)
|
912
|
+
result[parsedAddress['currency']] = parsedAddress
|
913
|
+
return result
|
914
|
+
|
915
|
+
def parse_deposit_address(self, depositAddress, currency: Currency = None):
|
916
|
+
#
|
917
|
+
# {
|
918
|
+
# chain_name: 'TRC20',
|
919
|
+
# currency_id: 'usdt',
|
920
|
+
# address: 'TPcS7VgKMFmpRrWY82GbJzDeMnemWxEbpg',
|
921
|
+
# memo: '',
|
922
|
+
# deposit_status: 'enabled'
|
923
|
+
# }
|
924
|
+
#
|
925
|
+
address = self.safe_string(depositAddress, 'address')
|
926
|
+
self.check_address(address)
|
927
|
+
currencyId = self.safe_string(depositAddress, 'currency_id')
|
928
|
+
networkId = self.safe_string(depositAddress, 'chain_name')
|
929
|
+
return {
|
930
|
+
'info': depositAddress,
|
931
|
+
'currency': self.safe_currency_code(currencyId, currency),
|
932
|
+
'address': address,
|
933
|
+
'tag': self.safe_string(depositAddress, 'memo'),
|
934
|
+
'network': self.network_id_to_code(networkId),
|
935
|
+
}
|
936
|
+
|
861
937
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
862
938
|
url = self.urls['api']['rest'] + '/' + self.version + '/' + self.implode_params(path, params)
|
863
939
|
query = self.omit(params, self.extract_params(path))
|