/* * 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; using System.Collections.Generic; using System.IO; using Newtonsoft.Json; using QuantConnect.Interfaces; namespace QuantConnect.Packets { /// /// Specifies values used to control algorithm limits /// public class Controls { /// /// The maximum number of minute symbols /// [JsonProperty(PropertyName = "iMinuteLimit")] public int MinuteLimit; /// /// The maximum number of second symbols /// [JsonProperty(PropertyName = "iSecondLimit")] public int SecondLimit; /// /// The maximum number of tick symbol /// [JsonProperty(PropertyName = "iTickLimit")] public int TickLimit; /// /// Ram allocation for this algorithm in MB /// [JsonProperty(PropertyName = "iMaxRamAllocation")] public int RamAllocation; /// /// CPU allocation for this algorithm /// [JsonProperty(PropertyName = "dMaxCpuAllocation")] public decimal CpuAllocation; /// /// The user backtesting log limit /// [JsonProperty(PropertyName = "iBacktestLogLimit")] public int BacktestLogLimit; /// /// The daily log limit of a user /// [JsonProperty(PropertyName = "iDailyLogLimit")] public int DailyLogLimit; /// /// The remaining log allowance for a user /// [JsonProperty(PropertyName = "iRemainingLogAllowance")] public int RemainingLogAllowance; /// /// Maximimum number of insights we'll store and score in a single backtest /// [JsonProperty(PropertyName = "iBacktestingMaxInsights")] public int BacktestingMaxInsights; /// /// Maximimum number of orders we'll allow in a backtest. /// [JsonProperty(PropertyName = "iBacktestingMaxOrders")] public int BacktestingMaxOrders { get; set; } /// /// Limits the amount of data points per chart series. Applies only for backtesting /// [JsonProperty(PropertyName = "iMaximumDataPointsPerChartSeries")] public int MaximumDataPointsPerChartSeries; /// /// The amount seconds used for timeout limits /// [JsonProperty(PropertyName = "iSecondTimeOut")] public int SecondTimeOut; /// /// Sets parameters used for determining the behavior of the leaky bucket algorithm that /// controls how much time is available for an algorithm to use the training feature. /// [JsonProperty(PropertyName = "oTrainingLimits")] public LeakyBucketControlParameters TrainingLimits; /// /// Limits the total size of storage used by /// [JsonProperty(PropertyName = "storageLimitMB")] public int StorageLimitMB; /// /// Limits the number of files to be held under the /// [JsonProperty(PropertyName = "storageFileCountMB")] public int StorageFileCount; /// /// Holds the permissions for the object store /// [JsonProperty(PropertyName = "storagePermissions")] public FileAccess StoragePermissions; /// /// The interval over which the will persistence the contents of /// the object store /// [JsonProperty(PropertyName = "persistenceIntervalSeconds")] public int PersistenceIntervalSeconds; /// /// Gets list of streaming data permissions /// [JsonProperty(PropertyName = "streamingDataPermissions")] public HashSet StreamingDataPermissions; /// /// Gets list of allowed data resolutions /// [JsonProperty(PropertyName = "dataResolutionPermissions")] public HashSet DataResolutionPermissions; /// /// The cost associated with running this job /// [JsonProperty(PropertyName = "iCreditCost")] public uint CreditCost; /// /// Initializes a new default instance of the class /// public Controls() { MinuteLimit = 500; SecondLimit = 100; TickLimit = 30; RamAllocation = 1024; BacktestLogLimit = 10000; BacktestingMaxOrders = int.MaxValue; DailyLogLimit = 3000000; RemainingLogAllowance = 10000; BacktestingMaxInsights = 10000; MaximumDataPointsPerChartSeries = 4000; SecondTimeOut = 300; StorageLimitMB = 5; StorageFileCount = 100; PersistenceIntervalSeconds = 5; StoragePermissions = FileAccess.ReadWrite; // initialize to default leaky bucket values in case they're not specified TrainingLimits = new LeakyBucketControlParameters(); StreamingDataPermissions = new HashSet(); DataResolutionPermissions = new HashSet(); } /// /// Gets the maximum number of subscriptions for the specified resolution /// public int GetLimit(Resolution resolution) { switch (resolution) { case Resolution.Tick: return TickLimit; case Resolution.Second: return SecondLimit; case Resolution.Minute: case Resolution.Hour: case Resolution.Daily: default: return MinuteLimit; } } } }