Ejemplo n.º 1
0
        /// <inheritdoc cref="IAlphaVantageService.GetIntradaySeriesAsync"/>
        public async Task <List <SampleDto> > GetIntradaySeriesAsync(string symbol, Enums.Intervals interval, OutputSize outputSize = OutputSize.Full)
        {
            if (string.IsNullOrEmpty(symbol))
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            if (outputSize == OutputSize.None)
            {
                throw new ArgumentException(nameof(outputSize));
            }

            if (interval == Enums.Intervals.Unknown)
            {
                throw new ArgumentException(nameof(interval));
            }

            var function = ApiFunctions.TIME_SERIES_INTRADAY;

            var parameters = new Dictionary <ApiParameters, string>
            {
                { ApiParameters.Symbol, symbol },
                { ApiParameters.Interval, Intervals.Values[interval] },
                { ApiParameters.OutputSize, outputSize.ToLower() },
            };

            var response = await _connector.RequestApiAsync <Dictionary <DateTime, SampleAlphaDto> >(function, parameters);

            return(response.Data.Select(q => (SampleDto)q).ToList());
        }
Ejemplo n.º 2
0
        /// <inheritdoc cref="IAlphaVantageService.GetDailyTimeSeriesAdjustedAsync"/>
        public async Task <List <SampleAdjustedDto> > GetDailyTimeSeriesAdjustedAsync(string symbol, OutputSize outputSize = OutputSize.Compact)
        {
            if (string.IsNullOrEmpty(symbol))
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            if (outputSize == OutputSize.None)
            {
                throw new ArgumentException(nameof(outputSize));
            }

            var function = ApiFunctions.TIME_SERIES_DAILY_ADJUSTED;

            var parameters = new Dictionary <ApiParameters, string>
            {
                { ApiParameters.Symbol, symbol },
                { ApiParameters.OutputSize, outputSize.ToLower() },
            };

            var response = await _connector.RequestApiAsync <Dictionary <DateTime, SampleAdjustedAlphaDto> >(function, parameters);

            return(response.Data.Select(q => (SampleAdjustedDto)q).ToList());
        }