public void Update() { lnklblUpdate.Text = "Ladataan..."; Task.Run(() => { lock (reloadLock) { double oMXH25 = WebReader.ReadPage("https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=OMXH25&interval=60min&outputsize=compact&apikey=8YFH2JQFGQIM9T4L"); double sP500 = WebReader.ReadPage("https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=SPX&interval=60min&outputsize=compact&apikey=8YFH2JQFGQIM9T4L"); double eURUSD = WebReader.ReadCurrencyPage("https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=EUR&to_currency=USD&apikey=8YFH2JQFGQIM9T4L"); double bitcoin = WebReader.ReadCryptoCurrencyPage("https://www.alphavantage.co/query?function=DIGITAL_CURRENCY_DAILY&symbol=BTC&market=EUR&apikey=8YFH2JQFGQIM9T4L"); Invoke(new Action(() => { if (oMXH25 != 0) { lblOMXH25Value.Text = oMXH25.ToString() + " %"; lblOMXH25Value.Color(); } if (sP500 != 0) { lblSP500Value.Text = sP500.ToString() + " %"; lblSP500Value.Color(); } if (eURUSD != 0) { lblEURUSD.Text = eURUSD.ToString(); } if (bitcoin != 0) { lblBitcoinCurrency.Text = bitcoin.ToString() + " %"; lblBitcoinCurrency.Color(); } lnklblUpdate.Text = "Päivitä"; })); } }); }
private void txtFind_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.Hide("FindStock"); string item = txtFind.Text; bool containslist = false; Stock stock1 = null; foreach (var stock in this.loadedStocks) { if (stock.ExchangeID == item) { containslist = true; stock1 = stock; } } Stock s; if (containslist) { s = stock1; } else { s = WebReader.FindStock(item); } if (s != null) { pnlFindStock.Show(); if (this.user != null) { btnBuyStock.Show(); } this.stock = s; lblItem.Text = s.ExchangeID; lblStockPrice.Text = Math.Round(s.SharePrice, 2).ToString(); lblStockChange.Text = Math.Round(s.Change, 2).ToString() + " %"; lblStockChange.Color(); lblStockPrice.Color(); lblCorporationName.Text = s.Name; lblCurrency.Text = "Valuutta: " + s.Currency; graph.Series.Clear(); crtVolumes.Series.Clear(); Series Minimum = graph.Series.Add("Graph"); Series Volumes = crtVolumes.Series.Add("Volume"); List <string> keys = new List <string>(); List <double> chart = new List <double>(); List <long> volume = new List <long>(); for (int y = s.Keys.Count - 1; y > 0; y--) { keys.Add(s.Keys[y]); chart.Add(s.Chart[y]); volume.Add(s.Volumes[y]); } Minimum.Points.DataBindXY(keys, chart); Minimum.ChartType = SeriesChartType.Line; //graph.Scale(new SizeF(500f, 500f)); graph.Legends.Clear(); // graph.ChartAreas[0].AlignmentOrientation = AreaAlignmentOrientations.Vertical; double yMax = s.Chart.Max() + 1; double yMin = s.Chart.Min() - 1; graph.ChartAreas[0].AxisY.Maximum = yMax; graph.ChartAreas[0].AxisY.Minimum = yMin; Volumes.Points.DataBindXY(keys, volume); Volumes.ChartType = SeriesChartType.Column; crtVolumes.Legends.Clear(); double vyMax = s.Volumes.Max() + 1; double vyMin = 0; crtVolumes.ChartAreas[0].AxisY.Maximum = vyMax; crtVolumes.ChartAreas[0].AxisY.Minimum = vyMin; this.loadedStocks.Add(s); } } }