Files
quantconnect--lean/Engine/Initializer.cs
T
Martin-Molinero 41636c94c3
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Common engine initialization (#5809)
- Create Lean common engine initialization class, which will be called
  by research and Lean launcher
- Fix backtest deserialization bug due to failing to handle decimal
  value
2021-07-29 21:14:17 -03:00

73 lines
2.7 KiB
C#

/*
* 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 QuantConnect.Util;
using QuantConnect.Logging;
using QuantConnect.Configuration;
namespace QuantConnect.Lean.Engine
{
/// <summary>
/// Helper class to initialize a Lean engine
/// </summary>
public static class Initializer
{
/// <summary>
/// The current Lean Engine System handlers
/// </summary>
public static LeanEngineSystemHandlers LeanEngineSystemHandlers { get; private set; }
/// <summary>
/// The current Lean Engine Algorithm handlers
/// </summary>
public static LeanEngineAlgorithmHandlers LeanEngineAlgorithmHandlers { get; private set; }
/// <summary>
/// Basic common Lean initialization
/// </summary>
public static void Start()
{
try
{
var mode = "RELEASE";
#if DEBUG
mode = "DEBUG";
#endif
Log.DebuggingEnabled = Config.GetBool("debug-mode");
Log.FilePath = Path.Combine(Config.Get("results-destination-folder"), "log.txt");
Log.LogHandler = Composer.Instance.GetExportedValueByTypeName<ILogHandler>(Config.Get("log-handler", "CompositeLogHandler"));
Log.Trace($"Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v{Globals.Version} Mode: {mode} ({(Environment.Is64BitProcess ? "64" : "32")}bit) Host: {Environment.MachineName}");
Log.Trace("Engine.Main(): Started " + DateTime.Now.ToShortTimeString());
LeanEngineSystemHandlers = LeanEngineSystemHandlers.FromConfiguration(Composer.Instance);
//Setup packeting, queue and controls system: These don't do much locally.
LeanEngineSystemHandlers.Initialize();
LeanEngineAlgorithmHandlers = LeanEngineAlgorithmHandlers.FromConfiguration(Composer.Instance);
}
catch (Exception e)
{
Log.Error(e);
throw;
}
}
}
}