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/htx.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.htx import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
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
|
9
|
+
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
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -202,7 +202,7 @@ class htx(Exchange, ImplicitAPI):
|
|
202
202
|
},
|
203
203
|
'www': 'https://www.huobi.com',
|
204
204
|
'referral': {
|
205
|
-
'url': 'https://www.
|
205
|
+
'url': 'https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223',
|
206
206
|
'discount': 0.15,
|
207
207
|
},
|
208
208
|
'doc': [
|
@@ -2955,6 +2955,7 @@ class htx(Exchange, ImplicitAPI):
|
|
2955
2955
|
def fetch_accounts(self, params={}) -> List[Account]:
|
2956
2956
|
"""
|
2957
2957
|
fetch all the accounts associated with a profile
|
2958
|
+
:see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
|
2958
2959
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2959
2960
|
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
2960
2961
|
"""
|
@@ -3018,6 +3019,7 @@ class htx(Exchange, ImplicitAPI):
|
|
3018
3019
|
def fetch_currencies(self, params={}) -> Currencies:
|
3019
3020
|
"""
|
3020
3021
|
fetches all available currencies on an exchange
|
3022
|
+
:see: https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains
|
3021
3023
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3022
3024
|
:returns dict: an associative dictionary of currencies
|
3023
3025
|
"""
|
@@ -6380,7 +6382,7 @@ class htx(Exchange, ImplicitAPI):
|
|
6380
6382
|
sorted = self.sort_by(rates, 'timestamp')
|
6381
6383
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
6382
6384
|
|
6383
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
6385
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
6384
6386
|
#
|
6385
6387
|
# {
|
6386
6388
|
# "status": "ok",
|
@@ -6399,6 +6401,9 @@ class htx(Exchange, ImplicitAPI):
|
|
6399
6401
|
nextFundingRate = self.safe_number(contract, 'estimated_rate')
|
6400
6402
|
fundingTimestamp = self.safe_integer(contract, 'funding_time')
|
6401
6403
|
nextFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
|
6404
|
+
fundingTimeString = self.safe_string(contract, 'funding_time')
|
6405
|
+
nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
|
6406
|
+
millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
|
6402
6407
|
marketId = self.safe_string(contract, 'contract_code')
|
6403
6408
|
symbol = self.safe_symbol(marketId, market)
|
6404
6409
|
return {
|
@@ -6419,9 +6424,20 @@ class htx(Exchange, ImplicitAPI):
|
|
6419
6424
|
'previousFundingRate': None,
|
6420
6425
|
'previousFundingTimestamp': None,
|
6421
6426
|
'previousFundingDatetime': None,
|
6427
|
+
'interval': self.parse_funding_interval(millisecondsInterval),
|
6422
6428
|
}
|
6423
6429
|
|
6424
|
-
def
|
6430
|
+
def parse_funding_interval(self, interval):
|
6431
|
+
intervals: dict = {
|
6432
|
+
'3600000': '1h',
|
6433
|
+
'14400000': '4h',
|
6434
|
+
'28800000': '8h',
|
6435
|
+
'57600000': '16h',
|
6436
|
+
'86400000': '24h',
|
6437
|
+
}
|
6438
|
+
return self.safe_string(intervals, interval, interval)
|
6439
|
+
|
6440
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
6425
6441
|
"""
|
6426
6442
|
fetch the current funding rate
|
6427
6443
|
:param str symbol: unified market symbol
|
@@ -6458,12 +6474,12 @@ class htx(Exchange, ImplicitAPI):
|
|
6458
6474
|
result = self.safe_value(response, 'data', {})
|
6459
6475
|
return self.parse_funding_rate(result, market)
|
6460
6476
|
|
6461
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
6477
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
6462
6478
|
"""
|
6463
6479
|
fetch the funding rate for multiple markets
|
6464
6480
|
:param str[]|None symbols: list of unified market symbols
|
6465
6481
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6466
|
-
:returns dict: a
|
6482
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
6467
6483
|
"""
|
6468
6484
|
self.load_markets()
|
6469
6485
|
symbols = self.market_symbols(symbols)
|
@@ -8094,6 +8110,9 @@ class htx(Exchange, ImplicitAPI):
|
|
8094
8110
|
def fetch_settlement_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
8095
8111
|
"""
|
8096
8112
|
Fetches historical settlement records
|
8113
|
+
:see: https://huobiapi.github.io/docs/dm/v1/en/#query-historical-settlement-records-of-the-platform-interface
|
8114
|
+
:see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-settlement-records-of-the-platform-interface
|
8115
|
+
:see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-settlement-records-of-the-platform-interface
|
8097
8116
|
:param str symbol: unified symbol of the market to fetch the settlement history for
|
8098
8117
|
:param int [since]: timestamp in ms, value range = current time - 90 days,default = current time - 90 days
|
8099
8118
|
:param int [limit]: page items, default 20, shall not exceed 50
|
ccxt/hyperliquid.py
CHANGED
@@ -1926,6 +1926,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1926
1926
|
# "crossed": True,
|
1927
1927
|
# "dir": "Close Long",
|
1928
1928
|
# "fee": "0.050062",
|
1929
|
+
# "feeToken": "USDC",
|
1929
1930
|
# "hash": "0x09d77c96791e98b5775a04092584ab010d009445119c71e4005c0d634ea322bc",
|
1930
1931
|
# "liquidationMarkPx": null,
|
1931
1932
|
# "oid": 3929354691,
|
@@ -1984,7 +1985,11 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1984
1985
|
'price': price,
|
1985
1986
|
'amount': amount,
|
1986
1987
|
'cost': None,
|
1987
|
-
'fee': {
|
1988
|
+
'fee': {
|
1989
|
+
'cost': fee,
|
1990
|
+
'currency': self.safe_string(trade, 'feeToken'),
|
1991
|
+
'rate': None,
|
1992
|
+
},
|
1988
1993
|
}, market)
|
1989
1994
|
|
1990
1995
|
def fetch_position(self, symbol: str, params={}):
|
ccxt/krakenfutures.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.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
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2033
|
+
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
|
self.load_markets()
|
2042
2042
|
marketIds = self.market_ids(symbols)
|
2043
2043
|
response = 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
|
def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
ccxt/kucoin.py
CHANGED
ccxt/kucoinfutures.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.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
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
2049
|
+
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
|
+
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
|
+
self.load_markets()
|
2755
|
+
market = self.market(symbol)
|
2756
|
+
request: dict = {
|
2757
|
+
'symbol': market['id'],
|
2758
|
+
}
|
2759
|
+
response = 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
|
+
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
|
+
self.load_markets()
|
2794
|
+
market = self.market(symbol)
|
2795
|
+
request: dict = {
|
2796
|
+
'symbol': market['id'],
|
2797
|
+
'marginMode': marginMode.upper(),
|
2798
|
+
}
|
2799
|
+
response = 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
|
+
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
|
+
self.load_markets()
|
2825
|
+
market = self.market(symbol)
|
2826
|
+
request: dict = {
|
2827
|
+
'symbol': market['id'],
|
2828
|
+
}
|
2829
|
+
response = 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
|
+
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
|
+
self.load_markets()
|
2859
|
+
market = self.market(symbol)
|
2860
|
+
request: dict = {
|
2861
|
+
'symbol': market['id'],
|
2862
|
+
'leverage': str(leverage),
|
2863
|
+
}
|
2864
|
+
response = 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/mexc.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.mexc import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
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
|
9
|
+
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
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -3904,7 +3904,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
3904
3904
|
})
|
3905
3905
|
return result
|
3906
3906
|
|
3907
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
3907
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
3908
3908
|
#
|
3909
3909
|
# {
|
3910
3910
|
# "symbol": "BTC_USDT",
|
@@ -3940,9 +3940,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
3940
3940
|
'previousFundingRate': None,
|
3941
3941
|
'previousFundingTimestamp': None,
|
3942
3942
|
'previousFundingDatetime': None,
|
3943
|
+
'interval': None,
|
3943
3944
|
}
|
3944
3945
|
|
3945
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
3946
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
3946
3947
|
"""
|
3947
3948
|
fetch the current funding rate
|
3948
3949
|
:see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
|
ccxt/oceanex.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.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
|
+
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
|
+
self.load_markets()
|
875
|
+
currency = self.currency(code)
|
876
|
+
request: dict = {
|
877
|
+
'currency': currency['id'],
|
878
|
+
}
|
879
|
+
response = 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))
|
ccxt/okx.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.okx import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Balances, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Account, Balances, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from typing import Any
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -5622,7 +5622,7 @@ class okx(Exchange, ImplicitAPI):
|
|
5622
5622
|
headers['OK-ACCESS-SIGN'] = signature
|
5623
5623
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
5624
5624
|
|
5625
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
5625
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
5626
5626
|
#
|
5627
5627
|
# {
|
5628
5628
|
# "fundingRate": "0.00027815",
|
@@ -5656,6 +5656,9 @@ class okx(Exchange, ImplicitAPI):
|
|
5656
5656
|
symbol = self.safe_symbol(marketId, market)
|
5657
5657
|
nextFundingRate = self.safe_number(contract, 'nextFundingRate')
|
5658
5658
|
fundingTime = self.safe_integer(contract, 'fundingTime')
|
5659
|
+
fundingTimeString = self.safe_string(contract, 'fundingTime')
|
5660
|
+
nextFundingTimeString = self.safe_string(contract, 'nextFundingRate')
|
5661
|
+
millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
|
5659
5662
|
# https://www.okx.com/support/hc/en-us/articles/360053909272-Ⅸ-Introduction-to-perpetual-swap-funding-fee
|
5660
5663
|
# > The current interest is 0.
|
5661
5664
|
return {
|
@@ -5676,9 +5679,20 @@ class okx(Exchange, ImplicitAPI):
|
|
5676
5679
|
'previousFundingRate': None,
|
5677
5680
|
'previousFundingTimestamp': None,
|
5678
5681
|
'previousFundingDatetime': None,
|
5682
|
+
'interval': self.parse_funding_interval(millisecondsInterval),
|
5679
5683
|
}
|
5680
5684
|
|
5681
|
-
def
|
5685
|
+
def parse_funding_interval(self, interval):
|
5686
|
+
intervals: dict = {
|
5687
|
+
'3600000': '1h',
|
5688
|
+
'14400000': '4h',
|
5689
|
+
'28800000': '8h',
|
5690
|
+
'57600000': '16h',
|
5691
|
+
'86400000': '24h',
|
5692
|
+
}
|
5693
|
+
return self.safe_string(intervals, interval, interval)
|
5694
|
+
|
5695
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
5682
5696
|
"""
|
5683
5697
|
fetch the current funding rate
|
5684
5698
|
:see: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
|
ccxt/oxfun.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.oxfun import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -83,7 +83,7 @@ class oxfun(Exchange, ImplicitAPI):
|
|
83
83
|
'fetchDepositWithdrawFee': False,
|
84
84
|
'fetchDepositWithdrawFees': False,
|
85
85
|
'fetchFundingHistory': True,
|
86
|
-
'fetchFundingRate':
|
86
|
+
'fetchFundingRate': 'emulated',
|
87
87
|
'fetchFundingRateHistory': True,
|
88
88
|
'fetchFundingRates': True,
|
89
89
|
'fetchIndexOHLCV': False,
|
@@ -987,10 +987,10 @@ class oxfun(Exchange, ImplicitAPI):
|
|
987
987
|
timestamp = self.safe_integer(data, 'lastUpdatedAt')
|
988
988
|
return self.parse_order_book(data, market['symbol'], timestamp)
|
989
989
|
|
990
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
990
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
991
991
|
"""
|
992
|
+
fetch the current funding rates for multiple markets
|
992
993
|
:see: https://docs.ox.fun/?json#get-v3-funding-estimates
|
993
|
-
fetch the current funding rates
|
994
994
|
:param str[] symbols: unified market symbols
|
995
995
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
996
996
|
:returns Order[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
@@ -1020,14 +1020,13 @@ class oxfun(Exchange, ImplicitAPI):
|
|
1020
1020
|
result = self.parse_funding_rates(data)
|
1021
1021
|
return self.filter_by_array(result, 'symbol', symbols)
|
1022
1022
|
|
1023
|
-
def parse_funding_rate(self, fundingRate, market: Market = None):
|
1023
|
+
def parse_funding_rate(self, fundingRate, market: Market = None) -> FundingRate:
|
1024
1024
|
#
|
1025
1025
|
# {
|
1026
1026
|
# "marketCode": "OX-USD-SWAP-LIN",
|
1027
1027
|
# "fundingAt": "1715515200000",
|
1028
1028
|
# "estFundingRate": "0.000200000"
|
1029
|
-
# }
|
1030
|
-
#
|
1029
|
+
# }
|
1031
1030
|
#
|
1032
1031
|
symbol = self.safe_string(fundingRate, 'marketCode')
|
1033
1032
|
market = self.market(symbol)
|
@@ -1050,6 +1049,7 @@ class oxfun(Exchange, ImplicitAPI):
|
|
1050
1049
|
'previousFundingRate': None,
|
1051
1050
|
'previousFundingTimestamp': None,
|
1052
1051
|
'previousFundingDatetime': None,
|
1052
|
+
'interval': None,
|
1053
1053
|
}
|
1054
1054
|
|
1055
1055
|
def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|