algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::backtest::ReportCaveats Struct Reference

What a replay's figures assumed and did not account for. More...

#include <algotradelib/src/backtest/report.hpp>

Collaboration diagram for algotradelib::backtest::ReportCaveats:

Public Attributes

LimitFillPrice limit_fill_ {LimitFillPrice::AT_LIMIT}
 Which price a filled limit order was credited.
std::vector< AppliedRate > applied_rates_
 Every commission rate that charged an execution, with how many it charged.
std::size_t inclusive_commission_executions_ {0}
 How many executions were charged a single combined rate (no institution fee split).
std::optional< VenueKey > asserted_venue_
 The venue costs were computed at, as the caller asserted it (a replay cannot observe where a fill executed).
std::string commission_tariff_
 The tariff the commission schedule named; empty for a flat model.
bool cost_totals_incomplete_ {false}
 Whether some cost could not be summed exactly, so the cost totals are incomplete.
Decimal64 slippage_basis_points_
 The basis points of slippage applied.
int slippage_ticks_ {0}
 The ticks of slippage configured; fewer apply where the grid has no further step.
bool multiple_instruments_ {false}
 Whether more than one instrument traded: a caution about survivorship bias.
std::size_t gaps_ {0}
 Bars that did not follow their predecessor (see ReplayClock::contiguous); gaps are not interpolated.
std::size_t unfilled_ {0}
 Orders still queued, unfilled, when the replay ended.
std::size_t quotes_ {0}
 How many quotes the replay was fed (zero for a bars-only replay).
std::size_t unchecked_fill_causality_ {0}
 How many times a fill was allowed without the engine being able to prove its price came after the decision.
std::size_t unvalued_bars_ {0}
 Bars whose equity total could not be computed exactly (ReplayResult::unvalued_bars_).
std::optional< std::chrono::system_clock::time_point > first_unvalued_
 The period end of the first unvalued bar, if any.
std::size_t stop_releases_ {0}
 How many stop-limit orders a bar released, each using the assumed direction (a sell stop releases when the price falls to the trigger, a buy stop when it rises; brokers do not document it).
std::size_t stop_fills_intrabar_ {0}
 Fills of stops released inside a bar, which assume the price moved continuously through the trigger.
std::size_t limit_fills_bounded_ {0}
 Limit-type fills whose price was moved to stay within the bar's range and the limit (see LimitFillPrice::AT_LIMIT).
std::size_t overdrawn_bars_ {0}
 Bars that closed with cash below zero in the replay's currency: the replay borrowed, which the default limits allow.
std::optional< std::chrono::system_clock::time_point > first_overdrawn_
 The first bar end at which cash was below zero.
std::optional< Money > lowest_cash_
 The lowest cash an execution left, if it went below zero.
std::size_t other_currency_executions_ {0}
 Executions in a currency other than the equity curve's (ReplayConfig::currency_).
std::optional< std::chrono::system_clock::time_point > lowest_cash_at_
 When the lowest cash was reached.
std::optional< SellTax > sell_tax_
 The sale tax given to the fill model; absent if none was modelled.
std::size_t expired_day_orders_ {0}
 DAY orders withdrawn unfilled when their session ended, as they would expire live.

Static Public Attributes

static constexpr bool volume_ignored = true
 Always true: fills are never capped by traded volume, and queue position, market impact and borrow availability are not modelled.
static constexpr bool bar_tape_unverified = true
 Always true: the replay cannot know which venue's tape its bars came from.
static constexpr bool sellable_is_whole_holding = true
 Always true: a replay reports every held share as sellable.
static constexpr bool buying_power_is_ledger_cash = true
 Always true: a replay's buying power is the ledger's own cash, not a broker's figure.

Detailed Description

What a replay's figures assumed and did not account for.

Definition at line 27 of file report.hpp.

Member Data Documentation

◆ applied_rates_

std::vector<AppliedRate> algotradelib::backtest::ReportCaveats::applied_rates_

Every commission rate that charged an execution, with how many it charged.

Only rates actually used, not every rate in the schedule. A zero-cost run that traded lists a zero rate.

Definition at line 36 of file report.hpp.

◆ asserted_venue_

std::optional<VenueKey> algotradelib::backtest::ReportCaveats::asserted_venue_

The venue costs were computed at, as the caller asserted it (a replay cannot observe where a fill executed).

Empty when no scheduled commission policy was used.

Definition at line 50 of file report.hpp.

◆ bar_tape_unverified

