コード例 #1
0
        public async Task <MajorIndex> GetMajorIndex(MajorIndexType indexType)
        {
            using (FinancialModelingPreHttpClient client = new FinancialModelingPreHttpClient())
            {
                string     uri        = "major-indexes/" + GetUriSuffix(indexType);
                MajorIndex majorIndex = await client.GetAsync <MajorIndex>(uri);

                majorIndex.Type = indexType;
                return(majorIndex);
            }
        }
コード例 #2
0
        public async Task <double> GetPrice(string symbol)
        {
            using (FinancialModelingPreHttpClient client = new FinancialModelingPreHttpClient())
            {
                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);
            }
        }