QuantJourney Backtester

QuantJourney Backtester

Share product feedback

✓

Thank you.

Your note is now in the QuantJourney inbox.

docs/engine/mode-selection.mdx

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.
WEIGHT MODE allocation research

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
ORDER MODE discrete execution research

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.

Sourcebacktester/core.py
LayerStrategy interface selection
ModeWeights or orders
Inputresearch question, timing, state and execution requirement
Outputstrategy hook and engine path
Primary APIexecution_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

QuestionWeight modeOrder mode
What do I implement?_compute_signals() and _compute_weights()_compute_orders(date, bars, current_positions, nav)
What is strategy output?Target weight matrixSubmitted orders
What creates positions?Rebalanced realized weightsFilled orders
What creates costs?Turnover on rebalance daysSlippage and commission per fill
What creates NAV?Weighted portfolio return pathCash plus marked positions
Best forallocation, ranking, factors, rotationstops, 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:

  1. Prototype the idea in weight mode.
  2. Inspect target weights, turnover, drawdown, benchmark-relative behavior and crisis periods.
  3. Promote only promising candidates to order mode.
  4. Add stops, brackets, TIF, expiry, slippage, commission and volume participation.
  5. Report any daily-bar same-bar assumptions before sharing the packet.