Package com.quantfinlib.backtest


package com.quantfinlib.backtest
Bar-based backtesting. Backtester is the classic engine (fills at the close, intrabar gap-aware stops); ExecutionAwareBacktester upgrades signals to parent orders worked through a pluggable ExecutionModel (InstantExecution, SorExecution, IcebergExecution, LastLookExecution — FX last-look rejects on adverse hold-window moves) with multi-bar fills and one-call TCA per ParentOrder; ExecutionAlgoBacktester answers the execution desk's own question — which benchmark algorithm, at what cost — by replaying execution.BenchmarkExecutor over a session's bars and grading it TCA-style (shortfall vs arrival, slippage vs session VWAP), with its simplifications stated in the javadoc. BenchmarkComparison scores a strategy the way an allocator does — alpha, beta, tracking error, information ratio, up/down capture against a benchmark — and DrawdownAnalytics reports drawdown STRUCTURE (episode depth and duration, time under water), because the number that fires clients is how long the pain lasted, not just how deep it went. Sub-packages: strategies (built-ins), validation (walk-forward, purged K-fold, CSCV overfit probability, deflated Sharpe), portfolio (multi-asset), and tick (event-driven tick-level engine).
  • Class
    Description
    Backtest execution parameters.
    Event-driven, single-instrument, long-only backtesting engine.
    Result of a backtest run: full equity curve (one point per bar), completed trade history, and derived performance metrics.
    BENCHMARK-RELATIVE performance — the numbers an allocator actually asks for.
     
    DRAWDOWN structure — because "max drawdown 18%" hides the number that actually fires clients: how LONG the pain lasted.
    One peak-to-recovery episode.
     
    Backtests the DYNAMIC execution stack over bar data — the bridge between execution.BenchmarkExecutor (built for live intervals) and the backtest lane: replay a session's bars, let the executor re-decide each bar exactly as it would live, fill against the bar with a TradeCostModel, and grade the result the way a TCA desk would (implementation shortfall vs arrival, slippage vs the session VWAP).
     
    The TCA-style verdict for one parent worked over one session.
    Execution-aware backtesting engine: strategy signals create parent orders that are worked through an ExecutionModel — routed by SorExecution, sliced by IcebergExecution, or filled instantly by InstantExecution.
    Result of an execution-aware backtest: the standard BacktestResult (equity curve, trades, performance metrics) plus the full parent-order / child-fill history, with one-call TCA per parent order.
    How parent orders turn into fills in an execution-aware backtest (ExecutionAwareBacktester).
    Iceberg execution: wraps another ExecutionModel and caps each bar's execution at the IcebergOrder state machine's visible tranche (optionally randomized), plus an optional participation cap versus the bar's volume.
    Baseline execution model: the full quantity fills at the bar close with commission and slippage folded into the all-in price — equivalent to the classic Backtester fill assumption.
    Last-look execution model — the missing realism for FX backtests: on ECN and single-dealer FX liquidity, the provider holds your order briefly and may reject it if the price moves against them during the hold.
    One parent order worked by the ExecutionAwareBacktester: the signal that created it, the arrival price (close at signal time — the TCA benchmark), and the child fills with the bar index each filled on.
    Computes PerformanceMetrics from an equity curve and trade history.
    Strategy performance analytics.
    Trading signal emitted by a strategy for a single bar.
    Smart-order-routed execution over a synthetic fragmented market.
     
    A completed round-trip trade.
    TRADE-LEVEL analytics — the numbers a discretionary reviewer asks for that a Sharpe ratio hides.
     
    A pluggable per-trade cost model — the ONE definition of "what a trade costs" shared by the backtest engines, so an execution-aware number and a survivorship-aware number can come out of the same run: TradeCostModel.flat(double) — a fixed all-in bps (the classic commission assumption, and the exact equivalent of the legacy commissionRate configs); TradeCostModel.institutional(double, double, double, int) — commission + half-spread + slippage + square-root market impact, with per-symbol ADV/vol estimated from the trailing bars via MarketImpactModel.estimate(com.quantfinlib.core.BarSeries, int, int).
    A bar-driven trading strategy.