Beispiel #1
0
        public static DateTime Offset(MongoDataReader w, BaseDataItemClass SecItem, DateTime dt, int N, Cycle cyc)
        {
            DateTime begt = SecItem.Ipo_date;

            if (SecItem.SecType == SecType.Index)
            {
                //指数不停牌,自然日按交易日*7/5,放大到10/2=2倍指定开始日
                switch (cyc)
                {
                case Cycle.Day:
                {
                    begt = dt.AddDays(-2 * N);
                    break;
                }

                case Cycle.Week:
                {
                    begt = dt.AddDays(-7 * N);
                    break;
                }

                case Cycle.Month:
                {
                    begt = dt.AddMonths(N);
                    break;
                }

                case Cycle.Year:
                {
                    begt = dt.AddYears(N);
                    break;
                }
                }
            }
            if (begt.CompareTo(SecItem.Ipo_date) < 0)//任何情况(index的ipo日期为1899-12-31)如果开始日期小于ipo日期,开始日期设置为Ipo日期。
            {
                begt = SecItem.Ipo_date;
            }


            BaseDataTable tb = CommMGToolClass.GetBaseSerialData(
                w,
                SecItem.WindCode,
                begt,
                dt,
                Cycle.Day,
                PriceAdj.UnDo,
                BaseDataPoint.trade_status, BaseDataPoint.sec_type);
            BaseDataTable ttb = tb.AvaliableData;

            if (ttb.Count == 0)
            {
                return(dt);              //如果数据为空,返回回览日
            }
            if (ttb.Count > N)
            {
                return(((BaseDataItemClass)ttb[ttb.Count - N]).DateTime);
            }
            return(((BaseDataItemClass)ttb[0]).DateTime);
        }
Beispiel #2
0
 public CrossSectionForm(BaseDataTable <BaseCrossSection> table)
 {
     InitializeComponent();
     DataGraphView = new DataGraphView <BaseCrossSection>(table);
     this.Controls.Add(DataGraphView);
     DataGraphView.Dock = DockStyle.Fill;
 }
Beispiel #3
0
        public static DateTime[] getTradeDates(MongoDataReader w, string SecCode, DateTime begt, DateTime endt, Cycle cyc)
        {
            BaseDataTable tb  = CommWDToolClass.GetBaseSerialData(w, SecCode, begt, endt, cyc, PriceAdj.UnDo, BaseDataPoint.trade_status, BaseDataPoint.sec_type, BaseDataPoint.close);
            BaseDataTable ttb = tb.AvaliableData;

            return(ttb["DateTime"].ToList <DateTime>().ToArray());
        }
Beispiel #4
0
        private BaseDataTable CreateBaseTable(Guid id, string tableName)
        {
            BaseDataTable table = new BaseDataTable(id, tableName);
            table.MinimumCapacity = TableMinCapacity;

            return table;
        }
Beispiel #5
0
        public ITable CreateDataTable(Guid id)
        {
            BaseDataTable table = new BaseDataTable(id);
            table.MinimumCapacity = TableMinCapacity;

            return table;
        }
