Offline quickstart

Author: Artur Sepp / First recorded: 2026-07-25

Implemented in qis — Quantitative Investment Strategies. Software citation: CITATION.cff.

Start with an installed core package. The examples below use the frozen synthetic fixture with default seed 20260725 and a fixed 2 January 2018–31 December 2025 sample. Their outputs demonstrate software behaviour under those inputs, not historical market returns.

Minimum supported released version for this example: qis>=5.37.0. This conservative support floor was checked against the released API. See versions and compatibility for channel selection, capability boundaries and dependency licences.

First chart

The first example draws a quarterly rebalanced 60/40 portfolio of synthetic US equities and government bonds. It charges 10 basis points per unit of traded notional and suppresses performance labels so the chart presents the NAV path without implying a Sharpe convention. It displays a Matplotlib figure and writes no report file. In a headless session, use the figure object for saving or embedding instead of expecting a desktop window.

The first backtest in a fresh environment may pause while Numba compiles the portfolio kernel. The script prints a notice before that work begins; runtime depends on the environment.

Open the complete first-chart script. The rendered site includes it below. In a Markdown viewer that shows the include directive as text, follow the source link.

 1"""Draw a first qis portfolio-backtest chart from core-only synthetic data."""
 2
 3import matplotlib.pyplot as plt
 4
 5import qis
 6from qis.datasets import generate_synthetic_universe
 7
 8
 9universe = generate_synthetic_universe(start='2018-01-02', end='2025-12-31')
10prices = universe.prices[['SEQ_US', 'SBD_TSY']]
11
12print('Running first backtest (Numba compiles the portfolio kernel on first use)...')
13portfolio = qis.backtest_model_portfolio(
14    prices=prices,
15    weights={'SEQ_US': 0.60, 'SBD_TSY': 0.40},
16    rebalancing_freq='QE',
17    rebalancing_costs=0.0010,
18    ticker='Quarterly 60/40',
19)
20figure = qis.plot_prices(
21    prices=portfolio.get_portfolio_nav(),
22    title='Quarterly rebalanced 60/40 portfolio',
23)
24plt.show()
25plt.close(figure)

Complete checked workflow

Open in Colab

After installation, the calculation needs no network, credentials, optional extras or local data files. It builds a target schedule over the instruments priced at each decision date, runs the portfolio, then prints performance and benchmark-relative risk.

The optional Colab notebook first installs qis from PyPI, which requires network access. It prints the installed version/import path and runs a cell checked against the authoritative script. The committed notebook has no execution outputs. The stable documentation provides a release-oriented entry point; the latest/source page may contain unreleased changes.

From a repository checkout, run:

python examples/getting_started/offline_quickstart.py

With only the installed package, save the complete workflow source as offline_quickstart.py and run python offline_quickstart.py. The site displays that same file below, avoiding a second code copy.

 1"""First portfolio-analytics result from a core qis install, entirely offline.
 2
 3Run from a repository checkout with
 4``python examples/getting_started/offline_quickstart.py``. The same complete script is included
 5in the documentation quickstart so it can be copied after ``pip install qis``.
 6"""
 7
 8import pandas as pd
 9
