INNER CODE UNIT · Python

offset

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

    offset = (page - 1) * limit

    count_row = db.query(f"SELECT COUNT(*) as cnt FROM trades WHERE {where_sql}", tuple(params), one=True)
    total = count_row["cnt"] if count_row else 0

    params_with_pagination = params + [limit, offset]
    trades = db.query(
        f"""SELECT id, ticket, direction, entry_price, exit_price, lot_size,
                   profit_usd, profit_pips, sl_price, tp_price,
                   opened_at, closed_at, exit_reason, confidence,
                   regime, session, duration_minutes
            FROM trades
            WHERE {where_sql}
            ORDER BY closed_at DESC
            LIMIT %s OFFSET %s""",
        tuple(params_with_pagination),
    )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…