/* * public static void enterListenMode(string message) * { * while (true) * Console.WriteLine(message); * string input = * * * } */ public static void StockInformationSearch() { Console.Clear(); StockServiceClass Service = new StockServiceClass(); //Get number of stocks to listen to numberOfStocks = Service.getNumberOfStocks("Please enter in the number of stocks you would like to listen to", true, true); for (var i = 0; i < numberOfStocks; i++) { //Get the stock information for each stock you are listening to Console.WriteLine("Please enter the Stock Symbol you wish receive trade advice on"); string mySearchStock = Console.ReadLine(); Stock newStock = new Stock(); newStock = Service.getStockInformation(mySearchStock); listeningStocks.Add(newStock); stockComparisonList.Add(new StockComparison { current = newStock }); } Console.Clear(); //Output Chosen Stock Inforamtion to Screen foreach (Stock stock in listeningStocks) { Service.OutputStockData(stock); } EndSearchPrompt(); }
public static void GetCurrentStockPrice() { Console.Clear(); var stockService = new StockServiceClass(); foreach (var stockComparison in stockComparisonList) { stockComparison.previous = stockComparison.current; stockComparison.current = stockService.getStockInformation(stockComparison.current.symbol); // compare stockComparison.current.price to stockComparison.previous.price // show message advising BUY, SELL or KEEP string previousAsk = stockComparison.previous.ask; string currentAsk = stockComparison.current.ask; Console.WriteLine("The Previous price is: {0} || The current Price is: {1}", previousAsk, currentAsk); try { decimal previousPrice = Decimal.Parse(previousAsk); decimal currentPrice = Decimal.Parse(currentAsk); if (previousPrice > currentPrice) { Console.WriteLine("The price of {0} is falling. You should BUY! The Previous Price is: ${1} || The Current Price is ${2}", stockComparison.current.symbol, previousAsk, currentAsk); Console.WriteLine(" \n \n "); } else if (currentPrice > previousPrice) { Console.WriteLine("The price of {0} is Rising!. You should SELL! The Previous Price is: ${1} || The Current Price is ${2}", stockComparison.current.symbol, previousAsk, currentAsk); Console.WriteLine(" \n \n "); } else { Console.WriteLine("The price of {0} is Stagnent!. You should HOLD! The Previous Price is: ${1} || The Current Price is ${2}", stockComparison.current.symbol, previousAsk, currentAsk); Console.WriteLine(" \n \n "); } } catch (Exception) { Console.WriteLine("Your Stock is not availble..."); Console.WriteLine("CATCH WAS THROWN -- The Previous price is: {0} || The current Price is: {1}", previousAsk, currentAsk); } } Console.WriteLine(Line); Console.WriteLine("Press Enter to Exit Listen Mode"); Console.ReadLine(); isListening = false; return; /* * string input = Console.ReadLine(); * if(input == null) * { * EndSearchPrompt(); * isListening = false; * * } * else * { * EndSearchPrompt(); * isListening = false; * * } */ }