chore: remove edge from freqtradebot

This commit is contained in:
Matthias
2025-06-10 06:53:07 +02:00
parent ca32cb9e61
commit 340cad3707
2 changed files with 13 additions and 47 deletions
+8 -34
View File
@@ -18,7 +18,6 @@ from freqtrade.configuration import validate_config_consistency
from freqtrade.constants import BuySell, Config, EntryExecuteMode, ExchangeConfig, LongShort from freqtrade.constants import BuySell, Config, EntryExecuteMode, ExchangeConfig, LongShort
from freqtrade.data.converter import order_book_to_dataframe from freqtrade.data.converter import order_book_to_dataframe
from freqtrade.data.dataprovider import DataProvider from freqtrade.data.dataprovider import DataProvider
from freqtrade.edge import Edge
from freqtrade.enums import ( from freqtrade.enums import (
ExitCheckTuple, ExitCheckTuple,
ExitType, ExitType,
@@ -131,13 +130,6 @@ class FreqtradeBot(LoggingMixin):
# Attach Wallets to strategy instance # Attach Wallets to strategy instance
self.strategy.wallets = self.wallets self.strategy.wallets = self.wallets
# Initializing Edge only if enabled
self.edge = (
Edge(self.config, self.exchange, self.strategy)
if self.config.get("edge", {}).get("enabled", False)
else None
)
# Init ExternalMessageConsumer if enabled # Init ExternalMessageConsumer if enabled
self.emc = ( self.emc = (
ExternalMessageConsumer(self.config, self.dataprovider) ExternalMessageConsumer(self.config, self.dataprovider)
@@ -242,9 +234,8 @@ class FreqtradeBot(LoggingMixin):
self.rpc.startup_messages(self.config, self.pairlists, self.protections) self.rpc.startup_messages(self.config, self.pairlists, self.protections)
# Update older trades with precision and precision mode # Update older trades with precision and precision mode
self.startup_backpopulate_precision() self.startup_backpopulate_precision()
if not self.edge: # Adjust stoploss if it was changed
# Adjust stoploss if it was changed Trade.stoploss_reinitialization(self.strategy.stoploss)
Trade.stoploss_reinitialization(self.strategy.stoploss)
# Only update open orders on startup # Only update open orders on startup
# This will update the database after the initial migration # This will update the database after the initial migration
@@ -335,7 +326,7 @@ class FreqtradeBot(LoggingMixin):
def _refresh_active_whitelist(self, trades: list[Trade] | None = None) -> list[str]: def _refresh_active_whitelist(self, trades: list[Trade] | None = None) -> list[str]:
""" """
Refresh active whitelist from pairlist or edge and extend it with Refresh active whitelist from pairlist and extend it with
pairs that have open trades. pairs that have open trades.
""" """
# Refresh whitelist # Refresh whitelist
@@ -343,11 +334,6 @@ class FreqtradeBot(LoggingMixin):
self.pairlists.refresh_pairlist() self.pairlists.refresh_pairlist()
_whitelist = self.pairlists.whitelist _whitelist = self.pairlists.whitelist
# Calculating Edge positioning
if self.edge:
self.edge.calculate(_whitelist)
_whitelist = self.edge.adjust(_whitelist)
if trades: if trades:
# Extend active-pair whitelist with pairs of open trades # Extend active-pair whitelist with pairs of open trades
# It ensures that candle (OHLCV) data are downloaded for open trades as well # It ensures that candle (OHLCV) data are downloaded for open trades as well
@@ -701,9 +687,7 @@ class FreqtradeBot(LoggingMixin):
else: else:
self.log_once(f"Pair {pair} is currently locked.", logger.info) self.log_once(f"Pair {pair} is currently locked.", logger.info)
return False return False
stake_amount = self.wallets.get_trade_stake_amount( stake_amount = self.wallets.get_trade_stake_amount(pair, self.config["max_open_trades"])
pair, self.config["max_open_trades"], self.edge
)
bid_check_dom = self.config.get("entry_pricing", {}).get("check_depth_of_market", {}) bid_check_dom = self.config.get("entry_pricing", {}).get("check_depth_of_market", {})
if (bid_check_dom.get("enabled", False)) and ( if (bid_check_dom.get("enabled", False)) and (
@@ -1042,7 +1026,7 @@ class FreqtradeBot(LoggingMixin):
precision_mode_price=self.exchange.precision_mode_price, precision_mode_price=self.exchange.precision_mode_price,
contract_size=self.exchange.get_contract_size(pair), contract_size=self.exchange.get_contract_size(pair),
) )
stoploss = self.strategy.stoploss if not self.edge else self.edge.get_stoploss(pair) stoploss = self.strategy.stoploss
trade.adjust_stop_loss(trade.open_rate, stoploss, initial=True) trade.adjust_stop_loss(trade.open_rate, stoploss, initial=True)
else: else:
@@ -1170,7 +1154,7 @@ class FreqtradeBot(LoggingMixin):
pair, enter_limit_requested, leverage pair, enter_limit_requested, leverage
) )
if not self.edge and trade is None: if trade is None:
stake_available = self.wallets.get_available_stake_amount() stake_available = self.wallets.get_available_stake_amount()
stake_amount = strategy_safe_wrapper( stake_amount = strategy_safe_wrapper(
self.strategy.custom_stake_amount, default_retval=stake_amount self.strategy.custom_stake_amount, default_retval=stake_amount
@@ -1382,7 +1366,7 @@ class FreqtradeBot(LoggingMixin):
datetime.now(timezone.utc), datetime.now(timezone.utc),
enter=enter, enter=enter,
exit_=exit_, exit_=exit_,
force_stoploss=self.edge.get_stoploss(trade.pair) if self.edge else 0, force_stoploss=0,
) )
for should_exit in exits: for should_exit in exits:
if should_exit.exit_flag: if should_exit.exit_flag:
@@ -1487,13 +1471,6 @@ class FreqtradeBot(LoggingMixin):
# If enter order is fulfilled but there is no stoploss, we add a stoploss on exchange # If enter order is fulfilled but there is no stoploss, we add a stoploss on exchange
if len(stoploss_orders) == 0: if len(stoploss_orders) == 0:
stop_price = trade.stoploss_or_liquidation stop_price = trade.stoploss_or_liquidation
if self.edge:
stoploss = self.edge.get_stoploss(pair=trade.pair)
stop_price = (
trade.open_rate * (1 - stoploss)
if trade.is_short
else trade.open_rate * (1 + stoploss)
)
if self.create_stoploss_order(trade=trade, stop_price=stop_price): if self.create_stoploss_order(trade=trade, stop_price=stop_price):
# The above will return False if the placement failed and the trade was force-sold. # The above will return False if the placement failed and the trade was force-sold.
@@ -2370,10 +2347,7 @@ class FreqtradeBot(LoggingMixin):
if send_msg: if send_msg:
# Don't cancel stoploss in recovery modes immediately # Don't cancel stoploss in recovery modes immediately
trade = self.cancel_stoploss_on_exchange(trade) trade = self.cancel_stoploss_on_exchange(trade)
if not self.edge: trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True)
# TODO: should shorting/leverage be supported by Edge,
# then this will need to be fixed.
trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True)
if ( if (
order.ft_order_side == trade.entry_side order.ft_order_side == trade.entry_side
or (trade.amount > 0 and trade.is_open) or (trade.amount > 0 and trade.is_open)
+5 -13
View File
@@ -352,7 +352,7 @@ class Wallets:
return max(stake_amount, 0) return max(stake_amount, 0)
def get_trade_stake_amount( def get_trade_stake_amount(
self, pair: str, max_open_trades: IntOrInf, edge=None, update: bool = True self, pair: str, max_open_trades: IntOrInf, update: bool = True
) -> float: ) -> float:
""" """
Calculate stake amount for the trade Calculate stake amount for the trade
@@ -366,19 +366,11 @@ class Wallets:
val_tied_up = Trade.total_open_trades_stakes() val_tied_up = Trade.total_open_trades_stakes()
available_amount = self.get_available_stake_amount() available_amount = self.get_available_stake_amount()
if edge: stake_amount = self._config["stake_amount"]
stake_amount = edge.stake_amount( if stake_amount == UNLIMITED_STAKE_AMOUNT:
pair, stake_amount = self._calculate_unlimited_stake_amount(
self.get_free(self._stake_currency), available_amount, val_tied_up, max_open_trades
self.get_total(self._stake_currency),
val_tied_up,
) )
else:
stake_amount = self._config["stake_amount"]
if stake_amount == UNLIMITED_STAKE_AMOUNT:
stake_amount = self._calculate_unlimited_stake_amount(
available_amount, val_tied_up, max_open_trades
)
return self._check_available_stake_amount(stake_amount, available_amount) return self._check_available_stake_amount(stake_amount, available_amount)