コード例 #1
0
        public IRuleResult RuleExecuted(Solbot solbot)
        {
            var accountInfo = _binanceClient.General.GetAccountInfo();

            var result   = false;
            var baseMsg  = string.Empty;
            var quoteMsg = string.Empty;

            if (accountInfo.Success)
            {
                var availableBase  = accountInfo.Data.Balances.FirstOrDefault(e => e.Asset == solbot.Communication.Symbol.BaseAsset).Free;
                var availableQuote = accountInfo.Data.Balances.FirstOrDefault(e => e.Asset == solbot.Communication.Symbol.QuoteAsset).Free;

                solbot.Communication.AvailableAsset = new AvailableAssetMessage
                {
                    Base  = availableBase,
                    Quote = availableQuote
                };

                baseMsg  = $"{solbot.Communication.Symbol.BaseAsset}:{availableBase}";
                quoteMsg = $"{solbot.Communication.Symbol.QuoteAsset}:{availableQuote}";

                result = true;
            }

            return(new ExchangeRuleResult
            {
                Success = result,
                Message = LogGenerator.ExchangeLog(baseMsg, quoteMsg, accountInfo.Error?.Message)
            });
        }
コード例 #2
0
        public IRuleResult RuleExecuted(Solbot solbot)
        {
            var accountInfo = _kucoinClient.GetAccounts();

            var result   = false;
            var baseMsg  = string.Empty;
            var quoteMsg = string.Empty;

            if (accountInfo.Success)
            {
                var accountType = accountInfo.Data.Where(a => a.Type == KucoinAccountType.Trade).ToList();

                var           quote = accountType.FirstOrDefault(q => q.Currency == solbot.Communication.Symbol.QuoteAsset);
                KucoinAccount basee = null;

                if (solbot.Communication.Symbol.BaseAsset.ToUpper() == "BSV")
                {
                    basee = accountType.FirstOrDefault(q => q.Currency == "BCHSV");
                }
                else
                {
                    basee = accountType.FirstOrDefault(q => q.Currency == solbot.Communication.Symbol.BaseAsset);
                }

                var baseAvailable = basee != null ? basee.Available : 0m;

                if (accountType.AnyAndNotNull())
                {
                    solbot.Communication.AvailableAsset = new AvailableAssetMessage
                    {
                        Quote = quote.Available,
                        Base  = baseAvailable
                    };

                    baseMsg  = $"{solbot.Communication.Symbol.BaseAsset}:{baseAvailable}";
                    quoteMsg = $"{solbot.Communication.Symbol.QuoteAsset}:{quote.Available}";

                    result = true;
                }
            }

            return(new ExchangeRuleResult
            {
                Success = result,
                Message = LogGenerator.ExchangeLog(baseMsg, quoteMsg, accountInfo.Error?.Message)
            });
        }
コード例 #3
0
        public IRuleResult RuleExecuted(Solbot solbot)
        {
            var accountInfo = _binanceClient.GetAccountInfo();

            var availableBase  = accountInfo.Data.Balances.FirstOrDefault(e => e.Asset == solbot.Communication.Symbol.BaseAsset).Free;
            var availableQuote = accountInfo.Data.Balances.FirstOrDefault(e => e.Asset == solbot.Communication.Symbol.QuoteAsset).Free;

            solbot.Communication.AvailableAsset = new AvailableAssetMessage
            {
                Base  = availableBase,
                Quote = availableQuote
            };

            return(new ExchangeRuleResult
            {
                Success = true,
                Message = LogGenerator.ExchangeLog($"{solbot.Communication.Symbol.BaseAsset}:{availableBase}", $"{solbot.Communication.Symbol.QuoteAsset}:{availableQuote}")
            });
        }