The Backtester class is responsible for performing backtest runs in WL8, and returning information about those runs. This document will focus on the Backtester properties that provide performance information about backtest runs, typically for use in the development of ScoreCard or Performance Visualizer extensions.
Returns the Backtester instance for the benchmark comparison backtest run. This property might contain null, in which case it is most likely the benchmark backtest itself that is running.
Returns a TimeSeries instance that represents how much simulated cash was available during the backtest.
Returns the total simulated cash interest earned during the backtest.
Returns the total amount of simulated commission paid in the backtest.
Returns the simulated cash available at the end of the backtest.
Returns the total equity (capital) at the end of the backtest.
Returns a TimeSeries containing the daily percentage returns of backtest equity curve.
Returns the amount of simulated dividends collected in the backtest. Dividends are captured from EventDataPoint instances in the BarHistory EventDataPoints property with "dividend" in the instance's Name property. Deduping logic is used to ensure that only a single dividend is accounted for each day, even if multiple Event Data Providers that return dividends are enabled.
Returns a TimeSeries instance of the backtest drawdown, which is the largest peak to trough decline of the equity over time. Drawdown is calculated on a closing price basis, and does not consider highs and lows.
Returns a TimeSeries instance of the backtest drawdown percentage, which is the largest peak to trough percentage decline of the equity over time. Drawdown is calculated on a closing price basis, and does not consider highs and lows.
Returns a TimeSeries instance that represents the equity curve of the backtest.
Returns the amount of simulated interest paid for going on margin in the backtest.
Returns a TimeSeries containing the negative monthly percentage returns of the backtest. The negative returns are used when calculating the Sortino Ratio.
Returns a TimeSeries containing the monthly percentage returns of backtest equity curve.
Returns the net profit of the backtest.
Returns the percentage net profit of the backtest.
Returns a PositionList instance that contains Position instances representing the positions that were flagged as NSF (non-sufficient funds) and thus not included in the performance results. The Backtest still tracks these NSF positions during a backtest so the Strategy's integrity can be maintained. It also issues exit signals for NSF positions, since you might have initiated an entry into an NSF position in your live trading account, even if the Backtester did not have enough simulated capital to enter the trade.
Returns the number of currently open position in the backtest, excluding Position instances that were flagged NSF (non-sufficient funds).
Returns a TimeSeries instance containing the number of open positions over time during the backtest.
Returns a list of all available Position Metrics for this backtest run. This includes all of the default Position Metrics, such as Profit and BarsHeld, as well as any Strategy assigned PositionMetrics that were the result of calls to Position.SetMetric or Transaction.SetPositionMetric. Typically used by certain Performance Visualizers that deal with Positions, such as the Position Metrics Visualizer in the Power Pack Extension.
Returns the average percentage return of the 1-year US Treasury yield for the time span of the backtest. Used in calculating Sharpe Ratio and Sortino Ratio in the Basic Scorecard.
Returns a TimeSeries instance containing the number of trades at each point in time for the backtest.
Returns a list of the Transaction instances that represent all of the buy, sell, short, and cover trades that were placed.
Returns a TimeSeries containing the yearly percentage returns of backtest equity curve.
Returns the backtest settings (instance of the BacktestSettings class) used in the backtest.
Returns the context in which the Strategy is being executed. Possible values are:
Returns the positing sizing method (instance of the PositionSize class) used in the backtest.
Returns the starting capital that was used for the backtest.
Returns the instance of the Strategy class.
Returns a List containing the BarHistory instances for the symbols that were backtested.
The Metrics property returns an instance of the dynamic class that contains various performance metrics from the ScoreCards available in WL8. ScoreCards assign named property values to the Metrics propety for the performance metrics that they calculate. For example, the net profit of the backtest run is assigned to the Metrics.NetProfit property, and the APR to the Metrics.APR property. Performance Visualizers typically access these metrics values when depicting the backtest performance in an individual way.
Assign a value to Backtester.CancelationCode in your Strategy to cause separate exit orders that occur after the assignment to be grouped into one logical unit. When one of the exit orders fills, any other open exit orders with the same CancelationCode will be canceled. The Backtester assigns the CancelationCode to the exit orders at the time of their creation behind the scenes (while processing PlaceTrade or ClosePosition.)
The see an example of how to use this, open the C# Code for a Building Block Strategy.