public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType)
        {
            string uri = "majors-indexes/" + GetUriSuffix(indexType);

            MajorIndex majorIndex = await _client.GetAsync <MajorIndex>(uri);

            majorIndex.Type = indexType;

            return(majorIndex);
        }
        public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType)
        {
            using (FinancialModelingPrepHttpClient client = new FinancialModelingPrepHttpClient())
            {
                string     uri        = "majors-indexes/" + GetUriSuffix(indexType);
                MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri);

                majorIndex.Type = indexType;
                return(majorIndex);
            }
        }
        public async Task <double> GetPrice(string symbol)
        {
            string           uri = $"stock/real-time-price/{symbol}";
            StockPriceResult stockPriceResult = await client.GetAsync <StockPriceResult>(uri);

            if (stockPriceResult.Price == 0)
            {
                throw new InvalidSymbolException(symbol);
            }

            return(stockPriceResult.Price);
        }
        public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType)
        {
            using (FinancialModelingPrepHttpClient client = new FinancialModelingPrepHttpClient())
            {
                string uri = "majors-indexes/" + GetUriSuffix(indexType) + @"?apikey=b346753a14deb665d5489815d0a56b42";

                MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri);

                majorIndex.Type = indexType;

                return(majorIndex);
            }
        }
Exemple #5
0
        public async Task <double> GetPrice(string symbol)
        {
            using (FinancialModelingPrepHttpClient client = new FinancialModelingPrepHttpClient())
            {
                string           uri = "stock/real-time-price/" + symbol;
                StockPriceResult stockPriceResult = await client.GetAsync <StockPriceResult>(uri);

                if (stockPriceResult.Price == 0)
                {
                    throw new InvalidSymbolException(symbol);
                }
                return(stockPriceResult.Price);
            }
        }
        public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType)
        {
            using (FinancialModelingPrepHttpClient client = new FinancialModelingPrepHttpClient())
            {
                string uri = @"majors-indexes/" + GetUriSuffix(indexType) +
                             "?apikey=618edc49f868d97ae7a519ed762c4bf7";

                MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri);

                majorIndex.Type = indexType;

                return(majorIndex);
            }
        }
        public async Task <double> GetPrice(string symbol)
        {
            using var client = new FinancialModelingPrepHttpClient();
            var    uri    = "stock/real-time-price/" + symbol;
            string apiKey = "f9640047997a5e29a933b2a86d1c337f";

            var stockPriceResult = await client.GetAsync <StockPriceResult>($"{uri}?apikey={apiKey}");

            if (stockPriceResult.Price == 0)
            {
                throw new InvalidSymbolException(symbol);
            }

            return(stockPriceResult.Price);
        }
        public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType)
        {
            using var client = new FinancialModelingPrepHttpClient();
            var          uri    = "majors-indexes/" + GetUriSuffix(indexType);
            const string apiKey = "f9640047997a5e29a933b2a86d1c337f";

            var response = await client.GetAsync($"{uri}?apikey={apiKey}");

            var jsonResponse = await response.Content.ReadAsStringAsync();

            var majorIndex = JsonConvert.DeserializeObject <MajorIndex>(jsonResponse);

            majorIndex.Type = indexType;

            return(majorIndex);
        }
        public async Task <double> GetPrice(string symbol)
        {
            using (FinancialModelingPrepHttpClient client = new FinancialModelingPrepHttpClient())
            {
                string uri = "stock/real-time-price/" + symbol + @"?apikey=b346753a14deb665d5489815d0a56b42";

                StockPriceResult stockPriceResult = await client.GetAsync <StockPriceResult>(uri);

                if (stockPriceResult.price == 0)
                {
                    throw new InValidSymbolException(symbol);
                }

                return(stockPriceResult.price);
            }
        }
        public async Task <double> GetPrice(string symbol)
        {
            using (FinancialModelingPrepHttpClient client = new FinancialModelingPrepHttpClient())
            {
                string uri = @"stock/real-time-price/" + symbol +
                             "?apikey=618edc49f868d97ae7a519ed762c4bf7";


                StockPriceResult stockPriceResult = await client.GetAsync <StockPriceResult>(uri);

                if (stockPriceResult.Price == 0)
                {
                    throw new InvalidSymbolException(symbol);
                }

                return(stockPriceResult.Price);
            }
        }