private async void History2y(object sender, RoutedEventArgs e) { var values = new ChartValues <DateTimePoint>(); Int_TIME_SERIES_WEEKLY_ADJUSTED time_series_weekly_adjusted = _connection.GetQueryObject_TIME_SERIES_WEEKLY_ADJUSTED(); try { IAvapiResponse_TIME_SERIES_WEEKLY_ADJUSTED time_series_weekly_adjustedResponse = await time_series_weekly_adjusted.QueryPrimitiveAsync(_args.Symbol); var data = time_series_weekly_adjustedResponse.Data; if (data.Error) { MessageBox.Show("Failed to fetch data", "Error"); SeriesCollection[0].Values = Read("\\2y.csv"); ResetZoomOnClick(sender, e); return; } else { DateTime offset = new DateTime(DateTime.Today.Year - 2, DateTime.Today.Month, DateTime.Today.Day); DateTime temp; foreach (var timeseries in data.TimeSeries) { temp = DateTime.ParseExact(timeseries.DateTime, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (temp > offset) { values.Add(new DateTimePoint(temp, double.Parse(timeseries.adjustedclose) * _exchangeRate)); } } Write("\\2y.csv", values); } } catch (Exception) { MessageBox.Show("Previse zahteva poslato u kratkom vremene server misli da si spamer! Oladi malo sa kliktanjem."); SeriesCollection[0].Values = Read("\\2y.csv"); ResetZoomOnClick(sender, e); return; } SeriesCollection[0].Values = Read("\\2y.csv"); //SeriesCollection[0].Values = values; ResetZoomOnClick(sender, e); }