/* * 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.Collections.Generic; using Newtonsoft.Json; namespace QuantConnect.Packets { /// /// Algorithm Node Packet is a work task for the Lean Engine /// public class AlgorithmNodePacket : Packet { /// /// Default constructor for the algorithm node: /// /// public AlgorithmNodePacket(PacketType type) : base(type) { } /// /// User Id placing request /// [JsonProperty(PropertyName = "iUserID")] public int UserId = 0; /// User API Token [JsonProperty(PropertyName = "sUserToken")] public string UserToken = ""; /// /// Project Id of the request /// [JsonProperty(PropertyName = "iProjectID")] public int ProjectId = 0; /// /// Algorithm Id - BacktestId or DeployId - Common Id property between packets. /// [JsonProperty(PropertyName = "sAlgorithmID")] public string AlgorithmId { get { if (Type == PacketType.LiveNode || Type == PacketType.AlphaNode) { return ((LiveNodePacket)this).DeployId; } return ((BacktestNodePacket)this).BacktestId; } } /// /// User session Id for authentication /// [JsonProperty(PropertyName = "sSessionID")] public string SessionId = ""; /// /// User subscriptions state - free or paid. /// [JsonProperty(PropertyName = "sUserPlan")] public UserPlan UserPlan = UserPlan.Free; /// /// Language flag: Currently represents IL code or Dynamic Scripted Types. /// [JsonProperty(PropertyName = "eLanguage")] public Language Language = Language.CSharp; /// /// Server type for the deployment (512, 1024, 2048) /// [JsonProperty(PropertyName = "sServerType")] public ServerType ServerType = ServerType.Server512; /// /// Unique compile id of this backtest /// [JsonProperty(PropertyName = "sCompileID")] public string CompileId = ""; /// /// Version number identifier for the lean engine. /// [JsonProperty(PropertyName = "sVersion")] public string Version; /// /// An algorithm packet which has already been run and is being redelivered on this node. /// In this event we don't want to relaunch the task as it may result in unexpected behaviour for user. /// [JsonProperty(PropertyName = "bRedelivered")] public bool Redelivered = false; /// /// Algorithm binary with zip of contents /// [JsonProperty(PropertyName = "oAlgorithm")] public byte[] Algorithm = new byte[] { }; /// /// Request source - Web IDE or API - for controling result handler behaviour /// [JsonProperty(PropertyName = "sRequestSource")] public string RequestSource = "WebIDE"; /// /// The maximum amount of RAM (in MB) this algorithm is allowed to utilize /// [JsonProperty(PropertyName = "iMaxRamAllocation")] public int RamAllocation { get { return Controls.RamAllocation; } } /// /// Specifies values to control algorithm limits /// [JsonProperty(PropertyName = "oControls")] public Controls Controls; /// /// The parameter values used to set algorithm parameters /// [JsonProperty(PropertyName = "aParameters")] public Dictionary Parameters = new Dictionary(); /// /// String name of the HistoryProvider we're running with /// [JsonProperty(PropertyName = "sHistoryProvider")] public string HistoryProvider = ""; /// /// Gets a unique name for the algorithm defined by this packet /// public string GetAlgorithmName() { return $"{UserId}-{ProjectId}-{AlgorithmId}"; } } }