void updateTimer_Tick(object sender, EventArgs e) { //Fetching all the stocks at once in XDocument file XDocument doc = Stock_quotes.FetchQuote(this.getAllSymbolsFromTable(data_table) + Main_view.market_symbol_string); //This will update the data_table this.addValuesToTheTable(data_table, doc); //This will update the market_table this.addValuesToTheTable(market_data_table, doc); }
/// <summary> /// Adds a stock symbol to the table or throws an ArgumentException /// </summary> /// <param name="symbol">symbol(s) to the added. Multiple entries are allowed that are separated by " " or ","</param> /// <param name="table"></param> public void addStockSymbolToTheTable(string symbol, DataTable table) { if (symbol != null && symbol.Length > 0) { XDocument xDoc = Stock_quotes.FetchQuote(symbol); List <Stock> list = Stock_quotes.getValidStocks(xDoc); foreach (Stock stock in list) { table.Rows.Add(stock.Symbol, stock.Company, stock.Date, stock.Time, stock.Y_close, stock.Trade, stock.Chg, stock.Perc_chg, stock.Volume, stock.High, stock.Low, stock.Chart_url, stock.Market_cap, stock.Exchange, stock.Currency); } } else { throw new ArgumentException("Added symbol is not accepted as a valid input"); } }