feat: return "capture_start_ts" as part of API response
This commit is contained in:
@@ -683,6 +683,9 @@ class WalletsSummary(BaseModel):
|
|||||||
columns: list[str]
|
columns: list[str]
|
||||||
length: int
|
length: int
|
||||||
data: list[list[Any]]
|
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):
|
class MarketRequest(ExchangeModePayloadMixin, BaseModel):
|
||||||
|
|||||||
@@ -111,12 +111,13 @@ def stats(rpc: RPC = Depends(get_rpc)):
|
|||||||
tags=["info"],
|
tags=["info"],
|
||||||
)
|
)
|
||||||
def api_get_wallet_history(rpc: RPC = Depends(get_rpc)):
|
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 {
|
return {
|
||||||
"columns": results.columns.tolist(),
|
"columns": results.columns.tolist(),
|
||||||
"data": results.values.tolist(),
|
"data": results.values.tolist(),
|
||||||
"length": len(results),
|
"length": len(results),
|
||||||
|
"capture_start_ts": capture_date_ts,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -785,10 +785,10 @@ class RPC:
|
|||||||
"bot_start_date": format_date(bot_start),
|
"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
|
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 = 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"]
|
||||||
@@ -796,7 +796,8 @@ class RPC:
|
|||||||
results.loc[:, "__date_ts"] = results.loc[:, "date"].astype("int64") // 1000 // 1000
|
results.loc[:, "__date_ts"] = results.loc[:, "date"].astype("int64") // 1000 // 1000
|
||||||
|
|
||||||
results = results.groupby(["date", "__date_ts"]).agg({"total": "sum"}).reset_index()
|
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(
|
def __balance_get_est_stake(
|
||||||
self, coin: str, stake_currency: str, amount: float, balance: Wallet
|
self, coin: str, stake_currency: str, amount: float, balance: Wallet
|
||||||
|
|||||||
Reference in New Issue
Block a user