Exemplo n.º 1
0
        private void CalculateData()
        {
            //对每个股票进行分析
            StockSQL.DeleteRule();

            analyse_now = 0;
            foreach (StockData stockheader in StockApp.allstock.Values)
            {
                //初始化股票
                StockData stock = StockSQL.GetStockDetail_2(stockheader.code, stockheader.name);
                UtilLog.AddInfo(TAG, "Start to calculate " + stock.code);
                int stock_length = stock.items.Length;
                //第几个分析的股票
                analyse_now++;

                CalBuy(stock);
                CalSell(stock);

                prog.SetProgress(analyse_now * 100 / analyse_total);
                //释放内存
                if (analyse_now % 100 == 0)
                {
                    UtilLog.AddInfo(TAG, "Start to free memory");
                    GC.Collect();
                    UtilLog.AddInfo(TAG, "Free memory done!");
                    System.Threading.Thread.CurrentThread.Join(500);
                }
                UtilLog.AddInfo(TAG, analyse_now + "/" + analyse_total + ":" + stock.name + "(" + stock.code + ")" + " calculate finished ");
            }

            RuleScore.SetRuleScore();
            RuleScore.SetAllPreScore();
            lbl_status.Text = "Calculation Done";
        }
Exemplo n.º 2
0
        private void dg_list_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            dg_detail.Rows.Clear();

            DataGridViewRow row = null;

            try
            {
                row = this.dg_list.Rows[this.dg_list.SelectedCells[0].RowIndex];
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return;
            }

            StockData stock = StockSQL.GetStockDetail_2((string)row.Cells[0].Value, (string)row.Cells[1].Value);

            lbl_code.Text = stock.code;
            lbl_name.Text = stock.name;
            foreach (StockItem s in stock.items)
            {
                dg_detail.Rows.Add(s.ToRowInfo());
            }
            ShowDetail(true);
        }
Exemplo n.º 3
0
        public static void resetSimulate()
        {
            DialogResult result = MessageBox.Show("Confirm delete simulation!!!!!!? It'll take long time to regenerate", "Delete Stock", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                StockSQL.DeleteSimulate();
                MessageBox.Show("Reset Simulate Done!");
            }
        }
Exemplo n.º 4
0
        private void truncateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Confirm truncate!!!!!!? It'll take long time to regenerate", "Delete Stock", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                StockSQL.DeleteRule();  //rulebuy, rullsell
                StockSQL.DeleteStock(); //header, item, attribute, kpi, dapan
                StockSQL.DeleteAnalysis();
                StockSQL.DeleteSimulate();
                MessageBox.Show("Reset Database Done!");
            }
        }
Exemplo n.º 5
0
        //同步股票数据
        //2018-03-14 Reviewed
        private void SyncData()
        {
            //更新进度
            int statusNum = 0;

            //删除已有股票
            StockSQL.DeleteStock();
            this.btn_syncData.Enabled = false;

            foreach (object obj in filelist)
            {
                statusNum++;
                string filename = (string)obj;

                StockData stock = new StockData();
                stock.Init(filename);
                UtilLog.AddInfo(TAG, "Start to analyse " + stock.code + ";");
                StockAttribute attri = new StockAttribute(stock);
                StockKPI       kpi   = new StockKPI(stock);

                if (!stock.IsValid())
                {
                    UtilLog.AddInfo(TAG, statusNum + "/" + filelist.Count + "  " + stock.code + " skipped");
                }
                else
                {
                    attri.InitAttribute();
                    kpi.InitKPI();

                    StockSQL.InsertStockWithItem(stock);
                    UtilLog.AddInfo(TAG, statusNum + "/" + filelist.Count + "  " + stock.code + " initialization finished");
                }
                int status = statusNum * 100 / filelist.Count;
                if (statusNum % 100 == 0)
                {
                    GC.Collect();
                }
                prog.SetProgress(status);
            }
            StockData.SetStockFull();
            StockDapan.InsertStockDaPan();
            this.btn_syncData.Enabled = true;
        }
Exemplo n.º 6
0
 private void resetRuleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     StockSQL.DeleteRuleFilter(); //rule_filter, rule_filter_dapan
     MessageBox.Show("Reset Rule Done!");
 }