public async Task GetStockPrices_TickerFrequency(string ticker, ResampleFrequency frequency) { TiingoList <TiingoStockPrice> result = await this.service.GetStockPricesAsync(ticker : ticker, frequency : frequency); Assert.NotNull(result); Assert.True(result.ApiSuccessful); Assert.Equal(1, result.Count); }
/// <summary> /// Get stock prices. /// </summary> /// <param name="ticker">The ticker associated with the stock, Mutual Fund or ETF</param> /// <param name="startDate">(optional) If startDate or endDate is not null, historical data will be queried. This filter limits metrics to on or later than the startDate.</param> /// <param name="endDate">(optional) If startDate or endDate is not null, historical data will be queried. This filter limits metrics to on or less than the endDate.</param> /// <param name="frequency">(optional) Default: daily. Allows re-sampled values that allow you to choose the values returned as daily, weekly, monthly, or annually values. Note: ONLY DAILY takes into account holidays. All others use standard business days</param> /// <returns>TiingoList of StockPriceData</returns> public async Task<TiingoList<TiingoStockPrice>> GetStockPricesAsync( string ticker, DateTime? startDate = null, DateTime? endDate = null, ResampleFrequency frequency = ResampleFrequency.Daily) { StringBuilder paramter = new StringBuilder(); paramter.AppendUrlParamter("startDate", startDate); paramter.AppendUrlParamter("endDate", endDate); paramter.AppendUrlParamter("resampleFreq", frequency.ToString()); paramter.AppendUrlParamter("format", "json"); string path = $"tiingo/daily/{ticker}/prices{paramter}"; return await this.GetJsonAsync<TiingoList<TiingoStockPrice>, TiingoStockPrice>(path); }
public async Task GetStockPrices_DateRange(string ticker, string startDate, string endDate, ResampleFrequency frequency, int count) { TiingoList <TiingoStockPrice> result = await this.service.GetStockPricesAsync( ticker : ticker, startDate : Parse.NullDateTime(startDate), endDate : Parse.NullDateTime(endDate), frequency : frequency); Assert.NotNull(result); Assert.True(result.ApiSuccessful); Assert.Equal(count, result.Count); }