feat: improve balance_history response

This commit is contained in:
Matthias
2026-01-06 16:07:44 +01:00
parent 61a5ab8e1c
commit 7b223f3d38
+5 -3
View File
@@ -791,13 +791,15 @@ class RPC:
:return: DataFrame with the balance history and the timestamp of the migration
"""
results = read_sql("wallet_history", con=Trade.session.bind, parse_dates=["timestamp"])
results.loc[:, "total"] = results["price"] * results["balance"]
results.loc[:, "total"] = results["price"] * results["balance"] / results["leverage"]
results = results.rename({"timestamp": "date"}, axis=1)
results.loc[:, "__date_ts"] = results.loc[:, "date"].astype("int64") // 1000 // 1000
# Exclude non-bot managed for now
results = results.loc[results["bot_managed"]]
results = results.groupby(["date", "__date_ts"]).agg({"total": "sum"}).reset_index()
results_final = results.groupby(["date", "__date_ts"]).agg({"total": "sum"}).reset_index()
hist = KeyValueStore.get_datetime_value("wallet_history_migration_date")
return results, dt_ts_def(hist, 0)
return results_final, dt_ts_def(hist, 0)
def __balance_get_est_stake(
self, coin: str, stake_currency: str, amount: float, balance: Wallet