示例#1
0
        public bool TryGetRecord(DateTime time, out T record)
        {
            int ind = Records.BinarySearch(time);

            if (ind > -1)
            {
                record = Records[ind];
                return(true);
            }
            else
            {
                record = default(T);
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// Sets the cursor to the nearest tick after or exacty at provided time.
 /// If the provided time is higher or lower than the know prices range it will be set to the last tick or first tick
 /// </summary>
 public void SeekNearestAfter(DateTime time)
 {
     lock (Locker)
     {
         var ind = Records.BinarySearch(time);
         if (ind > -1)
         {
             Cursor = ind;
         }
         else
         {
             Cursor = ~ind;
         }
         Debug.Assert(Cursor > -1);
     }
 }
示例#3
0
 public void AddRecord(T historyRecord, bool scatteredOrder = false)
 {
     if (scatteredOrder)
     {
         int index = Records.BinarySearch(historyRecord.Time);
         if (index > -1)
         {
             Records[index] = historyRecord;
         }
         else
         {
             Records.Add(historyRecord);
         }
     }
     else
     {
         if (Records.Count > 0 && EndTime > historyRecord.Time)
         {
             throw new Exception("you cannot add a tick that's preceding the last one ");
         }
         Records.Add(historyRecord);
     }
 }