Lesson 17 / Day-by-Day Backtesting and the Cash Ledger
Where did each yuan on the equity curve come from?
Execute v1, the rule frozen in Lesson 13. Each day, execute yesterday's signal at the open, value the account at the close, and then set the next target. Turn five days of data into a ledger you can check line by line.
What you will learn
- Keep four kinds of timestamps in order
- Recalculate cash, holdings, and equity
- Handle unfilled orders and end-of-sample plans
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 ↓Fix the order of events
Record the data timestamp, when the data became available, the signal time, and the execution time separately. In v1, a close strictly above the three-period average that includes that close targets 10 units. Otherwise target 0. The first two days produce no signal. Trade the difference at the next open and charge a fixed fee of 1 for each completed buy or sell.
Start with 10,000 in cash. There is no borrowing, short selling, dividend income, or tax. Assume complete fills at the open, subject to canceling the entire order if cash is insufficient. These assumptions make the example easy to verify by hand.
D3 signals a trade for the next open
D1–D5 opens are 100, 101, 102, 104, 100. Closes are 100, 102, 103, 101, 100. The D3 average is 101.6667. The close of 103 exceeds it, setting a target of 10 after the close.
D3 still ends with 10,000 in cash and 0 units. At the D4 open, buy 10 units at 104 and pay a fee of 1, leaving cash of 8,959. At the D4 close, the position is worth 1,010 and account equity is 9,969.
Close the position on D5 and reconcile the round trip
The D4 closing average is 102. The close of 101 is below it, setting a target of 0. At the D5 open, sell 10 × 100 and pay a fee of 1, leaving 9,958 in cash. The price loss is 40 and the fees total 2, for a loss of 42.
The account return is −0.42%, using starting equity as the denominator. D5's closing price has no effect once the position is closed. If a signal appears at the final close with no following open, retain the unexecuted plan.
Check the benchmark and end conditions
The benchmark starts with the same cash. It buys 10 units at the D1 open, pays the buy fee, and holds through the final close. Its default ending equity is 9,999. The benchmark is a simple comparison with a different exposure period.
Value both accounts at the final close without an extra sale. To compare liquidated balances, specify the timing and costs for both in advance. The five days verify the ledger and are too short for reliable estimates of annual returns, Sharpe ratio, or an investment edge.
Day-by-Day Backtesting and the Cash Ledger experiment
Predict D4 cash and D5 ending equity. Then change the D5 open to 102. Only results that depend on the exit price should change. D3 holdings should stay the same.
Use a fictional five-day v1 ledger. Change the final open and the fixed fee. The day-by-day button controls what you see. Trades use signals that were already available.
Points follow the order in the example. See the table for exact values.
Try the calculations
Use the values in each question. Enter amounts and percentages in the requested units, including a minus sign where needed.
Explain your reasoning
Lesson work
Save the review of your day-by-day ledger for Stage 5.
Submit a five-day cash ledger
Start with 10,000. Opens are 100, 101, 102, 104 and 100. Closes are 100, 102, 103, 101 and 100. Version 1 targets 10 if the close is strictly above the three-period average including that close, and 0 otherwise. There is no signal on the first two days. Trade the difference at the next open. Each filled order costs 1. Enter cash, actual holdings and equity after each close using these fixed inputs.
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.
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.