Clone our Wealth-Lab 8 Extension Demo project on GitHub to get a head start in developing your own Extensions!

Performance Visualizer API

This document details the API for building Performance Visualizer Extensions for Wealth-Lab 8. A Performance Visualizer occupies a tab in the Backtest Results section of the Strategy window, and lets you present the results of a backtest in a particular way.

Build Environment

You can create a Performance Visualizer in a .NET development tool such as Visual Studio 2022. Create a class library project that targets .NET8, then reference the WealthLab.WPF library DLL that you'll find in the WL8 installation folder.

Note: If you are using Visual Studio 2022, it will need to be updated to at least version 17.8.6 to use .NET8.

Your Performance Visualizer will be a class in this library that descends from VisualizerBase, which is defined in the WealthLab.WPF library, in the WealthLab.WPF namespace. After you implement and build your library, simply copy the resulting assembly DLL into the WL8 installation folder. The next time WL8 starts up, it will discover your Performance Visualizer, making it available in appropriate locations of the WL8 user interface.

Visual Studio 2022 Build Environment

ResultViewerBase

VisualizerBase is derived from the ResultViewerBase base class, defined in WealthLab.WPF. ResultViewerBase is derived from the WPF UserControl. ResultViewerBase contains additional members that can be useful when developing Visualizers. In particular, the ViewerName and GlyphResource properties control the text and image that appear in the Visualizer's tab in WL8.

Creating the Files in Visual Studio

To get started, it's best to create a new UserControl in Visual Studio, which generates the boilerplate XAML and CS classes. Next, change the CS file so that your class derives from VisualizerBase instead of UserControl. You'll need to add WealthLab.WPF to the using clause.

Open the XAML file and add an XMLNS reference to the WealthLab.WPF library. Change the base class in the XAML from UserControl to VisualizerBase. Here an example of what part of such a XAML file will look like:

Creating a Visualizer in Visual Studio

Accessing the Host (WL8) Environment

The IHost interface allows your extension to access information about the user's WealthLab environment. For example, the location of the user data folder, or obtaining a list of DataSets defined by the user. At any point in your extension's code base, you can access an instance of the IHost interface using the singleton class WLHost and its Instance property. Example:

//get user data folder
string folder = WLHost.Instance.DataFolder;

Visualizers for Specific Strategy Types

public virtual bool AllowForStrategyType(StrategyTypes st)

You can optionally override this property to specify which Strategy type(s) are supported by your Visualizer. If a Strategy of an unsupported type is opened, your Visualizer will not be added as a tab in the backtest results section of the Strategy window. The StrategyTypes enum contains the following values:

  • Code
  • BuildingBlock
  • Rotation
  • Compiled
  • MetaStrategy
  • TradeHistory

Visualizing Backtest Results

public virtual void Initialize()

Override this method to implement any one-time initialization that your Visualizer requires.

public virtual void Populate(Backtester backtester, Backtester backtesterBenchmark)

Override this method to implement the visualization of a backtest. You are passed two instances of the Backtester class. The first instance, backtester, contains the results of the Strategy backtest. The second instance, backtesterBenchmark, contains the results of the benchmark backtest, which is a buy & hold run on the benchmark symbol.

Consult the Backtester class reference for a list of the various properties available that describe the backtest results. Most notably the Metrics property, which exposes all of the performance metrics that are generated by WL8 ScoreCards.

public Backtester Backtester

Returns the instance of the Backtester that contains the Strategy performance results.

public Backtester BacktesterBenchmark

Returns the instance of the Backtester that contains the benchmark buy & hold results.

Interacting with the Strategy Window

public IStrategyHost ParentStrategyWindow

This property returns an instance of the IStrategyHost interface, which contains properties and methods that allow you to interact with the Strategy window hosting your Visualizer. You can, for example, cause the Strategy window to chart a specific symbol.