Beispiel #1
0
 public void Execute(IJobExecutionContext context)
 {
     try
     {
         var portfolio = new Repository.Repository().GetPortfolio().Result;
         if (!portfolio.Any())
         {
             for (int i = 45; i > 0; i--)
             {
                 var date          = DateTime.Now.AddDays(-i);
                 var buyOrSellInfo =
                     FindStocksToBuyOrSell(date).Where(
                         s => s.Value.Item1 >= DistinctByers || s.Value.Item2 >= DistinctSelles).ToDictionary(
                         item => item.Key, item => item.Value);
                 UpdatePortfolio(buyOrSellInfo, date);
             }
         }
         else
         {
             var date          = DateTime.Now.AddDays(-1);
             var buyOrSellInfo =
                 FindStocksToBuyOrSell(date).Where(
                     i => i.Value.Item1 >= DistinctByers || i.Value.Item2 >= DistinctSelles).ToDictionary(
                     i => i.Key, i => i.Value);
             UpdatePortfolio(buyOrSellInfo, date);
         }
         Logger.AddMessage("[OK] FindAndStoreActionJob " + DateTime.Now);
     }
     catch (Exception ex) {
         Logger.AddMessage("[ERROR] FindAndStoreActionJob " + ex.InnerException);
     }
 }