public void TestFromLocalFile() { var reader = new LatestCandleReader(Frequency.EveryDay); var str = new StringReader(File.ReadAllText("Files\\latest.fb.txt")); var candles = reader.Read(str); Assert.IsNotNull(candles); var firstCandle = candles.First(); Assert.AreEqual(firstCandle.Date, new DateTime(2012, 5, 17)); }
public IEnumerable <Candle> GetValues(string market, string symbol, int numberOfSeconds, DateTime?from = null, DateTime?to = null) { try { var url = this.GetUrl(market, symbol, numberOfSeconds, from, to); var response = this.restCaller.Get(url); if (response == null) { throw new QuotesServiceException(market, symbol, from, to); } if (response.Length == 0) { return(new Candle[0]); } if ((numberOfSeconds < Frequency.EveryDay) && (to.HasValue && to.Value.TimeOfDay.Equals(new TimeSpan(0, 0, 0)))) { // If to value is set and the time has not been set (so it's 0:00) then is set to 23:59:59 // to include values for that day in the result. to = to.Value.Add(new TimeSpan(23, 59, 59)); } var reader = new LatestCandleReader(numberOfSeconds); return(reader.Read(new StringReader(response)) .Where(c => (!from.HasValue || c.Date >= from.Value) && (!to.HasValue || c.Date <= to.Value))); } catch (QuotesServiceException) { throw; } catch (Exception e) { throw new QuotesServiceException(market, symbol, from, to, e); } }