Files
project-work/sources/instruction.md

2.2 KiB
Raw Permalink Blame History

Task Title

Trading Activity Summary for a User

You are given access to a PostgreSQL database, exported to csv and sql files, containing trading activity data. The goal is to generate a JSON report that summarizes trading activity for a specific user over a specified date range.

Write the report to /app/report.json. It must contain exactly these seven 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)

Constraints

  • The report must be valid JSON parseable by jsonlint
  • Write the file to /app/report.json; no other output files are permitted
  • Read any tables in the schema but DO 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

Key definitions

  • 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 loads /app/report.json, parses it, and compares 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.