public void AddCandle(string symbol, int interval, long time, double open, double close, double high, double low, double volume, bool isAddToAll, bool isTriggerEvent)
 {
     lock (this)
     {
         if (Intervals.Contains(interval))
         {
             if (isAddToAll)
             {
                 var index   = this.Intervals.FindIndex(i => i == interval);
                 var quoteId = this.CreateQuote(symbol, interval);
                 var num     = Quotes[quoteId].AddUpdate(time, open, high, low, close, volume, isTriggerEvent);  //trigger dataadded event
                 //var num = Quotes[quoteId].AddUpdate(time, open, high, low, close, volume, false);             //do not trigger dataadded event to prevent from reducing number in buffer
                 if (num >= 0)
                 {
                     var d = this.AddToOtherQuotes(Quotes[quoteId], index + 1, isTriggerEvent);
                     //QuoteStore_OnDataAddedOrUpdated(this, this.Quotes[quoteId], num);
                     //foreach (var id in d.Keys) QuoteStore_OnDataAddedOrUpdated(this, this.Quotes[id], d[id]);
                 }
             }
             else
             {
                 var quoteId = this.CreateQuote(symbol, interval);
                 Quotes[quoteId].AddUpdate(time, open, high, low, close, volume, true);
             }
         }
     }
 }
 public void AddQuoteBasic(IQuoteBasicBase qb, bool isAddToAll, bool isTriggerEvent)
 {
     lock (this)
     {
         if (qb != null && qb.Count > 0 && Intervals.Contains(qb.Interval))
         {
             if (isAddToAll)
             {
                 var index    = this.Intervals.FindIndex(i => i == qb.Interval);
                 var interval = this.Intervals[index];
                 var quoteId  = this.CreateQuote(qb.Symbol, interval);
                 var num      = Quotes[quoteId].Append(qb, isTriggerEvent);                                                    //trigger OnQuoteBasicDataAddedOrUpdated
                 //var num = Quotes[quoteId].Append(qb, false);                                                      //do not trigger OnQuoteBasicDataAddedOrUpdated until we add to all quotes
                 if (num >= 0)
                 {
                     var d = this.AddToOtherQuotes(Quotes[quoteId], index + 1, isTriggerEvent);
                     //QuoteStore_OnDataAddedOrUpdated(this, this.Quotes[quoteId], num);
                     //foreach (var qId in d.Keys) QuoteStore_OnDataAddedOrUpdated(this, this.Quotes[qId], d[qId]);
                 }
             }
             else
             {
                 var quoteId = this.CreateQuote(qb.Symbol, qb.Interval);
                 var num     = Quotes[quoteId].Append(qb, isTriggerEvent);
             }
         }
     }
 }
Exemple #3
0
        public void PerfectFill()
        {
            var a = new Intervals<float>();
            a.Add(0, 5);
            Assert.That(a.Contains(-float.Epsilon), Is.False);
            Assert.That(a.Contains(0));
            Assert.That(a.Contains(4.999f));
            Assert.That(a.Contains(5), Is.False);
            a.Add(6, 10);
            Assert.That(a.Contains(6));
            Assert.That(a.Contains(9.999f));
            Assert.That(a.Contains(10), Is.False);

            Assert.That(a.Count(), Is.EqualTo(2));
            a.Add(5, 6);
            Assert.That(a.Count(), Is.EqualTo(1));
        }
Exemple #4
0
 public void AddingWithoutOverlap()
 {
     var a = new Intervals<int>();
     a.Add(0, 5);
     Assert.That(a.Contains(-1), Is.False);
     Assert.That(a.Contains(0));
     Assert.That(a.Contains(1));
     Assert.That(a.Contains(2));
     Assert.That(a.Contains(3));
     Assert.That(a.Contains(4));
     Assert.That(a.Contains(5), Is.False);
     a.Add(6, 10);
     Assert.That(a.Contains(6));
     Assert.That(a.Contains(7));
     Assert.That(a.Contains(8));
     Assert.That(a.Contains(9));
     Assert.That(a.Contains(10), Is.False);
     a.Add(-2, -1);
     Assert.That(a.Contains(-3), Is.False);
     Assert.That(a.Contains(2));
     Assert.That(a.Contains(-1), Is.False);
 }