updated instructions, README and task.toml
This commit is contained in:
@@ -2,43 +2,33 @@
|
||||
|
||||
Trading Activity Summary for a User
|
||||
|
||||
### Description (instruction.md)
|
||||
You are given access to a PostgreSQL database containing trading activity data. Your goal is to generate a JSON report that summarizes trading activity for a specific user over a specified date range.
|
||||
|
||||
│ You are given access to a PostgreSQL database that stores trading activity for multiple users and accounts. Using only the tools provided inside the
|
||||
│ container, your goal is to generate a JSON report that summarizes the trading activity for a specific user (provided via a command‑line argument or
|
||||
│ environment variable) over a date range (also provided).
|
||||
The report must be written to /app/report.json and must contain exactly these seven fields:
|
||||
|
||||
│ The report must be written to /app/report.json and must contain the following fields:
|
||||
1. user_id – identifier of the user whose activity is being summarized
|
||||
2. date_range_start – start date (inclusive) in YYYY-MM-DD format
|
||||
3. date_range_end – end date (inclusive) in YYYY-MM-DD format
|
||||
4. total_fills – count of rows in the trades table where event_type = 'fill' and exec_timestamp falls within the date range (inclusive)
|
||||
5. total_pnl – sum of the net_pnl column for all rows counted in total_fills, including only rows where completed_trade_id is not null (completed trades)
|
||||
6. symbol_quantities – object mapping each symbol to the net quantity from filled trades in the date range (positive for buys, negative for sells), summed per symbol
|
||||
7. position_mismatches – array of symbol names where the net trade quantity differs from the net quantity in the positions table for the same user and date range by more than 1 (allowing for rounding)
|
||||
|
||||
1. user_id – the identifier of the user whose activity is being summarized.
|
||||
2. date_range_start – the start date (inclusive) of the analysis, in YYYY‑MM‑DD format.
|
||||
3. date_range_end – the end date (inclusive) of the analysis, in YYYY‑MM‑DD format.
|
||||
4. total_fills – the count of rows in trades where event_type = 'fill' and the exec_timestamp falls within the date range.
|
||||
5. total_pnl – the sum of the net_pnl column (numeric) for all rows counted in total_fills. Include only rows where completed_trade_id is not null
|
||||
(i.e., completed trades).
|
||||
6. symbol_quantities – a map (object) where each key is a symbol (e.g., "AAPL") and the value is the net quantity (positive for buys, negative for
|
||||
sells) that resulted from the filled trades in the date range. Quantities should be summed per symbol.
|
||||
7. position_mismatches – an array of symbol names where the net quantity from the trades does not match the net quantity reflected in the positions
|
||||
table for the same user and date range. A mismatch exists if the absolute difference between the summed trade quantity and the net quantity in
|
||||
positions is greater than 1 (allowing for rounding). Each entry should be the symbol name.
|
||||
### Constraints
|
||||
|
||||
│ Constraints & Requirements
|
||||
│ - The report must be valid JSON (use jsonlint‑compatible syntax).
|
||||
│ - The file must be written exactly to /app/report.json; no other files are permitted for the final artifact.
|
||||
│ - You may read any tables in the schema, but you may not modify the underlying data (no INSERT/UPDATE/DELETE).
|
||||
│ - The solution must run offline (the container has no network access).
|
||||
│ - The task is considered solved when the oracle (solution/solve.sh) exits with status 0, causing the verifier to award a reward of 1.
|
||||
- The report must be valid JSON parseable by jsonlint
|
||||
- The file must be written exactly to /app/report.json; no other output files are permitted
|
||||
- You may read any tables in the schema but may not modify underlying data (no INSERT/UPDATE/DELETE)
|
||||
- The task runs offline (no network access)
|
||||
- The task is solved when solution/solve.sh exits with status 0, causing the verifier to award reward of 1
|
||||
|
||||
│ Hints
|
||||
│ - Use the exec_timestamp column (type timestamp with time zone) to filter by date range. Cast it to date for simple filtering.
|
||||
│ - The positions table contains net_qty (the net quantity for the position) and account_id; you can join on user_id → account_id to verify totals.
|
||||
│ - The trades table stores the raw trade data; the completed_trades table can be used to confirm that a trade is “completed”, but the net_pnl is
|
||||
│ already present in trades.
|
||||
│ - To compute net quantity per symbol, sum the qty values (positive for BUY, negative for SELL) for all rows that satisfy the event type and date
|
||||
│ filter.
|
||||
│ - For the mismatch check, join trades (aggregated per symbol) with positions (filtering on user_id, account_id, and the same date range). Compute the
|
||||
│ absolute difference and include symbols where it exceeds 1.
|
||||
### Key definitions
|
||||
|
||||
│ Success Criteria
|
||||
│ The verifier will load report.json, parse it, and compare the computed values against a ground‑truth generated by the oracle. If all fields match, the
|
||||
│ verifier writes a reward of 1 to /logs/verifier/reward.txt and {"reward": 1} to /logs/verifier/reward.json.
|
||||
- **Date range filter**: exec_timestamp values are filtered by casting to date and comparing inclusive boundaries
|
||||
- **Completed trade**: a trade row with completed_trade_id not null
|
||||
- **Net quantity**: sum of qty values (BUY = positive, SELL = negative) per symbol
|
||||
- **Position mismatch**: |summed trade qty per symbol − positions.net_qty per symbol| > 1
|
||||
|
||||
### Success criteria
|
||||
|
||||
The verifier will load /app/report.json, parse it, and compare all fields against a ground-truth generated by the oracle. If all fields match, the verifier writes reward of 1 to /logs/verifier/reward.txt and {"reward": 1} to /logs/verifier/reward.json.
|
||||
Reference in New Issue
Block a user