mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
refactor: move default trading mode determination to exchange
This commit is contained in:
@@ -18,10 +18,7 @@ from freqtrade.constants import Config
|
|||||||
from freqtrade.enums import (
|
from freqtrade.enums import (
|
||||||
NON_UTIL_MODES,
|
NON_UTIL_MODES,
|
||||||
TRADE_MODES,
|
TRADE_MODES,
|
||||||
CandleType,
|
|
||||||
MarginMode,
|
|
||||||
RunMode,
|
RunMode,
|
||||||
TradingMode,
|
|
||||||
)
|
)
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.loggers import setup_logging
|
from freqtrade.loggers import setup_logging
|
||||||
@@ -397,11 +394,6 @@ class Configuration:
|
|||||||
self._args_to_config(
|
self._args_to_config(
|
||||||
config, argname="trading_mode", logstring="Detected --trading-mode: {}"
|
config, argname="trading_mode", logstring="Detected --trading-mode: {}"
|
||||||
)
|
)
|
||||||
config["candle_type_def"] = CandleType.get_default(
|
|
||||||
config.get("trading_mode", "spot") or "spot"
|
|
||||||
)
|
|
||||||
config["trading_mode"] = TradingMode(config.get("trading_mode", "spot") or "spot")
|
|
||||||
config["margin_mode"] = MarginMode(config.get("margin_mode", "") or "")
|
|
||||||
self._args_to_config(
|
self._args_to_config(
|
||||||
config, argname="candle_types", logstring="Detected --candle-types: {}"
|
config, argname="candle_types", logstring="Detected --candle-types: {}"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -202,14 +202,17 @@ class Exchange:
|
|||||||
self._config.update(config)
|
self._config.update(config)
|
||||||
|
|
||||||
# Leverage properties
|
# Leverage properties
|
||||||
self.trading_mode: TradingMode = config.get(
|
self.trading_mode: TradingMode = TradingMode(
|
||||||
"trading_mode", self._supported_trading_mode_margin_pairs[0][0]
|
config.get("trading_mode", self._supported_trading_mode_margin_pairs[0][0])
|
||||||
)
|
)
|
||||||
self.margin_mode: MarginMode = (
|
self.margin_mode: MarginMode = MarginMode(
|
||||||
MarginMode(config.get("margin_mode"))
|
MarginMode(config.get("margin_mode"))
|
||||||
if config.get("margin_mode")
|
if config.get("margin_mode")
|
||||||
else self._supported_trading_mode_margin_pairs[0][1]
|
else self._supported_trading_mode_margin_pairs[0][1]
|
||||||
)
|
)
|
||||||
|
config["trading_mode"] = self.trading_mode
|
||||||
|
config["margin_mode"] = self.margin_mode
|
||||||
|
config["candle_type_def"] = CandleType.get_default(self.trading_mode)
|
||||||
self.liquidation_buffer = config.get("liquidation_buffer", 0.05)
|
self.liquidation_buffer = config.get("liquidation_buffer", 0.05)
|
||||||
|
|
||||||
exchange_conf: ExchangeConfig = exchange_config if exchange_config else config["exchange"]
|
exchange_conf: ExchangeConfig = exchange_config if exchange_config else config["exchange"]
|
||||||
|
|||||||
Reference in New Issue
Block a user