Historical replay

Work in Progress - Target version V0.38.0

The implementation of alerts and rule-based trading is not yet complete. This documentation describes the planned and partially implemented functionality.

A historical replay evaluates the strategies of a simulation environment on every trading day after its opening date and books the resulting orders as ordinary transactions inside the simulation. This shows how your allocation and your strategies would have behaved in the past, without touching your real portfolio.

An existing simulation environment is required. How to open one is described under Rule based trading.

Regular deposits, withdrawals, cash-account interest, and fees can be modelled with cash standing orders inside the simulation.

Starting a replay

Choose Start replay… from the context menu of a simulation environment, which opens the dialog Historical replay. The entry appears only in the main tenant and only with write permission: the replay books its executions as the owner of the environment, so it cannot be started from inside an entered simulation. If you have switched into a simulation, return first with Switch to main tenant.

In the dialog you supply the End date; the beginning is always the opening date of the environment and cannot be changed. This keeps it verifiable what a recorded result was calculated from. The end date must fall after the opening date and before the current day, because a day still in progress has no closing price to decide against. How many trading days a replay may cover at most is set by the administrator in the global settings with gt.simulation.max.run.trading.days. Between 300 and 7500 trading days are allowed, the default is 3000, roughly twelve years. You can additionally switch on Apply simulation tax models. GT then estimates trade taxes and income withholding from the simulation tax models of the tax countries. The option is off by default. Generate regular bond coupons is independent of that and creates contractual coupons when a direct fixed-rate bond has no stored distributions.

Start replay hands the work to the server. It continues in the background even if you close the dialog.

How a replay proceeds

Before the first trading day, GT returns the environment to its opening state: everything a previous replay produced is removed, while the opening holdings remain. A repeated execution therefore always begins from the same starting point instead of building on the positions of the previous run.

Each trading day is then evaluated in turn. GT first books due cash standing orders, followed by income and instrument end-of-life events. It then values the environment at that day’s closing prices, checks whether a rebalancing is due, and evaluates the strategies of the individual securities. A rebalancing is due only at a checkpoint, which recurs after the interval derived from the number of redeployments per year; how the checkpoint and the tolerance work together is described under Portfolio Rebalancing. An order that arises at the close of a day is never executed on that same day, but at the closing price of the security’s next eligible trading day. There is no market execution before an instrument’s start date or after its end date; for a direct bond, the end date itself is reserved for redemption.

graph TD
    A["Restore the opening state"] --> B["Next trading day"]
    B --> C["Process cash standing orders, income, and instrument end dates"]
    C --> D["Value the environment at the close"]
    D --> E["Rebalancing due?"]
    E --> F["Evaluate the securities' strategies"]
    F --> G["Execute orders at the next eligible close"]
    G -->|yes| B
    G -->|no| H["Calculate the figures and finish the run"]
Past prices only

A decision sees prices up to and including the day on which it is taken, and no further. Later prices and the current day’s price are unreachable for the replay. Only this makes a result meaningful at all.

Following the progress and cancelling

The dialog shows the Status of the run and, under Trading days and Evaluated, how far it has come. Refresh fetches the current state; while a run is working this also happens on its own. Cancel replay stops the run after the day it is currently evaluating. The environment stays locked until the run has actually ended, not merely until you ask for the cancellation. The executions booked until then remain in the environment, but no figures are reported for a cancelled run.

StatusMeaning
RunningThe run is queued or currently working.
CompletedThe run reached its end date; the figures are valid.
CancelledYou stopped the run.
FailedThe run ended on an error; the reason is shown in the dialog.
InterruptedThe server was stopped while the run was working. Such a run is not resumed but started anew.

Only one replay can run per simulation environment at a time, and the server executes only a few at once overall. When that capacity is exhausted, GT says so and you try again later.

Result

The card Run records what the run was calculated with: Status, Opening date, End date, the two chosen options, Started, Finished and the Fallback dividend payment delay (calendar days), see Income and instrument end dates. A completed run reports the following figures under Result. They refer to the equity of the simulation environment, valued on every evaluated day at that day’s closing prices. The opening holdings are capital, not profit. Deposits and withdrawals from cash standing orders are likewise treated as external capital flows rather than return.

FigureMeaning
Total returnChange in equity from the opening day to the end date.
Annualized returnThe total return scaled to a calendar year.
Maximum drawdownThe largest decline from an intermediate peak of the equity.
Sharpe ratioMean daily return divided by its deviation, scaled to a year.
Paid gross dividends (tenant currency)Sum of the dividends paid out up to the end date, before tax deductions.
Unpaid gross dividends (tenant currency)Dividends whose entitlement arose up to the end date but whose payment date lies after it.
TradesNumber of fully closed engagements. A position still open on the end date does not count; its value is part of the closing equity.
Winning trades and Losing tradesHow many of the closed trades brought in more than they cost, and how many brought in less.

A figure that cannot be determined stays empty instead of showing zero. Equity that never moved yields no Sharpe ratio, and a run with only one evaluated day yields no return.

Calculation assumptions

Figures are only as meaningful as the assumptions they were produced under. GT therefore records these with every run and lists them with the result.

