예제 #1
0
        public void UpdateCurrentWallet()
        {
            using (var client = CreateBinanceClient())
            {
                var price       = client.GetPrice(_symbolPair.ToString());
                var accountInfo = client.GetAccountInfo();
                var s1b         = accountInfo.Data.Balances
                                  .Where(b => b.Asset == _symbolPair.Symbol1)
                                  .First();

                var s2b = accountInfo.Data.Balances
                          .Where(b => b.Asset == _symbolPair.Symbol2)
                          .First();

                SymbolAmountPair cw;
                var s1pcb = s1b.Total * price.Data.Price;
                if (s1pcb > s2b.Total)
                {
                    cw = SymbolAmountPair.Create(s1b.Asset, s1b.Total);
                }
                else
                {
                    cw = SymbolAmountPair.Create(s2b.Asset, s2b.Total);
                }

                if (cw != CurrentWallet)
                {
                    Wallets.Add(cw);
                }
            }
        }
예제 #2
0
        private async void AddWalletsView()
        {
            List <DBWallet> _wallets = null;

            try
            {
                IsWalletPanelEnabled = false;

                _wallets = await _serviceWallet.GetUserWalletsAsync(_currentUser.Login);

                foreach (var wallet in _wallets)
                {
                    Wallets.Add(new WalletDetailsViewModel(wallet, _serviceWallet, DeleteCurrentWallet));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Wallets loading was failed: {ex.Message}");
                return;
            }
            finally
            {
                IsWalletPanelEnabled = true;
            }
        }
예제 #3
0
        private void HandleEvent(object sender, ProfitableUserTradedEventArgs e)
        {
            if (e.Report.CurrencySymbol != _config.TargetCurrencySymbol)
            {
                _logger.Information("Report was not targeting our currency symbol.");
                return;
            }

            var eventOwnerUser = _repo.GetUserById(e.UserId);

            if (eventOwnerUser.CurrentWallet.Symbol == CurrentWallet.Symbol)
            {
                _logger.Information($"Skipping report due to trader and our wallets currency equality.");
            }

            if (AttachedUser == null || AttachedUser.Identifier == e.UserId)
            {
                if (!_attempCalculator.IsSucceededAttemp())
                {
                    _logger.Information("Skipping trade due to low attemps count.");
                    return;
                }

                if (AttachedUser == null)
                {
                    _logger.Information($"Attaching to user with Id: {e.UserId}");
                    AttachedUsersHistory.Add(e.UserId);
                    AttachedUserProfit = e.Report;
                    AttachedUser       = eventOwnerUser;
                }

                _logger.Information("Attached user traded. Repeating actions.");
                var trade = _repo.GetTradeById(e.TradeId);
                _lastTradeDate = trade.TradeTime;
                if (AttachedUser.CurrentWallet.Symbol == CurrentWallet.Symbol)
                {
                    _logger.Information("Currently the trader holds the currency that we already have.");
                    return;
                }

                _logger.Warning($"Wallet balance was {CurrentWallet.Amount}{CurrentWallet.Symbol}");
                _logger.Warning($"Selling {CurrentWallet.Amount}{CurrentWallet.Symbol} and buying {AttachedUser.CurrentWallet.Symbol}");
                var newWallet = CalculateWalletBalanceAfterTrade(CurrentWallet, trade.Price);
                Wallets.Add(newWallet);
                _logger.Warning($"After selling balance is {CurrentWallet.Amount}{CurrentWallet.Symbol}");
            }
            else
            {
                var maxTimeToWaitForAttachedUser = TimeSpan.FromTicks(AttachedUserProfit.AverageTradeThreshold.Ticks * 2);

                if (DateTime.UtcNow - _lastTradeDate > maxTimeToWaitForAttachedUser ||
                    e.Report.AverageProfitPerHour > AttachedUserProfit.AverageProfitPerHour)
                {
                    DetachAttachedUser();
                    HandleEvent(this, e);
                }
            }
        }
예제 #4
0
        public void UpdateCurrentWallet()
        {
            var nw = SymbolAmountPair.Create("USDT", 100m);

            if (nw != CurrentWallet)
            {
                Wallets.Add(nw);
            }
        }
예제 #5
0
        public void ReloadWallets()
        {
            Wallets.Clear();

            foreach (var wallet in _repository.GetWallets())
            {
                Wallets.Add(wallet);
            }
        }
예제 #6
0
        public MainWindowViewModel()
        {
            foreach (var wallet in WalletViewModel.Load(App.AppDir))
            {
                Wallets.Add(wallet);
                wallet.Update();
            }
            SelectedWallet = Wallets.FirstOrDefault();

            StartConnecting();
        }
예제 #7
0
 public static void UpdateWalletsCollection()
 {
     Wallets.Clear();
     foreach (Wallet wallet in _service.GetWallets())
     {
         if (wallet.OwnerGuid == CurrentInformation.User.Guid)
         {
             Wallets.Add(new WalletDetailsViewModel(wallet));
         }
     }
 }
예제 #8
0
        public void CreateWallet()
        {
            Wallet wallet   = new Wallet(_service.User);
            var    goodName = false;

            while (!goodName)
            {
                try
                {
                    wallet.Name = "new_wallet" + _service.User.WalletNextNumber;
                    goodName    = true;
                }
                catch (ArgumentException e) { }
            }
            _service.Wallets.Add(wallet);
            _service.User.MyWallets.Add(wallet);
            WalletDetailsViewModel wdvm = new WalletDetailsViewModel(wallet, this);

            Wallets.Add(wdvm);
            CurrentWallet = wdvm;
        }
예제 #9
0
        public async void AddNewWallet()
        {
            try
            {
                IsWalletPanelEnabled = false;
                DBWallet w = new DBWallet(Guid.NewGuid(), "My wallet", 0, "UAH", _currentUser.Login, "Here you can add description.", new List <DBTransaction>());
                await _serviceWallet.AddWalletsAsync(w);

                Wallets.Add(new WalletDetailsViewModel(w, _serviceWallet, DeleteCurrentWallet));
                RaisePropertyChanged(nameof(Wallets));
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Wallet add was failed: {ex.Message}");
                return;
            }
            finally
            {
                IsWalletPanelEnabled = true;
            }
            MessageBox.Show($"Wallet was added successfully!");
        }
예제 #10
0
 public void AddWallet(Wallet newWallet)
 {
     Wallets.Add(newWallet);
 }
예제 #11
0
 public void GiveWallet(Wallet newWallet)
 {
     Wallets.Add(newWallet);
 }
예제 #12
0
 public void AddWallet(Wallet wallet)
 {
     wallet.OwnerID = ID;
     Wallets.Add(wallet);
 }
 public void AddWallet(Wallet wallet)
 {
     Wallets.Add(wallet);
 }
예제 #14
0
 /// <summary>
 /// Adds a new wallet to the user.
 /// </summary>
 public void AddWallet()
 {
     Wallets.Add(walletBuilder.Build());
 }
예제 #15
0
        public void CreateWallet(string name)
        {
            var wallet = _repository.CreateWallet(name);

            Wallets.Add(wallet);
        }