feat: use proper starting balance

This commit is contained in:
Matthias
2025-09-14 11:42:16 +02:00
parent b5f31bf82d
commit 9ddabbd849
3 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -237,7 +237,7 @@ class FreqtradeBot(LoggingMixin):
Called on startup and after reloading the bot - triggers notifications and
performs startup tasks
"""
migrate_live_content(self.config, self.exchange)
migrate_live_content(self.config, self.exchange, self.wallets.get_starting_balance())
set_startup_time()
self.rpc.startup_messages(self.config, self.pairlists, self.protections)
+4 -3
View File
@@ -1,9 +1,10 @@
from freqtrade.constants import Config
from freqtrade.exchange import Exchange
from freqtrade.util.migrations.funding_rate_mig import migrate_funding_fee_timeframe
from freqtrade.util.migrations.migrate_wallet_history import migrate_wallet_history
def migrate_data(config, exchange: Exchange | None = None) -> None:
def migrate_data(config: Config, exchange: Exchange | None = None) -> None:
"""
Migrate persisted data from old formats to new formats
"""
@@ -11,9 +12,9 @@ def migrate_data(config, exchange: Exchange | None = None) -> None:
migrate_funding_fee_timeframe(config, exchange)
def migrate_live_content(config, exchange: Exchange) -> None:
def migrate_live_content(config: Config, exchange: Exchange, starting_balance: float) -> None:
"""
Migrate database content from old formats to new formats
Used for dry/live mode.
"""
migrate_wallet_history(config, exchange)
migrate_wallet_history(config, exchange, starting_balance)
@@ -16,7 +16,7 @@ from freqtrade.util.datetime_helpers import dt_now, dt_ts
logger = logging.getLogger(__name__)
def migrate_wallet_history(config: Config, exchange: Exchange):
def migrate_wallet_history(config: Config, exchange: Exchange, starting_balance: float):
if not exchange.get_option("ohlcv_has_history", True):
# we can't fill up wallet history without ohlcv history
return
@@ -24,18 +24,16 @@ def migrate_wallet_history(config: Config, exchange: Exchange):
logger.debug("Wallet history migration already completed.")
return
logger.info("Starting wallet history migration...")
_migrate_wallet_history(config, exchange)
_migrate_wallet_history(config, exchange, starting_balance)
logger.info("Wallet history migration completed.")
KeyValueStore.store_value("wallet_history_migration", 1)
def _migrate_wallet_history(config: Config, exchange: Exchange):
def _migrate_wallet_history(config: Config, exchange: Exchange, starting_balance: float):
trade_df = trade_list_to_dataframe(Trade.get_trades_proxy())
if trade_df.empty:
# no trades, nothing to do
return
# TODO: use a proper starting balance.
starting_balance = 1000 # wallets.get_starting_balance()
pairlist = list(trade_df["pair"].unique())
timeframe = "1d"
stake_currency = config["stake_currency"]