mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
feat: implement __str__ for marign and tradingmode enums
This commit is contained in:
parent
990dbb6c06
commit
6a4b641250
|
@ -11,3 +11,6 @@ class MarginMode(str, Enum):
|
||||||
CROSS = "cross"
|
CROSS = "cross"
|
||||||
ISOLATED = "isolated"
|
ISOLATED = "isolated"
|
||||||
NONE = ""
|
NONE = ""
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.name.lower()}"
|
||||||
|
|
|
@ -10,3 +10,6 @@ class TradingMode(str, Enum):
|
||||||
SPOT = "spot"
|
SPOT = "spot"
|
||||||
MARGIN = "margin"
|
MARGIN = "margin"
|
||||||
FUTURES = "futures"
|
FUTURES = "futures"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.name.lower()}"
|
||||||
|
|
|
@ -192,7 +192,7 @@ class Binance(Exchange):
|
||||||
if maintenance_amt is None:
|
if maintenance_amt is None:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
"Parameter maintenance_amt is required by Binance.liquidation_price"
|
"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:
|
if self.trading_mode == TradingMode.FUTURES:
|
||||||
|
|
|
@ -707,7 +707,7 @@ class Exchange:
|
||||||
# Note: ccxt has BaseCurrency/QuoteCurrency format for pairs
|
# Note: ccxt has BaseCurrency/QuoteCurrency format for pairs
|
||||||
if self.markets and pair not in self.markets:
|
if self.markets and pair not in self.markets:
|
||||||
raise OperationalException(
|
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."
|
f"Please remove {pair} from your whitelist."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -890,7 +890,7 @@ class Exchange:
|
||||||
):
|
):
|
||||||
mm_value = margin_mode and margin_mode.value
|
mm_value = margin_mode and margin_mode.value
|
||||||
raise OperationalException(
|
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:
|
def get_option(self, param: str, default: Optional[Any] = None) -> Any:
|
||||||
|
|
|
@ -623,7 +623,7 @@ class LocalTrade:
|
||||||
self.orders = []
|
self.orders = []
|
||||||
if self.trading_mode == TradingMode.MARGIN and self.interest_rate is None:
|
if self.trading_mode == TradingMode.MARGIN and self.interest_rate is None:
|
||||||
raise OperationalException(
|
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):
|
def __repr__(self):
|
||||||
|
@ -1079,7 +1079,7 @@ class LocalTrade:
|
||||||
return float(self._calc_base_close(amount1, rate, self.fee_close)) + funding_fees
|
return float(self._calc_base_close(amount1, rate, self.fee_close)) + funding_fees
|
||||||
else:
|
else:
|
||||||
raise OperationalException(
|
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(
|
def calc_profit(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user