public ExchangeAccountViewModel(ExchangeAccount acc) { Account = acc; Account.Deposits.Connect() .Sort(SortExpressionComparer <Transfer> .Descending(x => x.Timestamp)) .ObserveOnDispatcher() .Bind(out deposits) .Subscribe() .DisposeWith(disposables); Account.Withdrawals.Connect() .Sort(SortExpressionComparer <Transfer> .Descending(x => x.Timestamp)) .ObserveOnDispatcher() .Bind(out withdrawals) .Subscribe() .DisposeWith(disposables); Account.OpenOrders.Connect() .Sort(SortExpressionComparer <Order> .Descending(x => x.Created)) .ObserveOnDispatcher() .Bind(out openOrders) .Subscribe() .DisposeWith(disposables); Account.OrdersHistory.Connect() .Sort(SortExpressionComparer <Order> .Descending(x => x.Created)) .Filter(x => CancelledOrdersVisible || x.Status != OrderStatus.Cancelled) .ObserveOnDispatcher() .Bind(out ordersHistory) .Subscribe() .DisposeWith(disposables); Account.TradesHistory.Connect() .Sort(SortExpressionComparer <OrderTrade> .Descending(x => x.Timestamp)) .ObserveOnDispatcher() .Bind(out tradesHistory) .Subscribe() .DisposeWith(disposables); Account.BalanceManager.Balances.Connect() .Sort(SortExpressionComparer <Balance> .Ascending(x => x.Asset)) .ObserveOnDispatcher() .Bind(out balances) .Subscribe() .DisposeWith(disposables); this.WhenAnyValue(x => x.Account.BalanceManager.TotalBtc) .ToPropertyEx(this, vm => vm.TotalBtc); this.WhenAnyValue(x => x.Account.BalanceManager.TotalUsd) .ToPropertyEx(this, vm => vm.TotalUsd); }
public DsxViewModel() { var defaultAccount = new ExchangeAccount("default", client); Accounts.AddOrUpdate(defaultAccount); CurrentAccount = defaultAccount; this.HasSignedAccount = client.IsSigned; //AddRule(CreateStopLoss("ltcusd", 28.49m, 28.2m, 9.98m)); //AddRule(CreateStopLoss("ltcusd", 31.39m, 31.0m, 35.837m)); //AddRule(CreateStopLoss("ltceur", 25.59m, 25.29m, 10.08m)); //AddRule(CreateStopLoss("ltceur", 26.29m, 26.29m, 10.08m)); //AddRule(CreateStopLoss("ltcusd", 31.39m, 31.0m, 50m)); //AddRule(CreateTakeProfit("ltcusd", 39.99m, 39.49m, 65.97m)); //AddRule(CreateStopLoss("ethusd", 133.39m, 133.0m, 20m)); //AddRule(CreateTakeProfit("ethusd", 156.09m, 155.91m, 20m)); //Initialize(); }
public BinanceViewModel() { var defaultAccount = new ExchangeAccount("default", client); Accounts.AddOrUpdate(defaultAccount); CurrentAccount = defaultAccount; //getServerTimeCommand = ReactiveCommand.CreateFromTask<long, DateTime>(x => GetServerTimeAsync()); GetServerTime = ReactiveCommand.CreateFromTask(GetServerTimeImpl); GetSystemStatus = ReactiveCommand.CreateFromTask(GetSystemStatusImpl); KeepAliveUserDataStream = ReactiveCommand.CreateFromTask <string>(KeepAliveUserDataStreamImpl); FetchKlines = ReactiveCommand.CreateFromTask <int>(FetchKlinesImpl).DisposeWith(Disposables); ConvertKlines = ReactiveCommand.Create(ConvertKlinesImpl).DisposeWith(Disposables); //this.WhenActivated(disposables => //{ //registerDisposable(getServerTimeCommand); //var resultExchangeInfo = client.GetExchangeInfoOffline(); //currentExchangeInfo = resultExchangeInfo.Data; //var symbols = resultExchangeInfo.Data.symbols.Select(CreateSymbolInformation); //ProcessExchangeInfo(symbols); //var resultTickers = client.GetPriceTicker24hrOffline(); //var tickers = resultTickers.Data.Select(ToPriceTicker); //ProcessPriceTicker(tickers); //}); this.HasSignedAccount = client.IsSigned; Disposables.Add(klineSubscriptions); StatusItems = new ReadOnlyCollection <StatusItem>(new StatusItem[] { new StatusItem(), // Server time new StatusItem(), // # of trading pairs new StatusItem(), // client state new StatusItem(), // price ticker new StatusItem(), // book ticker new StatusItem() // system status }); }