10import qis
11from qis.datasets import generate_synthetic_universe
12
13
14ASSETS = ['SEQ_US', 'SBD_TSY', 'SEQ_EM']
15STATIC_WEIGHTS = {'SEQ_US': 0.50, 'SBD_TSY': 0.30, 'SEQ_EM': 0.20}
16REBALANCING_FREQ = 'QE'
17TRANSACTION_COST = 0.0010  # fractional units: 10 bp of traded notional
18
19
20# The source panel is business-daily. SEQ_EM starts late, so the schedule must allocate over the
21# instruments that are live at each rebalance without looking beyond that date.
22universe = generate_synthetic_universe(start='2018-01-02', end='2025-12-31')
23prices = universe.prices[ASSETS]
24benchmark_nav = universe.benchmark_prices.iloc[:, 0].rename('SBM_6040')
25weight_schedule = qis.generate_static_weights_schedule(
26    prices=prices,
27    weights=STATIC_WEIGHTS,
28    rebalancing_freq=REBALANCING_FREQ,
29)
30
31# A target observed at t sets units at that close; those units earn the return over [t, t+1].
32# The DataFrame owns its quarterly rebalance dates, so rebalancing_freq is None in the backtest.
33portfolio_data = qis.backtest_model_portfolio(
34    prices=prices,
35    weights=weight_schedule,
36    rebalancing_freq=None,
37    rebalancing_costs=TRANSACTION_COST,
38    weight_implementation_lag=0,
39    ticker='Live-universe portfolio',
40)
41portfolio_nav = portfolio_data.get_portfolio_nav()
42
43# Monthly simple returns and the arithmetic Sharpe convention are explicit. The rf=0 arithmetic
44# Sharpe is selected below; an excess Sharpe would additionally require rates_data.
45perf_params = qis.PerfParams(
46    freq='ME',
47    return_type=qis.ReturnTypes.RELATIVE,
48    sharpe_convention=qis.SharpeConvention.ARITHMETIC,
49)
50performance_columns = [
51    qis.PerfStat.PA_RETURN.to_str(),
52    qis.PerfStat.VOL.to_str(),
53    qis.PerfStat.SHARPE_ARITH.to_str(),
54    qis.PerfStat.MAX_DD.to_str(),
55]
56performance_table = qis.compute_ra_perf_table(
57    prices=portfolio_nav,
58    perf_params=perf_params,
59)[performance_columns]
60
61# Tracking error and information ratio use the same monthly simple-return difference.
62monthly_returns = qis.to_returns(
63    prices=pd.concat([portfolio_nav, benchmark_nav], axis=1),
64    freq='ME',
65    is_log_returns=False,
66    drop_first=True,
67)
68return_difference = (
69    monthly_returns['Live-universe portfolio'] - monthly_returns['SBM_6040']
70).to_frame('Portfolio vs SBM_6040')
71tracking_error, information_ratio = qis.compute_te_ir_errors(return_difference)
72
73final_target_weights = weight_schedule.iloc[-1]
74final_realised_weights = portfolio_data.weights.iloc[-1]
75final_nav = float(portfolio_nav.iloc[-1])
76
77print(f'Date range: {prices.index[0]:%Y-%m-%d} to {prices.index[-1]:%Y-%m-%d}')
78print(f'Prices: business-day frequency, shape={prices.shape}')
79print(
80    f'Target schedule: {weight_schedule.shape}, {REBALANCING_FREQ}, '
81    'live-universe-aware'
82)
83print(f'Final target weights: {final_target_weights.round(4).to_dict()}')
84print(f'Final realised weights: {final_realised_weights.round(4).to_dict()}')
85print('\nMonthly simple-return performance (arithmetic Sharpe, rf=0):')
86print(performance_table.round(3).to_string())
87print(f'\nFinal NAV: {final_nav:.4f}')
88print(
89    'Benchmark-relative monthly simple returns: '
90    f'TE={tracking_error.iloc[0]:.4f}, IR={information_ratio.iloc[0]:.4f}'
91)
92print(
93    'Next reporting step (no file is written here): '
94    'https://quantinveststrats.readthedocs.io/en/latest/factsheets_and_reporting.html'
95)

What the result establishes

The checked workflow uses synthetic US equities, government bonds and emerging-market equities. The last instrument, SEQ_EM, starts late. The schedule redistributes the target allocation across priced instruments until it becomes available.

Output

Fixed-fixture result or convention

Price panel

2,087 business-day rows, three instruments.

Target schedule

33 quarterly decision dates, three weights per date.

Terminal NAV

119.9866, rounded to four decimals; initial capital is 100.

Tracking error

0.0299 annualised, about 2.99%, rounded to four decimals.

Information ratio

−0.2899, annualised and rounded to four decimals.

Benchmark

The fixture’s synthetic 60/40 reference, SBM_6040.

Output-to-object map

The printed groups map to the following reusable objects. Target weights and realised holdings are different: weight_schedule holds each rebalance decision, while portfolio_data.weights reflects the units held after prices move. See portfolio backtesting for the timing convention and performance and Sharpe conventions for the statistic definitions.

Printed output

Python object to reuse

Price panel shape

prices, selected as universe.prices[ASSETS]

Target schedule shape and final target weights

weight_schedule

Final realised weights

portfolio_data.weights

Monthly performance table

performance_table

Terminal NAV

portfolio_nav, or portfolio_data.get_portfolio_nav()

TE and IR

tracking_error and information_ratio from compute_te_ir_errors(return_difference)

The quickstart regression test checks the schedule, output and terminal NAV against the current source. These values are a reproducibility reference for this fixture and cost setup, not a forecast or an assertion that every published release produces identical results.

A target decided at time \(t\) sets the units held over \([t,t+1]\), with zero implementation lag. Between quarterly rebalances, units remain held while weights drift. Cost 0.0010 is 10 basis points of traded notional; it is not a flat deduction of 10 basis points from every day’s NAV.

The performance table uses simple monthly returns and the arithmetic, zero-rate Sharpe convention explicitly. Its headline annual return is compounded. Tracking error and information ratio use monthly simple strategy-minus-benchmark returns, sample standard deviation and 12 periods per year. For exact definitions, see performance and Sharpe conventions and tracking error.

What to change first

  • Statistic set: edit performance_columns, using qis.PerfStat labels.

  • Return and Sharpe convention: edit return_type and sharpe_convention in perf_params; excess-return statistics also require a rate series.

  • Rebalance cadence: change REBALANCING_FREQ. The weight DataFrame then owns the decision dates passed to the backtest.

  • Transaction costs: change TRANSACTION_COST in fractional units of traded notional.

  • Benchmark: replace benchmark_nav and align its return convention, observation grid and common sample with the strategy.

  • Reporting cadence: use the corresponding reporting_frequency when creating a factsheet, and check its reporting-grid conventions.

Next reporting step

The complete checked workflow prints its results and writes no chart, PDF or factsheet. Continue with factsheets and reporting to create report figures. The portfolio backtesting guide explains held units and costs, while the API reference and public API record locate the exported functions.

References