Ejemplo n.º 1
0
        public void btcOutput()
        {
            StockMarket stockmarket = new StockMarket("MWSOY45W94DB1V3J");
            string      finalOutputString;



            try
            {
                List <BitCoin> GetBTCInfo = stockmarket.GetBitCoinInfo();

                BitCoin latestData = GetBTCInfo[0];


                string outputString = string.Format("The current open price of {0} in China is {1:C2}, highest it has been" +
                                                    "is {2:C2}, lower it has been is {3:C2}, close is {4}. The current open price of {5} in US is {6:C2}, highest it has been" +
                                                    "is {7:C2}, lower it has been is {8:C2}, close is {9}. Market Volume is {10}, and Market Cap is {11} BTC info is pulled at {12}, " +
                                                    "current time is {13:d} at {13:t}", latestData.GetType().Name, latestData.OpenCNY, latestData.HighCNY, latestData.LowCNY,
                                                    latestData.CloseCNY, latestData.GetType().Name, latestData.OpenUSD, latestData.HighUSD, latestData.LowUSD,
                                                    latestData.CloseUSD, latestData.Volume, latestData.MarketCap, latestData.Timestamp, DateTime.Now);
                finalOutputString = outputString;

                foreach (BitCoin bit in GetBTCInfo)
                {
                    string historicalString = String.Format("" +
                                                            "CNY Open: {1:C2} \r\n " +
                                                            "CNY Highest: {2:C2} \r\n " +
                                                            "CNY Lowest: {3:C2} \r\n " +
                                                            "CNY Close: {4} \r\n " +
                                                            "USD Open: {5:C2} \r\n " +
                                                            "USD Highest: {6:C2} \r\n " +
                                                            "USD Lowest: {7:C2} \r\n " +
                                                            "USD Close: {8} \r\n " +
                                                            "Market Volume: {9} \r\n " +
                                                            "Market Cap: {10} \r\n " +
                                                            "BTC info is pulled at:  {11}, \r\n  " +
                                                            "Current time: {12:d} at {12:t}", bit.GetType().Name, bit.OpenCNY,
                                                            bit.HighCNY, bit.LowCNY, bit.CloseCNY, latestData.OpenUSD, latestData.HighUSD, latestData.LowUSD,
                                                            latestData.CloseUSD, latestData.Volume, latestData.MarketCap, bit.Timestamp, DateTime.Now);

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

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