![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
Replays a strategy over stored bars: fill and cost models, the replay ledger, and the report. More...
Classes | |
| struct | AppliedRate |
| The commission rate that charged an execution, as the backtest report lists it. More... | |
| class | Backtester |
| Replays bars (and quotes) through one strategy, with a ledger and a fill model. More... | |
| struct | BacktestTag |
| The broker tag of a replay's order references (they reach no broker). More... | |
| struct | CommissionCharge |
| What one execution was charged: the broker's commission and the institution fee. More... | |
| struct | CommissionModel |
| A flat commission: a rate on traded value, with an optional per-execution minimum. More... | |
| class | CommissionPolicy |
| How a backtest charges commission: one stated model, or a schedule resolved per execution. More... | |
| struct | EquityPoint |
| One point on a replay's equity curve, recorded per bar. More... | |
| struct | Execution |
| One execution a backtest produced, and what it cost. More... | |
| struct | FillDecision |
| What NextBarFillModel::decide concluded about one order and one bar. More... | |
| class | NextBarFillModel |
| The fill model: market orders at the next bar's open, limit orders when the next bar's range reaches them, stop-limit orders once released. More... | |
| struct | QueuedOrder |
| One order a replay accepted and has not yet filled or withdrawn. More... | |
| class | QueueingExecutor |
| The replay's executor: accepts orders and holds them until they fill or are withdrawn. More... | |
| class | ReplayClock |
| A backtest's clock: the current instant and market phase, moved by the replayed events. More... | |
| struct | ReplayConfig |
| A replay's settings, besides the strategy and the bars. More... | |
| class | ReplayLedger |
| Positions, cash and realized profit, updated by each execution of a replay. More... | |
| struct | ReplayResult |
| Everything a replay produced; summarize turns it into a Report. More... | |
| struct | Report |
| The summary of a replay; read halted_ and caveats_ before the figures. More... | |
| struct | ReportCaveats |
| What a replay's figures assumed and did not account for. More... | |
| struct | SellTax |
| A tax on sales, stated by the caller; see NextBarFillModel::with_sell_tax. More... | |
| struct | SlippageModel |
| Slippage: how far a fill price moves against the order (a buy pays more, a sell gets less). More... | |
Enumerations | |
| enum class | LimitFillPrice { AT_LIMIT , AT_OPEN_IF_BETTER } |
| Which price a backtest credits a limit order that fills. More... | |
Functions | |
| std::optional< std::chrono::seconds > | interval_duration (BarInterval interval) |
| Returns the fixed duration of an interval (bar_interval_length). | |
| std::optional< math::Scalar > | periods_per_year (BarInterval interval, const strategy::SessionWindow &session, math::Scalar trading_days) |
| Returns how many bars of an interval a year contains, for analytics::annualize_ratio. | |
| Result< CommissionModel > | commission_model_from (const CommissionSchedule &schedule, Country country, const Date &date) |
| Builds a flat commission model from a schedule's rate for a market on a date. | |
| constexpr std::string_view | limit_fill_price_name (LimitFillPrice choice) noexcept |
| Returns a lowercase name for a choice, such as "at_limit", for reports. | |
| Report | summarize (const ReplayResult &result, const NextBarFillModel &fills, std::optional< math::Scalar > periods_per_year=std::nullopt, math::Scalar risk_free=math::Scalar{0}) |
| Summarizes a replay into a Report. | |
Replays a strategy over stored bars: fill and cost models, the replay ledger, and the report.
|
strong |
Which price a backtest credits a limit order that fills.
| Enumerator | |
|---|---|
| AT_LIMIT | The default: fill at the limit, or at the bar's worst traded price when the whole bar was better than the limit. A bar that gaps through a resting limit is not credited its open. A limit marketable through the whole bar (a buy above the high) is credited the high (a sell below the low, the low), which is better than the limit; ReportCaveats::limit_fills_bounded_ counts those fills. |
| AT_OPEN_IF_BETTER | Fill at the bar's open when it opened through the limit (assumes the order was resting before the open). |
|
inline |
Builds a flat commission model from a schedule's rate for a market on a date.
The model has no minimum (none is published) and no tax; it charges that one rate for the whole replay, even if the schedule changes rate later. For per-date rates use CommissionPolicy::scheduled.
| schedule | The schedule, published by a broker or stated by the caller. |
| country | The market. |
| date | The date whose rate to use. |
Definition at line 94 of file cost.hpp.
Referenced by commission_model_from().
|
inline |
Returns the fixed duration of an interval (bar_interval_length).
| interval | The interval. |
Definition at line 30 of file clock.hpp.
Referenced by algotradelib::backtest::ReplayClock::contiguous(), interval_duration(), and periods_per_year().
|
inlineconstexprnoexcept |
Returns a lowercase name for a choice, such as "at_limit", for reports.
| choice | The choice. |
Definition at line 584 of file cost.hpp.
Referenced by limit_fill_price_name().
|
inline |
Returns how many bars of an interval a year contains, for analytics::annualize_ratio.
Daily bars: trading_days. Intraday bars: the bars a session holds, times trading_days. A session that is not a whole number of bars ends with a shorter one, which counts: KRX's 390-minute session holds 390 one-minute bars (95,550 a year over 245 days) and 7 hourly ones, the last of them 30 minutes.
| interval | The bar interval. |
| session | The session window (used for intraday bars). |
| trading_days | Trading days per year, such as about 245 for KRX or 252 for US markets. |
Definition at line 47 of file clock.hpp.
Referenced by periods_per_year(), and summarize().
|
inline |
Summarizes a replay into a Report.
| result | The replay's result. |
| fills | The fill model the replay used, so the report states its costs and assumptions. |
| periods_per_year | Periods in a year, for the annualized Sharpe ratio (see backtest::periods_per_year); absent leaves it missing(). |
| risk_free | The risk-free rate per period, in the units of the returns. |
| std::invalid_argument | if periods_per_year is given, not positive, and the equity curve is not empty. |
Definition at line 326 of file report.hpp.
Referenced by summarize().