Exemple #1
0
        /*
         * void IAbstractStreamingClient.GetMarketDetails(MarketData mktData)
         * {
         *  var mktLevels = _reader.GetMarketLevels(_startTime, new List<string> { mktData.Id }).Values.First();
         *  Market mkt = new Market();
         *  mkt.epic = mktData.Id;
         *  mkt.high = mktLevels.High; mkt.low = mktLevels.Low; mkt.bid = mktLevels.CloseBid; mkt.offer = mktLevels.CloseOffer;
         *  mktData.Levels = new MarketLevels(mkt.epic, mkt.low.Value, mkt.high.Value, mkt.bid.Value, mkt.offer.Value);
         * }*/

        protected void replay(Dictionary <string, List <CqlQuote> > priceData, IHandyTableListener tableListener)
        {
            DateTime curtime = _startTime;

            while (priceData.Count > 0)
            {
                DateTimeOffset   minNextTime   = _stopTime;
                ReplayUpdateInfo nextUpdate    = null;
                List <string>    epicsToDelete = new List <string>();
                foreach (var epicQuotes in priceData)
                {
                    if (epicQuotes.Value.Count == 0)
                    {
                        epicsToDelete.Add(epicQuotes.Key);
                    }
                    else
                    {
                        if (epicQuotes.Value[0].t <= minNextTime)
                        {
                            minNextTime = epicQuotes.Value[0].t;
                            nextUpdate  = new ReplayUpdateInfo(epicQuotes.Value[0]);
                        }
                    }
                }
                if (nextUpdate == null)
                {
                    foreach (var epic in epicsToDelete)
                    {
                        priceData.Remove(epic);
                    }
                }
                else
                {
                    priceData[nextUpdate.Id].RemoveAt(0);
                    if (_samplingMs != -1)
                    {
                        if ((nextUpdate.Time - curtime).TotalMilliseconds < _samplingMs)
                        {
                            continue;
                        }
                        curtime = nextUpdate.Time;
                    }
                    tableListener.OnUpdate(0, nextUpdate.Id, nextUpdate);
                    if (_closing.Signaled)
                    {
                        _closing.Set();
                        break;
                    }
                }
            }
        }
Exemple #2
0
 /*
 void IAbstractStreamingClient.GetMarketDetails(MarketData mktData)
 {
     var mktLevels = _reader.GetMarketLevels(_startTime, new List<string> { mktData.Id }).Values.First();
     Market mkt = new Market();
     mkt.epic = mktData.Id;
     mkt.high = mktLevels.High; mkt.low = mktLevels.Low; mkt.bid = mktLevels.CloseBid; mkt.offer = mktLevels.CloseOffer;
     mktData.Levels = new MarketLevels(mkt.epic, mkt.low.Value, mkt.high.Value, mkt.bid.Value, mkt.offer.Value);
 }*/
 protected void replay(Dictionary<string, List<CqlQuote>> priceData, IHandyTableListener tableListener)
 {
     DateTime curtime = _startTime;
     while (priceData.Count > 0)
     {
         DateTimeOffset minNextTime = _stopTime;
         ReplayUpdateInfo nextUpdate = null;
         List<string> epicsToDelete = new List<string>();
         foreach (var epicQuotes in priceData)
         {
             if (epicQuotes.Value.Count == 0)
                 epicsToDelete.Add(epicQuotes.Key);
             else
             {
                 if (epicQuotes.Value[0].t <= minNextTime)
                 {
                     minNextTime = epicQuotes.Value[0].t;
                     nextUpdate = new ReplayUpdateInfo(epicQuotes.Value[0]);
                 }
             }
         }
         if (nextUpdate == null)
         {
             foreach (var epic in epicsToDelete)
                 priceData.Remove(epic);
         }
         else
         {
             priceData[nextUpdate.Id].RemoveAt(0);
             if (_samplingMs != -1)
             {
                 if ((nextUpdate.Time - curtime).TotalMilliseconds < _samplingMs)
                     continue;
                 curtime = nextUpdate.Time;
             }
             tableListener.OnUpdate(0, nextUpdate.Id, nextUpdate);
             if (_closing.Signaled)
             {
                 _closing.Set();
                 break;
             }
         }
     }
 }