forked from QuantConnect/Lean
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3bcfd5
commit f66a682
Showing
35 changed files
with
3,684 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
* | ||
*/ | ||
|
||
using System; | ||
using Python.Runtime; | ||
using QuantConnect.Logging; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.Extensions.CommandLineUtils; | ||
|
||
namespace QuantConnect.Configuration | ||
{ | ||
/// <summary> | ||
/// Command Line arguments parser for Report Creator | ||
/// </summary> | ||
public static class ReportArgumentParser | ||
{ | ||
private const string ApplicationName = "Report Creator"; | ||
|
||
private const string ApplicationDescription = | ||
"LEAN Report Creator generates beautiful PDF reports from your backtesting strategies for sharing with prospective partners."; | ||
|
||
private const string ApplicationHelpText = | ||
"If you are looking for help, please go to https://www.quantconnect.com/docs"; | ||
|
||
private static readonly List<CommandLineOption> Options = new List<CommandLineOption> | ||
{ | ||
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"), | ||
new CommandLineOption("backtest-data-source-file", CommandOptionType.SingleValue, "Backtest source data json file"), | ||
new CommandLineOption("report-destination", CommandOptionType.SingleValue, "Destination of processed report file") | ||
}; | ||
|
||
/// <summary> | ||
/// Parse and construct the args. | ||
/// </summary> | ||
public static Dictionary<string, object> ParseArguments(string[] args) | ||
{ | ||
return ApplicationParser.Parse(ApplicationName, ApplicationDescription, ApplicationHelpText, args, Options); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp60</s:String> | ||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_INVOCATION_PARS/@EntryValue">INSIDE</s:String> | ||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String> | ||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">True</s:Boolean> | ||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">CHOP_IF_LONG</s:String> | ||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue">True</s:Boolean> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Quant/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=QUANTCONNECT/@EntryIndexedValue">True</s:Boolean> | ||
</wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. | ||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
using System; | ||
using System.IO; | ||
using Newtonsoft.Json; | ||
using QuantConnect.Configuration; | ||
using QuantConnect.Logging; | ||
using QuantConnect.Orders; | ||
using QuantConnect.Packets; | ||
|
||
namespace QuantConnect.Report | ||
{ | ||
/// <summary> | ||
/// Lean Report creates a PDF strategy summary from the backtest and live json objects. | ||
/// </summary> | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
// Parse report arguments and merge with config to use in report creator: | ||
if (args.Length > 0) | ||
{ | ||
Config.MergeCommandLineArgumentsWithConfiguration(ReportArgumentParser.ParseArguments(args)); | ||
} | ||
var name = Config.Get("strategy-name"); | ||
var description = Config.Get("strategy-description"); | ||
var version = Config.Get("strategy-version"); | ||
var backtestDataFile = Config.Get("backtest-data-source-file"); | ||
var liveDataFile = Config.Get("live-data-source-file"); | ||
var destination = Config.Get("report-destination"); | ||
|
||
//Set the Order Parser For JSON: | ||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings | ||
{ | ||
Converters = { new OrderJsonConverter() } | ||
}; | ||
|
||
// Parse content from source files into result objects | ||
Log.Trace($"QuantConnect.Report.Main(): Parsing source files...{backtestDataFile}, {liveDataFile}"); | ||
var backtest = JsonConvert.DeserializeObject<BacktestResult>(File.ReadAllText(backtestDataFile)); | ||
|
||
LiveResult live = null; | ||
if (liveDataFile != string.Empty) | ||
{ | ||
live = JsonConvert.DeserializeObject<LiveResult>(File.ReadAllText(liveDataFile)); | ||
} | ||
|
||
//Create a new report | ||
Log.Trace("QuantConnect.Report.Main(): Instantiating report..."); | ||
var report = new Report(name, description, version, backtest, live); | ||
|
||
// Generate the html content | ||
Log.Trace("QuantConnect.Report.Main(): Starting content compile..."); | ||
var html = report.Compile(); | ||
|
||
//Write it to target destination. | ||
if (destination != string.Empty) | ||
{ | ||
Log.Trace($"QuantConnect.Report.Main(): Writing content to file {destination}"); | ||
File.WriteAllText(destination, html); | ||
} | ||
else | ||
{ | ||
Console.Write(html); | ||
} | ||
Log.Trace("QuantConnect.Report.Main(): Completed."); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("QuantConnect.Report")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("QuantConnect.Report")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("2431419f-8bc6-4f59-944e-9a1cd28982df")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.