quantlab.backtest.approximate.ApproximateAccount#
- class quantlab.backtest.approximate.ApproximateAccount(record, value_without_costs, weights, metrics, universe_value=None, benchmark_value=None)[source]#
Bases:
objectThe account an approximate backtest simulated:
ApproximateBacktest.run’s result.- Attributes:
- recordAccountRecord
The account record, as a backtest run’s (
BaseBacktester.account): the value after each bar (1.0 at the first bar,init_cash1.0) and its returns, one fill per symbol traded at each fill bar (its notional at the fill price, its share of the costs asfees) and the rebalance record. The approximate backtest settles, rejects and caps nothing, sosettlementsandrejected_ordersare empty; it keeps no round trips, per-bar holdings or target deviation (trades,holdingsandmax_target_deviationareNone).- value_without_costsxr.DataArray
The value of the same weights traded without costs.
- weightsxr.Dataset
weighton(timestamp, symbol)over the window, NaN on every bar but the decided ones, and the rebalance recordscheduledanddecidedontimestamp: whatDecisionInputs.weightsreturns, so a backtest run takes it as it is (BaseBacktester.run_weights).- metricsdict
run_metricsofrecord:whole(opened by the return statistics of the window andTotal Fees Paid) andexecution, with a benchmarkbenchmarkandrelative;attribution(attribution_metricsofrecord, the universe ranked by the rule’s score label);iterations(themeanandmaxiterations of the solver per decision bar, 0 for a rule that does not iterate) andconverged(whether every bar met the solver’s stopping rule). The approximate backtest has no training window, so no slice.- universe_valuexr.DataArray or None
The equal-weighted universe of the attribution, on
timestamp, 1.0 at the first bar (a delisted symbol is not settled, as the approximate simulation settles none).- benchmark_valuexr.DataArray or None
The benchmark bought at the second bar’s fill price with all of 1.0 at the same cost and held, on
timestamp;Nonewithout abenchmark_dataset.
Examples
>>> account = backtest.run(predictions, rule) >>> float(account.value[0]), account.decided_weights.dims (1.0, ('timestamp', 'symbol')) >>> account.metrics["converged"], account.metrics["iterations"] (True, {'mean': 0.0, 'max': 0}) >>> sorted(account.metrics["attribution"]["decomposition"]) ['costs', 'selection', 'total']
- property decided_weights#
The target weights at the decided bars, on
(timestamp, symbol).
- property returns#
Per-bar returns of
value, 0.0 at the first bar.
- property value#
The account’s value after each bar, on
timestamp, 1.0 at the first bar.