Ejemplo n.º 1
0
        public bool AddRecord(string Name, double SellPrice, double BuyPrice, double SellSentiment, double BuySentiment)
        {
            bool ret          = false;
            bool ValueUpdated = false;

            foreach (var itr in DataHistory)
            {
                if (itr.Name == Name)
                {
                    double SellPriceDifference = Math.Abs(itr.PrevSellPrice - SellPrice);
                    double BuyPriceDifference  = Math.Abs(itr.PrevBuyPrice - BuyPrice);
                    double SellPriceChangePCT  = Math.Abs(itr.PrevSellPrice / SellPrice);
                    double BuyPriceChangePCT   = Math.Abs(itr.PrevBuyPrice / BuyPrice);
//                    if ((SellPriceChangePCT < (1-Globals.IgnorePriceChangePCT) || SellPriceChangePCT > (1 + Globals.IgnorePriceChangePCT))
//                        || (BuyPriceChangePCT < (1 - Globals.IgnorePriceChangePCT) || BuyPriceChangePCT > (1 + Globals.IgnorePriceChangePCT)))
                    //               if(itr.PrevSellPrice != SellPrice || itr.PrevBuyPrice != BuyPrice)
                    ret          = itr.AddValue(SellPrice, BuyPrice, SellSentiment, BuySentiment);
                    ValueUpdated = true;
                    break;
                }
            }
            if (ValueUpdated == false)
            {
                StockDataHistory h = new StockDataHistory();
                h.Name = Name;
                h.AddValue(SellPrice, BuyPrice, SellSentiment, BuySentiment, FinishedLoading == false);
                DataHistory.Add(h);
                ret = true;
            }
            return(ret);
        }
Ejemplo n.º 2
0
 public void StartPriceChangeWatchdog()
 {
     while (WatchodRunning == true)
     {
         string MailToSend = "";
         //for each watched instrument event, check status
         foreach (NotificationParams itr in WatchedEvents)
         {
             StockDataHistory iv = Globals.vHistory.GetInstrumentStore(itr.InstrumentName);
             //can't process until we start getting soem values for this instrument
             if (iv == null)
             {
                 continue;
             }
             //send alert on sell price reached ?
             if (itr.MyAction == "Sell")
             {
                 if (iv.PrevSellPrice < itr.SellPriceReached)
                 {
                     MailToSend += iv.Name + " SellPrice is " + iv.PrevSellPrice + " watched price is " + itr.SellPriceReached;
                 }
                 if (itr.ProfitExceeded != 0)
                 {
                     double ExpectedProfit = (iv.PrevBuyPrice - itr.BoughtAtPrice) * itr.BoughtAmount;
                     if (ExpectedProfit > itr.ProfitExceeded)
                     {
                         MailToSend += iv.Name + " profit is " + ExpectedProfit + " exceeded limit " + itr.ProfitExceeded;
                     }
                 }
             }
             if (itr.MyAction == "Buy")
             {
                 if (iv.PrevSellPrice < itr.SellPriceReached)
                 {
                     MailToSend += iv.Name + " Buy is " + iv.PrevSellPrice + " watched price is " + itr.SellPriceReached;
                 }
                 if (itr.ProfitExceeded != 0)
                 {
                     double ExpectedProfit = (iv.PrevBuyPrice - itr.BoughtAtPrice) * itr.BoughtAmount;
                     if (ExpectedProfit > itr.ProfitExceeded)
                     {
                         MailToSend += iv.Name + " profit is " + ExpectedProfit + " exceeded limit " + itr.ProfitExceeded;
                     }
                 }
             }
         }
         Thread.Sleep(100);
     }
 }