ccxt 4.4.75__py2.py3-none-any.whl → 4.4.78__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 +3 -3
- ccxt/abstract/apex.py +31 -0
- ccxt/abstract/myokx.py +4 -0
- ccxt/abstract/okx.py +4 -0
- ccxt/abstract/upbit.py +51 -37
- ccxt/abstract/xt.py +3 -0
- ccxt/apex.py +1884 -0
- ccxt/ascendex.py +2 -2
- ccxt/async_support/__init__.py +3 -3
- ccxt/async_support/apex.py +1884 -0
- ccxt/async_support/ascendex.py +2 -2
- ccxt/async_support/base/exchange.py +2 -2
- ccxt/async_support/binance.py +39 -217
- ccxt/async_support/bingx.py +1 -1
- ccxt/async_support/bitfinex.py +2 -2
- ccxt/async_support/bitflyer.py +2 -2
- ccxt/async_support/bitget.py +135 -65
- ccxt/async_support/bitmart.py +2 -2
- ccxt/async_support/bitmex.py +6 -6
- ccxt/async_support/bitrue.py +48 -0
- ccxt/async_support/cex.py +1 -1
- ccxt/async_support/coinbase.py +29 -4
- ccxt/async_support/coincatch.py +66 -0
- ccxt/async_support/coinex.py +3 -1
- ccxt/async_support/coinlist.py +85 -2
- ccxt/async_support/cryptocom.py +2 -2
- ccxt/async_support/defx.py +1 -1
- ccxt/async_support/delta.py +1 -1
- ccxt/async_support/deribit.py +2 -2
- ccxt/async_support/derive.py +2 -2
- ccxt/async_support/digifinex.py +2 -2
- ccxt/async_support/gate.py +1 -1
- ccxt/async_support/hitbtc.py +5 -2
- ccxt/async_support/htx.py +2 -2
- ccxt/async_support/hyperliquid.py +13 -6
- ccxt/async_support/kraken.py +2 -2
- ccxt/async_support/krakenfutures.py +2 -2
- ccxt/async_support/kucoinfutures.py +2 -2
- ccxt/async_support/mexc.py +50 -52
- ccxt/async_support/okx.py +21 -9
- ccxt/async_support/oxfun.py +2 -2
- ccxt/async_support/paradex.py +5 -10
- ccxt/async_support/phemex.py +4 -3
- ccxt/async_support/poloniex.py +3 -3
- ccxt/async_support/probit.py +1 -0
- ccxt/async_support/tradeogre.py +2 -1
- ccxt/async_support/upbit.py +265 -89
- ccxt/async_support/vertex.py +2 -2
- ccxt/async_support/whitebit.py +1 -0
- ccxt/async_support/woo.py +5 -3
- ccxt/async_support/woofipro.py +2 -2
- ccxt/async_support/xt.py +115 -5
- ccxt/base/exchange.py +76 -3
- ccxt/binance.py +39 -217
- ccxt/bingx.py +1 -1
- ccxt/bitfinex.py +2 -2
- ccxt/bitflyer.py +2 -2
- ccxt/bitget.py +135 -65
- ccxt/bitmart.py +2 -2
- ccxt/bitmex.py +6 -6
- ccxt/bitrue.py +48 -0
- ccxt/cex.py +1 -1
- ccxt/coinbase.py +29 -4
- ccxt/coincatch.py +66 -0
- ccxt/coinex.py +3 -1
- ccxt/coinlist.py +85 -2
- ccxt/cryptocom.py +2 -2
- ccxt/defx.py +1 -1
- ccxt/delta.py +1 -1
- ccxt/deribit.py +2 -2
- ccxt/derive.py +2 -2
- ccxt/digifinex.py +2 -2
- ccxt/gate.py +1 -1
- ccxt/hitbtc.py +5 -2
- ccxt/htx.py +2 -2
- ccxt/hyperliquid.py +13 -6
- ccxt/kraken.py +2 -2
- ccxt/krakenfutures.py +2 -2
- ccxt/kucoinfutures.py +2 -2
- ccxt/mexc.py +50 -52
- ccxt/okx.py +21 -9
- ccxt/oxfun.py +2 -2
- ccxt/paradex.py +5 -10
- ccxt/phemex.py +4 -3
- ccxt/poloniex.py +3 -3
- ccxt/pro/__init__.py +5 -1
- ccxt/pro/apex.py +984 -0
- ccxt/pro/coinbase.py +4 -6
- ccxt/pro/gate.py +22 -2
- ccxt/pro/hollaex.py +2 -2
- ccxt/pro/hyperliquid.py +1 -1
- ccxt/pro/p2b.py +2 -2
- ccxt/pro/tradeogre.py +272 -0
- ccxt/probit.py +1 -0
- ccxt/test/tests_async.py +27 -0
- ccxt/test/tests_sync.py +27 -0
- ccxt/tradeogre.py +2 -1
- ccxt/upbit.py +265 -89
- ccxt/vertex.py +2 -2
- ccxt/whitebit.py +1 -0
- ccxt/woo.py +5 -3
- ccxt/woofipro.py +2 -2
- ccxt/xt.py +115 -5
- {ccxt-4.4.75.dist-info → ccxt-4.4.78.dist-info}/METADATA +4 -4
- {ccxt-4.4.75.dist-info → ccxt-4.4.78.dist-info}/RECORD +108 -106
- ccxt/abstract/ace.py +0 -15
- ccxt/ace.py +0 -1152
- ccxt/async_support/ace.py +0 -1152
- {ccxt-4.4.75.dist-info → ccxt-4.4.78.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.75.dist-info → ccxt-4.4.78.dist-info}/WHEEL +0 -0
- {ccxt-4.4.75.dist-info → ccxt-4.4.78.dist-info}/top_level.txt +0 -0
ccxt/async_support/coinex.py
CHANGED
@@ -763,6 +763,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
763
763
|
for j in range(0, len(chains)):
|
764
764
|
chain = chains[j]
|
765
765
|
networkId = self.safe_string(chain, 'chain')
|
766
|
+
if networkId is None:
|
767
|
+
continue
|
766
768
|
precisionString = self.parse_precision(self.safe_string(chain, 'withdrawal_precision'))
|
767
769
|
feeString = self.safe_string(chain, 'withdrawal_fee')
|
768
770
|
minNetworkDepositString = self.safe_string(chain, 'min_deposit_amount')
|
@@ -3857,7 +3859,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3857
3859
|
data = self.safe_list(response, 'data', [])
|
3858
3860
|
return self.parse_trades(data, market, since, limit)
|
3859
3861
|
|
3860
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
3862
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
3861
3863
|
"""
|
3862
3864
|
fetch all open positions
|
3863
3865
|
|
ccxt/async_support/coinlist.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.coinlist import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import math
|
10
|
-
from ccxt.base.types import Account, Any, Balances, Currencies, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Account, Any, Balances, Currencies, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, 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
|
@@ -79,7 +79,7 @@ class coinlist(Exchange, ImplicitAPI):
|
|
79
79
|
'fetchDepositWithdrawFee': False,
|
80
80
|
'fetchDepositWithdrawFees': False,
|
81
81
|
'fetchFundingHistory': False,
|
82
|
-
'fetchFundingRate':
|
82
|
+
'fetchFundingRate': True,
|
83
83
|
'fetchFundingRateHistory': False,
|
84
84
|
'fetchFundingRates': False,
|
85
85
|
'fetchIndexOHLCV': False,
|
@@ -2405,6 +2405,89 @@ class coinlist(Exchange, ImplicitAPI):
|
|
2405
2405
|
}
|
2406
2406
|
return self.safe_string(types, type, type)
|
2407
2407
|
|
2408
|
+
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2409
|
+
"""
|
2410
|
+
fetch the current funding rate
|
2411
|
+
|
2412
|
+
https://trade-docs.coinlist.co/#coinlist-pro-api-Funding-Rates
|
2413
|
+
|
2414
|
+
:param str symbol: unified market symbol
|
2415
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2416
|
+
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2417
|
+
"""
|
2418
|
+
await self.load_markets()
|
2419
|
+
market = self.market(symbol)
|
2420
|
+
if not market['swap']:
|
2421
|
+
raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
|
2422
|
+
request: dict = {
|
2423
|
+
'symbol': market['id'],
|
2424
|
+
}
|
2425
|
+
response = await self.publicGetV1SymbolsSymbolFunding(self.extend(request, params))
|
2426
|
+
#
|
2427
|
+
# {
|
2428
|
+
# "last": {
|
2429
|
+
# "funding_rate": "-0.00043841",
|
2430
|
+
# "funding_time": "2025-04-15T04:00:00.000Z"
|
2431
|
+
# },
|
2432
|
+
# "next": {
|
2433
|
+
# "funding_rate": "-0.00046952",
|
2434
|
+
# "funding_time": "2025-04-15T12:00:00.000Z"
|
2435
|
+
# },
|
2436
|
+
# "indicative": {
|
2437
|
+
# "funding_rate": "-0.00042517",
|
2438
|
+
# "funding_time": "2025-04-15T20:00:00.000Z"
|
2439
|
+
# },
|
2440
|
+
# "timestamp": "2025-04-15T07:01:15.219Z"
|
2441
|
+
# }
|
2442
|
+
#
|
2443
|
+
return self.parse_funding_rate(response, market)
|
2444
|
+
|
2445
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2446
|
+
#
|
2447
|
+
# {
|
2448
|
+
# "last": {
|
2449
|
+
# "funding_rate": "-0.00043841",
|
2450
|
+
# "funding_time": "2025-04-15T04:00:00.000Z"
|
2451
|
+
# },
|
2452
|
+
# "next": {
|
2453
|
+
# "funding_rate": "-0.00046952",
|
2454
|
+
# "funding_time": "2025-04-15T12:00:00.000Z"
|
2455
|
+
# },
|
2456
|
+
# "indicative": {
|
2457
|
+
# "funding_rate": "-0.00042517",
|
2458
|
+
# "funding_time": "2025-04-15T20:00:00.000Z"
|
2459
|
+
# },
|
2460
|
+
# "timestamp": "2025-04-15T07:01:15.219Z"
|
2461
|
+
# }
|
2462
|
+
#
|
2463
|
+
previous = self.safe_dict(contract, 'last', {})
|
2464
|
+
current = self.safe_dict(contract, 'next', {})
|
2465
|
+
next = self.safe_dict(contract, 'indicative', {})
|
2466
|
+
previousDatetime = self.safe_string(previous, 'funding_time')
|
2467
|
+
currentDatetime = self.safe_string(current, 'funding_time')
|
2468
|
+
nextDatetime = self.safe_string(next, 'funding_time')
|
2469
|
+
datetime = self.safe_string(contract, 'timestamp')
|
2470
|
+
return {
|
2471
|
+
'info': contract,
|
2472
|
+
'symbol': self.safe_symbol(None, market),
|
2473
|
+
'markPrice': None,
|
2474
|
+
'indexPrice': None,
|
2475
|
+
'interestRate': None,
|
2476
|
+
'estimatedSettlePrice': None,
|
2477
|
+
'timestamp': self.parse8601(datetime),
|
2478
|
+
'datetime': datetime,
|
2479
|
+
'fundingRate': self.safe_number(current, 'funding_rate'),
|
2480
|
+
'fundingTimestamp': self.parse8601(currentDatetime),
|
2481
|
+
'fundingDatetime': currentDatetime,
|
2482
|
+
'nextFundingRate': self.safe_number(next, 'funding_rate'),
|
2483
|
+
'nextFundingTimestamp': self.parse8601(nextDatetime),
|
2484
|
+
'nextFundingDatetime': nextDatetime,
|
2485
|
+
'previousFundingRate': self.safe_number(previous, 'funding_rate'),
|
2486
|
+
'previousFundingTimestamp': self.parse8601(previousDatetime),
|
2487
|
+
'previousFundingDatetime': previousDatetime,
|
2488
|
+
'interval': '8h',
|
2489
|
+
}
|
2490
|
+
|
2408
2491
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
2409
2492
|
request = self.omit(params, self.extract_params(path))
|
2410
2493
|
endpoint = '/' + self.implode_params(path, params)
|
ccxt/async_support/cryptocom.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.cryptocom import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Any, Balances, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction
|
9
|
+
from ccxt.base.types import Account, Any, Balances, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -2789,7 +2789,7 @@ class cryptocom(Exchange, ImplicitAPI):
|
|
2789
2789
|
data = self.safe_list(result, 'data', [])
|
2790
2790
|
return self.parse_position(self.safe_dict(data, 0), market)
|
2791
2791
|
|
2792
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2792
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
2793
2793
|
"""
|
2794
2794
|
fetch all open positions
|
2795
2795
|
|
ccxt/async_support/defx.py
CHANGED
@@ -1495,7 +1495,7 @@ class defx(Exchange, ImplicitAPI):
|
|
1495
1495
|
first = self.safe_dict(data, 0, {})
|
1496
1496
|
return self.parse_position(first, market)
|
1497
1497
|
|
1498
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
1498
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
1499
1499
|
"""
|
1500
1500
|
fetch all open positions
|
1501
1501
|
|
ccxt/async_support/delta.py
CHANGED
@@ -1660,7 +1660,7 @@ class delta(Exchange, ImplicitAPI):
|
|
1660
1660
|
result = self.safe_dict(response, 'result', {})
|
1661
1661
|
return self.parse_position(result, market)
|
1662
1662
|
|
1663
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
1663
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
1664
1664
|
"""
|
1665
1665
|
fetch all open positions
|
1666
1666
|
|
ccxt/async_support/deribit.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.deribit import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, Greeks, Int, Market, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, MarketInterface, TransferEntry
|
9
|
+
from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, Greeks, Int, Market, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, MarketInterface, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -2673,7 +2673,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2673
2673
|
result = self.safe_dict(response, 'result')
|
2674
2674
|
return self.parse_position(result)
|
2675
2675
|
|
2676
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2676
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
2677
2677
|
"""
|
2678
2678
|
fetch all open positions
|
2679
2679
|
|
ccxt/async_support/derive.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.derive import ImplicitAPI
|
8
8
|
import asyncio
|
9
|
-
from ccxt.base.types import Any, Balances, Bool, Currencies, Currency, Int, Market, MarketType, Num, Order, OrderSide, OrderType, Str, Strings, Ticker, FundingRate, Trade, Transaction
|
9
|
+
from ccxt.base.types import Any, Balances, Bool, Currencies, Currency, Int, Market, MarketType, Num, Order, OrderSide, OrderType, Position, Str, Strings, Ticker, FundingRate, Trade, Transaction
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -2028,7 +2028,7 @@ class derive(Exchange, ImplicitAPI):
|
|
2028
2028
|
trades = self.safe_list(result, 'trades', [])
|
2029
2029
|
return self.parse_trades(trades, market, since, limit, params)
|
2030
2030
|
|
2031
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2031
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
2032
2032
|
"""
|
2033
2033
|
fetch all open positions
|
2034
2034
|
|
ccxt/async_support/digifinex.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.digifinex import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
from ccxt.base.types import Any, Balances, BorrowInterest, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
11
|
+
from ccxt.base.types import Any, Balances, BorrowInterest, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import AuthenticationError
|
@@ -3376,7 +3376,7 @@ class digifinex(Exchange, ImplicitAPI):
|
|
3376
3376
|
'tierBased': None,
|
3377
3377
|
}
|
3378
3378
|
|
3379
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
3379
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
3380
3380
|
"""
|
3381
3381
|
fetch all open positions
|
3382
3382
|
|
ccxt/async_support/gate.py
CHANGED
@@ -5724,7 +5724,7 @@ class gate(Exchange, ImplicitAPI):
|
|
5724
5724
|
#
|
5725
5725
|
return self.parse_position(response, market)
|
5726
5726
|
|
5727
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
5727
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
5728
5728
|
"""
|
5729
5729
|
fetch all open positions
|
5730
5730
|
|
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 Any, Balances, Currencies, Currency, DepositAddress, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, OrderBooks, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, OrderBooks, 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
|
@@ -966,6 +966,8 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
966
966
|
transferEnabled = self.safe_bool(entry, 'transfer_enabled', False)
|
967
967
|
active = payinEnabled and payoutEnabled and transferEnabled
|
968
968
|
rawNetworks = self.safe_value(entry, 'networks', [])
|
969
|
+
isCrypto = self.safe_bool(entry, 'crypto')
|
970
|
+
type = 'crypto' if isCrypto else 'fiat'
|
969
971
|
networks: dict = {}
|
970
972
|
fee = None
|
971
973
|
depositEnabled = None
|
@@ -1023,6 +1025,7 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
1023
1025
|
'max': None,
|
1024
1026
|
},
|
1025
1027
|
},
|
1028
|
+
'type': type,
|
1026
1029
|
}
|
1027
1030
|
return result
|
1028
1031
|
|
@@ -2823,7 +2826,7 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
2823
2826
|
sorted = self.sort_by(rates, 'timestamp')
|
2824
2827
|
return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
|
2825
2828
|
|
2826
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2829
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
2827
2830
|
"""
|
2828
2831
|
fetch all open positions
|
2829
2832
|
|
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, Any, Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Account, Any, Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, 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
|
@@ -7338,7 +7338,7 @@ class htx(Exchange, ImplicitAPI):
|
|
7338
7338
|
'takeProfitPrice': None,
|
7339
7339
|
})
|
7340
7340
|
|
7341
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
7341
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
7342
7342
|
"""
|
7343
7343
|
fetch all open positions
|
7344
7344
|
|
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.hyperliquid import ImplicitAPI
|
8
8
|
import asyncio
|
9
9
|
import math
|
10
|
-
from ccxt.base.types import Any, Balances, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Any, Balances, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, 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 ArgumentsRequired
|
@@ -772,12 +772,15 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
772
772
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
773
773
|
:param str [params.user]: user address, will default to self.walletAddress if not provided
|
774
774
|
:param str [params.type]: wallet type, ['spot', 'swap'], defaults to swap
|
775
|
+
:param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None
|
775
776
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
776
777
|
"""
|
777
778
|
userAddress = None
|
778
779
|
userAddress, params = self.handle_public_address('fetchBalance', params)
|
779
780
|
type = None
|
780
781
|
type, params = self.handle_market_type_and_params('fetchBalance', None, params)
|
782
|
+
marginMode = None
|
783
|
+
marginMode, params = self.handle_margin_mode_and_params('fetchBalance', params)
|
781
784
|
isSpot = (type == 'spot')
|
782
785
|
reqType = 'spotClearinghouseState' if (isSpot) else 'clearinghouseState'
|
783
786
|
request: dict = {
|
@@ -834,12 +837,16 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
834
837
|
spotBalances[code] = account
|
835
838
|
return self.safe_balance(spotBalances)
|
836
839
|
data = self.safe_dict(response, 'marginSummary', {})
|
840
|
+
usdcBalance = {
|
841
|
+
'total': self.safe_number(data, 'accountValue'),
|
842
|
+
}
|
843
|
+
if (marginMode is not None) and (marginMode == 'isolated'):
|
844
|
+
usdcBalance['free'] = self.safe_number(response, 'withdrawable')
|
845
|
+
else:
|
846
|
+
usdcBalance['used'] = self.safe_number(data, 'totalMarginUsed')
|
837
847
|
result: dict = {
|
838
848
|
'info': response,
|
839
|
-
'USDC':
|
840
|
-
'total': self.safe_number(data, 'accountValue'),
|
841
|
-
'used': self.safe_number(data, 'totalMarginUsed'),
|
842
|
-
},
|
849
|
+
'USDC': usdcBalance,
|
843
850
|
}
|
844
851
|
timestamp = self.safe_integer(response, 'time')
|
845
852
|
result['timestamp'] = timestamp
|
@@ -2453,7 +2460,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2453
2460
|
positions = await self.fetch_positions([symbol], params)
|
2454
2461
|
return self.safe_dict(positions, 0, {})
|
2455
2462
|
|
2456
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2463
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
2457
2464
|
"""
|
2458
2465
|
fetch all open positions
|
2459
2466
|
|
ccxt/async_support/kraken.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.kraken import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, IndexType, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, IndexType, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, 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
|
@@ -3067,7 +3067,7 @@ class kraken(Exchange, ImplicitAPI):
|
|
3067
3067
|
return self.parse_transaction(result, currency)
|
3068
3068
|
raise ExchangeError(self.id + " withdraw() requires a 'key' parameter(withdrawal key name, up on your account)")
|
3069
3069
|
|
3070
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
3070
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
3071
3071
|
"""
|
3072
3072
|
fetch all open positions
|
3073
3073
|
|
@@ -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 Any, Balances, Currency, Int, Leverage, Leverages, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TransferEntry
|
9
|
+
from ccxt.base.types import Any, Balances, Currency, Int, Leverage, Leverages, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, 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
|
@@ -2287,7 +2287,7 @@ class krakenfutures(Exchange, ImplicitAPI):
|
|
2287
2287
|
sorted = self.sort_by(result, 'timestamp')
|
2288
2288
|
return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
|
2289
2289
|
|
2290
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2290
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
2291
2291
|
"""
|
2292
2292
|
|
2293
2293
|
https://docs.futures.kraken.com/#http-api-trading-v3-api-account-information-get-open-positions
|
@@ -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 Any, Balances, Currency, DepositAddress, Int, Leverage, LeverageTier, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
8
|
+
from ccxt.base.types import Any, Balances, Currency, DepositAddress, Int, Leverage, LeverageTier, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, 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
|
@@ -1232,7 +1232,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1232
1232
|
data = self.safe_dict(response, 'data', {})
|
1233
1233
|
return self.parse_position(data, market)
|
1234
1234
|
|
1235
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
1235
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
1236
1236
|
"""
|
1237
1237
|
fetch all open positions
|
1238
1238
|
|
ccxt/async_support/mexc.py
CHANGED
@@ -1098,80 +1098,47 @@ class mexc(Exchange, ImplicitAPI):
|
|
1098
1098
|
id = self.safe_string(currency, 'coin')
|
1099
1099
|
code = self.safe_currency_code(id)
|
1100
1100
|
name = self.safe_string(currency, 'name')
|
1101
|
-
currencyActive = False
|
1102
|
-
currencyFee = None
|
1103
|
-
currencyWithdrawMin = None
|
1104
|
-
currencyWithdrawMax = None
|
1105
|
-
depositEnabled = False
|
1106
|
-
withdrawEnabled = False
|
1107
1101
|
networks: dict = {}
|
1108
1102
|
chains = self.safe_value(currency, 'networkList', [])
|
1109
1103
|
for j in range(0, len(chains)):
|
1110
1104
|
chain = chains[j]
|
1111
1105
|
networkId = self.safe_string_2(chain, 'netWork', 'network')
|
1112
1106
|
network = self.network_id_to_code(networkId)
|
1113
|
-
isDepositEnabled = self.safe_bool(chain, 'depositEnable', False)
|
1114
|
-
isWithdrawEnabled = self.safe_bool(chain, 'withdrawEnable', False)
|
1115
|
-
active = (isDepositEnabled and isWithdrawEnabled)
|
1116
|
-
currencyActive = active or currencyActive
|
1117
|
-
withdrawMin = self.safe_string(chain, 'withdrawMin')
|
1118
|
-
withdrawMax = self.safe_string(chain, 'withdrawMax')
|
1119
|
-
currencyWithdrawMin = withdrawMin if (currencyWithdrawMin is None) else currencyWithdrawMin
|
1120
|
-
currencyWithdrawMax = withdrawMax if (currencyWithdrawMax is None) else currencyWithdrawMax
|
1121
|
-
fee = self.safe_number(chain, 'withdrawFee')
|
1122
|
-
currencyFee = fee if (currencyFee is None) else currencyFee
|
1123
|
-
if Precise.string_gt(currencyWithdrawMin, withdrawMin):
|
1124
|
-
currencyWithdrawMin = withdrawMin
|
1125
|
-
if Precise.string_lt(currencyWithdrawMax, withdrawMax):
|
1126
|
-
currencyWithdrawMax = withdrawMax
|
1127
|
-
if isDepositEnabled:
|
1128
|
-
depositEnabled = True
|
1129
|
-
if isWithdrawEnabled:
|
1130
|
-
withdrawEnabled = True
|
1131
1107
|
networks[network] = {
|
1132
1108
|
'info': chain,
|
1133
1109
|
'id': networkId,
|
1134
1110
|
'network': network,
|
1135
|
-
'active':
|
1136
|
-
'deposit':
|
1137
|
-
'withdraw':
|
1138
|
-
'fee':
|
1111
|
+
'active': None,
|
1112
|
+
'deposit': self.safe_bool(chain, 'depositEnable', False),
|
1113
|
+
'withdraw': self.safe_bool(chain, 'withdrawEnable', False),
|
1114
|
+
'fee': self.safe_number(chain, 'withdrawFee'),
|
1139
1115
|
'precision': None,
|
1140
1116
|
'limits': {
|
1141
1117
|
'withdraw': {
|
1142
|
-
'min': withdrawMin,
|
1143
|
-
'max': withdrawMax,
|
1118
|
+
'min': self.safe_string(chain, 'withdrawMin'),
|
1119
|
+
'max': self.safe_string(chain, 'withdrawMax'),
|
1144
1120
|
},
|
1145
1121
|
},
|
1146
1122
|
}
|
1147
|
-
|
1148
|
-
networkKeysLength = len(networkKeys)
|
1149
|
-
if (networkKeysLength == 1) or ('NONE' in networks):
|
1150
|
-
defaultNetwork = self.safe_value_2(networks, 'NONE', networkKeysLength - 1)
|
1151
|
-
if defaultNetwork is not None:
|
1152
|
-
currencyFee = defaultNetwork['fee']
|
1153
|
-
result[code] = {
|
1123
|
+
result[code] = self.safe_currency_structure({
|
1154
1124
|
'info': currency,
|
1155
1125
|
'id': id,
|
1156
1126
|
'code': code,
|
1157
1127
|
'name': name,
|
1158
|
-
'active':
|
1159
|
-
'deposit':
|
1160
|
-
'withdraw':
|
1161
|
-
'fee':
|
1128
|
+
'active': None,
|
1129
|
+
'deposit': None,
|
1130
|
+
'withdraw': None,
|
1131
|
+
'fee': None,
|
1162
1132
|
'precision': None,
|
1163
1133
|
'limits': {
|
1164
1134
|
'amount': {
|
1165
1135
|
'min': None,
|
1166
1136
|
'max': None,
|
1167
1137
|
},
|
1168
|
-
'withdraw': {
|
1169
|
-
'min': currencyWithdrawMin,
|
1170
|
-
'max': currencyWithdrawMax,
|
1171
|
-
},
|
1172
1138
|
},
|
1139
|
+
'type': 'crypto',
|
1173
1140
|
'networks': networks,
|
1174
|
-
}
|
1141
|
+
})
|
1175
1142
|
return result
|
1176
1143
|
|
1177
1144
|
async def fetch_markets(self, params={}) -> List[Market]:
|
@@ -3254,13 +3221,27 @@ class mexc(Exchange, ImplicitAPI):
|
|
3254
3221
|
|
3255
3222
|
def parse_order(self, order: dict, market: Market = None) -> Order:
|
3256
3223
|
#
|
3257
|
-
# spot
|
3224
|
+
# spot
|
3225
|
+
# createOrder
|
3258
3226
|
#
|
3259
|
-
#
|
3227
|
+
# {
|
3228
|
+
# "symbol": "FARTCOINUSDT",
|
3229
|
+
# "orderId": "C02__342252993005723644225",
|
3230
|
+
# "orderListId": "-1",
|
3231
|
+
# "price": "1.1",
|
3232
|
+
# "origQty": "6.3",
|
3233
|
+
# "type": "IMMEDIATE_OR_CANCEL",
|
3234
|
+
# "side": "SELL",
|
3235
|
+
# "transactTime": "1745852205223"
|
3236
|
+
# }
|
3237
|
+
#
|
3238
|
+
# unknown endpoint on spot
|
3239
|
+
#
|
3240
|
+
# {
|
3260
3241
|
# "symbol": "BTCUSDT",
|
3261
3242
|
# "orderId": "123738410679123456",
|
3262
3243
|
# "orderListId": -1
|
3263
|
-
#
|
3244
|
+
# }
|
3264
3245
|
#
|
3265
3246
|
# margin: createOrder
|
3266
3247
|
#
|
@@ -3422,6 +3403,10 @@ class mexc(Exchange, ImplicitAPI):
|
|
3422
3403
|
id = order
|
3423
3404
|
else:
|
3424
3405
|
id = self.safe_string_2(order, 'orderId', 'id')
|
3406
|
+
timeInForce = self.parse_order_time_in_force(self.safe_string(order, 'timeInForce'))
|
3407
|
+
typeRaw = self.safe_string(order, 'type')
|
3408
|
+
if timeInForce is None:
|
3409
|
+
timeInForce = self.get_tif_from_raw_order_type(typeRaw)
|
3425
3410
|
marketId = self.safe_string(order, 'symbol')
|
3426
3411
|
market = self.safe_market(marketId, market)
|
3427
3412
|
timestamp = self.safe_integer_n(order, ['time', 'createTime', 'transactTime'])
|
@@ -3443,8 +3428,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
3443
3428
|
'lastTradeTimestamp': None, # TODO: self might be 'updateTime' if order-status is filled, otherwise cancellation time. needs to be checked
|
3444
3429
|
'status': self.parse_order_status(self.safe_string_2(order, 'status', 'state')),
|
3445
3430
|
'symbol': market['symbol'],
|
3446
|
-
'type': self.parse_order_type(
|
3447
|
-
'timeInForce':
|
3431
|
+
'type': self.parse_order_type(typeRaw),
|
3432
|
+
'timeInForce': timeInForce,
|
3448
3433
|
'side': self.parse_order_side(self.safe_string(order, 'side')),
|
3449
3434
|
'price': self.safe_number(order, 'price'),
|
3450
3435
|
'triggerPrice': self.safe_number_2(order, 'stopPrice', 'triggerPrice'),
|
@@ -3473,6 +3458,9 @@ class mexc(Exchange, ImplicitAPI):
|
|
3473
3458
|
'MARKET': 'market',
|
3474
3459
|
'LIMIT': 'limit',
|
3475
3460
|
'LIMIT_MAKER': 'limit',
|
3461
|
+
# on spot, during submission below types are used only accepted order
|
3462
|
+
'IMMEDIATE_OR_CANCEL': 'limit',
|
3463
|
+
'FILL_OR_KILL': 'limit',
|
3476
3464
|
}
|
3477
3465
|
return self.safe_string(statuses, status, status)
|
3478
3466
|
|
@@ -3500,6 +3488,16 @@ class mexc(Exchange, ImplicitAPI):
|
|
3500
3488
|
}
|
3501
3489
|
return self.safe_string(statuses, status, status)
|
3502
3490
|
|
3491
|
+
def get_tif_from_raw_order_type(self, orderType: Str = None):
|
3492
|
+
statuses: dict = {
|
3493
|
+
'LIMIT': 'GTC',
|
3494
|
+
'LIMIT_MAKER': 'POST_ONLY',
|
3495
|
+
'IMMEDIATE_OR_CANCEL': 'IOC',
|
3496
|
+
'FILL_OR_KILL': 'FOK',
|
3497
|
+
'MARKET': 'IOC',
|
3498
|
+
}
|
3499
|
+
return self.safe_string(statuses, orderType, orderType)
|
3500
|
+
|
3503
3501
|
async def fetch_account_helper(self, type, params):
|
3504
3502
|
if type == 'spot':
|
3505
3503
|
return await self.spotPrivateGetAccount(params)
|
@@ -4850,7 +4848,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4850
4848
|
response = await self.fetch_positions(None, self.extend(request, params))
|
4851
4849
|
return self.safe_value(response, 0)
|
4852
4850
|
|
4853
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
4851
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
4854
4852
|
"""
|
4855
4853
|
fetch all open positions
|
4856
4854
|
|