private void CheckCandleTimestamp(CandlePeriod candlePeriod, DateTime timestamp) { var period = candlePeriod.Id; if (period == CandlePeriod.OneMinute.Id || period == CandlePeriod.FiveMinutes.Id || period == CandlePeriod.FifteenMinutes.Id || period == CandlePeriod.ThirtyMinutes.Id) { //Seconds and MilliSeconds should be zero. if (timestamp.Second != 0) { throw new TrendAnalysisDomainException($"The \"Second\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } if (timestamp.Millisecond != 0) { throw new TrendAnalysisDomainException($"The \"MilliSecond\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } } else if (period == CandlePeriod.OneHour.Id || period == CandlePeriod.TwoHours.Id || period == CandlePeriod.FourHours.Id) { //Minutes and Seconds and MilliSeconds should be zero. if (timestamp.Minute != 0) { throw new TrendAnalysisDomainException($"The \"Minute\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } if (timestamp.Second != 0) { throw new TrendAnalysisDomainException($"The \"Second\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } if (timestamp.Millisecond != 0) { throw new TrendAnalysisDomainException($"The \"MilliSecond\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } } else if (period == CandlePeriod.OneDay.Id) { //Hours and Minutes and Seconds and MilliSeconds should be zero. if (timestamp.Hour != 0) { throw new TrendAnalysisDomainException($"The \"Hour\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } if (timestamp.Minute != 0) { throw new TrendAnalysisDomainException($"The \"Minute\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } if (timestamp.Second != 0) { throw new TrendAnalysisDomainException($"The \"Second\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } if (timestamp.Millisecond != 0) { throw new TrendAnalysisDomainException($"The \"MilliSecond\" property in timestamp for the given candle should be zero on {CandlePeriod.From(period)} chart."); } } if (period == CandlePeriod.OneMinute.Id) { } else if (period == CandlePeriod.FiveMinutes.Id) { if (timestamp.Minute % 5 != 0) { throw new TrendAnalysisDomainException("The minute property of timestamp must be divisible by 5 on 5m chart."); } } else if (period == CandlePeriod.FifteenMinutes.Id) { if (timestamp.Minute % 15 != 0) { throw new TrendAnalysisDomainException("The minute property of timestamp must be divisible by 15 on 15m chart."); } } else if (period == CandlePeriod.ThirtyMinutes.Id) { if (timestamp.Minute % 30 != 0) { throw new TrendAnalysisDomainException("The minute property of timestamp must be divisible by 30 on 30m chart."); } } else if (period == CandlePeriod.OneHour.Id) { } else if (period == CandlePeriod.TwoHours.Id) { if (timestamp.Hour % 2 != 0) { throw new TrendAnalysisDomainException("The hour property of timestamp must be divisible by 2 on 2hr chart."); } } else if (period == CandlePeriod.FourHours.Id) { if (timestamp.Hour % 4 != 0) { throw new TrendAnalysisDomainException("The hour property of timestamp must be divisible by 4 on 4hr chart."); } } else if (period == CandlePeriod.OneDay.Id) { } else if (period == CandlePeriod.OneWeek.Id) { if (timestamp.DayOfWeek != DayOfWeek.Monday) { throw new TrendAnalysisDomainException("The DayOfWeek property of timestamp must be equal to Monday."); } } }