예제 #1
0
        public void AddReason(decimal score, string reason, StockTrend trend = StockTrend.Bullish, bool isSignificant = false)
        {
            if (trend == StockTrend.Bearish && score > 0)
            {
                score = score * -1;
            }

            Reasons.Add(new ReasonScore {
                Reason = reason, Score = score, Trend = trend, IsSignificant = isSignificant
            });
        }
예제 #2
0
        public ActionResult StockTrendAnalysis()
        {
            StockTrend stockTrend = new StockTrend();

            List <Category>   categories  = stockTrend.GetCategories();
            List <Department> departments = stockTrend.GetDepartments();

            ViewBag.categories  = categories;
            ViewBag.departments = departments;
            return(View());
        }
예제 #3
0
        private StockTrend GetStockTrendInstance(CompanyQuote companyQuote)
        {
            StockTrend newstockTrend = new StockTrend();

            newstockTrend.StockSymbol = companyQuote.Symbol;
            newstockTrend.StockName   = companyQuote.name;
            newstockTrend.Price       = companyQuote.Price;
            newstockTrend.Change      = companyQuote.Change;
            newstockTrend.YearHigh    = companyQuote.YearHigh;
            newstockTrend.YearLow     = companyQuote.YearLow;

            return(newstockTrend);
        }
예제 #4
0
        private void InsertStockTrendList(CompanyQuote companyQuote)
        {
            StockTrend newstockTrend = GetStockTrendInstance(companyQuote);

            lock (stocktrendLocker)
            {
                stockTrend.Add(newstockTrend);
                if (stockTrend.Count > 1)//save at least 2 entries at a time to minimize the db access.
                {
                    InsertStockTrendToDB(stockTrend);
                    stockTrend.Clear();
                }
            }
        }
예제 #5
0
        void AnalyzeChangeOverTime()
        {
            try
            {
                for (int x = 0; x < dataGridView1.RowCount; x++)
                {
                    ObservableCollection <DataPoint> dataPointCollection = new ObservableCollection <DataPoint>();

                    for (int y = 1; y < dataGridView1.Rows[x].Cells.Count - 1; y++)
                    {
                        float diff = 0.0f;
                        try
                        {
                            diff = ((float.Parse(dataGridView1.Rows[x].Cells[y].Value.ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat) / float.Parse(dataGridView1.Rows[x].Cells[y + 1].Value.ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat)) - 1.0f) * 100;
                        }
                        catch
                        {
                            continue;
                        }
                        DataPoint point = new DataPoint();
                        point.PercentChanged = diff;
                        point.date           = Convert.ToDateTime(dataGridView1.Columns[y].HeaderText);
                        dataPointCollection.Add(point);

                        if (diff < 2f && diff > -2f)
                        {
                            //Neutral change between 2% and -2%
                            dataGridView1.Rows[x].Cells[y].Style.BackColor = System.Drawing.Color.Beige;
                        }
                        else if (diff >= 2f && diff < 6f)
                        {
                            //Slight Growth between 2% and 6%
                            dataGridView1.Rows[x].Cells[y].Style.BackColor = System.Drawing.Color.LightGreen;
                        }
                        else if (diff >= 6f && diff < 10f)
                        {
                            //Solid Growth between 6% and 10%
                            dataGridView1.Rows[x].Cells[y].Style.BackColor = System.Drawing.Color.Green;
                        }
                        else if (diff >= 10f)
                        {
                            //Impressive Growth above 10%
                            dataGridView1.Rows[x].Cells[y].Style.BackColor = System.Drawing.Color.DarkGreen;
                        }
                        else if (diff <= -2f && diff > -6f)
                        {
                            //Slight Decay between -2% and -6%
                            dataGridView1.Rows[x].Cells[y].Style.BackColor = System.Drawing.Color.Yellow;
                        }

                        else if (diff <= -6f && diff > -10f)
                        {
                            //Solid Decay between -6% and -10%
                            dataGridView1.Rows[x].Cells[y].Style.BackColor = System.Drawing.Color.Orange;
                        }
                        else if (diff <= -10f)
                        {
                            //Impressive Decay lower than -10%
                            dataGridView1.Rows[x].Cells[y].Style.BackColor = System.Drawing.Color.Red;
                        }
                        else
                        {
                            //Other
                            dataGridView1.Rows[x].Cells[y].Style.BackColor = System.Drawing.Color.Purple;
                            Console.WriteLine(diff + " Row:" + x + " & Cell:" + y);
                        }
                    }

                    StockTrend stock = new StockTrend();

                    stock.CompanyTicker       = dataGridView1.Rows[x].Cells[0].Value.ToString();
                    stock.dataPointCollection = dataPointCollection;

                    for (int v = 0; v < CompanyCollection.Count - 1; v++)
                    {
                        if (stock.CompanyTicker == CompanyCollection[v].Symbol)
                        {
                            stock.industry = CompanyCollection[v].industry;
                            break;
                        }
                    }

                    CompanyPercentChangeWeekly.Add(stock);
                }

                UpdateCartChartWeeklyGrowth();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }