Lean  $LEAN_TAG$
Packet.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 
17 using Newtonsoft.Json;
18 using Newtonsoft.Json.Converters;
19 
20 namespace QuantConnect.Packets
21 {
22  /// <summary>
23  /// Base class for packet messaging system
24  /// </summary>
25  public class Packet
26  {
27  /// <summary>
28  /// Packet type defined by a string enum
29  /// </summary>
30  public PacketType Type { get; set; } = PacketType.None;
31 
32  /// <summary>
33  /// User unique specific channel endpoint to send the packets
34  /// </summary>
35  public virtual string Channel { get; set; } = "";
36 
37  /// <summary>
38  /// Initialize the base class and setup the packet type.
39  /// </summary>
40  /// <param name="type">PacketType for the class.</param>
41  public Packet(PacketType type)
42  {
43  Channel = "";
44  Type = type;
45  }
46  }
47 
48  /// <summary>
49  /// Classifications of internal packet system
50  /// </summary>
51  [JsonConverter(typeof(StringEnumConverter))]
52  public enum PacketType
53  {
54  /// Default, unset:
55  None,
56 
57  /// Base type for backtest and live work
59 
60  /// Autocomplete Work Packet
62 
63  /// Result of the Autocomplete Job:
65 
66  /// Controller->Backtest Node Packet:
67  BacktestNode,
68 
69  /// Packet out of backtest node:
71 
72  /// API-> Controller Work Packet:
74 
75  /// Controller -> Live Node Packet:
76  LiveNode,
77 
78  /// Live Node -> User Packet:
79  LiveResult,
80 
81  /// API -> Controller Packet:
82  LiveWork,
83 
84  /// Node -> User Algo Security Types
86 
87  /// Controller -> User Error in Backtest Settings:
89 
90  /// Nodes -> User Algorithm Status Packet:
92 
93  /// API -> Compiler Work Packet:
94  BuildWork,
95 
96  /// Compiler -> User Build Success
97  BuildSuccess,
98 
99  /// Compiler -> User, Compile Error
100  BuildError,
101 
102  /// Node -> User Algorithm Runtime Error
103  RuntimeError,
104 
105  /// Error is an internal handled error packet inside users algorithm
106  HandledError,
107 
108  /// Nodes -> User Log Message
109  Log,
110 
111  /// Nodes -> User Debug Message
112  Debug,
113 
114  /// Nodes -> User, Order Update Event
115  OrderEvent,
116 
117  /// Boolean true/false success
118  Success,
119 
120  /// History live job packets
121  History,
122 
123  /// Result from a command
125 
126  /// Hook from git hub
127  GitHubHook,
128 
129  /// Documentation result from docs server
131 
132  /// Documentation request to the docs server
134 
135  /// Debug packet generated by Lean
136  SystemDebug,
137 
138  /// Packet containing insights generated by the algorithm
139  AlphaResult,
140 
141  /// Alpha API -> Controller packet
142  AlphaWork,
143 
144  /// Alpha Controller -> Alpha Node packet
145  AlphaNode,
146 
147  /// Packet containing list of algorithms to run as a regression test
149 
150  /// Packet containing a heartbeat
152 
153  /// Used when debugging to send status updates
155 
156  /// Optimization Node Packet:
158 
159  /// Optimization Estimate Packet:
161 
162  /// Optimization work status update
163  OptimizationStatus,
164 
165  /// Optimization work result
167 
168  /// Aggregated packets
169  Aggregated,
170 
171  /// Query the language model
173 
174  /// Send feedback to a language model response
176 
177  /// The language models response
179 
180  /// Language model code analysis
182 
183  /// Language model chat work
185 
186  /// Language model chat response
188 
189  /// Algorithm name update
191 
192  /// Algorithm tags update
194  }
195 }