mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 14:00:38 +00:00
feat: Log if user has a Gate unified account
This commit is contained in:
@@ -3,9 +3,13 @@
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
import ccxt
|
||||
|
||||
from freqtrade.constants import BuySell
|
||||
from freqtrade.enums import MarginMode, PriceType, TradingMode
|
||||
from freqtrade.exceptions import DDosProtection, OperationalException, TemporaryError
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.common import retrier
|
||||
from freqtrade.exchange.exchange_types import CcxtOrder, FtHas
|
||||
from freqtrade.misc import safe_value_fallback2
|
||||
|
||||
@@ -23,6 +27,8 @@ class Gate(Exchange):
|
||||
may still not work as expected.
|
||||
"""
|
||||
|
||||
unified_account = False
|
||||
|
||||
_ft_has: FtHas = {
|
||||
"ohlcv_candle_limit": 1000,
|
||||
"order_time_in_force": ["GTC", "IOC"],
|
||||
@@ -53,6 +59,35 @@ class Gate(Exchange):
|
||||
(TradingMode.FUTURES, MarginMode.ISOLATED)
|
||||
]
|
||||
|
||||
@retrier
|
||||
def additional_exchange_init(self) -> None:
|
||||
"""
|
||||
Additional exchange initialization logic.
|
||||
.api will be available at this point.
|
||||
Must be overridden in child methods if required.
|
||||
"""
|
||||
try:
|
||||
if not self._config["dry_run"]:
|
||||
# TODO: This should work with 4.4.34 and later.
|
||||
self._api.load_unified_status()
|
||||
is_unified = self._api.options.get("unifiedAccount")
|
||||
|
||||
# Returns a tuple of bools, first for margin, second for Account
|
||||
if is_unified:
|
||||
self.unified_account = True
|
||||
logger.info("Gate: Unified account.")
|
||||
else:
|
||||
self.unified_account = False
|
||||
logger.info("Gate: Classic account.")
|
||||
except ccxt.DDoSProtection as e:
|
||||
raise DDosProtection(e) from e
|
||||
except (ccxt.OperationFailed, ccxt.ExchangeError) as e:
|
||||
raise TemporaryError(
|
||||
f"Error in additional_exchange_init due to {e.__class__.__name__}. Message: {e}"
|
||||
) from e
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
def _get_params(
|
||||
self,
|
||||
side: BuySell,
|
||||
|
||||
@@ -410,6 +410,7 @@ def get_futures_exchange(exchange_name, exchange_conf, class_mocker):
|
||||
class_mocker.patch("freqtrade.exchange.okx.Okx.additional_exchange_init")
|
||||
class_mocker.patch("freqtrade.exchange.binance.Binance.additional_exchange_init")
|
||||
class_mocker.patch("freqtrade.exchange.bybit.Bybit.additional_exchange_init")
|
||||
class_mocker.patch("freqtrade.exchange.gate.Gate.additional_exchange_init")
|
||||
class_mocker.patch(f"{EXMS}.load_cached_leverage_tiers", return_value=None)
|
||||
class_mocker.patch(f"{EXMS}.cache_leverage_tiers")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user