Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Ability to tag `Insight` and `PortfolioTarget` similar to `Order.Tag`

Open ArthurAsenheimer opened this issue 2 years ago • 0 comments

Expected Behavior

We can add a tag to an insight or portfolio target similar to Order.Tag.

Actual Behavior

Not supported.

Potential Solution

Implement the property Tag for insights and portfolio targets so that we can access it via Insight.Tag and PortfolioTarget.Tag.

Reproducing the Problem

Try adding a tag to an insight or portfolio target, for example: insight.Tag = "Hello World!". This throws an error (unknown property "Tag").

Motivation and Context

Tagging can provide additional information and help us to better understand the processes of an algorithm. In order to comply with the separation of concerns principle, we should develop the framework modules in a way that makes them independent from each other. Although this is powerful principle, it makes debugging/logging much more difficult. The use of tags represents a good compromise in my opinion as it does not violate the separation of concerns principle (we don't have to use tags for decision making) and at the same time it can provide additional information.

Here is an application scenario: Let's consider an AlphaModel that emit insights based an moving average crossovers + trailing stop. This means there can be more than one reason why an insight direction changed. It can be because of a moving average crossover or because of the trailing stop. We could add the tag insight.Tag = "Trailing stop triggered!" and pass it on to the execution model and there we could add it as a classical tag to the order and see it in the order history once the backtest finished.

The same goes for portfolio targets. PortfolioTarget.Tag could include information on why the target has changed (could be rebalancing, or insight direction change or something else).

System Information

QC Cloud

Checklist

  • [X] I have completely filled out this template
  • [X] I have confirmed that this issue exists on the current master branch
  • [X] I have confirmed that this is not a duplicate issue by searching issues
  • [X] I have provided detailed steps to reproduce the issue

ArthurAsenheimer avatar May 20 '22 08:05 ArthurAsenheimer