INNER CODE UNIT · Python

get_equity_curve

GifariKemal/xaubot-ai · web-dashboard/api/main.py:239

async def get_equity_curve(
    start_date: Optional[str] = None,
    end_date: Optional[str] = None,
):
    """Get cumulative equity curve from closed trades."""
    if not db.is_available():
        return {"points": []}

    where = ["closed_at IS NOT NULL"]
    params = []
    date_clauses, date_params = _date_filter("closed_at", start_date, end_date)
    where.extend(date_clauses)
    params.extend(date_params)
    where_sql = " AND ".join(where)

    rows = db.query(
        f"""SELECT closed_at, profit_usd,
                   SUM(profit_usd) OVER (ORDER BY closed_at) as cumulative

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…