Free lesson · Putting it all together
9 / Run the miniature system and define the promotion decision
Open interactive lessonPractice calculationsExplore labs
Start with the idea
A complete miniature system should be small enough to inspect line by line. Use it to verify interfaces and accounting; empirical research and paper execution are separate steps toward a deployable strategy.
Symbols, units & horizon
- E_start,E_end: marked account equity in dollars at period boundaries
- F_external: net external deposits minus withdrawals over the example interval
- Π_net: investment P&L in dollars
- synthetic example: starts/ends flat, no external flows, no cash interest
- equation is a cash reconciliation identity, not a return estimator for complex flow timing
When and why to use this
Use the miniature pipeline as a reproducible integration exercise and a reference for a larger research or paper-trading implementation.
The Python example below joins a trailing feature, an assumed positive-edge gate, a fixed estimated volatility, risk sizing, next-open entry, adverse exit slippage, fees and a cash ledger. It trades one session at a time and is flat afterward. The supplied three bars and parameters are synthetic. It does not train an ML model, estimate a real edge, model a queue or send an order.
With lookback 2, closes 99 and 100 give a positive signal after the second close. The next session opens at 100 and closes at 101. The program takes 25 shares, exits at 100.92 and ends with $10,022.50. Change the future close to 98 and the earlier decision should be unchanged, while the resulting P&L changes.
To grow the system, replace one interface at a time: a versioned data loader, a model fitted only on allowed history, a joint allocator, and an order adapter with reconciliation. Keep the tested ledger and explicit time contract. Archive data version, parameters, code version, seed, trials, decisions and costs with each run.
Before promotion, verify statistical evidence, operational behavior and instrument assumptions separately. Monitor quote age, data gaps, inventory, unresolved orders, cash reconciliation, fill quality, forecast calibration and realized risk. Define pause and restart criteria before incidents. Changes made after seeing forward outcomes belong to a new experiment.
Your final deliverable is a research dossier plus a replayable paper-trading trace: hypothesis, asset specification, timing diagram, model-selection record, benchmark comparison, sensitivity analysis, constraints, order-state tests, cash ledger and a reasoned proceed/revise/reject decision. A good result can be rejection if the evidence does not support the extra complexity.
9 / Run the miniature system and define the promotion decision
- Run the dated sequence in order and apply each simulated fill to cash and holdings.
- Mark any residual position and compute ending equity.
- Subtract starting equity and net external flows to isolate investment P&L. Use an appropriate time- or money-weighted return method when measuring performance with material intraperiod flows.
The synthetic run starts at $10,000, finishes flat at $10,022.50 and has no external flows. Net investment P&L is $22.50. A separate $500 deposit would raise cash but would not increase this investment profit.
Apply it in a strategy
- Copy the complete Python example and reproduce the ledger by hand or in the practice calculator.
- Replace one synthetic assumption at a time and rerun timing, risk and accounting checks.
- Use the promotion criteria and investment-committee brief to defend the final decision.
Research deliverable
Submit a complete, reproducible dossier with a reconciled event trace and a justified proceed/revise/reject decision.
Research sources, review dates and limitations
Extend the research question
Build a source-to-decision record: source version, data availability, model, cost assumptions, positions and reconciled output. State the strongest reason to reject promotion.
Continue with the connected research module →
Connect the ideas: Cash flows and accounting
Retrieve: Track units, signed cash movements and ownership at each event.
Check the change: Instrument obligations, financing and external capital flows change the ledger you need.
Math & notation → Markets & returns → Trading different assets → Research & backtests → Execution & microstructure → Fund operations & capstone
Self-assessed. Write your explanation before opening this comparison. A deposit raises the balance without being investment P&L. Reconcile external flows separately from fills, fees and marked holdings.Explain it yourself: Why can an account balance rise without an investment profit?
Connect the ideas: Information and decision time
Retrieve: Use only information available when the decision is made.
Check the change: Observation dates, release delays, revisions and label maturity require different availability checks.
Statistics → Research & backtests → Point-in-time data → Time series → Research & robust tuning → Financial machine learning
Self-assessed. Write your explanation before opening this comparison. No. A revised value or delayed release may still contain unavailable information. Audit actual availability timestamps and fit preprocessing inside each training window.Explain it yourself: Does shifting a feature by one row guarantee that it was available?
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
from math import floor, isfinite
# Offline synthetic teaching simulator. No broker, network or fitted predictive model.
# Bars are chronologically ordered session records: {time, open, close}.
# After close t, choose a share quantity using only information through t.
# A cash-budget guard at the next open may reduce it, then exit that session.
def run_training_system(bars,capital=10000,lookback=2,probability=.56,
gain=.012,loss=.008,volatility=.02,
target_vol=.005,max_weight=.25,
fee_rate=.0001,exit_slip_rate=.0008):
values=[capital,probability,gain,loss,volatility,target_vol,max_weight,fee_rate,exit_slip_rate]
if not all(isfinite(x) for x in values): raise ValueError("Finite inputs required")
if capital<=0 or volatility<=0 or not 0<=probability<=1 or not 0<=max_weight<=1 or min(gain,loss,target_vol,fee_rate,exit_slip_rate)<0:
raise ValueError("Invalid model/risk/cost inputs")
if not isinstance(lookback,int) or lookback<1 or len(bars)<=lookback:
raise ValueError("Enough historical bars required")
for i,b in enumerate(bars):
if not all(isfinite(b[k]) and b[k]>0 for k in ['open','close']): raise ValueError("Positive finite prices required")
if i and b['time']<=bars[i-1]['time']: raise ValueError("Unique increasing session times required")
cost_rate=2*fee_rate+exit_slip_rate # both fees use entry notional in this toy
edge=probability*gain-(1-probability)*loss-cost_rate
cash=capital; trace=[]
for t in range(lookback-1,len(bars)-1):
history=[b['close'] for b in bars[t-lookback+1:t+1]]
reference=history[-1]; feature=reference/(sum(history)/lookback)-1
weight=min(max_weight,target_vol/volatility)
target=floor(cash*weight/reference) if feature>0 and edge>0 else 0
decision={'decision_time':bars[t]['time'],'feature':feature,'edge':edge,'target':target}
nxt=bars[t+1]; entry=nxt['open']
# Conservative cash and reference-dollar budget guards at execution time.
quantity=min(target,floor(cash*weight/entry),floor(cash/(entry*(1+2*fee_rate))))
exit_price=nxt['close']-entry*exit_slip_rate
if exit_price<0: raise ValueError("Cost scenario implies an invalid exit price")
before=cash; fee=quantity*entry*fee_rate
cash-=quantity*entry+fee
cash+=quantity*exit_price-fee
trace.append({**decision,'execution_time':nxt['time'],'filled':quantity,
'entry':entry,'exit':exit_price,'fees':2*fee,
'pnl':cash-before,'cash':cash,'ending_holdings':0})
return {'cash':cash,'pnl':cash-capital,'trace':trace}
bars=[{'time':1,'open':99,'close':99},
{'time':2,'open':99,'close':100},
{'time':3,'open':100,'close':101}]
print(run_training_system(bars))Continue learning
Putting It All Together: Build a Complete Trading Research System — all lessons- 1 / Define the job and a small research contract
- 2 / Make a point-in-time data contract
- 3 / Turn an idea into a causal feature and a baseline
- 4 / Replay decisions into fills and net returns
- 5 / Add ML, regime models or RL only at a defined interface
- 6 / Convert forecasts into constrained portfolio positions
- 7 / Turn targets into idempotent orders and handle partial fills
- 8 / Reconcile fills, costs, cash and performance
- 9 / Run the miniature system and define the promotion decision
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations