refactor: add generic "migrate" method

This commit is contained in:
Matthias
2025-11-16 09:11:02 +01:00
parent 5c0cf8f228
commit bc516db3f8
3 changed files with 19 additions and 4 deletions

View File

@@ -63,7 +63,7 @@ from freqtrade.rpc.rpc_types import (
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
from freqtrade.util import FtPrecise, MeasureTime, PeriodicCache, dt_from_ts, dt_now
from freqtrade.util.migrations.binance_mig import migrate_binance_futures_names
from freqtrade.util.migrations import migrate_live_content
from freqtrade.wallets import Wallets
@@ -229,7 +229,7 @@ class FreqtradeBot(LoggingMixin):
Called on startup and after reloading the bot - triggers notifications and
performs startup tasks
"""
migrate_binance_futures_names(self.config)
migrate_live_content(self.config, self.exchange)
set_startup_time()
self.rpc.startup_messages(self.config, self.pairlists, self.protections)

View File

@@ -1,12 +1,23 @@
from freqtrade.exchange import Exchange
from freqtrade.util.migrations.binance_mig import migrate_binance_futures_data
from freqtrade.util.migrations.binance_mig import (
migrate_binance_futures_data,
migrate_binance_futures_names,
)
from freqtrade.util.migrations.funding_rate_mig import migrate_funding_fee_timeframe
def migrate_data(config, exchange: Exchange | None = None):
def migrate_data(config, exchange: Exchange | None = None) -> None:
"""
Migrate persisted data from old formats to new formats
"""
migrate_binance_futures_data(config)
migrate_funding_fee_timeframe(config, exchange)
def migrate_live_content(config, exchange: Exchange | None = None) -> None:
"""
Migrate database content from old formats to new formats
Used for dry/live mode.
"""
migrate_binance_futures_names(config)

View File

@@ -14,6 +14,10 @@ logger = logging.getLogger(__name__)
def migrate_binance_futures_names(config: Config):
"""
Migrate binance futures names in both database and data files.
This is needed because ccxt naming changed from "BTC/USDT" to "BTC/USDT:USDT"
"""
if not (
config.get("trading_mode", TradingMode.SPOT) == TradingMode.FUTURES
and config["exchange"]["name"] == "binance"