public void GetStatsForRunTests() { Zakaz zak; int run; OutStats result; zak = new Zakaz(16000); run = 1000; result = new OutStats(zak, run, 0, 16); Assert.AreEqual(Analizer.GetStatsForRun(zak, run), result); zak = new Zakaz(15000); run = 1000; result = new OutStats(zak, run, 0, 15); Assert.AreEqual(Analizer.GetStatsForRun(zak, run), result); zak = new Zakaz(800, 2000, 2000, 26000); run = 2000; result = new OutStats(zak, run, 1200, 16); Assert.AreEqual(Analizer.GetStatsForRun(zak, run), result); zak = new Zakaz(69600, 91500); run = 2000; result = new OutStats(zak, run, 1200, 16); }
public void OutStatsTest() { OutStats a = new OutStats(); OutStats b = new OutStats(); Assert.AreEqual(a.Equals(b), true); Assert.AreEqual(b.Equals(a), true); Assert.AreEqual(a.Equals(1), false); Assert.AreEqual(a.Equals(null), false); a.OverprintsSum = 1000; Assert.AreNotEqual(a, b); Assert.AreEqual(a > b, true); b.OverprintsSum = 1000; Assert.AreEqual(a, b); b.OverprintsSum = 2000; Assert.AreNotEqual(a, b); Assert.AreEqual(a < b, true); a.EtsOnSheetCount = 14; a.Run = 1000; a.OverprintsSum = 1000; b.OverprintsSum = 3000; Assert.AreEqual(a, b); a.EtsOnSheetCount = Constants.ETS_ON_SHEET + 1; Assert.AreEqual(a.IsValid, false); }
public void DecreaseRunTests() { Zakaz zak; int run; OutStats result; zak = new Zakaz(4500); run = 1000; result = new OutStats(zak, run, 0, 16); Assert.AreEqual((Analizer.DecreaseRun(zak, run)).ToString(), result.ToString()); }
public OutStats BuildOutTableRows(string path, int period) { var outStats = new OutStats(); var table = new List <TableRow>(); using (var reader = new StreamReader(File.OpenRead($"{path}"))) { var counter = 0; var dsPos = 0; var yhatPos = 0; var yhatUpperPos = 0; var yhatLowerPos = 0; while (!reader.EndOfStream) { counter++; var line = reader.ReadLine(); if (line == null) { continue; } var values = line.Split(','); if (counter == 1) { dsPos = FindPosition(values, "ds"); yhatPos = FindPosition(values, "yhat"); yhatUpperPos = FindPosition(values, "yhat_upper"); yhatLowerPos = FindPosition(values, "yhat_lower"); } else { var row = new TableRow() { Id = values[0], Ds = values[dsPos], Yhat = decimal.Parse(values[yhatPos], NumberStyles.Any, CultureInfo.InvariantCulture), YhatUpper = decimal.Parse(values[yhatUpperPos], NumberStyles.Any, CultureInfo.InvariantCulture), YhatLower = decimal.Parse(values[yhatLowerPos], NumberStyles.Any, CultureInfo.InvariantCulture) }; table.Add(row); } } } outStats.MaxValue = table.Take(table.Count - period).Select(x => x.Yhat).Max(); outStats.MinValue = table.Take(table.Count - period).Select(x => x.Yhat).Min(); outStats.Table = table.Skip(Math.Max(0, table.Count() - period)).Reverse().ToList(); outStats.YhatLowerList = table.Select(x => x.YhatLower); outStats.YhatUpperList = table.Select(x => x.YhatUpper); return(outStats); }
public CoinPerformance DefinePerformance(OutStats table) { var tableRows = table.Table; var result = new CoinPerformance(); if (!decimal.TryParse(_settings.LowerBorder, out var lowerBorder)) { throw new Exception("Wrong Value of Border in App Settings!"); } if (!decimal.TryParse(_settings.UpperBorder, out var upperBorder)) { throw new Exception("Wrong Value of BorderUp in App Settings!"); } if (!decimal.TryParse(_settings.UpperWidth, out var widthRateUpper)) { throw new Exception("Wrong Value of BorderUp in App Settings!"); } if (!decimal.TryParse(_settings.LowerWidth, out var widthRateLower)) { throw new Exception("Wrong Value of BorderUp in App Settings!"); } result.Width = Width(table.YhatLowerList, table.YhatUpperList, widthRateUpper, widthRateLower); var enumerable = tableRows.ToList(); var upper = enumerable.First().Yhat; var lower = enumerable.Last().Yhat; var max = table.MaxValue; var min = table.MinValue; if (max < upper) { max = upper; } if (min > lower) { min = lower; } decimal length; if (upper - lower > 0) { length = 1 / (max - min) * (upper - lower) * 100; } else if (upper - lower < 0) { length = -1 * (1 / (max - min) * (lower - upper) * 100); } else { result.Indicator = Indicator.Neutral; result.Rate = 0; return(result); } if (length > upperBorder) { result.Indicator = Indicator.StrongPositive; result.Rate = length / 100; return(result); } if (length > 0 && length <= upperBorder) { result.Indicator = Indicator.Positive; result.Rate = length / 100; return(result); } if (length < 0 && lowerBorder < length) { result.Indicator = Indicator.Neutral; result.Rate = -1 * length / 100; return(result); } result.Indicator = Indicator.Negative; result.Rate = -1 * length / 100; return(result); }