Lean  $LEAN_TAG$
Result.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 Newtonsoft.Json;
18 using QuantConnect.Orders;
19 using QuantConnect.Packets;
20 using System.Collections.Generic;
21 
22 namespace QuantConnect
23 {
24  /// <summary>
25  /// Base class for backtesting and live results that packages result data.
26  /// <see cref="LiveResult"/>
27  /// <see cref="BacktestResult"/>
28  /// </summary>
29  public class Result
30  {
31  /// <summary>
32  /// Charts updates for the live algorithm since the last result packet
33  /// </summary>
34  [JsonProperty(PropertyName = "Charts", NullValueHandling = NullValueHandling.Ignore)]
35  public IDictionary<string, Chart> Charts;
36 
37  /// <summary>
38  /// Order updates since the last result packet
39  /// </summary>
40  [JsonProperty(PropertyName = "Orders", NullValueHandling = NullValueHandling.Ignore)]
41  public IDictionary<int, Order> Orders;
42 
43  /// <summary>
44  /// OrderEvent updates since the last result packet
45  /// </summary>
46  [JsonProperty(PropertyName = "OrderEvents", NullValueHandling = NullValueHandling.Ignore)]
47  public List<OrderEvent> OrderEvents;
48 
49  /// <summary>
50  /// Trade profit and loss information since the last algorithm result packet
51  /// </summary>
52  [JsonProperty(PropertyName = "ProfitLoss", NullValueHandling = NullValueHandling.Ignore)]
53  public IDictionary<DateTime, decimal> ProfitLoss;
54 
55  /// <summary>
56  /// Statistics information sent during the algorithm operations.
57  /// </summary>
58  /// <remarks>Intended for update mode -- send updates to the existing statistics in the result GUI. If statistic key does not exist in GUI, create it</remarks>
59  [JsonProperty(PropertyName = "Statistics", NullValueHandling = NullValueHandling.Ignore)]
60  public IDictionary<string, string> Statistics;
61 
62  /// <summary>
63  /// Runtime banner/updating statistics in the title banner of the live algorithm GUI.
64  /// </summary>
65  [JsonProperty(PropertyName = "RuntimeStatistics", NullValueHandling = NullValueHandling.Ignore)]
66  public IDictionary<string, string> RuntimeStatistics;
67 
68  /// <summary>
69  /// State of the result packet.
70  /// </summary>
71  [JsonProperty(PropertyName = "State", NullValueHandling = NullValueHandling.Ignore)]
72  public IDictionary<string, string> State;
73 
74  /// <summary>
75  /// Server status information, including CPU/RAM usage, ect...
76  /// </summary>
77  [JsonProperty(PropertyName = "ServerStatistics", NullValueHandling = NullValueHandling.Ignore)]
78  public IDictionary<string, string> ServerStatistics;
79 
80  /// <summary>
81  /// The algorithm's configuration required for report generation
82  /// </summary>
83  [JsonProperty(PropertyName = "AlgorithmConfiguration", NullValueHandling = NullValueHandling.Ignore)]
85 
86  /// <summary>
87  /// Creates new empty instance
88  /// </summary>
89  public Result()
90  {
91  }
92 
93  /// <summary>
94  /// Creates a new result from the given parameters
95  /// </summary>
96  public Result(BaseResultParameters parameters)
97  {
98  Charts = parameters.Charts;
99  Orders = parameters.Orders;
100  ProfitLoss = parameters.ProfitLoss;
101  Statistics = parameters.Statistics;
103  OrderEvents = parameters.OrderEvents;
105  State = parameters.State;
106  }
107  }
108 }