Ejemplo n.º 1
0
        /// <inheritdoc cref="IAlphaVantageService.GetEmaAsync"/>
        public async Task <List <EmaSampleDto> > GetEmaAsync(string symbol, Enums.Intervals interval, int timePeriod, SeriesType seriesType)
        {
            if (string.IsNullOrEmpty(symbol))
            {
                throw new ArgumentNullException(nameof(symbol));
            }

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

            if (timePeriod < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(timePeriod));
            }

            var function = ApiFunctions.EMA;

            var parameters = new Dictionary <ApiParameters, string>
            {
                { ApiParameters.Symbol, symbol },
                { ApiParameters.Interval, Intervals.Values[interval] },
                { ApiParameters.TimePeriod, timePeriod.ToString() },
                { ApiParameters.SeriesType, seriesType.ToLower() },
            };

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

            return(response.Data.Select(q => (EmaSampleDto)q).ToList());
        }
Ejemplo n.º 2
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.º 3
0
        public string this[Enums.Intervals value]
        {
            get
            {
                switch (value)
                {
                case Enums.Intervals.OneMin:
                    return("1min");

                case Enums.Intervals.FiveMin:
                    return("5min");

                case Enums.Intervals.FifteenMin:
                    return("15min");

                case Enums.Intervals.ThirtyMin:
                    return("30min");

                case Enums.Intervals.SixtyMin:
                    return("60min");

                case Enums.Intervals.Daily:
                    return("daily");

                case Enums.Intervals.Weekly:
                    return("weekly");

                case Enums.Intervals.Monthly:
                    return("monthly");

                default:
                    throw new IndexOutOfRangeException(AvResources.InvalidtIntervalValueError);
                }
            }
        }
Ejemplo n.º 4
0
        /// <inheritdoc cref="IAlphaVantageService.GetVwapAsync"/>
        public async Task <List <VwapSampleDto> > GetVwapAsync(string symbol, Enums.Intervals interval)
        {
            if (string.IsNullOrEmpty(symbol))
            {
                throw new ArgumentNullException(nameof(symbol));
            }

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

            var function = ApiFunctions.VWAP;

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

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

            return(response.Data.Select(q => (VwapSampleDto)q).ToList());
        }
Ejemplo n.º 5
0
 public void Reset()
 {
     _currentEnumValue = (Enums.Intervals) 1;
 }
Ejemplo n.º 6
0
 public void Dispose()
 {
     _currentEnumValue = (Enums.Intervals) 1;
 }