Exemplo n.º 1
0
        public static MTable getBkList(MongoDataReader w, string sec, DateTime dt, bool FilterTheNoPrice)
        {
            SecIndexClass   sic = new SecIndexClass(sec);
            secIndexBuilder sib = new secIndexBuilder(w, sic);
            MTable          mt  = sib.getBkList(dt);

            if (mt == null || mt.Count == 0)
            {
                return(mt);
            }
            BaseDataProcess_ForMG bdp = new BaseDataProcess_ForMG(w);

            string[]       seccodes = mt["wind_code"].ToList <string>().ToArray();
            RunResultClass rc       = bdp.getSetDataResult(seccodes, "close", dt);
            MTable         ret      = new MTable();
            List <DataRow> NewDrs   = new List <DataRow>();

            for (int i = 0; i < rc.Result.Count; i++)
            {
                DataRow retdr = mt.GetTable().Rows[i];
                DataRow dr    = rc.Result.GetTable().Rows[i];
                if (dr.IsNull("CLOSE") && FilterTheNoPrice)
                {
                    continue;
                }
                NewDrs.Add(retdr);
            }
            ret.FillList(NewDrs.ToArray());
            return(ret);
        }
Exemplo n.º 2
0
        public static int getTradeDays(MongoDataReader w, DateTime begt, DateTime endt)
        {
            TDaysGuidClas          tgc = new TDaysGuidClas();
            TDayGuildBuilder_ForMG tgb = new TDayGuildBuilder_ForMG(w, tgc);
            MTable ret = tgb.getRecordsCount(begt, endt);

            return((int)ret.GetTable().Rows[0][0]);
        }
Exemplo n.º 3
0
        public static DateTime Offset(MongoDataReader w, DateTime endt, int N, Cycle cyc)
        {
            TDaysGuidClas tgc = new TDaysGuidClas();

            tgc.cycle = cyc;
            TDayGuildBuilder_ForMG tgb = new TDayGuildBuilder_ForMG(w, tgc);
            MTable   ret      = tgb.getRecords(endt, N);
            DateTime lastdate = Convert.ToDateTime(ret.GetTable().Rows[0][0]);

            if (cyc == Cycle.Day)
            {
                return(lastdate);
            }
            DateTime[] dates = getTradeDates(w, lastdate, endt);
            for (int i = 0; i < dates.Length - 1; i++)
            {
                if (dates[i].AddDays(1).CompareTo(dates[i + 1]) < 0)
                {
                    return(dates[i]);
                }
            }
            return(lastdate);
        }
