private async Task CheckArguments() { await Task.Run(() => { var parser = new ArgumentParser(); parser.Check("log", () => { Log.Instance.ShouldSave = true; }); parser.Check("title", (arg) => { SimObjectTitle = arg; log.Info(string.Format("Title argument: {0}", arg)); }); parser.Check("confidence", (arg) => { int val = 0; int.TryParse(arg, out val); if (val > 100) { MinimumConfidence = 100; } else if (val < 0) { MinimumConfidence = 0; } else { MinimumConfidence = val; } log.Info(string.Format("Confidence argument: {0} parsed: {1}", arg, MinimumConfidence)); }); parser.Check("download", (arg) => { log.Info(string.Format("Download argument: {0}", arg)); if (Datasets.ContainsKey(arg)) { SelectedDatasetUrl = Datasets[arg]; } else { log.Warning(string.Format("Unknown dataset: \"{0}\". Defaulting to World.", arg)); } activeFires.LoadData(SelectedDatasetUrl); OnPropertyChanged("TotalFiresCount"); }); parser.Check("connect", () => { log.Info(string.Format("Connect argument")); log.Info(string.Format("Minimum detection confidence: {0}%", MinimumConfidence)); if (SimInfo.Instance.IncompatibleFSXRunning) { throw new NotSupportedException("FS Active Fires is only compatible with Microsoft Flight Simulator X: Acceleration and SP2."); } sc.AddLocations(SimObjectTitle, activeFires.hotspots.Where(x => x.Confidence >= MinimumConfidence)); sc.Connect(); }); }); }
public double?GetData(string assetName, int timeframe, string dataName, int offset = 1) { if (!Datasets.ContainsKey(timeframe) || !Assets.ContainsKey(assetName) || !Assets[assetName].Data.ContainsKey(timeframe)) { return(null); } //get the open time of the bar with the passed offset Bar bar = Datasets[timeframe][offset]; if (!Assets[assetName].Data[timeframe].Data.ContainsKey(bar.OpenTime)) { return(null); } //the Data object will have the corresponding data in a dictionary with the key as the bar open time //look this up and return it. return(Assets[assetName].Data[timeframe].Data[bar.OpenTime][dataName]); }
public void InitBarData() { //add in the required minute bars with a 1 bar lookback //If a strategy needs these bars it will be overwritted in the next foreach loop Datasets.Add(1, new Bar[5]); BarIndices.Add(1, 0); foreach (KeyValuePair <int, int> required in RequiredData) { int timeframe = required.Key; int lookback = required.Value; //overwrite the minute bar details if the strategy requires this if (Datasets.ContainsKey(timeframe)) { Datasets[timeframe] = new Bar[lookback]; } else { Datasets.Add(timeframe, new Bar[lookback]); BarIndices.Add(timeframe, 0); } } }