Exemple #1
0
        // Refreshes a single stock price
        public async static Task RefreshCurrentStockPrices(string ticker)
        {
            // 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      = GetStockPrice(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 newStock = new StockPriceHistory()
            {
                Id          = id,
                Ticker      = ticker,
                TickerPrice = price,
                Time        = dateTime
            };

            // Asynchronously inserts the data
            await StockPriceHistoryDataAccess.InsertData(newStock);
        }
Exemple #2
0
        public static async Task <StockPriceHistory> GetStockPriceHistory(string id)
        {
            var stockPriceHistory = await StockPriceHistoryDataAccess.GetStockPriceHistoryById(id);

            return(stockPriceHistory);
        }
Exemple #3
0
        public static async Task <List <StockPriceHistory> > GetAllStockPriceHistorys()
        {
            var stockPriceHistorys = await StockPriceHistoryDataAccess.GetAllStockPriceHistorys();

            return(stockPriceHistorys);
        }
Exemple #4
0
 public async static Task DeleteStockPriceHistory(string id)
 {
     await StockPriceHistoryDataAccess.DeleteData(id);
 }
Exemple #5
0
 public async static Task UpdateStockPriceHistory(StockPriceHistory stockPriceHistory)
 {
     await StockPriceHistoryDataAccess.UpdateData(stockPriceHistory);
 }
Exemple #6
0
 public async static Task InsertStockPriceHistory(StockPriceHistory stockPriceHistory)
 {
     await StockPriceHistoryDataAccess.InsertData(stockPriceHistory);
 }