asxinyu/Stock

优化逻辑和统计算法
董斌辉 authored at 2018-02-24 22:52:55 董斌辉 committed at 2018-02-24 22:53:05
f84c9d4
Tree
1 Parent(s) 96945d8
Summary: 1 changed files with 7 additions and 4 deletions.
Modified +7 -4
Modified +7 -4
diff --git a/StockData/Analysis/StockHelper.cs b/StockData/Analysis/StockHelper.cs
index 6b81174..5c099f4 100644
--- a/StockData/Analysis/StockHelper.cs
+++ b/StockData/Analysis/StockHelper.cs
@@ -105,6 +105,8 @@ namespace StockData
         public static void AnalysisFirst()
         {
             DateTime year5 = new DateTime(2013, 1, 1);
+            DateTime year2 = new DateTime(2016, 1, 1);
+
             var all = StockBaseInfo.FindAll(StockBaseInfo._.Kind, 1);
             int index = 1;
             Parallel.For(0, all.Count, new ParallelOptions() { MaxDegreeOfParallelism = 8 }, i =>
@@ -119,16 +121,17 @@ namespace StockData
                     et.Code = all[i].Code;
                     et.Name = all[i].Name;
                     et.Price = list.Last().EndPrice;
-                    et.MaxPrice = list.Max(n => n.EndPrice);
-                    et.MinPrice = list.Min(n => n.EndPrice);
+                    et.MaxPrice = list.Where(n => n.StatDate > year5).Max(n => n.EndPrice); //list.Max(n => n.EndPrice);
+                    et.MinPrice = list.Where(n => n.StatDate > year5).Min(n => n.EndPrice);// list.Min(n => n.EndPrice);
                     et.MaxRate = et.MaxPrice / et.MinPrice;
-                    et.Max5year = list.Where(n => n.StatDate > year5).Max(n => n.EndPrice);
-                    et.Min5year = list.Where(n => n.StatDate > year5).Min(n => n.EndPrice);
+                    et.Max5year = list.Where(n => n.StatDate > year2).Max(n => n.EndPrice);
+                    et.Min5year = list.Where(n => n.StatDate > year2).Min(n => n.EndPrice);
                     et.Max5Rate = et.Max5year / et.Min5year;
                     et.Rate = et.Max5year / et.Price;
                     et.UpdateDate = DateTime.Now;
                     et.Save();
                 }
+                //SELECT * from StockElementInfo WHERE Price > 8 and MaxRate >8 and Max5Rate > 4
             });
         }
         #endregion