public void TestGetKLineDataTimeInfo_Days() { IList <double[]>[] openTimeArr = new List <double[]> [2]; openTimeArr[0] = GetDay1(); openTimeArr[1] = GetDay2(); KLineDataTimeInfo timeInfo = TradingTimeUtils.GetKLineDataTimeInfo(openTimeArr, new KLinePeriod(KLineTimeType.MINUTE, 1)); //List<double[]> klineTimeList = TradingTimeUtils.GetKLineTimeList_Full(openTime, KLinePeriod.KLinePeriod_15Minute); //List<double[]> klineTimeList = TradingTimeUtils.GetKLineTimeList_Full(openTime, KLinePeriod.KLinePeriod_1Hour); Console.WriteLine(timeInfo); }
public void TestGetKLineDataTimeInfo() { List <double[]> openTime = new List <double[]>(); openTime.Add(new double[] { 20150107.210000, 20150107.230000 }); openTime.Add(new double[] { 20150110.090000, 20150110.101500 }); openTime.Add(new double[] { 20150110.103000, 20150110.113000 }); openTime.Add(new double[] { 20150110.133000, 20150110.150000 }); KLineDataTimeInfo timeInfo = TradingTimeUtils.GetKLineDataTimeInfo(openTime, new KLinePeriod(KLineTimeType.MINUTE, 1)); //List<double[]> klineTimeList = TradingTimeUtils.GetKLineTimeList_Full(openTime, KLinePeriod.KLinePeriod_15Minute); //List<double[]> klineTimeList = TradingTimeUtils.GetKLineTimeList_Full(openTime, KLinePeriod.KLinePeriod_1Hour); Console.WriteLine(timeInfo); }
public void TestGetKLineTimeList_Full() { List <double[]> openTime = new List <double[]>(); openTime.Add(new double[] { 20150107.210000, 20150108.023000 }); openTime.Add(new double[] { 20150110.090000, 20150110.101500 }); openTime.Add(new double[] { 20150110.103000, 20150110.113000 }); openTime.Add(new double[] { 20150110.133000, 20150110.150000 }); List <double[]> klineTimeList = TradingTimeUtils.GetKLineTimeList(openTime, new KLinePeriod(KLineTimeType.SECOND, 1)); //List<double[]> klineTimeList = TradingTimeUtils.GetKLineTimeList_Full(openTime, KLinePeriod.KLinePeriod_15Minute); //List<double[]> klineTimeList = TradingTimeUtils.GetKLineTimeList_Full(openTime, KLinePeriod.KLinePeriod_1Hour); for (int i = 0; i < klineTimeList.Count; i++) { double[] time = klineTimeList[i]; Console.WriteLine(time[0] + "-" + time[1]); } }
/// <summary> /// 得到当日的所有K线时间列表 /// </summary> /// <param name="openDate">今日</param> /// <param name="lastOpenDate">上一个开盘日</param> /// <param name="tradingSession">交易时段</param> /// <param name="targetPeriod"></param> /// <returns></returns> public static List <double> GetKLineTimeList(int date, int lastOpenDate, List <double[]> tradingSession, KLinePeriod targetPeriod) { bool overNight = IsOverNight(tradingSession); bool isWeekStart = IsWeekStart(date, lastOpenDate); KLineOpenPeriods dayOpenTime = TradingTimeUtils.GetKLineTimeList_DayOpenTime(tradingSession, targetPeriod); List <double> klineFullTimes = new List <double>(dayOpenTime.KlineTimes.Count); List <double> klineTimes = dayOpenTime.KlineTimes; if (overNight) { bool isFistOpenTimeOverNight = IsOpenTimeOverNight(tradingSession[0]); if (isWeekStart) { int firstDate = lastOpenDate; int secondDate = (int)TimeUtils.AddDays(firstDate, 1); AddFullKLineTimes(klineFullTimes, firstDate, klineTimes, 0, dayOpenTime.OverNightIndex - 1); AddFullKLineTimes(klineFullTimes, secondDate, klineTimes, dayOpenTime.OverNightIndex, dayOpenTime.SplitIndeies[1] - 1); AddFullKLineTimes(klineFullTimes, date, klineTimes, dayOpenTime.SplitIndeies[1], dayOpenTime.KlineTimes.Count - 1); } else { int firstDate = lastOpenDate; AddFullKLineTimes(klineFullTimes, firstDate, dayOpenTime.KlineTimes, 0, dayOpenTime.OverNightIndex - 1); AddFullKLineTimes(klineFullTimes, date, dayOpenTime.KlineTimes, dayOpenTime.OverNightIndex, dayOpenTime.KlineTimes.Count - 1); } } else { AddFullKLineTimes(klineFullTimes, date, dayOpenTime.KlineTimes, 0, dayOpenTime.KlineTimes.Count - 1); } return(klineFullTimes); }