Beispiel #6
0
        static void InitEquites()
        {
            AllMarketEquitClass aec = new AllMarketEquitClass();
            MTable dt = CommWDToolClass.getBkList(w, aec.SummaryCode, DateTime.Today, false);

            if (dt == null || dt.Count == 0)
            {
                return;
            }
            string[]      equitcodes = dt["WIND_CODE"].ToList <string>().ToArray();
            BaseDataTable bdt        = CommWDToolClass.GetBaseData(w,
                                                                   equitcodes,
                                                                   DateTime.Today,
                                                                   Cycle.Day,
                                                                   PriceAdj.Beyond,
                                                                   new object[0] {
            });                                                                                                   //获得所有股票的基本信息

            OnMarketDate = bdt[BaseDataPoint.ipo_date.ToString().ToUpper()].ToList <DateTime>().Min <DateTime>(); //所有股票中的最早的IPO日期
            EquitCnt     = bdt.Count;
            Dictionary <string, SecurityInfo>      alllist = new Dictionary <string, SecurityInfo>();
            Dictionary <int, List <SecurityInfo> > grps    = new Dictionary <int, List <SecurityInfo> >();

            for (int i = 0; i < bdt.Count; i++)
            {
                BaseDataItemClass info = bdt[i] as BaseDataItemClass;
                SecurityInfo      si   = new SecurityInfo
                {
                    secType   = SecType.Equit,
                    BaseInfo  = info,
                    DateIndex = new Dictionary <DateTime, int>()
                };
                if (alllist.ContainsKey(si.BaseInfo.WindCode))
                {
                    throw (new Exception("初始化系统出现重复股票!"));
                }
                int t = i % GroupCnt;
                if (!grps.ContainsKey(t))
                {
                    grps.Add(t, new List <SecurityInfo>());
                }
                grps[t].Add(si);
                alllist.Add(si.BaseInfo.WindCode, si);
            }
            int cnt = 0;

            foreach (int k in grps.Keys)
            {
                if (cnt++ == 0)
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(runBuild), grps[k]);
                }
            }
            if (!AllSecSet.ContainsKey(SecType.Equit))
            {
                AllSecSet.Add(SecType.Equit, alllist);
            }
        }
        /// <summary>
        /// 基础过滤
        /// </summary>
        public RunNoticeClass BaseFilter()
        {
            RunNoticeClass ret    = new RunNoticeClass();
            BaseDataTable  sectab = CommWDToolClass.GetMarketsStocks(w, InParam.SecIndex, InParam.EndT, InParam.OnMarketDays, InParam.CalcLastData, InParam.IsExcludeST, InParam.IsMAFilter, InParam.ExcludeSecList);

            this.SelectTable = sectab;
            this.SelectTable.AddColumnByArray <bool>("Enable", false);
            return(ret);
        }
 public DataGraphView(BaseDataTable <T> table)
 {
     BaseDataTable = table;
     InitializeComponent();
     pane       = ZedGraph.GraphPane;
     pane.Title = table.Name;
     initialize();
     chartType = ChartType.Line;
     drawChart(BaseDataTable.Data, chartType, xlog.Checked, ylog.Checked);
 }
Beispiel #9
0
        public static DateTime LastTradeDay(MongoDataReader w, string SecCode, DateTime dt)
        {
            BaseDataTable tb  = CommMGToolClass.GetBaseSerialData(w, SecCode, dt.AddDays(-1000), dt, Cycle.Day, PriceAdj.UnDo, BaseDataPoint.trade_status, BaseDataPoint.sec_type, BaseDataPoint.close);
            BaseDataTable ttb = tb.AvaliableData;

            if (ttb.Count == 0)
            {
                return(DateTime.MinValue);
            }
            return(((BaseDataItemClass)ttb[ttb.Count - 1]).DateTime);
        }
Beispiel #10
0
        /// <summary>
        /// 根据指数获得未停牌股票
        /// </summary>
        /// <param name="indexName">板块/指数组合</param>
        /// <param name="EndT"></param>
        /// <param name="CheckDays"></param>
        /// <param name="NextDay"></param>
        /// <param name="ExcludeSt"></param>
        /// <param name="MAFilter"></param>
        /// <param name="ExcludeSecList"></param>
        public static BaseDataTable GetMarketsStocks(MongoDataReader w, string indexName, DateTime EndT, Int64 CheckDays, bool NextDay, bool ExcludeSt, bool MAFilter, List <string> ExcludeSecList)
        {
            BaseDataTable ret = new BaseDataTable();

            string[] bkArr    = indexName.Split(';');
            string[] seclist  = new string[0]; //默认股票列表为空
            string[] secnames = new string[0]; //默认股票列表为空
            if (bkArr.Length > 1)              //板块或指数组合
            {
                return(ret);
            }
            else
            {
                if (!IsSecIndex(w, indexName, EndT, out seclist, out secnames)) //不是集合
                {
                    if (indexName.IndexOf(".") > 0)                             //如果是0000xx.xx类型
                    {
                        seclist = new string[1] {
                            indexName
                        };
                    }
                    else
                    {
                        return(ret);
                    }
                }
            }
            //ret.Result.AddColumnByArray<string>("Code", seclist);
            //ret.Result.AddColumnByArray<string>("Name", secnames);
            BaseDataTable dt = GetBaseData(w, seclist, EndT, Cycle.Day, PriceAdj.Beyond, new object[0] {
            });

            dt = dt.AvaliableData;
            BaseDataTable rdt = new BaseDataTable();

            rdt = new BaseDataTable(dt.GetTable().Clone());
            var Tarr = from dr in dt.ToFillableList <BaseDataItemClass>()
                       where dr.OnMarketDayCount >= CheckDays
                       select dr;

            rdt.FillByItems <BaseDataItemClass>(Tarr.ToArray <BaseDataItemClass>());
            ret = rdt;
            if (ExcludeSt)
            {
                var NoSTArr = from dr in rdt.ToFillableList <BaseDataItemClass>()
                              where dr.IsST == false
                              select dr;

                ret = new BaseDataTable(rdt.GetTable());
                ret.FillByItems <BaseDataItemClass>(NoSTArr.ToArray <BaseDataItemClass>());
            }
            return(ret);
        }
