The program reads the input line by line from stdin.
Each line is exactly one of the following message types:
- Trade print — a trade that occurred on the exchange
print <timestamp> <security> <quantity> <price>
- Volume check — request to report the total traded quantity of a security in the preceding minute, and its latest price
volume-check <timestamp> <security>
- Order — request to trade shares subject to participation limits
order <timestamp> <security> <client> <goal> <participation_rate>
Fields (space-delimited):
timestamp: seconds since market open (non-negative integer). Timestamps are monotonically non-decreasing.security: security symbol (alphabetic string).quantity: number of shares traded (positive integer).price: trade price (positive integer).client: client name (alphabetic string).goal: total number of shares to trade (positive integer).participation_rate: max percent of the security’s trailing 1-minute volume (computed without this order) that this order may constitute (positive integer).
An order is:
- filled when its
goalquantity has been traded, - active from its timestamp until it is filled or expires after one minute (T to T+60, exclusive of T+60),
- at most one active order per (client, security) at any time.
Output
For each volume-check for security S at time T, emit exactly one line:
traded-volume T S <volume> <price>
Where:
<volume>is the sum of quantities in allprintmessages whose timestamps are in (T-60, T]. If none, output0.<price>is the price of the most recent print forSat or beforeT. If none, output0.
A volume-check response must be printed immediately before reading the next input line.
For each order on security S at time T, emit a sequence of prints you execute:
print T' S <quantity> <price>
Subject to all constraints below (maximize filled shares as soon as possible):
- Monotone timestamps: your emitted timestamps must not go backwards relative to observed exchange activity; in particular,
T' ≥ T. - Expiry: all your prints must satisfy
T' < T + 60. - Participation limit: for the trailing minute ending at each T’, \frac{\text{(your emitted volume within that minute)}}{\text{(all *other* trades’volume within that minute)}} \le \text{participation_rate \%} The denominator uses observed exchange prints only (i.e., excludes the order you are executing).
- Positive integer quantities: each emitted print has positive integer
<quantity>, and the sum over the sequence must not exceedgoal. - Price: each emitted print must use the latest observed price of
S(from the most recent exchangeprintat or beforeT'). If no price exists, you cannot print.
Notes:
- As earlier exchange prints roll out of the 60-second window, your instantaneous participation ratio may appear to spike; that’s okay — the limit is evaluated at emission time.
- Always trade as much as possible as soon as possible while respecting the constraints above.
Brief Summary
Build a line-by-line exchange simulator with three messages: print (market trades), volume-check (report trailing-minute volume and latest price), and order (client algo with a 60-second life and a participation-rate cap vs other trades).
On each volume check, immediately output total volume over (T-60, T] and the latest price; on each order, emit your own print executions as early and as large as possible while keeping timestamps monotone, staying before T+60, respecting the participation cap computed against external prints only, using the latest observed price, and keeping integer quantities with total ≤ goal.
The VOprep team has long accompanied candidates through various major company OAs and VOs, including Voleon, Google, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for Tiktok or similar engineering-focused companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.