Exemple #1
0
        public void QuoteStore_GetMissingQuote()
        {
            var expDate = new DateTime(2013, 08, 07, 22, 35, 00, DateTimeKind.Utc);

              var expQuote = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33924,
              Bid = 1.33907,
              Time = expDate
            };

              var expQuote2 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33925,
              Bid = 1.33908,
              Time = expDate.AddSeconds(1)
            };

              var quoteStore = new QuoteStore();

              quoteStore.Add(expQuote);
              quoteStore.Add(expQuote2);

              var actQuote = quoteStore.Get(expDate.AddHours(1));

              Assert.AreEqual(null, actQuote);
        }
Exemple #2
0
        public void QuoteStore_GetExistsQuote()
        {
            var expDate = new DateTime(2013, 08, 07, 22, 35, 00, DateTimeKind.Utc);

              var expQuote = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33924,
              Bid = 1.33907,
              Time = new DateTime(2013, 08, 07, 22, 35, 00, DateTimeKind.Utc)
            };

              var expQuote2 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33925,
              Bid = 1.33908,
              Time = expDate.AddSeconds(1)
            };

              var quoteStore = new QuoteStore();

              quoteStore.Add(expQuote);
              quoteStore.Add(expQuote2);

              var actQuote = quoteStore.Get(expDate);

              Assert.AreEqual(expQuote.Ask, actQuote.Ask);
              Assert.AreEqual(expQuote.Bid, actQuote.Bid);
              Assert.AreEqual(expQuote.Symbol, actQuote.Symbol);
        }
Exemple #3
0
 public void Add(Quote quote)
 {
     //Todo: Add check for each field of quote?
       //Todo: Check if some symbol is not unique in the same time?
       lock (_store)
       {
     _store.Add(quote);
       }
 }
Exemple #4
0
        public void QuoteStore_GetQuoteWithNullTime()
        {
            var expDate = new DateTime(2013, 08, 07, 22, 35, 00, DateTimeKind.Utc);

              var expQuote = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33924,
              Bid = 1.33907,
              Time = expDate
            };

              var expQuote2 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33925,
              Bid = 1.33908,
            };

              var quoteStore = new QuoteStore();

              quoteStore.Add(expQuote);
              quoteStore.Add(expQuote2);

              var actQuote = quoteStore.Get(Convert.ToDateTime(null));

              Assert.AreEqual(expQuote2.Ask, actQuote.Ask);
              Assert.AreEqual(expQuote2.Bid, actQuote.Bid);
              Assert.AreEqual(expQuote2.Symbol, actQuote.Symbol);
        }
Exemple #5
0
        public void QuoteStore_SaveQuotesToFileAndLoadQuotesFromSavedFile()
        {
            var expDate = new DateTime(2013, 08, 07, 22, 35, 00, DateTimeKind.Utc);

              var expQuote = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33924,
              Bid = 1.33907,
              Time = expDate
            };

              var expQuote2 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33925,
              Bid = 1.33908,
              Time = expDate.AddSeconds(1)
            };

              var quoteStore = new QuoteStore();

              quoteStore.Add(expQuote);
              quoteStore.Add(expQuote2);

              quoteStore.SaveToFile(AppDomain.CurrentDomain.BaseDirectory + @"\QuoteStore.xml");

              var quoteStoreFromFile = new QuoteStore();

              quoteStoreFromFile.LoadFromFile(AppDomain.CurrentDomain.BaseDirectory + @"\QuoteStore.xml");

              var actQuote = quoteStoreFromFile.Get(expDate);

              Assert.AreEqual(expQuote.Ask, actQuote.Ask);
              Assert.AreEqual(expQuote.Bid, actQuote.Bid);
              Assert.AreEqual(expQuote.Symbol, actQuote.Symbol);
        }
Exemple #6
0
        public void QuoteStore_RemoveQuote()
        {
            var expDate = new DateTime(2013, 08, 07, 22, 35, 00, DateTimeKind.Utc);
              var expDate2 = expDate.AddMinutes(2);
              var expDate3 = expDate.AddMinutes(3);
              var expDate4 = expDate.AddMinutes(5);

              var expQuote = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33924,
              Bid = 1.33907,
              Time = expDate
            };

              var expQuote2 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33925,
              Bid = 1.33908,
              Time = expDate2
            };

              var expQuote3 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33929,
              Bid = 1.33912,
              Time = expDate3
            };

              var expQuote4 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33927,
              Bid = 1.33910,
              Time = expDate4
            };

              var quoteStore4Elements = new QuoteStore();

              quoteStore4Elements.Add(expQuote);
              quoteStore4Elements.Add(expQuote2);
              quoteStore4Elements.Add(expQuote3);
              quoteStore4Elements.Add(expQuote4);

              quoteStore4Elements.Remove(expDate.AddMinutes(2), expDate.AddMinutes(3));

              Assert.AreEqual(expQuote, quoteStore4Elements.Get(expDate));
              Assert.AreEqual(null, quoteStore4Elements.Get(expDate2));
              Assert.AreEqual(null, quoteStore4Elements.Get(expDate3));
              Assert.AreEqual(expQuote4, quoteStore4Elements.Get(expDate4));
        }
Exemple #7
0
        public void QuoteStore_GetRangeOfQoutes()
        {
            var expDate = new DateTime(2013, 08, 07, 22, 35, 00, DateTimeKind.Utc);
              var expDate2 = expDate.AddMinutes(2);
              var expDate3 = expDate.AddMinutes(3);
              var expDate4 = expDate.AddMinutes(5);

              var expQuote = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33924,
              Bid = 1.33907,
              Time = expDate
            };

              var expQuote2 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33925,
              Bid = 1.33908,
              Time = expDate2
            };

              var expQuote3 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33929,
              Bid = 1.33912,
              Time = expDate3
            };

              var expQuote4 = new Quote
            {
              Symbol = "EURUSD",
              Ask = 1.33927,
              Bid = 1.33910,
              Time = expDate4
            };

              var quoteStore = new QuoteStore();

              quoteStore.Add(expQuote);
              quoteStore.Add(expQuote2);
              quoteStore.Add(expQuote3);
              quoteStore.Add(expQuote4);

              var actQuotes = quoteStore.GetRange(expDate2, expDate3).ToList();

              Assert.AreEqual(false, actQuotes.Exists(p => p.Time == expDate));
              Assert.AreEqual(true, actQuotes.Exists(p => p.Time == expDate2));
              Assert.AreEqual(true, actQuotes.Exists(p => p.Time == expDate3));
              Assert.AreEqual(false, actQuotes.Exists(p => p.Time == expDate4));
        }