예제 #1
0
        private void StockOutput(string Symbol)
        {
            StockMarket stockmarket = new StockMarket("MWSOY45W94DB1V3J");
            string      finalOutputString;

            try
            {
                List <Equity> equityInfos = stockmarket.GetEquityInfo(Symbol);

                Equity latestData = equityInfos[0];


                string outputString = string.Format("The current open price of {0} is {1:C2}, highest it has been" +
                                                    "is {2:C2}, lower it has been is {3:C2}, current volume is {4}, stock info is pulled at {5}, " +
                                                    "current time is {6:d} at {6:t}", latestData.Symbol, latestData.Open, latestData.High, latestData.Low,
                                                    latestData.Volume, latestData.Timestamp, DateTime.Now);
                finalOutputString = outputString;

                foreach (Equity equity in equityInfos)
                {
                    string historicalString = String.Format("" +
                                                            "Open: {1:C2} \r\n " +
                                                            "Highest: {2:C2} \r\n " +
                                                            "Lowest: {3:C2} \r\n " +
                                                            "Volume: {4} \r\n " +
                                                            "Stock info is pulled at:  {5}, \r\n  " +
                                                            "Current time: {6:d} at {6:t}", equity.Symbol, equity.Open,
                                                            equity.High, equity.Low, equity.Volume, equity.Timestamp, DateTime.Now);

                    finalOutputString += "\r\n" + "\r\n" + historicalString;
                }

                resultBox.AppendText(finalOutputString);
                stockPriceBox.Text = latestData.Open.ToString();
            }
            catch (APICallLimitReachedException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception Eex)
            {
                MessageBox.Show(Eex.Message);
            }
        }