backtest / wire operation
Run a vectorized backtest
totalfinance.backtest.vectorized_run
Run a single-asset vectorized backtest: signal-following fills at close, optional bps fees. Returns final value, turnover, and the performance summary; every hidden policy the run assumed (fill timing, costs, slippage, settlement, calendar, margin) is echoed in `assumptions`, and the implementation-risk warnings (look-ahead, data alignment) ride `diagnostics`. Deliberately opt-in (backtestPack) — payloads and runtime are heavier than the default tools. executionLag shifts signal lookup before rebalance sampling; a month-end target can miss the next monthly sample. Use the SDK researchProtocol and selection-hygiene workflow before comparing candidates; see docs/guides/dogfood-journeys.md.
| Pack / profiles | backtest / backtesting, full |
|---|---|
| Default discovery | Opt-in |
| Required capabilities | None |
| Effects / authorization | none / none |
| Cost / cancellation | small / Do not assume inline interruption |
| Handle-eligible inputs | None |
| Idempotency | not-applicable |
Input schema
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "Ticker (default SYMBOL)"
},
"timestampMs": {
"type": "number",
"description": "Bar timestamp (epoch ms)"
},
"open": {
"type": "number",
"exclusiveMinimum": 0
},
"high": {
"type": "number",
"exclusiveMinimum": 0
},
"low": {
"type": "number",
"exclusiveMinimum": 0
},
"close": {
"type": "number",
"exclusiveMinimum": 0
},
"volume": {
"type": "number"
}
},
"additionalProperties": false,
"required": [
"timestampMs",
"open",
"high",
"low",
"close"
]
},
"description": "OHLC bars, chronological"
},
"signal": {
"type": "array",
"items": {
"type": "number"
},
"description": "Target position per bar (1 long, 0 flat, -1 short; fractional = sized), aligned to data"
},
"initialCapital": {
"type": "number",
"exclusiveMinimum": 0,
"description": "Opening capital (default 1)"
},
"feeBps": {
"type": "number",
"minimum": 0,
"description": "Per-trade fee in basis points of traded notional"
},
"slippageBps": {
"type": "number",
"minimum": 0,
"description": "Existing slippage.bps model; basis points, zero means no slippage"
},
"executionLag": {
"type": "integer",
"minimum": 0,
"description": "Signal-to-fill lag in bars (SDK default 1); 0 carries a look-ahead warning"
},
"rebalance": {
"anyOf": [
{
"type": "string",
"enum": [
"everyBar",
"daily",
"weekly",
"monthly"
]
},
{
"type": "integer",
"exclusiveMinimum": 0
}
],
"description": "Existing SDK sampling schedule; samples signal[i - executionLag] only on rebalance bars"
},
"periodsPerYear": {
"type": "number",
"exclusiveMinimum": 0,
"description": "Bars per year for metrics (SDK default 252)"
},
"riskFreeRate": {
"type": "number",
"description": "Annual risk-free rate as a decimal (SDK default 0)"
},
"maxLeverage": {
"type": "number",
"exclusiveMinimum": 0,
"description": "Existing per-asset gross weight cap (SDK default 1)"
}
},
"additionalProperties": false,
"required": [
"data",
"signal"
]
}Output schema
{
"type": "object",
"properties": {
"finalValue": {
"type": "number"
},
"turnover": {
"type": "number",
"description": "Traded notional ÷ average equity over the run"
},
"performance": {
"type": "object",
"description": "The standard performance summary"
},
"assumptions": {
"type": "object",
"description": "The modelling policies the run assumed: initialCapital, fill, cost, slippage, cashSettlement, corporateAction, calendar, margin, conventionsVersion"
},
"diagnostics": {
"type": "object",
"description": "Implementation-risk warnings (look-ahead / data alignment) + benchmarkFixtureVersion"
}
},
"required": [
"finalValue",
"turnover",
"performance",
"assumptions",
"diagnostics"
]
}