Exemplo n.º 1
0
 public Trade(string ticker, decimal quantity)
 {
     this.ticker            = ticker;
     this.quantity          = quantity;
     response               = APIQuoteInfo.GetPriceInfo(ticker.ToUpper());
     lastPrice              = response.Ticker.LastPrice;
     description            = response.Ticker.Description;
     assetType              = response.Ticker.AssetType;
     cashAmount             = lastPrice * quantity;
     currentCash            = this.CurrentHoldingQuantity("CASH");
     currentHoldingQuantity = this.CurrentHoldingQuantity(ticker);
 }
        //End Region - Current Portfolio

        //Region - Get Quote Info

        private void buttonGetQuote_Click(object sender, EventArgs e)
        {
            string userInputTicker = tickerVerifier(textBoxTickerInput.Text);

            if (userInputTicker != "invalid")
            {
                JSONParseQuote response    = APIQuoteInfo.GetPriceInfo(userInputTicker);
                decimal        lastPrice   = response.Ticker.LastPrice;
                string         description = response.Ticker.Description;
                string         assetType   = response.Ticker.AssetType;
                double         volume      = response.Ticker.TotalVolume;

                labelLastPrice.Text        = lastPrice.ToString();
                labelQuoteDescription.Text = description;
                labelQuoteAssetType.Text   = assetType;
                labelVolume.Text           = volume.ToString();
            }
            else
            {
                MessageBox.Show("Enter valid ticker.");
            }
        }