feat: implement __str__ for marign and tradingmode enums

This commit is contained in:
Matthias 2024-09-06 20:58:54 +02:00
parent 990dbb6c06
commit 6a4b641250
5 changed files with 11 additions and 5 deletions

View File

@ -11,3 +11,6 @@ class MarginMode(str, Enum):
CROSS = "cross"
ISOLATED = "isolated"
NONE = ""
def __str__(self):
return f"{self.name.lower()}"

View File

@ -10,3 +10,6 @@ class TradingMode(str, Enum):
SPOT = "spot"
MARGIN = "margin"
FUTURES = "futures"
def __str__(self):
return f"{self.name.lower()}"

View File

@ -192,7 +192,7 @@ class Binance(Exchange):
if maintenance_amt is None:
raise OperationalException(
"Parameter maintenance_amt is required by Binance.liquidation_price"
f"for {self.trading_mode.value}"
f"for {self.trading_mode}"
)
if self.trading_mode == TradingMode.FUTURES:

View File

@ -707,7 +707,7 @@ class Exchange:
# Note: ccxt has BaseCurrency/QuoteCurrency format for pairs
if self.markets and pair not in self.markets:
raise OperationalException(
f"Pair {pair} is not available on {self.name} {self.trading_mode.value}. "
f"Pair {pair} is not available on {self.name} {self.trading_mode}. "
f"Please remove {pair} from your whitelist."
)
@ -890,7 +890,7 @@ class Exchange:
):
mm_value = margin_mode and margin_mode.value
raise OperationalException(
f"Freqtrade does not support {mm_value} {trading_mode.value} on {self.name}"
f"Freqtrade does not support {mm_value} {trading_mode} on {self.name}"
)
def get_option(self, param: str, default: Optional[Any] = None) -> Any:

View File

@ -623,7 +623,7 @@ class LocalTrade:
self.orders = []
if self.trading_mode == TradingMode.MARGIN and self.interest_rate is None:
raise OperationalException(
f"{self.trading_mode.value} trading requires param interest_rate on trades"
f"{self.trading_mode} trading requires param interest_rate on trades"
)
def __repr__(self):
@ -1079,7 +1079,7 @@ class LocalTrade:
return float(self._calc_base_close(amount1, rate, self.fee_close)) + funding_fees
else:
raise OperationalException(
f"{self.trading_mode.value} trading is not yet available using freqtrade"
f"{self.trading_mode} trading is not yet available using freqtrade"
)
def calc_profit(