コード例 #1
0
ファイル: TradingViewModel.cs プロジェクト: loobins/tradeview
        public TradingViewModel(ViewModelContext viewModelContext,
                                AccountViewModel accountViewModel,
                                SymbolsViewModel symbolsViewModel,
                                TradePanelViewModel tradePanelViewModel,
                                IWpfExchangeService exchangeService,
                                IAccountsService accountsService,
                                IOrderBookHelperFactory orderBookHelperFactory,
                                ITradeHelperFactory tradeHelperFactory,
                                IChartHelper chartHelper)
            : base(viewModelContext)
        {
            AccountViewModel = accountViewModel;
            SymbolsViewModel = symbolsViewModel;
            TradeViewModel   = tradePanelViewModel;

            this.exchangeService        = exchangeService;
            this.accountsService        = accountsService;
            this.orderBookHelperFactory = orderBookHelperFactory;
            this.tradeHelperFactory     = tradeHelperFactory;
            this.chartHelper            = chartHelper;

            ObserveSymbols();
            ObserveAccount();
            ObserveTrade();
        }
コード例 #2
0
        protected async override void OnPublished(object data)
        {
            if (isOpen)
            {
                return;
            }

            IsBusy = true;

            if (Messages != null &&
                Messages.Any())
            {
                ClearMessages();
            }

            accountViewModel.Dispatcher = ViewModelContext.UiDispatcher;
            symbolsViewModel.Dispatcher = ViewModelContext.UiDispatcher;
            tradeViewModel.Dispatcher   = ViewModelContext.UiDispatcher;
            ordersViewModel.Dispatcher  = ViewModelContext.UiDispatcher;

            Account = new Account(new Core.Model.AccountInfo {
                User = new Core.Model.User()
            });

            try
            {
                userAccount = await accountsService.GetAccountAsync(Title);

                var json = JsonConvert.SerializeObject(userAccount, Formatting.Indented);
                Logger.Log(json, Category.Info, Priority.Medium);
            }
            catch (Exception ex)
            {
                TradingViewModelException(ex.ToString(), ex);
            }

            if (userAccount != null &&
                userAccount.Preferences != null)
            {
                if (!string.IsNullOrWhiteSpace(userAccount.ApiKey))
                {
                    Account.AccountName   = userAccount.AccountName;
                    Account.ApiKey        = userAccount.ApiKey;
                    Account.ApiSecret     = userAccount.ApiSecret;
                    Account.ApiPassPhrase = userAccount.ApiPassPhrase;
                    Account.Exchange      = userAccount.Exchange;
                }
            }

            await Task.WhenAll(SymbolsViewModel.SetAccount(userAccount), AccountViewModel.Login(Account));

            isOpen = true;
            IsBusy = false;
        }
コード例 #3
0
ファイル: TradingViewModel.cs プロジェクト: loobins/tradeview
        protected override void OnDisposing()
        {
            if (disposed)
            {
                return;
            }

            symbolsObservableSubscription?.Dispose();
            tradeObservableSubscription?.Dispose();
            accountObservableSubscription.Dispose();
            symbolObservableSubscription?.Dispose();

            AccountViewModel.Dispose();
            SymbolsViewModel?.Dispose();
            TradeViewModel?.Dispose();
            SymbolViewModel?.Dispose();

            disposed = true;
        }