コード例 #1
0
        public void CallServiceByDayWithoutDatesTest()
        {
            LatestQuotesService hqs = new LatestQuotesService();
            var candles             = hqs.GetValues("NASDAQ", "FB", Frequency.EveryDay);

            Assert.IsNotNull(candles);
            Assert.IsTrue(candles.Count() > 200);
            Assert.AreEqual(candles.First().Date, new DateTime(2012, 5, 17));
        }
コード例 #2
0
        public void CallServiceEveryHour()
        {
            var dateFrom            = new DateTime(2017, 6, 28);
            var dateTo              = new DateTime(2017, 7, 5);
            LatestQuotesService hqs = new LatestQuotesService();
            var candles             = hqs.GetValues("NASDAQ", "FB", Frequency.EveryHour, dateFrom, dateTo);

            Assert.IsNotNull(candles);
            Assert.AreEqual(candles.First().Date.Date, dateFrom);
            Assert.AreEqual(candles.Last().Date.Date, dateTo);
        }
コード例 #3
0
        public void CallServiceByDayWithDatesTest()
        {
            var dateFrom            = new DateTime(2017, 1, 1);
            var dateTo              = new DateTime(2017, 5, 1);
            LatestQuotesService hqs = new LatestQuotesService();
            var candles             = hqs.GetValues("NASDAQ", "FB", Frequency.EveryDay, dateFrom, dateTo);

            Assert.IsNotNull(candles);
            Assert.AreEqual(candles.Count(), 82);
            Assert.AreEqual(candles.First().Date, dateFrom.AddDays(2));
            Assert.AreEqual(candles.Last().Date, dateTo);
        }
コード例 #4
0
        public void CallServicesWithDifferentFrequencyAndCompareValues()
        {
            var dateFrom            = new DateTime(2017, 6, 28);
            var dateTo              = new DateTime(2017, 7, 5);
            LatestQuotesService hqs = new LatestQuotesService();
            var hourlyCandles       = hqs.GetValues("NASDAQ", "FB", Frequency.EveryHour, dateFrom, dateTo);
            var halfHourlycandles   = hqs.GetValues("NASDAQ", "FB", Frequency.EveryNMinutes(30), dateFrom, dateTo);

            var specificDateTime    = dateFrom.Add(new TimeSpan(12, 30, 0));
            var candleFor1230to1330 = hourlyCandles.FirstOrDefault(c => c.Date.Equals(specificDateTime));
            var candleFor1230to1300 = halfHourlycandles.FirstOrDefault(c => c.Date.Equals(specificDateTime));
            var candleFor1300to1330 = halfHourlycandles.FirstOrDefault(c => c.Date.Equals(specificDateTime.AddMinutes(30)));

            Assert.IsNotNull(candleFor1230to1330);
            Assert.IsNotNull(candleFor1230to1300);
            Assert.IsNotNull(candleFor1300to1330);
            Assert.IsTrue(candleFor1230to1330.Open.Equals(candleFor1230to1300.Open));
            Assert.IsTrue(candleFor1230to1330.Close.Equals(candleFor1300to1330.Close));
        }
コード例 #5
0
ファイル: GoogleFinanceApi.cs プロジェクト: Grawul/Graphance
 public List <Price> GetLatestData(Company company)
 {
     try
     {
         var lqs     = new LatestQuotesService();
         var candles = lqs.GetValues
                       (
             company.Market.Symbol,
             company.Symbol,
             Frequency.EveryNSeconds(10),
             company.Market.OpeningDateTime,
             DateTime.Now
                       );
         return(CandleConverterService.ConvertCandleToPrice(candles));
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #6
0
ファイル: GoogleFinanceApi.cs プロジェクト: Grawul/Graphance
 public List <Price> GetHistoricalData(Company company)
 {
     try
     {
         var lqs     = new LatestQuotesService();
         var candles = lqs.GetValues
                       (
             company.Market.Symbol,
             company.Symbol,
             Frequency.EveryNMinutes(10),
             DateTime.Today.Subtract(new TimeSpan(500, 0, 0, 0)),
             DateTime.Now
                       );
         return(CandleConverterService.ConvertCandleToPrice(candles));
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #7
0
        public void ComparePricesOfFbOnThisYearTest()
        {
            var historical = new HistoricalQuotesService();
            var latest     = new LatestQuotesService();

            var fromDate = new DateTime(2017, 1, 1);
            var toDate   = DateTime.Today;
            var symbol   = "FB";
            var market   = "NASDAQ";

            var histCandles = historical.GetValues(market, symbol, fromDate, toDate);
            var latCandles  = latest.GetValues(market, symbol, Frequency.EveryDay, fromDate, toDate);

            Assert.AreEqual(histCandles.Count(), latCandles.Count());
            this.CompareCandles(histCandles.First(), latCandles.First());

            var randomIndex = new Random().Next(histCandles.Count() - 1);

            this.CompareCandles(histCandles.ElementAt(randomIndex), latCandles.ElementAt(randomIndex));
        }
コード例 #8
0
ファイル: GoogleFinanceImporter.cs プロジェクト: lnaie/Trady
 public GoogleFinanceImporter()
 {
     _lqs = new LatestQuotesService();
 }