/// <summary> /// Default constructor for JSON of the Live Task Packet /// </summary> public LiveNodePacket() : base(PacketType.LiveNode) { Controls = new Controls { MinuteLimit = 50, SecondLimit = 25, TickLimit = 15 }; }
/// <summary> /// Default constructor for JSON of the Live Task Packet /// </summary> public LiveNodePacket() : base(PacketType.LiveNode) { Controls = new Controls { MinuteLimit = 100, SecondLimit = 50, TickLimit = 25, RamAllocation = 512 }; }
/// <summary> /// Initializes a new instance of the <see cref="UniverseSelection"/> class /// </summary> /// <param name="dataFeed">The data feed to add/remove subscriptions from</param> /// <param name="algorithm">The algorithm to add securities to</param> /// <param name="controls">Specifies limits on the algorithm's memory usage</param> public UniverseSelection(IDataFeed dataFeed, IAlgorithm algorithm, Controls controls) { _dataFeed = dataFeed; _algorithm = algorithm; _limiter = new SubscriptionLimiter(() => dataFeed.Subscriptions, controls.TickLimit, controls.SecondLimit, controls.MinuteLimit); }
/// <summary> /// Desktop/Local Get Next Task - Get task from the Algorithm folder of VS Solution. /// </summary> /// <returns></returns> public AlgorithmNodePacket NextJob(out string location) { location = AlgorithmLocation; Log.Trace("JobQueue.NextJob(): Selected " + location); // check for parameters in the config var parameters = new Dictionary<string, string>(); var parametersConfigString = Config.Get("parameters"); if (parametersConfigString != string.Empty) { parameters = JsonConvert.DeserializeObject<Dictionary<string, string>>(parametersConfigString); } var controls = new Controls() { MinuteLimit = Config.GetInt("symbol-minute-limit", 10000), SecondLimit = Config.GetInt("symbol-second-limit", 10000), TickLimit = Config.GetInt("symbol-tick-limit", 10000), RamAllocation = int.MaxValue }; //If this isn't a backtesting mode/request, attempt a live job. if (_liveMode) { var liveJob = new LiveNodePacket { Type = PacketType.LiveNode, Algorithm = File.ReadAllBytes(AlgorithmLocation), Brokerage = Config.Get("live-mode-brokerage", PaperBrokerageTypeName), HistoryProvider = Config.Get("history-provider", DefaultHistoryProvider), DataQueueHandler = Config.Get("data-queue-handler", DefaultDataQueueHandler), Channel = AccessToken, UserId = UserId, ProjectId = ProjectId, Version = Globals.Version, DeployId = AlgorithmTypeName, Parameters = parameters, Language = Language, Controls = controls }; try { // import the brokerage data for the configured brokerage var brokerageFactory = Composer.Instance.Single<IBrokerageFactory>(factory => factory.BrokerageType.MatchesTypeName(liveJob.Brokerage)); liveJob.BrokerageData = brokerageFactory.BrokerageData; } catch (Exception err) { Log.Error(err, string.Format("Error resolving BrokerageData for live job for brokerage {0}:", liveJob.Brokerage)); } return liveJob; } //Default run a backtesting job. var backtestJob = new BacktestNodePacket(0, 0, "", new byte[] {}, 10000, "local") { Type = PacketType.BacktestNode, Algorithm = File.ReadAllBytes(AlgorithmLocation), HistoryProvider = Config.Get("history-provider", DefaultHistoryProvider), Channel = AccessToken, UserId = UserId, ProjectId = ProjectId, Version = Globals.Version, BacktestId = AlgorithmTypeName, Language = Language, Parameters = parameters, Controls = controls }; return backtestJob; }