Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backtest self-categorization #7683

Conversation

jhonabreul
Copy link
Collaborator

@jhonabreul jhonabreul commented Jan 9, 2024

Description

  • Backtest name can now be set from the algorithm's Initialize method.
  • The algorithm name is limited to at most 200 characters.
  • Additionally, backtests can be tagged using the AddTag and SetTags for categorization.
  • Tags can be set outside the the Initialize method and are limited to at most 20 tags per backtest.

Example:

public override void Initialize()
{
    SetStartDate(2024, 01, 05);
    SetEndDate(2024, 01, 05);
    SetCash(100000);

    // ...

    SetName("Backtest Name");

    AddTag("Some tag");
    AddTag("Another tag");
}
def Initialize(self):
{
    self.SetStartDate(2024, 01, 05)
    self.SetEndDate(2024, 01, 05)
    self.SetCash(100000)

    # ...

    self.SetName("Backtest Name")

    self.AddTag("Some tag")
    self.AddTag("Another tag")
}

The final name and tags are available in the results' file "AlgorithmConfiguration" property:

{
  ...,
  "AlgorithmConfiguration": {
    "Name": "Backtest Name",
    "Tags": [
      "Some tag",
      "Another tag"
    ],
    "AccountCurrency": "USD",
    "Brokerage": 0,
    "AccountType": 0,
    "Parameters": {
      "intrinio-username": "",
      "intrinio-password": "",
      "ema-fast": "10",
      "ema-slow": "20"
    },
    "OutOfSampleMaxEndDate": null,
    "OutOfSampleDays": 0,
    "StartDate": "2015-12-24 00:00:00",
    "EndDate": "2015-12-24 23:59:59"
  }
}

During backtest run, name and tags updates are also communicated through the messaging handler using the new packet classes AlgorithmNameUpdatePacket and AlgorithmTagsUpdatePacket .

Related Issue

Close #7534

Motivation and Context

Requires Documentation Change

How Has This Been Tested?

Backtest runs

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@jhonabreul jhonabreul force-pushed the feature-7534-backtest-self-categorization branch from 63ed271 to b8885e1 Compare January 9, 2024 16:11
@jhonabreul jhonabreul requested review from Martin-Molinero and removed request for Martin-Molinero January 12, 2024 19:09
Copy link
Member

@Martin-Molinero Martin-Molinero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good, minor comments shared

@jhonabreul jhonabreul force-pushed the feature-7534-backtest-self-categorization branch from 0f8a7d3 to 0837f47 Compare January 17, 2024 20:29
Copy link
Member

@Martin-Molinero Martin-Molinero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍 looking good, shared mind comments

@jhonabreul jhonabreul force-pushed the feature-7534-backtest-self-categorization branch from 2ab7ef3 to 8b88fe9 Compare January 29, 2024 19:06
@Martin-Molinero Martin-Molinero merged commit d4ba8cc into QuantConnect:master Jan 30, 2024
10 of 12 checks passed
@jhonabreul jhonabreul deleted the feature-7534-backtest-self-categorization branch January 30, 2024 20:31
@Martin-Molinero Martin-Molinero mentioned this pull request Jan 30, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backtest Self-Categorization
2 participants