bool algotradelib::backtest::ReportCaveats::bar_tape_unverified = true
staticconstexpr

Always true: the replay cannot know which venue's tape its bars came from.

A KRX-listed stock trades on KRX and NXT, and KIS serves either tape or the consolidated one (KisConfig::market_tape_, consolidated by default; older datasets may be KRX only). Bars carry no venue, so a replay's bars and a live run's can legitimately differ.

Definition at line 121 of file report.hpp.

◆ buying_power_is_ledger_cash

bool algotradelib::backtest::ReportCaveats::buying_power_is_ledger_cash = true
staticconstexpr

Always true: a replay's buying power is the ledger's own cash, not a broker's figure.

The ledger models no settlement; a broker computes buying power on its own terms, and which way an account differs cannot be known here. With RiskLimits::enforce_buying_power_ on, the cash is reduced by what the replay's own resting buys commit (at their limit price or the last close).

Definition at line 138 of file report.hpp.

◆ commission_tariff_

std::string algotradelib::backtest::ReportCaveats::commission_tariff_

The tariff the commission schedule named; empty for a flat model.

Definition at line 52 of file report.hpp.

◆ cost_totals_incomplete_

bool algotradelib::backtest::ReportCaveats::cost_totals_incomplete_ {false}

Whether some cost could not be summed exactly, so the cost totals are incomplete.

When set, every scalar cost total is absent and the per-currency totals hold only what could be added. It takes amounts far beyond any real account.

Definition at line 59 of file report.hpp.

◆ expired_day_orders_

std::size_t algotradelib::backtest::ReportCaveats::expired_day_orders_ {0}

DAY orders withdrawn unfilled when their session ended, as they would expire live.

Definition at line 195 of file report.hpp.

◆ first_overdrawn_

std::optional<std::chrono::system_clock::time_point> algotradelib::backtest::ReportCaveats::first_overdrawn_

The first bar end at which cash was below zero.

Definition at line 178 of file report.hpp.

◆ first_unvalued_

std::optional<std::chrono::system_clock::time_point> algotradelib::backtest::ReportCaveats::first_unvalued_

The period end of the first unvalued bar, if any.

Definition at line 149 of file report.hpp.

◆ gaps_

std::size_t algotradelib::backtest::ReportCaveats::gaps_ {0}

Bars that did not follow their predecessor (see ReplayClock::contiguous); gaps are not interpolated.

Definition at line 76 of file report.hpp.

◆ inclusive_commission_executions_

std::size_t algotradelib::backtest::ReportCaveats::inclusive_commission_executions_ {0}

How many executions were charged a single combined rate (no institution fee split).

Nonzero means Report::commission_paid_ includes the institution fee for those executions and Report::institution_fees_paid_ is absent.

Definition at line 43 of file report.hpp.

◆ limit_fill_

LimitFillPrice algotradelib::backtest::ReportCaveats::limit_fill_ {LimitFillPrice::AT_LIMIT}

Which price a filled limit order was credited.

Definition at line 29 of file report.hpp.

◆ limit_fills_bounded_

std::size_t algotradelib::backtest::ReportCaveats::limit_fills_bounded_ {0}

Limit-type fills whose price was moved to stay within the bar's range and the limit (see LimitFillPrice::AT_LIMIT).

Definition at line 168 of file report.hpp.

◆ lowest_cash_

std::optional<Money> algotradelib::backtest::ReportCaveats::lowest_cash_

The lowest cash an execution left, if it went below zero.

Definition at line 180 of file report.hpp.

◆ lowest_cash_at_

std::optional<std::chrono::system_clock::time_point> algotradelib::backtest::ReportCaveats::lowest_cash_at_

When the lowest cash was reached.

Definition at line 191 of file report.hpp.

◆ multiple_instruments_

bool algotradelib::backtest::ReportCaveats::multiple_instruments_ {false}

Whether more than one instrument traded: a caution about survivorship bias.

A universe built from a broker's current listings omits instruments delisted during the period, which tends to flatter the result. The engine cannot see how the universe was chosen, so this is a proxy that is also set for a hand-picked universe with no such problem. Figures are still computed.

Definition at line 73 of file report.hpp.

◆ other_currency_executions_

std::size_t algotradelib::backtest::ReportCaveats::other_currency_executions_ {0}

Executions in a currency other than the equity curve's (ReplayConfig::currency_).

The curve and every figure measured from it leave these out, and so does the overdraft check above. When this is nonzero and every execution is one of them, Report::total_return_, sharpe_, annualized_sharpe_, sortino_ and max_drawdown_ are math::missing(): the curve then holds only the opening cash, which would read as a flat result. The opening and closing equity stay the curve's.

