Ejemplo n.º 1
0
        private async void GenerateReport(List <Trade> tradeIDs)
        {
            if (tradeIDs == null)
            {
                throw new NullReferenceException("tradeIDs");
            }
            if (tradeIDs.Count == 0)
            {
                await DialogService.ShowMessageAsync(this, "Error", "No trades meet the given criteria");

                return;
            }

            var gen = new ReportGenerator();
            ProgressDialogController progressDialog = await DialogService.ShowProgressAsync(this, "Generating Report", "Generating Report");

            var ds = await Task.Run(() => gen.TradeStats(
                                        tradeIDs,
                                        PerformanceReportPageViewModel.ReportSettings,
                                        Settings,
                                        Datasourcer,
                                        _contextFactory,
                                        backtestData: PerformanceReportPageViewModel.BacktestData,
                                        progressDialog: progressDialog));

            progressDialog.CloseAsync().Forget(); //don't await it!

            var window = new PerformanceReportWindow(ds, PerformanceReportPageViewModel.ReportSettings);

            window.Show();
        }
Ejemplo n.º 2
0
        private void CreateCommands()
        {
            GenerateReportFromStrategy = new RelayCommand <IList>(GenReportFromStrategy);
            GenerateReportFromTags     = new RelayCommand <IList>(GenReportFromTags);
            GenerateReportFromTrades   = new RelayCommand <IList>(GenReportFromTrades);

            LoadStatementFromWeb = ReactiveCommand.CreateFromTask <string>(async x =>
            {
                var progressDialog = await DialogService.ShowProgressAsync(this, "Load Statement from Web", "Downloading").ConfigureAwait(false);
                var newData        = await StatementHandler.LoadFromWeb(x, progressDialog);
                if (newData == null)
                {
                    await progressDialog.CloseAsync();
                    return;
                }

                await PostStatementLoadProcedures(newData, progressDialog);
            });
            LoadStatementFromFile = ReactiveCommand.CreateFromTask <string>(async x =>
            {
                var progressDialog = await DialogService.ShowProgressAsync(this, "Load Statement from File", "Opening File");
                var newData        = await StatementHandler.LoadFromFile(x, progressDialog);
                if (newData == null)
                {
                    await progressDialog.CloseAsync();
                    return;
                }

                await PostStatementLoadProcedures(newData, progressDialog);
            });

            LoadStatementFromFile.ThrownExceptions.Subscribe(ex =>
            {
                _logger.Error(ex, "Error on file load");
                DialogService.ShowMessageAsync(this, "Error", ex.Message);
            });
        }