private void FirstEventWhenMoreTest(DateTime start, double threshold) { KeyValuePair <DateTime, double>?entry = m_ticks.FirstEventWhenMore(start, threshold); foreach (var element in m_items) { if (element.Key < start) { continue; } if (element.Value <= threshold) { continue; } if (null == entry) { Assert.Fail("FirstEventWhenMore is failed - null return value"); } KeyValuePair <DateTime, double> item = (KeyValuePair <DateTime, double>)entry; if (element.Key != item.Key) { Assert.Fail("FirstEventWhenMore is failed - invalid time"); } if (element.Value != item.Value) { Assert.Fail("FirstEventWhenMore is failed - invalid value"); } return; } if (null != entry) { Assert.Fail("FirstEventWhenMore is failed - not null return value"); } }
//must return not more than element counts public int GetLevelHitInAbsoluteTime(int startTime, int distance) { if (distance > 0) { KeyValuePair <int, double>?entry = BidsIndexCollection.FirstEventWhenMore(startTime, Ticks[startTime].OpenAsk + distance); if (entry == null) { return(Ticks.Count - 1); } return(entry.Value.Key); } else { KeyValuePair <int, double>?entry = AsksIndexCollection.FirstEventWhenLess(startTime, Ticks[startTime].OpenBid + distance); if (entry == null) { return(Ticks.Count - 1); } return(entry.Value.Key); } }