Skip to content

Commit

Permalink
Initialize report correctly (QuantConnect#7803)
Browse files Browse the repository at this point in the history
- Fix report initialization, adding CI tests
  • Loading branch information
Martin-Molinero authored Feb 21, 2024
1 parent d3928fb commit 2e9c7ad
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/report-generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Report Generator Tests

on:
push:
branches: ['*']
tags: ['*']
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Free space
run: df -h && rm -rf /opt/hostedtoolcache* && df -h

- uses: addnab/docker-run-action@v3
with:
image: quantconnect/lean:foundation
options: --workdir /__w/Lean/Lean -v /home/runner/work:/__w
shell: bash
run: |
# Build
dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln
# Run Backtest
cd ./Launcher/bin/Release && dotnet QuantConnect.Lean.Launcher.dll && cd ../../../
# Run Report
cd ./Report/bin/Release && dotnet ./QuantConnect.Report.dll --backtest-data-source-file ../../../Launcher/bin/Release/BasicTemplateFrameworkAlgorithm.json --close-automatically true
4 changes: 3 additions & 1 deletion Configuration/ReportArgumentParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
Expand Down Expand Up @@ -33,6 +33,8 @@ public static class ReportArgumentParser

private static readonly List<CommandLineOption> Options = new List<CommandLineOption>
{
new CommandLineOption("close-automatically", CommandOptionType.SingleValue),
new CommandLineOption("data-folder", CommandOptionType.SingleValue),
new CommandLineOption("strategy-name", CommandOptionType.SingleValue, "Strategy name"),
new CommandLineOption("strategy-description", CommandOptionType.SingleValue, "Strategy description"),
new CommandLineOption("live-data-source-file", CommandOptionType.SingleValue, "Live source data json file"),
Expand Down
13 changes: 9 additions & 4 deletions Report/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
*/

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Newtonsoft.Json;
using QuantConnect.Configuration;
using QuantConnect.Util;
using System.Diagnostics;
using QuantConnect.Logging;
using QuantConnect.Packets;
using QuantConnect.Lean.Engine;
using System.Collections.Generic;
using QuantConnect.Configuration;

namespace QuantConnect.Report
{
Expand All @@ -36,6 +38,9 @@ static void Main(string[] args)
{
Config.MergeCommandLineArgumentsWithConfiguration(ReportArgumentParser.ParseArguments(args));
}

// initialize required lean handlers
LeanEngineAlgorithmHandlers.FromConfiguration(Composer.Instance);
var name = Config.Get("strategy-name");
var description = Config.Get("strategy-description");
var version = Config.Get("strategy-version");
Expand Down Expand Up @@ -159,7 +164,7 @@ static void Main(string[] args)

Log.Trace("QuantConnect.Report.Main(): Completed.");

if (!Console.IsInputRedirected)
if (!Console.IsInputRedirected && !Config.GetBool("close-automatically"))
{
Console.ReadKey();
}
Expand Down

0 comments on commit 2e9c7ad

Please sign in to comment.