Lean  $LEAN_TAG$
StatisticsResults.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.Collections.Generic;
17 
19 {
20  /// <summary>
21  /// The <see cref="StatisticsResults"/> class represents total and rolling statistics for an algorithm
22  /// </summary>
23  public class StatisticsResults
24  {
25  /// <summary>
26  /// The performance of the algorithm over the whole period
27  /// </summary>
28  public AlgorithmPerformance TotalPerformance { get; private set; }
29 
30  /// <summary>
31  /// The rolling performance of the algorithm over 1, 3, 6, 12 month periods
32  /// </summary>
33  public Dictionary<string, AlgorithmPerformance> RollingPerformances { get; private set; }
34 
35  /// <summary>
36  /// Returns a summary of the algorithm performance as a dictionary
37  /// </summary>
38  public Dictionary<string, string> Summary { get; private set; }
39 
40  /// <summary>
41  /// Initializes a new instance of the <see cref="StatisticsResults"/> class
42  /// </summary>
43  /// <param name="totalPerformance">The algorithm total performance</param>
44  /// <param name="rollingPerformances">The algorithm rolling performances</param>
45  /// <param name="summary">The summary performance dictionary</param>
46  public StatisticsResults(AlgorithmPerformance totalPerformance, Dictionary<string, AlgorithmPerformance> rollingPerformances, Dictionary<string, string> summary)
47  {
48  TotalPerformance = totalPerformance;
49  RollingPerformances = rollingPerformances;
50  Summary = summary;
51  }
52 
53  /// <summary>
54  /// Initializes a new instance of the <see cref="StatisticsResults"/> class
55  /// </summary>
57  {
59  RollingPerformances = new Dictionary<string, AlgorithmPerformance>();
60  Summary = new Dictionary<string, string>();
61  }
62 
63  internal void AddCustomSummaryStatistics(IDictionary<string, string> customSummary)
64  {
65  foreach (var kvp in customSummary)
66  {
67  if (!Summary.ContainsKey(kvp.Key))
68  {
69  Summary[kvp.Key] = kvp.Value;
70  }
71  }
72  }
73  }
74 }