コード例 #1
0
        public async Task <List <StockListItem> > GetStockListAsync()
        {
            using (FinancialModelingHttpClient client = _httpClientFactory.CreateHttpClient())
            {
                string uri = "stock/list";
                List <StockListItem> stockList = await client.GetAsync <List <StockListItem> >(uri);

                return(stockList);
            }
        }
コード例 #2
0
        public async Task <List <FinancialRatio> > GetFinancialRatiosAsync(string symbol)
        {
            using (FinancialModelingHttpClient client = _httpClientFactory.CreateHttpClient())
            {
                string uri = $"ratios/{symbol}";
                List <FinancialRatio> ratios = await client.GetAsync <List <FinancialRatio> >(uri);

                return(ratios);
            }
        }
コード例 #3
0
        public async Task <MajorIndex> GetMajorIndexAsync(MajorIndexType indexType)
        {
            using (FinancialModelingHttpClient client = _httpClientFactory.CreateHttpClient())
            {
                string     uri        = "majors-indexes/" + GetUriSuffix(indexType);
                MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri);

                majorIndex.Type = indexType;
                return(majorIndex);
            }
        }
コード例 #4
0
        public async Task <CompanyRaitingFinMod> GetCompanyRaitingAsync(string symbol)
        {
            using (FinancialModelingHttpClient client = _httpClientFactory.CreateHttpClient())
            {
                string uri = $"rating/{symbol}";
                List <CompanyRaitingFinMod> ratings = await client.GetAsync <List <CompanyRaitingFinMod> >(uri);

                if (!ratings.Any())
                {
                    throw new InvalidSymbolException(symbol);
                }
                return(ratings.First());
            }
        }
コード例 #5
0
        public async Task <double> GetPriceAsync(string symbol)
        {
            using (FinancialModelingHttpClient client = _httpClientFactory.CreateHttpClient())
            {
                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);
            }
        }