Execution takes place at the closing price of the security’s next eligible trading day, without price deviation on execution. If the securities account used has a configured fee model, its transaction costs are included; otherwise no transaction costs are charged. The gain or loss of a trade is measured in the currency of the security. The Sharpe ratio is calculated against a risk-free rate of zero; the return is annualized over calendar days, the deviation over 252 trading days.

Income reconciliation and warnings

When tax models or generated bond coupons are involved, a completed run additionally shows Income reconciliation. Gross payments, Withheld tax, and Net payments are reported separately for Interest/Dividends and Securities interest. Outstanding claims appear as Gross receivables and coupon accrual, Estimated withholding, and Net receivables and coupon accrual. FX and rounding reconciliation discloses differences that currency conversion and rounding can introduce between gross, tax, and net amounts.

Under Tax and income warnings, GT groups equivalent warnings and shows their count and affected period. If a country lacks a model section, period, required input, or matching rule, GT omits only that country’s contribution; valid contributions from other countries remain and the replay continues. An explicit zero rule instead counts as complete coverage. If estimated withholding exceeds gross income, that withholding is not booked, preventing negative net income. No tax warnings are generated while tax models are switched off.

Not a substitute for a real trading simulation

Price deviations on execution are not included. Without a configured fee model, transaction costs are absent as well. A result can therefore be more favourable than actual trading, especially for frequently traded strategies.

Income and instrument end dates

A stored dividend creates an entitlement on the ex-date for the units held before that day and is booked as cash on the payment date. If the payment date is missing, GT uses the ex-date plus a fallback delay in calendar days set by the administrator with gt.simulation.dividend.payment.delay.days (1 to 32, default 16). The run records the delay used. For direct fixed-rate bonds, GT can additionally generate regular coupons from the bond terms, which are entered in the Bond simulation tab of the security. Without a stored day-count convention, the usual convention of the currency is applied. Stored distributions take precedence. Generation supports regular fixed-rate periods; irregular first or last periods, floating rates, and business-day adjustments are not modelled.

A direct bond is redeemed at par on its end date. If no par value per unit is configured, GT uses 100. This principal repayment is independent of Generate regular bond coupons. When regular coupons are generated and redemption falls on a coupon date, the full coupon is booked separately. When it falls between coupon dates, the redemption includes interest accrued up to that date. The redemption itself carries no securities-account fee or trade tax; any withholding on the coupon remains separate.

Other non-margin positions are closed at the last available closing price on or before the instrument’s end date. The normal fee and tax models apply. If there is no usable price, the position stays open and the course shows Unavailable. If the instrument ended before the replay’s first trading day, GT catches up the redemption or close on the first evaluated day.

Course of the replay

Below the result GT lists what happened on which day. The course explains a run rather than merely summarising it: it equally records why nothing happened, because otherwise a run without trades and a run without price data would look the same.

ColumnContent
DateThe closing day the entry belongs to.
EventThe kind of entry, see below.
ReasonWhy it was decided this way, for example a triggered entry or an exhausted investment limit.
units, Price, Amount, CurrencySize and price, where the entry has them.
DetailsSupplementary information, such as the reason for a cancellation.

The entries Replay started and Replay ended enclose the run. Between them, Opening liquidation marks a CFD, Forex or leveraged position of the opening state that is closed before ordinary simulation trading, Cash standing order a recurring cash booking, Decision a triggered entry or exit, and Execution its booking on the following trading day. Rebalancing due and Rebalancing execution record the same for the alignment with your target weightings. Initial purchase due and Initial purchase execution appear only for an environment that held no positions on its opening date: it buys into its target weightings once at the beginning of the run, and only afterwards does the checkpoint interval of the rebalancing start counting. An environment that opens with positions goes straight to its first rebalancing instead. Cash moved to fund an order marks a transfer between two cash accounts of the environment so that an order can be paid for; it names the security it was made for. Dividend entitlement and Dividend payment record the entitlement arising on the ex-date and its payout. Maturity redemption identifies a direct bond repayment and End-of-life close the closing of another position. Blocked means an action was deliberately omitted, for instance because of a cooldown or an exhausted investment limit. Unavailable means no decision could be taken at all, because price data or an exchange rate was missing.

Limitations

CFDs, Forex and instruments with a leverage factor other than 1 are not traded in a replay. If the opening state contains such positions, they are closed before ordinary simulation trading (Opening liquidation), are not bought again afterwards, and their weighting is redistributed to the other securities for that run. An order for which no further eligible trading day follows within the replay stays unexecuted. Where closing prices or exchange rates are missing for a day, no decision is taken for the affected security; the run nevertheless continues its work and records the reason in the course.

Executions of a rebalancing carry no assignment to a strategy, because the accounting keeps such an assignment only for strategies of the tactical trading level. The strategy involved is visible in the course instead. Where a security is claimed both by an asset class with a target weighting and by a strategy of its own, that strategy reports the security as undecidable. Assign a security to one asset class only.

Results are replaced

Exactly one run is kept per simulation environment. Replaying again restores the opening state and replaces the previous result together with its course. To compare two periods side by side, create a second simulation environment. Delete simulation removes its run as well; while a replay is working, deleting is refused. What else is possible in an environment, and what you had better leave alone there, is described under Working in a simulation environment.