/// <summary> /// 获得某品种下一次开盘时间。 /// </summary> /// <param name="dt">时间</param> /// <param name="vID">品种编号</param> /// <returns></returns> public static DateTime GetNextTradeOpenDateTime(DateTime dt, long vID) { bool isTradeDay = IsTradeDay(dt.ToDate()); if (false == isTradeDay) { dt = GetNextTradeDate(dt.ToDate()); } var datas = VarietyOpenTimeDao.GetBy(vID); var timeDatas = getTradeTime(dt, datas); List <DateTime> beginDatas = timeDatas.Keys.ToList(); return(beginDatas.FindAll(i => i >= dt).Min()); }
/// <summary> /// 获取dt时间(dt是非交易日则取下一个交易日)的交易失效时间 /// </summary> /// <param name="dt"></param> /// <param name="vID"></param> /// <returns></returns> public static DateTime GetValidTime(DateTime dt, long vID) { DateTime result = DateTime.MinValue; if (false == IsTradeDay(dt.ToDate())) { dt = GetNextTradeDate(dt.ToDate()); } Dictionary <string, string> datas = VarietyOpenTimeDao.GetBy(vID); Dictionary <DateTime, DateTime> timeDatas = getTradeTime(dt, datas); timeDatas = timeDatas.Where(i => i.Value.Hour == 15).ToDictionary(d => d.Key, v => v.Value); if (timeDatas != null && timeDatas.Count > 0) { result = timeDatas.Values.ToList().Max(); if (result < dt) { result = string.Format("{0} {1}", GetNextTradeDate(result.ToDate()).ToString("yyyy-MM-dd"), result.ToString("HH:mm:ss")).ToDateTime(DateTime.MinValue, "yyyy-MM-dd HH:mm:ss");; } } return(result); }