public virtual Stockhist getstockhist(string ticker, int numdays, string period, string type) { string test = "{%22Normalized%22:false,%22NumberOfDays%22:" + numdays + ",%22DataPeriod%22:%22" + period + "%22,%22Elements%22:[{%22Symbol%22:%22" + ticker + "%22,%22Type%22:%22" + type + "%22,%22Params%22:[%22ohlc%22]},{%22Symbol%22:%22" + ticker + "%22,%22Type%22:%22volume%22}]}"; var client = new RestClient(clientwebadrress); var request = new RestRequest(clienthist + test, Method.GET); IRestResponse response = client.Execute(request); var content = response.Content; Console.WriteLine(content[0]); Stockhist stockhist1 = new Stockhist(); char test1 = content[0]; char r = 'R'; char g = '<'; do { if (content[0] != r && content[0] != g) { stockhist1 = JsonConvert.DeserializeObject <Stockhist>(content); } Console.WriteLine("Test"); Thread.Sleep(2000); } while (content[0] == r && content[0] == g); return(stockhist1); }
private void LookupButton_Click(object sender, EventArgs e) { string ticker = tickerBox.Text.ToUpper(); API_CALL call = new API_CALL(); currentStock = call.getspecificStock(ticker); StockInfoBox.Text = "Name: " + currentStock.Name + "\r\nTicker: " + currentStock.Symbol + "\r\nCurrent Price: " + currentStock.LastPrice.ToString() + " USD" + "\r\nRecord High : " + currentStock.High.ToString() + " USD" + "\r\nRecord Low : " + currentStock.Low.ToString() + " USD" + "\r\nTime Stamp : " + currentStock.TimeStamp; foreach (var series in chart1.Series) { series.Points.Clear(); } //Thread.Sleep(5000); Stockhist currentStockhist = new Stockhist(); currentStockhist = call.getstockhist(ticker, 365, "Day", "price"); if (currentStockhist.Dates != null) { for (int i = 0; i < currentStockhist.Positions.Length; i++) { chart1.Series["Close Price"].Points.AddXY(currentStockhist.Dates[i], currentStockhist.Elements[0].DataSeries.close.values[i]); } } }
public void chartest(string ticker) { //VolumeChart API_CALL call = new API_CALL(); Stockhist currentStock = new Stockhist(); currentStock = call.getstockhist(ticker, 365, "Day", "price"); if (currentStock.Dates != null) { for (int i = 0; i < currentStock.Positions.Length; i++) { VolumeChart.Series["Close Price"].Points.AddXY(currentStock.Dates[i], currentStock.Elements[0].DataSeries.close.values[i]); } } }