private static int GetTimeArr(double[] tradingPeriod, KLinePeriod period, List <double[]> timeList, int offset) { double currentTime = tradingPeriod[0]; double endTime = tradingPeriod[1]; if (offset != 0) { currentTime = TimeUtils.AddMinutes(currentTime, offset); //修正上一个时间段的结束时间 if (timeList.Count != 0) { timeList[timeList.Count - 1][1] = currentTime; } } double lastTime = currentTime; while (currentTime < endTime) { lastTime = currentTime; currentTime = TimeUtils.AddTime(currentTime, period.Period, period.PeriodType); if (currentTime >= endTime) { TimeSpan timeSpan = TimeUtils.Substract(currentTime, endTime); offset = timeSpan.Hours * 60 + timeSpan.Minutes; currentTime = endTime; } timeList.Add(new double[] { Math.Round(lastTime, 6), Math.Round(currentTime, 6) }); } return(offset); }
public static bool IsNightStart(double time, double lastTime) { //time在晚上6点之后,lasttime在晚上6点之前 //且前后时间相隔超过100分钟,说明time是夜盘开始 if (!IsNight(time)) { return(false); } if (IsNight(lastTime)) { return(false); } TimeSpan span = TimeUtils.Substract(time, lastTime); if (span.Hours * 60 + span.Minutes > 100) { return(true); } return(false); }