コード例 #1
0
        public async Task Handle(BalanceCheckEvent @event)
        {
            if (@event.Exchange == null || @event.Exchange == Constants.Binance)
            {
                var balanceInformation = await _exchangeService.GetBalance();

                if (@event.UserRequested)
                {
                    await _bus.SendAsync(new SendBalanceInfoCommand(balanceInformation));
                }
            }
        }
コード例 #2
0
        public async Task Handle(BagAndDustEvent @event)
        {
            var balanceInformation = await _binanceService.GetBalance();

            foreach (var walletBalance in balanceInformation.WalletBalances)
            {
                if (walletBalance.Currency == Constants.BTC)
                {
                    if (_config.LowBtcNotification.HasValue)
                    {
                        if (walletBalance.BtcAmount <= _config.LowBtcNotification.Value)
                        {
                            await SendBtcLowNotification(walletBalance.BtcAmount);
                        }
                    }
                }

                if (walletBalance.Currency != Constants.BTC && walletBalance.Currency != "USDT" &&
                    walletBalance.Currency != "USD")
                {
                    var averagePrice = await _databaseService.GetBuyAveragePrice(_generalConfig.TradingCurrency, walletBalance.Currency, Constants.Binance, walletBalance.Available);

                    var currentPrice = await _binanceService.GetPrice(_generalConfig.TradingCurrency, walletBalance.Currency);

                    if (_config.BagNotification.HasValue)
                    {
                        await BagManagement(currentPrice, averagePrice, walletBalance);
                    }

                    if (_config.DustNotification.HasValue)
                    {
                        await DustManagement(walletBalance);
                    }
                }
            }
        }