# routines/reports/daily_performance.py
async def generate_daily_report(agent_id: str):
"""Generate daily performance report for an agent."""
from datetime import datetime, timedelta
cutoff = datetime.utcnow() - timedelta(days=1)
executors = await get_executors(controller_id=agent_id, since=cutoff)
return {
"agent_id": agent_id,
"period": "24h",
"generated_at": datetime.utcnow().isoformat(),
"summary": {
"total_executors": len(executors),
"win_rate": calculate_win_rate(executors),
"net_pnl_quote": sum(e.net_pnl_quote for e in executors),
"volume_quote": sum(e.volume_quote for e in executors),
}
}