Beispiel #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;
            }
        }
Beispiel #2
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();
            }
        }