Exemplo n.º 1
0
        /* ***************************************************************************************************************************************************************
         * 1. Confirm the informaiton needed (Drop Percent) has been entered.
         * 2. Clear the last set of data.
         * 3. Collect the symbol information based on the percent entered.
         * *************************************************************************************************************************************************************** */

        private void button1_Click(object sender, EventArgs e)
        {
            String ls_CurSymbol   = "";
            String ls_RecSymbol   = "";
            double ld_TodaysPrice = 0.0;

            int li_stockday = 0;


            int i = 0;

            StockAnalysis b1c_Look = new StockAnalysis();

            b1c_Look.ClearBounces();

            Form_BounceinProgress = Check_on_pct(b1c_Look);

            if (Form_BounceinProgress && b1c_Look.sa_pct > 0.0)
            {
                // Initialize the query
                BounceBack.BounceData2DataSetTableAdapters.DailyQuoteTableAdapter BBQTA;
                BBQTA = new BounceData2DataSetTableAdapters.DailyQuoteTableAdapter();

                BounceData2DataSet.DailyQuoteDataTable List_BounceHistory;
                List_BounceHistory = BBQTA.GetData();

                dataGridVBounce.Rows.Clear();


                /* So the plan here is to run through the stock history and collect the times the stock fell by the percent entered in a single day.
                 * From that day count how many days it took to get back to the price before the fall or the bounceback.
                 * Then display the number of times that drop happened and the average days back.
                 */

                for (i = 0; i < List_BounceHistory.Rows.Count; i++)
                {
                    DataRow BounceRow = List_BounceHistory.Rows[i];
                    ls_RecSymbol   = BounceRow.Field <string>("Symbol");
                    ld_TodaysPrice = BounceRow.Field <double>("open");
                    li_stockday    = BounceRow.Field <int>("TickerID");


                    // Are you the first record of a new stock?
                    if (ls_RecSymbol != ls_CurSymbol)
                    {
                        // If you're not the first stock add the details of the current stock.
                        if (i > 0)
                        {
                            dataGridVBounce.Rows.Add(ls_CurSymbol, $"{b1c_Look.sa_PriceBounces}", $"{b1c_Look.find_median()}");
                        }

                        // Set the variables to start a new stock.
                        b1c_Look.ClearBounces();

                        ls_CurSymbol = ls_RecSymbol;
                        //MessageBox.Show("New stock", ls_CurSymbol);
                    }

                    // all the work happens here.
                    b1c_Look.SetPricePoint(1, ld_TodaysPrice, "NoDate");
                }

                // The for loop does not add the last stock.  Do that here.

                dataGridVBounce.Rows.Add(ls_CurSymbol, $"{b1c_Look.sa_PriceBounces}", $"{b1c_Look.sa_AvgBounce}");

                // RML - This highlights the first row.
                // I'm thinking when this is fleshed out the first row will be one of the exchanges
                // so you won't have to worry about there not being a row to select.
                dataGridVBounce.Rows[0].Selected = true;

                Form_BounceinProgress = false;
            }
        }
Exemplo n.º 2
0
        /* ***************************************************************************************************************************************************************
         * If you click one of the bars in the bouncegraph representing a recovery period this will replace the stock price details in the line chart to reflect just the
         * days of the recovery period you selected.
         * *************************************************************************************************************************************************************** */

        private void BounceGraph_Click(object sender, EventArgs e)
        {
            // If you click in the graph AND the mouse is on a series column the stock detail will redisplay for that period  (Date - Recover days)

            //MessageBox.Show("click", Convert.ToString(BG_Detail.i_ToolTip_col));


            // Interesting thing happens here.  The first selection you make after a grid reset doesn't catch here?
            // It acts like you have to double click the first row to take an action?
            string dgr_symbol = "xxx";

            double gvb_TodaysPrice = 0.0;
            int    gvb_Tickerid    = 0;
            string gvb_Date;

            double dstartprice = 0.0;
            int    istart      = 0;
            int    istop       = 0;

            // There's no analysis in this loop.  Just look up the pricepoints and add them to the graph when you hit the Ticker ID and keep going for recover days.

            if (!Form_BounceinProgress)
            {
                // Initialize the query
                BounceBack.BounceData2DataSetTableAdapters.DailyQuoteTableAdapter BGCQ;
                BGCQ = new BounceData2DataSetTableAdapters.DailyQuoteTableAdapter();

                // We're pulling a detailed set from the existing symbol.
                dgr_symbol = BounceChart.Series[0].Name;

                BounceData2DataSet.DailyQuoteDataTable List_BouncePoints;
                List_BouncePoints = BGCQ.GetDataBySymbol(dgr_symbol);


                BounceChart.Series[0].Points.Clear();


                // It would be cleaner to hold the actual row instead of the Ticker ID but I don't want to go back to fix it.
                // Loop through the records to find the ticker ID.  Back up one day because we want to see the drop.


                for (int i = 1; i < List_BouncePoints.Rows.Count; i++)
                {
                    gvb_Tickerid    = List_BouncePoints.Rows[i].Field <int>("TickerID");
                    gvb_TodaysPrice = List_BouncePoints.Rows[i].Field <double>("open");

                    if (gvb_Tickerid == Convert.ToInt32(Form_BounceGraph_DT.Rows[BG_Detail.i_ToolTip_col - 1]["TickerID"]))
                    {
                        istop = i;
                        i     = List_BouncePoints.Rows.Count + 1;
                    }
                }

                if (istop > 0)
                {
                    istart      = istop - (Convert.ToInt32(Form_BounceGraph_DT.Rows[BG_Detail.i_ToolTip_col - 1]["RecoverDays"]) + 1);
                    dstartprice = List_BouncePoints.Rows[istart].Field <double>("open");
                }



                for (int i = istart; i <= istop; i++)
                {
                    gvb_TodaysPrice = List_BouncePoints.Rows[i].Field <double>("open") - dstartprice;
                    gvb_Tickerid    = List_BouncePoints.Rows[i].Field <int>("TickerID");
                    gvb_Date        = List_BouncePoints.Rows[i].Field <string>("date");

                    BounceChart.Series[0].Points.AddXY(i - istart + 1, gvb_TodaysPrice);
                }
            }
        }