Definition at line 189 of file report.hpp.

◆ overdrawn_bars_

std::size_t algotradelib::backtest::ReportCaveats::overdrawn_bars_ {0}

Bars that closed with cash below zero in the replay's currency: the replay borrowed, which the default limits allow.

Figures measured over borrowed money are leveraged. Short sale proceeds count as cash, so leverage through shorts is not counted here. See ReplayResult::overdrawn_bars_.

Definition at line 176 of file report.hpp.

◆ quotes_

std::size_t algotradelib::backtest::ReportCaveats::quotes_ {0}

How many quotes the replay was fed (zero for a bars-only replay).

Note
An order placed from on_quote does not fill against the quote: it fills against a later bar (a market order at that bar's open), at the earliest the first bar whose period began at or after the decision, where the engine can tell when a period began. Live, the same order reaches the broker at once. So a quote-driven strategy's replayed fills can be later, and at a different price, than its live ones.

Definition at line 90 of file report.hpp.

◆ sell_tax_

std::optional<SellTax> algotradelib::backtest::ReportCaveats::sell_tax_

The sale tax given to the fill model; absent if none was modelled.

Definition at line 193 of file report.hpp.

◆ sellable_is_whole_holding

bool algotradelib::backtest::ReportCaveats::sellable_is_whole_holding = true
staticconstexpr

Always true: a replay reports every held share as sellable.

Live, the broker's figure can be smaller (unsettled, pledged or locked shares), so a sale a replay allows can be refused live under RiskLimits::enforce_sellable_quantity_.

Definition at line 129 of file report.hpp.

◆ slippage_basis_points_

Decimal64 algotradelib::backtest::ReportCaveats::slippage_basis_points_

The basis points of slippage applied.

Definition at line 61 of file report.hpp.

◆ slippage_ticks_

int algotradelib::backtest::ReportCaveats::slippage_ticks_ {0}

The ticks of slippage configured; fewer apply where the grid has no further step.

Definition at line 63 of file report.hpp.

◆ stop_fills_intrabar_

std::size_t algotradelib::backtest::ReportCaveats::stop_fills_intrabar_ {0}

Fills of stops released inside a bar, which assume the price moved continuously through the trigger.

A price that jumped past both trigger and limit (a halt reopening, a thin book) would instead have left the stop resting.

Definition at line 163 of file report.hpp.

◆ stop_releases_

std::size_t algotradelib::backtest::ReportCaveats::stop_releases_ {0}

How many stop-limit orders a bar released, each using the assumed direction (a sell stop releases when the price falls to the trigger, a buy stop when it rises; brokers do not document it).

Definition at line 155 of file report.hpp.

◆ unchecked_fill_causality_

std::size_t algotradelib::backtest::ReportCaveats::unchecked_fill_causality_ {0}

How many times a fill was allowed without the engine being able to prove its price came after the decision.

Counted once per queued order per bar considered (the fill model may still decline). It happens when a bar's period start or end is not known exactly: a close-stamped weekly, monthly or yearly bar, or an open-stamped bar of a day or longer, whose end is nominal (every shipped adapter produces those). An open-stamped weekly series whose bars each start at or after the previous bar's nominal end (Monday to Monday) counts nothing; a close-stamped weekly series counts every decision.

With no quotes, one interval per instrument and non-overlapping periods, the fills were causal whatever this says. See ReplayResult::unchecked_fill_causality_.

Definition at line 106 of file report.hpp.

◆ unfilled_

std::size_t algotradelib::backtest::ReportCaveats::unfilled_ {0}

Orders still queued, unfilled, when the replay ended.

Definition at line 79 of file report.hpp.

◆ unvalued_bars_

std::size_t algotradelib::backtest::ReportCaveats::unvalued_bars_ {0}

Bars whose equity total could not be computed exactly (ReplayResult::unvalued_bars_).

Each has no point on the equity curve and the point after it no return, so the return series is shorter than the bar count by at least this much. Weight-sized intents on such a bar are rejected for want of a portfolio value.

Definition at line 147 of file report.hpp.

◆ volume_ignored

bool algotradelib::backtest::ReportCaveats::volume_ignored = true
staticconstexpr

Always true: fills are never capped by traded volume, and queue position, market impact and borrow availability are not modelled.

Definition at line 112 of file report.hpp.


The documentation for this struct was generated from the following file: