Lean  $LEAN_TAG$
Initializer.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
17 using System.IO;
18 using QuantConnect.Util;
19 using QuantConnect.Logging;
21 
23 {
24  /// <summary>
25  /// Helper class to initialize a Lean engine
26  /// </summary>
27  public static class Initializer
28  {
29  /// <summary>
30  /// Basic common Lean initialization
31  /// </summary>
32  public static void Start()
33  {
34  try
35  {
36  var mode = "RELEASE";
37  #if DEBUG
38  mode = "DEBUG";
39  #endif
40 
41  Log.DebuggingEnabled = Config.GetBool("debug-mode");
42  var destinationDir = Globals.ResultsDestinationFolder;
43  if (!string.IsNullOrEmpty(destinationDir))
44  {
45  Directory.CreateDirectory(destinationDir);
46  Log.FilePath = Path.Combine(destinationDir, "log.txt");
47  }
48  Log.LogHandler = Composer.Instance.GetExportedValueByTypeName<ILogHandler>(Config.Get("log-handler", "CompositeLogHandler"));
49 
50  Log.Trace($"Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v{Globals.Version} Mode: {mode} ({(Environment.Is64BitProcess ? "64" : "32")}bit) Host: {Environment.MachineName}");
51  Log.Trace("Engine.Main(): Started " + DateTime.Now.ToShortTimeString());
52  }
53  catch (Exception e)
54  {
55  Log.Error(e);
56  throw;
57  }
58  }
59 
60  /// <summary>
61  /// Get and initializes System Handler
62  /// </summary>
64  {
66 
67  //Setup packeting, queue and controls system: These don't do much locally.
68  systemHandlers.Initialize();
69 
70  return systemHandlers;
71  }
72 
73  /// <summary>
74  /// Get and initializes Algorithm Handler
75  /// </summary>
76  public static LeanEngineAlgorithmHandlers GetAlgorithmHandlers(bool researchMode = false)
77  {
79  }
80  }
81 }