Exemplo n.º 4
0
        private void btn_query_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            string indexcode = new SIIIClass().SummaryCode; //必须先主动获取
            MTable mt        = CommWDToolClass.getBkList(this.gb.w, indexcode, this.txt_EndT.Value);

            if (mt == null)
            {
                return;
            }
            if (mt.Count == 0)
            {
                statusStrip1.Text          = string.Format("共计记录条数:{0}", 0);
                toolStripStatus_Right.Text = "无法查找到记录";
                dataGridView1.DataSource   = null;
                dataGridView1.Show();
                this.Cursor = Cursors.Default;
                return;
            }
            MTable secTab = mt["wind_code"];

            string[] sectors = secTab.ToList <string>().ToArray();
            MTable   tmp     = CommWDToolClass.GetMutliSetData(this.gb.w,
                                                               sectors,
                                                               this.txt_EndT.Value,
                                                               (Cycle)this.ddl_cycle.SelectedIndex,
                                                               PriceAdj.Beyond,
                                                               false,
                                                               txt_Content.Text);
            DataTable fdt = tmp.GetTable();

            this.dataGridView1.DataSource = fdt;
            dataGridView1.Tag             = fdt;
            dataGridView1.Show();
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 5
0
        private void btn_run_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            string indexcode = new SIIIClass().SummaryCode; //必须先主动获取
            MTable mt        = CommWDToolClass.getBkList(this.gb.w, indexcode, this.txt_EndT.Value);

            if (mt == null)
            {
                MessageBox.Show("股票池数据为空");
                return;
            }
            if (mt.Count == 0)
            {
                toolStripStatus_left.Text  = string.Format("共计记录条数:{0}", 0);
                toolStripStatus_Right.Text = "无法查找到记录";
                dataGridView1.DataSource   = null;
                dataGridView1.Show();
                this.Cursor = Cursors.Default;
                return;
            }
            MTable secTab = mt["wind_code"];

            string[] sectors = secTab.ToList <string>().ToArray();
            MTable   tmp     = CommWDToolClass.GetMutliSetData(this.gb.w,
                                                               sectors,
                                                               this.txt_EndT.Value,
                                                               (Cycle)this.ddl_cycle.SelectedIndex,
                                                               (PriceAdj)this.ddl_priceAdj.SelectedIndex,
                                                               false,
                                                               "KDJ.J");

            mt.AddColumnByArray("CurrCycleValue", tmp, "J");
            DateTime preDate = WDDayClass.Offset(this.gb.w, this.txt_EndT.Value, -1, (Cycle)this.ddl_cycle.SelectedIndex);

            tmp = CommWDToolClass.GetMutliSetData(this.gb.w,
                                                  sectors,
                                                  preDate,
                                                  (Cycle)this.ddl_cycle.SelectedIndex,
                                                  (PriceAdj)this.ddl_priceAdj.SelectedIndex,
                                                  false,
                                                  "KDJ.J");
            mt.AddColumnByArray("PreCycleValue", tmp, "J");
            //高一频度周期数据
            if (this.ddl_cycle.SelectedIndex > 0)
            {
                tmp = CommWDToolClass.GetMutliSetData(this.gb.w,
                                                      sectors,
                                                      this.txt_EndT.Value,
                                                      (Cycle)(this.ddl_cycle.SelectedIndex - 1),
                                                      (PriceAdj)this.ddl_priceAdj.SelectedIndex,
                                                      false,
                                                      "KDJ.K,KDJ.J");
                mt.AddColumnByArray("LowCycleValue", tmp, "J");
                mt.AddColumnByArray("LowCycleK", tmp, "K");
                tmp = CommWDToolClass.GetMutliSetData(this.gb.w,
                                                      sectors,
                                                      preDate,
                                                      (Cycle)(this.ddl_cycle.SelectedIndex - 1),
                                                      (PriceAdj)this.ddl_priceAdj.SelectedIndex,
                                                      false,
                                                      "KDJ.J");
                mt.AddColumnByArray("PreLowCycleValue", tmp, "J");
            }
            MTable dte = mt;
            MTable fdt = dte.Select("PreCycleValue>CurrCycleValue And (PreCycleValue <5 and CurrCycleValue<5)  And (LowCycleK<20 Or LowCycleValue<=5 Or PreLowCycleValue>LowCycleValue)");

            toolStripStatus_Right.Text          = "完成";
            toolStripStatus_left.Text           = string.Format("共计记录条数:{0}", fdt.Count);
            dataGridView1.CellMouseDoubleClick += new DataGridViewCellMouseEventHandler(dataGridView1_CellMouseDoubleClick);
            dataGridView1.DataSource            = fdt.GetTable();
            dataGridView1.Tag = fdt;
            dataGridView1.Show();
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 6
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            //DataTable table = (DataTable)dataGridView1.DataSource;//数据源
            //string secid = table.Rows[e.RowIndex]["wind_code"].ToString();
            //string SecName = table.Rows[e.RowIndex]["sec_name"].ToString();
            string        secid   = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["wind_code"].Value.ToString();
            string        SecName = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["sec_name"].Value.ToString();
            SecIndexClass sic     = new SIIIClass();

            sic.IndexCode = secid;
            secIndexBuilder sib = new secIndexBuilder(this.gb.w, sic);
            MTable          mt  = sib.getBkWeight(this.txt_EndT.Value);

            if (mt == null)
            {
                return;
            }
            DataTable dt = mt.GetTable();

            if (dt == null || dt.Rows.Count == 0 || !dt.Columns.Contains("i_weight"))
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(secid + "无详细信息!");
                return;
            }
            dt.Columns["i_weight"].DataType = typeof(float);
            dt.Columns.Add("CurrCycleValue", typeof(float));

            string[] sectors = new string[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sectors[i] = dt.Rows[i]["wind_code"].ToString();
            }
            KDJGuidClass kdj = new KDJGuidClass(9, 3, 3);

            kdj.cycle    = (Cycle)this.ddl_cycle.SelectedIndex;
            kdj.priceAdj = (PriceAdj)this.ddl_priceAdj.SelectedIndex;
            GuidBuilder_ForWD gb    = new GuidBuilder_ForWD(this.gb.w, kdj);
            MTable            newdt = gb.getRecords(sectors, this.txt_EndT.Value);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["CurrCycleValue"] = newdt.GetTable().Rows[i][0];
            }
            if (this.ddl_cycle.SelectedIndex > 0)
            {
                dt.Columns.Add("LowCycleValue", typeof(float));
                kdj.cycle = (Cycle)this.ddl_cycle.SelectedIndex - 1;
                gb        = new GuidBuilder_ForWD(gb.w, kdj);
                newdt     = gb.getRecords(sectors, this.txt_EndT.Value);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dt.Rows[i]["LowCycleValue"] = newdt.GetTable().Rows[i][0];
                }
            }
            Form dlgfrm = new Form();

            DrawForm(dlgfrm);
            DataGridView ddgrid = new DataGridView();

            dlgfrm.Controls.Add(ddgrid);
            DrawGrid(ddgrid);
            //dataGridView1.CellMouseDoubleClick += new DataGridViewCellMouseEventHandler(dataGridView1_CellMouseDoubleClick);
            ddgrid.DataSource = dt;
            ddgrid.Tag        = dt;
            ddgrid.Show();
            dlgfrm.TopMost = true;
            dlgfrm.Text    = SecName;
            dlgfrm.ShowDialog(this);
            this.Cursor = Cursors.Default;
        }