Strategy Evolver Visualizer API
This document details the API for building Strategy Evolver Visualizer Extensions for Wealth-Lab 8. A Strategy Evolver Visualizer appears after you stop an evolution session of the Strategy Genetic Evolver tool. Each Visualizer adds a new tab to the Strategy Evolver window and portrays the results of the Evolver run in some distinct way.
Build Environment
You can create a Strategy Evolver 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 Strategy Evolver Visualizer will be a class in this library that descends from StrategyEvolverVisualizerBase, 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 Strategy Evolver Visualizer, making it available in appropriate locations of the WL8 user interface.
ResultViewerBase
StrategyEvolverVisualizerBase 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 StrategyEvolverVisualizerBase 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 StrategyEvolverVisualizerBase. Here an example of what part of such a XAML file will look like:
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;
Accessing the Evolver Results
Results
public StrategyEvolverResults Results
The Results property returns an instance of the StrategyEvolverResults class, which contains the complete results of the Strategy Evolver session. This includes the most recent run, and any Apex runs which might have been completed.
Methods
Intitialize
public virtual void Initialize()
Override the Initialize method to perform one-time initialization for your Visualizer.
CleanUp
public virtual void Cleanup()
Override the Cleanup method to perform any required cleanup for your Visualizer.
Populate
public virtual void Populate(StrategyEvolverResults results)
Override the Populate method to render the Strategy Evolver results passed in the results parameter to your Visualizer.
Accessing the Selected Metrics
MetricNames
public List<string> MetricNames
The MetricsNames property returns a List<string> containing the names of the performance metrics used during the Evolver session.
Accessing the Parent Evolver Window
Host
public IStrategyEvolverHost Host
Returns an instance of the IStrategyEvolverHost interface that provides a way to interact with the Strategy Evolver window that is hosting your Visualizer.