Quant Trading for Programmers 22: Save Daily Paper-Trading Review Records
· 12 min read · Views --
Last updated on

Quant Trading for Programmers 22: Save Daily Paper-Trading Review Records

Author: Alex Xiang


Quant Trading for Programmers 22: Save Daily Paper-Trading Review Records

After adding recommendation summaries, the next step is not to connect notifications immediately. First, the system should record what happened each day.

Article 22 adds paper-trading review records. The object is not complex, but it matters: without review records, it is hard to know whether the system is repeating the same problem for several days in a row.

A ZiCode engineer recording daily paper-trading reviews

What A Review Record Saves

Chapter 22 adds app/paper_review.py.

A single review record contains the trade date, total equity, cash ratio, risk severity, recommendation action, and note.

@dataclass(frozen=True)
class PaperReviewRecord:
    trade_date: date
    total_equity: float
    cash_ratio: float
    risk_severity: str
    recommendation_action: str
    note: str

This is not the final database model. It only fixes the first version of the review vocabulary.

The review record should stay short because it works as a time-series index. Full snapshots, rebalance details, and message bodies can be stored elsewhere. In the daily list, the most important dimensions are stable ones: equity change, risk level, recommendation action, and manual notes.

Generate A Record From Run Results

The entry point is create_paper_review_record():

record = create_paper_review_record(
    snapshot,
    risk_report,
    recommendation,
    note="daily review",
)

It takes only the fields needed by the review record. It does not stuff the full snapshot and rebalance plan into the record. A review record should be stable, short, and easy to compare.

Multi-Day Summary

summarize_paper_reviews() sorts records by date, then calculates latest equity, equity change, blocker-risk days, and action counts.

These metrics can later enter weekly reports or become part of production checks.

Current Integrated Run

Continue using the same command:

uv run python -m scripts.chapter_examples paper-ops

The example generates review records for two adjacent days and summarizes action counts and equity changes:

Paper-review summary generated by the paper-ops command

In this output, both trading days trigger REDUCE_RISK, and blocker_days=2. This kind of continuous signal is more important than a single-day result. If the system asks for risk reduction for several consecutive days, either the account is truly too concentrated, or the target weights and risk thresholds need recalibration.

Chapter Update And Repository

This chapter adds:

  • app/paper_review.py.
  • Paper-trading review records and multi-day review summaries.
  • Date sorting, equity change, blocker-day counts, and recommendation-action counts.
  • An integrated paper-ops example showing two-day review summaries and consecutive blocker days.
  • Design context for review records as time-series indexes.
  • tests/test_paper_review.py, covering record generation, sorted summaries, and empty records.

Repository:

https://github.com/ax2/zi-quant-platform

Code for this chapter:

git clone https://github.com/ax2/zi-quant-platform.git
cd zi-quant-platform
git checkout chapter-22
uv sync --extra dev
uv run pytest tests/test_paper_review.py

Chapter 22 is commit 648ceb7, tagged as chapter-22.

Summary

Review records do not need to be huge.

Article 22 compresses the daily paper-trading state into stable entries, giving daily reports, weekly reports, and production checks a shared vocabulary. The next article links snapshots, risk controls, rebalancing, recommendations, daily reports, and reviews into one complete daily flow.