mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 05:50:36 +00:00
refactor: add generic "migrate" method
This commit is contained in:
@@ -63,7 +63,7 @@ from freqtrade.rpc.rpc_types import (
|
|||||||
from freqtrade.strategy.interface import IStrategy
|
from freqtrade.strategy.interface import IStrategy
|
||||||
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
|
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
|
||||||
from freqtrade.util import FtPrecise, MeasureTime, PeriodicCache, dt_from_ts, dt_now
|
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
|
from freqtrade.wallets import Wallets
|
||||||
|
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
Called on startup and after reloading the bot - triggers notifications and
|
Called on startup and after reloading the bot - triggers notifications and
|
||||||
performs startup tasks
|
performs startup tasks
|
||||||
"""
|
"""
|
||||||
migrate_binance_futures_names(self.config)
|
migrate_live_content(self.config, self.exchange)
|
||||||
set_startup_time()
|
set_startup_time()
|
||||||
|
|
||||||
self.rpc.startup_messages(self.config, self.pairlists, self.protections)
|
self.rpc.startup_messages(self.config, self.pairlists, self.protections)
|
||||||
|
|||||||
@@ -1,12 +1,23 @@
|
|||||||
from freqtrade.exchange import Exchange
|
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
|
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 persisted data from old formats to new formats
|
||||||
"""
|
"""
|
||||||
migrate_binance_futures_data(config)
|
migrate_binance_futures_data(config)
|
||||||
|
|
||||||
migrate_funding_fee_timeframe(config, exchange)
|
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)
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def migrate_binance_futures_names(config: Config):
|
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 (
|
if not (
|
||||||
config.get("trading_mode", TradingMode.SPOT) == TradingMode.FUTURES
|
config.get("trading_mode", TradingMode.SPOT) == TradingMode.FUTURES
|
||||||
and config["exchange"]["name"] == "binance"
|
and config["exchange"]["name"] == "binance"
|
||||||
|
|||||||
Reference in New Issue
Block a user