Skip to content

Commit

Permalink
Merge pull request QuantConnect#3704 from QuantConnect/research-impro…
Browse files Browse the repository at this point in the history
…vements

QuantBook improvements
  • Loading branch information
jaredbroad authored Oct 10, 2019
2 parents b2e4cdb + 4010c0b commit fb296e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Common/Packets/BacktestNodePacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Newtonsoft.Json;

Expand All @@ -26,6 +27,10 @@ namespace QuantConnect.Packets
/// </summary>
public class BacktestNodePacket : AlgorithmNodePacket
{
// default random id, static so its one per process
private static readonly string DefaultId
= Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);

/// <summary>
/// Name of the backtest as randomly defined in the IDE.
/// </summary>
Expand All @@ -36,7 +41,7 @@ public class BacktestNodePacket : AlgorithmNodePacket
/// BacktestId / Algorithm Id for this task
/// </summary>
[JsonProperty(PropertyName = "sBacktestID")]
public string BacktestId = "";
public string BacktestId = DefaultId;

/// <summary>
/// Backtest start-date as defined in the Initialize() method.
Expand Down
9 changes: 9 additions & 0 deletions Jupyter/QuantBook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using QuantConnect.Logging;
using QuantConnect.Packets;

namespace QuantConnect.Jupyter
Expand All @@ -45,6 +46,12 @@ public class QuantBook : QCAlgorithm
private dynamic _pandas;
private IDataCacheProvider _dataCacheProvider;

static QuantBook()
{
Logging.Log.LogHandler =
Composer.Instance.GetExportedValueByTypeName<ILogHandler>(Config.Get("log-handler", "CompositeLogHandler"));
}

/// <summary>
/// <see cref = "QuantBook" /> constructor.
/// Provides access to data for quantitative analysis
Expand All @@ -68,6 +75,8 @@ public QuantBook() : base()
var composer = new Composer();
var algorithmHandlers = LeanEngineAlgorithmHandlers.FromConfiguration(composer);
var systemHandlers = LeanEngineSystemHandlers.FromConfiguration(composer);
// init the API
systemHandlers.Initialize();
systemHandlers.LeanManager.Initialize(systemHandlers,
algorithmHandlers,
new BacktestNodePacket(),
Expand Down

0 comments on commit fb296e2

Please sign in to comment.