コード例 #1
0
        /// <summary>
        /// Returns Forex time series for a given currencies pair
        /// </summary>
        /// <param name="forexClient"></param>
        /// <param name="fromCurrency"></param>
        /// <param name="toCurrency"></param>
        /// <param name="interval"></param>
        /// <param name="outputSize"></param>
        /// <returns></returns>
        public static async Task <ForexTimeSeries> GetTimeSeriesAsync(this ForexClient forexClient,
                                                                      PhysicalCurrency fromCurrency,
                                                                      PhysicalCurrency toCurrency,
                                                                      Interval interval,
                                                                      OutputSize outputSize = OutputSize.Compact)
        {
            var parser = new ForexTimeSeriesParser(interval, fromCurrency, toCurrency);

            var query = new Dictionary <string, string>()
            {
                { ApiQueryConstants.FromSymbolQueryVar, fromCurrency.ToString() },
                { ApiQueryConstants.ToSymbolQueryVar, toCurrency.ToString() },
            };

            var function = interval.ConvertToApiFunction();

            if (function == ApiFunction.FX_INTRADAY)
            {
                query.Add(ApiQueryConstants.IntervalQueryVar, interval.ConvertToQueryString());
            }

            if (function == ApiFunction.FX_INTRADAY || function == ApiFunction.FX_DAILY)
            {
                query.Add(ApiQueryConstants.OutputSizeQueryVar, outputSize.ConvertToQueryString());
            }

            return(await forexClient.RequestApiAsync(parser, function, query));
        }
コード例 #2
0
        /// <summary>
        /// Returns stocks time series for requested symbol
        /// </summary>
        /// <param name="stocksClient"></param>
        /// <param name="symbol"></param>
        /// <param name="interval"></param>
        /// <param name="size"></param>
        /// <param name="isAdjusted"></param>
        /// <returns></returns>
        public static async Task <StockTimeSeries> GetTimeSeriesAsync(this StocksClient stocksClient,
                                                                      string symbol,
                                                                      Interval interval,
                                                                      OutputSize size = OutputSize.Compact,
                                                                      bool isAdjusted = false)
        {
            var parser = new StocksTimeSeriesParser(interval, isAdjusted);

            var query = new Dictionary <string, string>()
            {
                { ApiQueryConstants.SymbolQueryVar, symbol },
                { ApiQueryConstants.OutputSizeQueryVar, size.ConvertToQueryString() }
            };

            var function = interval.ConvertToApiFunction(isAdjusted);

            if (function == ApiFunction.TIME_SERIES_INTRADAY)
            {
                query.Add(ApiQueryConstants.IntervalQueryVar, interval.ConvertToQueryString());
            }

            return(await stocksClient.RequestApiAsync(parser, function, query));
        }