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); }
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); } }
public SecurityProcessClass(BaseDataItemClass dr) { if (dr == null) { return; } SecInfo = dr; Enable = false; }
public CommSecurityProcessClass SingleSecPreProcess(BaseDataItemClass dr) { CommSecurityProcessClass ret = new CommSecurityProcessClass(dr); switch (LogicType) { case CommStrategyLogicType.Reverse: ret = this.ReverseSelectSecurity(InParam); break; case CommStrategyLogicType.Breach: ret = this.BreachSelectSecurity(InParam); break; case CommStrategyLogicType.Balance: ret = this.BalanceSelectSecurity(InParam); break; default: break; } return(ret); }