Beispiel #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            //RunResultClass ret = CommWDToolClass.GetSetBaseData(gb.w,"000613.SZ,300369.SZ,002512.SZ,600721.SH,300344.SZ,000100.SZ",DateTime.Today);
            ////MACDGuidProcess mp = new MACDGuidProcess(gb.w);
            ////RunResultClass ret = mp.getDateSerialResult("000100.SZ",Convert.ToDateTime("2017/7/7"), DateTime.Today);
            ////BaseDataProcess bp = new BaseDataProcess(gb.w);
            ////RunResultClass bret = bp.getDateSerialResult("000100.SZ", Convert.ToDateTime("2017/7/7"), DateTime.Today);
            //RunResultClass ret =mp.getSetDataResult("000613.SZ,300369.SZ,002512.SZ,600721.SH,300344.SZ,000100.SZ", null, DateTime.Today);
            //RunResultClass ret = CommWDToolClass.(gb.w, "000613.SZ,300369.SZ,002512.SZ,600721.SH,300344.SZ,000100.SZ", DateTime.Today);
            //BaseDataTable dt = CommWDToolClass.GetBaseData(gb.w, "000613.SZ,300369.SZ,002512.SZ,600721.SH,300344.SZ,000100.SZ", Convert.ToDateTime("2018/3/10"), Cycle.Day, PriceAdj.Beyond);

            string        code = new SIIIClass().SummaryCode;
            BaseDataTable bdt  = CommWDToolClass.GetMarketsStocks(this.gb.w,
                                                                  "000300.SH",
                                                                  DateTime.Today,
                                                                  200,
                                                                  true,
                                                                  true,
                                                                  false,
                                                                  null);

            MessageBox.Show(bdt.Count.ToString());

            return;
            //////////MessageBox.Show(WDDayClass.LastTradeDay(gb.w,"002161.SZ",DateTime.Today).ToShortDateString());
            //////////return;
            //////////BaseDataTable dt = CommWDToolClass.GetBaseSerialData(gb.w, "000002.SZ", Convert.ToDateTime("2015/12/7"), Convert.ToDateTime("2016/7/7"));
            //////////if (dt != null)
            //////////{
            //////////    MessageBox.Show(string.Format("交易日数量:{0},股票实际交易日:{1}",dt.Count,dt.AvaliableData.Count));
            //////////    ////MTable tab = ret.Result;
            //////////    ////tab.Union(bret.Result);
            //////////    ////MACDTable mtab = new MACDTable(tab.GetTable());
            //////////    ////MessageBox.Show(mtab[0].ToClassInfo());
            //////////    //MessageBox.Show(new BaseDataTable(ret.Result)[5].IsST(DateTime.Today).ToString());
            //////////}
        }
Beispiel #12
0
 /// <summary>
 /// Creates a parameter for calling a stored procedure.
 /// </summary>
 /// <param name="parameterName">The name of the parameter.</param>
 /// <param name="dataTable">The <see cref="BaseDataTable"/>.</param>
 /// <returns>The created SQL Parameter.</returns>
 public SqlParameter CreateParameter(string parameterName, BaseDataTable dataTable)
 {
     return(dataTable.ToSqlParameter(parameterName));
 }