quantlab.execution.approximate#
The approximate backtest’s execution, compiled: a book of weights filled at prices and marked at closes.
The approximate backtest (quantlab.backtest.approximate) gives up most of
the Execution rules (quantlab.execution.rules) for speed. What it keeps is
here, once, for the backtest’s simulation and for the mean-variance solve
that drifts its own holdings forward in time with a turnover penalty
(quantlab.portfolio.predefined.approximate._support.mean_variance_kernels.solve_forward):
a weight decided at bar t fills at bar t + 1’s fill price, or the previous bar’s valuation price where it has none (
entry_prices);between fills a book is its weights at their fill prices, marked at each bar’s valuation price, the rest cash (
mark_book); a price missing on either side counts as no change (price_relative);each fill costs one rate times its traded weight, against the previous book marked at the fill’s prices (
simulate).
Everything is compiled with numba (cache=True: the compiled code is kept
in __pycache__ beside this file, or under NUMBA_CACHE_DIR; an install
that cannot write there compiles again in each process). Import this module
only where it is used: importing it imports numba.
Functions
|
|
Forward-fill NaN down the rows of a |
|
Mark a book at |
|
|
|
Simulate the targets decided at |