chore: minor improvements

This commit is contained in:
Matthias
2025-12-27 12:25:01 +01:00
parent 921cb4dad8
commit cbd1a4c060
3 changed files with 4 additions and 3 deletions
@@ -103,5 +103,6 @@ def balance_distribution_over_time(
df.loc[filled_at:end_date, trade.pair] -= real_amount df.loc[filled_at:end_date, trade.pair] -= real_amount
df.loc[filled_at:, stake_currency] += stake - fee df.loc[filled_at:, stake_currency] += stake - fee
# Round to avoid floating point issues
df = df.round(14) df = df.round(14)
return df return df
@@ -36,7 +36,7 @@ def convert_bt_wallet_collection(wallet_captures: list[tuple]) -> DataFrame:
(date, currency, price, balance). (date, currency, price, balance).
""" """
if len(wallet_captures) == 0: if len(wallet_captures) == 0:
return [] return DataFrame()
return DataFrame( return DataFrame(
wallet_captures, wallet_captures,
columns=["date", "currency", "price", "balance"], columns=["date", "currency", "price", "balance"],
@@ -109,7 +109,7 @@ def _migrate_wallet_history(config: Config, exchange: Exchange, starting_balance
WalletHistory.session.bulk_save_objects(wallet_entries) WalletHistory.session.bulk_save_objects(wallet_entries)
WalletHistory.session.commit() WalletHistory.session.commit()
KeyValueStore.store_value("wallet_history_migration_date", dt_now()) KeyValueStore.store_value("wallet_history_migration_date", dt_now())
print(f"Successfully created {len(wallet_entries)} wallet balance records") logger.info(f"Successfully created {len(wallet_entries)} wallet balance records")
except Exception as e: except Exception as e:
WalletHistory.session.rollback() WalletHistory.session.rollback()
print(f"Error saving wallet balance records: {e}") logger.error(f"Error saving wallet balance records: {e}")