Пример #1
0
        public static DateTime[] getTradeDates(WindAPI 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());
        }
Пример #2
0
        public static DateTime Offset(WindAPI 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 = CommWDToolClass.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);
        }
Пример #3
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);
            }
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
        public static DateTime LastTradeDay(WindAPI w, string SecCode, DateTime dt)
        {
            BaseDataTable tb  = CommWDToolClass.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);
        }