Exemplo n.º 3
0
        /* ***************************************************************************************************************************************************************
         *  This is the best routine I found to identify when a user picks a symbol from the list of symbols.
         *  It will display the stock activity for that ticker in the line chart on the bottom right of the form
         *  and the times that stock dropped below the percent entered in a single day with the days it took to recover as
         *  the bar chart amount.
         * *************************************************************************************************************************************************************** */

        private void dataGridVBounce_CellRowEnter(object sender, DataGridViewCellEventArgs e)
        {
            // Interesting thing happens here.  The first selection you make after a grid reset doesn't catch here?
            // It acts like you have to double click the first row to take an action?
            string dgr_symbol = "xxx";

            bool DummyFlag = false;

            int bri = e.RowIndex;

            double gvb_TodaysPrice = 0.0;
            int    gvb_Tickerid    = 0;
            string gvb_Date;
            int    gvb_counter = 0;

            StockAnalysis gvb_Look = new StockAnalysis();

            gvb_Look.ClearBounces();

            DummyFlag = Check_on_pct(gvb_Look);



            if (!Form_BounceinProgress)
            {
                // OK so I'm changing things up here a bit.  Instead of adding XY elements to bouncegraph I'm going to fill a datatable bound to the graph in the stock analyis routines.
                // This section will be respobsible for clearing the table and setting the global row value.

                //BounceinProgress = true;

                dgr_symbol = dataGridVBounce.Rows[bri].Cells[0].Value.ToString();

                DataRow dr;

                // Initialize the query


                BounceBack.BounceData2DataSetTableAdapters.DailyQuoteTableAdapter BBDGQ;
                BBDGQ = new BounceData2DataSetTableAdapters.DailyQuoteTableAdapter();

                BounceData2DataSet.DailyQuoteDataTable List_BouncePoints;
                List_BouncePoints = BBDGQ.GetDataBySymbol(dgr_symbol);


                BounceChart.Series[0].Points.Clear();

                BounceChart.Series[0].Name = dgr_symbol;

                //BounceGraph.Series[0].Points.Clear();
                Form_BounceGraph_DT.Clear();



                for (int i = 1; i < List_BouncePoints.Rows.Count; i++)
                {
                    gvb_TodaysPrice = List_BouncePoints.Rows[i].Field <double>("open");
                    gvb_Tickerid    = List_BouncePoints.Rows[i].Field <int>("TickerID");
                    gvb_Date        = List_BouncePoints.Rows[i].Field <string>("date");
                    BounceChart.Series[0].Points.AddXY(i, gvb_TodaysPrice);

                    // Here I want to run through the same logic the bounce process did when looking up all symbols.
                    // Then display the bounced days in the Bouncegraph chart.
                    gvb_Look.SetPricePoint(gvb_Tickerid, gvb_TodaysPrice, gvb_Date);

                    // Check to see if a bounce was recorded.
                    if (gvb_Look.sa_PriceBounces > gvb_counter)
                    {
                        gvb_counter = gvb_Look.sa_PriceBounces;

                        dr                = Form_BounceGraph_DT.NewRow();
                        dr["DropDate"]    = gvb_Look.sa_DropDate;
                        dr["GraphDays"]   = Convert.ToString(Math.Min(BG_Detail.i_gmax, gvb_Look.sa_BounceDay[gvb_counter]));
                        dr["RecoverDays"] = Convert.ToString(gvb_Look.sa_BounceDay[gvb_counter]);
                        dr["Price"]       = Convert.ToString(gvb_Look.sa_PricePoint);
                        dr["DropPct"]     = gvb_Look.sa_DropPct;
                        dr["TickerID"]    = Convert.ToString(gvb_Tickerid);


                        Form_BounceGraph_DT.Rows.Add(dr);
                    }
                }


                // Set the row after everything is full.
                BG_Detail.i_Rows = gvb_Look.sa_PriceBounces;
                BG_Detail.Set_Boundary();

                BounceGraph.DataSource = Form_BounceGraph_DT;
                BounceGraph.Series["Days"].XValueMember  = "DropDate";
                BounceGraph.Series["Days"].YValueMembers = "GraphDays";



                BounceGraph.DataBind();
            }
        }