Mode Selection
When to use weight mode, order mode or both in the same research workflow.
Engine Contract
Mode Selection: Weights vs Orders
Choose weight mode when target exposure is the research object. Choose order mode when pending orders, fills, cash movement or execution state can change the result.Use this when the strategy decides target exposure and the engine should handle risk overlays, rebalancing, realized weights and portfolio accounting.
Data prices, OHLCV, features
indicators rankings, signals, factors
_compute_signals()
_compute_weights()
optional RiskModel.adjust()
RebalanceEngine.run()
actual weights
positions
NAV
metrics/reports
Use this when pending orders, fills, stop/limit behavior, brackets, OCO, cash mutation or fill-level costs are part of the thesis.
Data prices, OHLCV, state
indicators/state current position and NAV
_compute_orders(date, bars, positions, nav)
FillEngine pending orders
fills
cash/positions/NAV
metrics/reports
Strategy output
Weights Target weight matrix
Orders Submitted orders
Engine owner
Weights RiskModel + RebalanceEngine
Orders FillEngine + execution costs
Position source
Weights Realized weights converted to units
Orders Accumulated fills and cash updates
Best for
Weights ranking, allocation, factors, rotation
Orders stops, limits, brackets, OCO, expiry
Mode selection is an engineering decision. Choose the path that matches the state your strategy actually controls.
Source
backtester/core.pyLayerStrategy interface selection
ModeWeights or orders
Inputresearch question, timing, state and execution requirement
Outputstrategy hook and engine path
Primary API
execution_mode="weights" or execution_mode="orders"Main caveatOrder mode adds state. State adds bugs. Use it only when the state is part of the thesis.
Engine Contract
| Question | Weight mode | Order mode |
|---|---|---|
| What do I implement? | _compute_signals() and _compute_weights() | _compute_orders(date, bars, current_positions, nav) |
| What is strategy output? | Target weight matrix | Submitted orders |
| What creates positions? | Rebalanced realized weights | Filled orders |
| What creates costs? | Turnover on rebalance days | Slippage and commission per fill |
| What creates NAV? | Weighted portfolio return path | Cash plus marked positions |
| Best for | allocation, ranking, factors, rotation | stops, limits, brackets, OCO, order state |
Weight Mode Is Correct When
- The strategy decides target exposure, not individual fills.
- You rank assets, select top-N names or allocate by factor score.
- You rebalance on calendar, drift, signal or turnover rules.
- You need gross/net exposure, cash sleeve, risk overlays and portfolio evidence.
- You care about broad parameter sweeps before execution detail.
Order Mode Is Correct When
- A pending order can remain live across bars.
- Stop, limit, trailing stop, bracket or OCO behavior changes the result.
- Entry price, actual fill price or gap-through matters.
- A signal exit must cancel resting protective orders.
- You need fill-level slippage, commission, partial fills or order expiry.
Hybrid Workflow
A strong research workflow often uses both paths:
- Prototype the idea in weight mode.
- Inspect target weights, turnover, drawdown, benchmark-relative behavior and crisis periods.
- Promote only promising candidates to order mode.
- Add stops, brackets, TIF, expiry, slippage, commission and volume participation.
- Report any daily-bar same-bar assumptions before sharing the packet.