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

Position ScoreCard API

This document details the API for building Position ScoreCard extensions for Wealth-Lab 8. A Position ScoreCard generates a roster of Performance Metrics (such as Profit, MAE, and ProfitPerBar) based on a single Position in a set of Backtest results. These Position Performance Metrics can be selected for display in the Positions Visualizer in WL8 and are available in other Visualizers such as the Position Metrics Visualizer in the Power Pack Extension.

Build Environment

You can create a Position ScoreCard in a .NET development tool such as Visual Studio 2022. Create a class library project that targets .NET8, then reference the WealthLab.Core 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 Position ScoreCard will be a class in this library that descends from PositionScoreCardBase, which is defined in the WealthLab.Core library, in the WealthLab.Backtest 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 Position ScoreCard, making it available in appropriate locations of the WL8 user interface.

Visual Studio 2022 Build Environment

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;

Descriptive Properties

public abstract string Name

Return the name of the Position ScoreCard, which appears in the Position Metrics Preference page in WL8 where the user can select which Position Metrics to include in the Positions Visualizer.

public abstract List<string> PositionMetricNames

Return a List containing the names of the Performance Metrics that your Position ScoreCard calculates and returns.

Calculating Metrics

public abstract double CalculatePositionMetric(Backtester bt, Position pos, string metricName)

Override this method to calculate the Position ScoreCard's Performance Metric specified by metricName, for the Position instance provided in the pos parameter. The instance of the Backtester class that generated the backtest is also available via the bt parameter. The calculated metric value should be returned as a floating-point double value.

Metric Properties

public abstract bool ColorizeMetric(string metric)

Return true if the specified metric should be colorized by profit (green)/loss (red) when displayed in the WL8 Positions Visualizer.

public abstract int DecimalsMetric(string metric)

Return the number of decimal places to use when displaying the metric value in the WL8 Positions Visualizer.

Position Metrics