q.Quantitative TradingEnglish course · Lesson 23 of 24Course home

Lesson 23 / Paper Trading and Order States

If an order submission times out, should you send it again?

Distinguish targets, orders, and fills. Replay timeouts, partial fills, and duplicate reports to see why a running service still needs account reconciliation.

What you will learn

  1. Recover actual state from order and fill reports
  2. Prevent duplicate orders and duplicate ledger entries
  3. Distinguish offline replay from forward paper trading

Allow about 30–45 minutes. The exercises use fictional data. The page checks structured answers in your browser. Export your work before refreshing.

Start with the concepts ↓
Concept 01

Freeze the version and environment

Record the versions of the rules, inputs, data processing, and costs. Offline replay delivers existing data one event at a time. Forward paper trading waits for new data to arrive in real time. Each exercise can reveal different issues.

This page is an offline order-state exercise with no connected account or background process. Forward paper trading requires a calendar and records of outages, data availability, and events.

Concept 02

A timeout leaves the order state unknown

The target is to buy 4 units. Submission times out, so you have no definitive response. A status query shows 1 filled and 3 outstanding. Cash falls from 1,000 to 900, and the account holds 1 unit.

A second full order for 4 could leave you with 8 if both orders eventually fill. Confirm the original order's state before waiting or canceling the remainder under the predefined rule.

Concept 03

Identify orders and fills

If the same fill report arrives again, apply no additional cash or position change. In this exercise, each fill ID is recorded once. A different fill ID identifies a separate fill.

After a restart, reconstruct state from orders, fills, and account records. The observed position takes precedence over an assumed flat position in memory. The unfilled remainder is still part of the existing order.

Concept 04

Reconcile before resuming

When the state is unknown, stop adding exposure. Follow predefined rules for existing positions and open orders. Before resuming, confirm order states, holdings, cash, and the cause of the issue.

Reconcile one trade each day from signal through order and fill. Paper trading can test logging and state management. A simplified fill model leaves actual queueing, market impact, and liquidity to be verified. Record explicitly if forward paper trading has yet to begin.

Experiment · Predict the outcome, then change one input

Paper Trading and Order States experiment

Follow this sequence: submit and time out, query, receive a duplicate fill report, then cancel the remainder. Predict whether the duplicate will change cash. Try sending another order while the original status is unknown.

The fictional order starts with 1,000 in cash, a target of 4 units at 100 each, and no fees. The status query returns a unique fill F1 for 1 unit, with 3 still outstanding. The lab replays preset events offline.

The buttons replay preset events. A canceled remainder leaves any confirmed fills in place.

Practice with fixed inputs

Try the calculations

Use the values in each question. Enter amounts and percentages in the requested units, including a minus sign where needed.

Knowledge check

Explain your reasoning

1. Can a request timeout prove that the order was never submitted?
2. The target is 4, with 1 filled and 3 outstanding. What is the current holding?
3. What should you do if the same fill ID arrives again?
4. Does passing this replay establish that a week of forward paper trading is complete?

Record your work

Lesson work

Save the Stage 6 event log and recovery notes.

Recover the order state

You start with 1,200 in cash and submit a buy order for 5 units at 100 each with no fee. The request times out. A query shows that order O2 filled 2 units, with 3 remaining. A duplicate execution report F2 then arrives. Cancellation of the remainder is confirmed, and there are no other fills.

Complete the questions below before trying the optional writing exercise. Use the fixed inputs here, even if you changed the experiment above. Enter numbers in the units shown and keep at least two decimal places where needed. Follow the specified precision for tables. You can check one answer at a time or all answers together.

1. Cash after the first status query confirms the fill
yuan
Reference answer (try the question first)
2. Actual holdings after the first status query confirms the fill
units
Reference answer (try the question first)
3. Cash after receiving the duplicate F2 execution report
yuan
Reference answer (try the question first)
4. Quantity still working after the remainder is canceled
units
Reference answer (try the question first)
5. After the timeout, should you immediately submit a new order for all 5 units?
Reference answer (try the question first)

Save your homework to export these results. Check again after changing an answer. Optional writing and self-assessment are ungraded. Save your work before refreshing.

Optional writing (ungraded)

Writing guidance and self-review

Record the inputs, rules, results and open questions in each field. You can cite the earlier calculations and experiments as fictional examples. Tie each conclusion to specific data or events.

Use the checklist to review your own writing. Use evidence from the study to evaluate the strategy.

Save the experiment, the run log, your first and current checks, written work and self-review. Export before refreshing or closing the page.