mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
feat: properly parse marginmode on startup
This commit is contained in:
parent
f95cc960e1
commit
704e32b0dc
|
@ -15,7 +15,14 @@ from freqtrade.configuration.directory_operations import create_datadir, create_
|
||||||
from freqtrade.configuration.environment_vars import enironment_vars_to_dict
|
from freqtrade.configuration.environment_vars import enironment_vars_to_dict
|
||||||
from freqtrade.configuration.load_config import load_file, load_from_files
|
from freqtrade.configuration.load_config import load_file, load_from_files
|
||||||
from freqtrade.constants import Config
|
from freqtrade.constants import Config
|
||||||
from freqtrade.enums import NON_UTIL_MODES, TRADE_MODES, CandleType, RunMode, TradingMode
|
from freqtrade.enums import (
|
||||||
|
NON_UTIL_MODES,
|
||||||
|
TRADE_MODES,
|
||||||
|
CandleType,
|
||||||
|
MarginMode,
|
||||||
|
RunMode,
|
||||||
|
TradingMode,
|
||||||
|
)
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.loggers import setup_logging
|
from freqtrade.loggers import setup_logging
|
||||||
from freqtrade.misc import deep_merge_dicts, parse_db_uri_for_logging
|
from freqtrade.misc import deep_merge_dicts, parse_db_uri_for_logging
|
||||||
|
@ -389,6 +396,7 @@ class Configuration:
|
||||||
config.get("trading_mode", "spot") or "spot"
|
config.get("trading_mode", "spot") or "spot"
|
||||||
)
|
)
|
||||||
config["trading_mode"] = TradingMode(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: {}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,6 +22,7 @@ from freqtrade.edge import Edge
|
||||||
from freqtrade.enums import (
|
from freqtrade.enums import (
|
||||||
ExitCheckTuple,
|
ExitCheckTuple,
|
||||||
ExitType,
|
ExitType,
|
||||||
|
MarginMode,
|
||||||
RPCMessageType,
|
RPCMessageType,
|
||||||
SignalDirection,
|
SignalDirection,
|
||||||
State,
|
State,
|
||||||
|
@ -108,6 +109,7 @@ class FreqtradeBot(LoggingMixin):
|
||||||
PairLocks.timeframe = self.config["timeframe"]
|
PairLocks.timeframe = self.config["timeframe"]
|
||||||
|
|
||||||
self.trading_mode: TradingMode = self.config.get("trading_mode", TradingMode.SPOT)
|
self.trading_mode: TradingMode = self.config.get("trading_mode", TradingMode.SPOT)
|
||||||
|
self.margin_mode: MarginMode = self.config.get("margin_mode", MarginMode.NONE)
|
||||||
self.last_process: Optional[datetime] = None
|
self.last_process: Optional[datetime] = None
|
||||||
|
|
||||||
# RPC runs in separate threads, can start handling external commands just after
|
# RPC runs in separate threads, can start handling external commands just after
|
||||||
|
@ -2216,7 +2218,11 @@ class FreqtradeBot(LoggingMixin):
|
||||||
# TODO: should shorting/leverage be supported by Edge,
|
# TODO: should shorting/leverage be supported by Edge,
|
||||||
# then this will need to be fixed.
|
# then this will need to be fixed.
|
||||||
trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True)
|
trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True)
|
||||||
if order.ft_order_side == trade.entry_side or (trade.amount > 0 and trade.is_open):
|
if (
|
||||||
|
order.ft_order_side == trade.entry_side
|
||||||
|
or (trade.amount > 0 and trade.is_open)
|
||||||
|
or self.margin_mode == MarginMode.CROSS
|
||||||
|
):
|
||||||
# Must also run for partial exits
|
# Must also run for partial exits
|
||||||
# TODO: Margin will need to use interest_rate as well.
|
# TODO: Margin will need to use interest_rate as well.
|
||||||
# interest_rate = self.exchange.get_interest_rate()
|
# interest_rate = self.exchange.get_interest_rate()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user