Пример #1
0
        // Refreshes a single fund price
        public async static Task RefreshCurrentFundPrices(string ticker, string fundId)
        {
            // Gets the yahoo finance url, gets its html, and parses through it to get the price
            var    financeUrl = string.Format("https://finance.yahoo.com/quote/{0}/?p={1}", ticker, ticker);
            string html       = GetHtml(financeUrl);
            double price      = GetFundPrice(html);

            // Need to use something in the format of Ticker-Date also put in time
            DateTime dateTime     = DateTime.Now;
            string   idDateString = dateTime.ToString("yyyy-MM-dd-HH:mm:ss");
            var      id           = ticker + "-" + idDateString;

            //var random = new Random();
            //var id = random.Next().ToString();
            var newFundPriceHistory = new FundPriceHistory()
            {
                Id          = id,
                FundId      = fundId,
                Ticker      = ticker,
                TickerPrice = price,
                Time        = dateTime
            };

            // Asynchronously inserts the data
            await FundPriceHistoryDataAccess.InsertData(newFundPriceHistory);
        }
Пример #2
0
 public async static Task InsertFundPriceHistory(FundPriceHistory fundPriceHistory)
 {
     await FundPriceHistoryDataAccess.InsertData(fundPriceHistory);
 }