feat: prevent duplicate wallet migrations
This commit is contained in:
@@ -22,6 +22,7 @@ KeyStoreKeys = Literal[
|
||||
"bot_start_time",
|
||||
"startup_time",
|
||||
"binance_migration",
|
||||
"wallet_history_migration",
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from freqtrade.constants import Config
|
||||
@@ -11,10 +13,22 @@ from freqtrade.persistence.wallet_history import WalletBalance
|
||||
from freqtrade.util.datetime_helpers import dt_now, dt_ts
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate_wallet_history(config: Config, exchange: Exchange):
|
||||
if not exchange.get_option("ohlcv_has_history", True):
|
||||
# we can't fill up wallet history without ohlcv history
|
||||
return
|
||||
if KeyValueStore.get_int_value("wallet_history_migration"):
|
||||
logger.debug("Wallet history migration already completed.")
|
||||
return
|
||||
|
||||
_migrate_wallet_history(config, exchange)
|
||||
KeyValueStore.store_value("wallet_history_migration", 1)
|
||||
|
||||
|
||||
def _migrate_wallet_history(config: Config, exchange: Exchange):
|
||||
trade_df = trade_list_to_dataframe(Trade.get_trades_proxy())
|
||||
if trade_df.empty:
|
||||
# no trades, nothing to do
|
||||
|
||||
Reference in New Issue
Block a user