feat: return "capture_start_ts" as part of API response

This commit is contained in:
Matthias
2025-06-15 07:41:41 +02:00
parent 6c24925522
commit 15be0510fc
3 changed files with 9 additions and 4 deletions
+3
View File
@@ -683,6 +683,9 @@ class WalletsSummary(BaseModel):
columns: list[str]
length: int
data: list[list[Any]]
# start date of the effectively captured data
# Before this date, it's based on a reconstructed wallet history
capture_start_ts: int | None = None
class MarketRequest(ExchangeModePayloadMixin, BaseModel):
+2 -1
View File
@@ -111,12 +111,13 @@ def stats(rpc: RPC = Depends(get_rpc)):
tags=["info"],
)
def api_get_wallet_history(rpc: RPC = Depends(get_rpc)):
results = rpc._rpc_get_historic_balance()
results, capture_date_ts = rpc._rpc_get_historic_balance()
return {
"columns": results.columns.tolist(),
"data": results.values.tolist(),
"length": len(results),
"capture_start_ts": capture_date_ts,
}
+4 -3
View File
@@ -785,10 +785,10 @@ class RPC:
"bot_start_date": format_date(bot_start),
}
def _rpc_get_historic_balance(self) -> DataFrame:
def _rpc_get_historic_balance(self) -> tuple[DataFrame, int]:
"""
Returns the historic balance of the bot
:return: DataFrame with the balance history
: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"]
@@ -796,7 +796,8 @@ class RPC:
results.loc[:, "__date_ts"] = results.loc[:, "date"].astype("int64") // 1000 // 1000
results = results.groupby(["date", "__date_ts"]).agg({"total": "sum"}).reset_index()
return results
hist = KeyValueStore.get_datetime_value("wallet_history_migration_date", None)
return results, dt_ts_def(hist, 0)
def __balance_get_est_stake(
self, coin: str, stake_currency: str, amount: float, balance: Wallet