public async void Delete(DashboardPrediction prediction) { if (await this.PersistenceService.DeleteStockWithId(prediction.StockId)) { Messenger.Default.Send(new TrainStatusMessage($"Deleted {prediction.Name}")); this.Refresh(); } else { Messenger.Default.Send(new TrainStatusMessage($"Could not delete {prediction.Name}")); } }
public void NavigateToTrainView(DashboardPrediction prediction) { this.NavigationService.Navigate("TrainView", null, prediction, this, true); }
private async Task LoadData() { try { if (this._cancellationTokenSource != null && this._cancellationTokenSource.Token.CanBeCanceled && !this._cancellationTokenSource.IsCancellationRequested) { this._cancellationTokenSource.Cancel(); return; } this._cancellationTokenSource = new CancellationTokenSource(); this.IsBusy = true; await this.LoadSettings().ConfigureAwait(false); this.SetPortfolio(); // get list of all saved predictions var listBestPredictionsDtos = await this.PersistenceService.GetBestNetworkDTOs().ConfigureAwait(false); this.Predictions = new ObservableCollection <DashboardPrediction>(); // for each foreach (var dto in listBestPredictionsDtos) { if (this._cancellationTokenSource.Token.IsCancellationRequested) { return; } var stock = await this.PersistenceService.GetStockFromId(dto.StockId); stock.HistoricalData = await this.DownloaderService.GetHistoricalData(stock, this._settings.StartDate, DateTime.Now, true).ConfigureAwait(false); var dashboardPrediction = new DashboardPrediction { Symbol = stock.Symbol, Name = stock.Name, StockId = stock.GetUniqueId() }; lock (Locker) { Application.Current.Dispatcher?.Invoke(() => this.Predictions.Add(dashboardPrediction)); } TrainingSession trainingSession; try { trainingSession = await Task.Run(() => new TrainingSession(this.Portfolio, stock, dto, this._settings)).ConfigureAwait(false); } catch (Exception ex) { Messenger.Default.Send(new TrainStatusMessage($"Could setup training session for stock {stock.Name}: {ex.Message}", SeverityEnum.Error)); trainingSession = new TrainingSession(this.Portfolio, stock); } dashboardPrediction.TrainingSession = trainingSession; dashboardPrediction.Close = trainingSession.Stock.HistoricalData?.Quotes?.LastOrDefault().Value?.Close ?? 0d; dashboardPrediction.LastTrainingDate = dto.Timestamp; if (trainingSession.Stock.HistoricalData != null) { dashboardPrediction.LastUpdate = trainingSession.Stock.HistoricalData.EndDate; } } } finally { this.IsBusy = false; this._cancellationTokenSource = null; } }
public bool CanDelete(DashboardPrediction prediction) { return(prediction != null); }