public IRuleResult RuleExecuted(Solbot solbot) { _rules.Add(new AvailableAssetBaseRule()); _rules.Add(new AvailableEnoughAssetBaseRule()); _rules.Add(new SellPriceReachedRule()); _rules.Add(new BoughtPriceBeforeSellAndStopLossRule()); _rules.Add(new SellPriceHigherThanBoughtPriceRule()); var result = true; foreach (var item in _rules) { var resultOrderStep = item.RuleExecuted(solbot); if (resultOrderStep.Success) { Logger.Info($"{MarketOrder.GetDescription()} => {resultOrderStep.Message}"); } else { result = false; Logger.Warn($"{MarketOrder.GetDescription()} => {resultOrderStep.Message}"); } } solbot.Communication.Sell.IsReady = result; return(new MarketRuleResult() { Success = result, Message = result ? LogGenerator.PriceMarketSuccess(MarketOrder) : LogGenerator.PriceMarketError(MarketOrder) }); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = _marketService.IsGoodToBuy( solbot.Strategy.AvailableStrategy.CommissionType, solbot.Strategy.AvailableStrategy.BuyDown, solbot.Communication.Average.Current, solbot.Communication.Price.Current); solbot.Communication.Buy = new ChangeMessage { Change = result.Changed, PriceReached = result.IsReadyForMarket }; if (_isInProductionMode) { var fundResponse = _marketService.AvailableQuote(solbot.Strategy.AvailableStrategy.FundPercentage, solbot.Communication.AvailableAsset.Quote, solbot.Communication.Symbol.QuoteAssetPrecision); solbot.Communication.Buy.AvailableFund = fundResponse.QuoteAssetToTrade; } var change = solbot.BuyChange(); return(new MarketRuleResult() { Success = result.IsReadyForMarket, Message = result.Changed < 0 ? LogGenerator.StepMarketSuccess(MarketOrder, solbot.Communication.Price.Current, solbot.Communication.Average.Current, change) : LogGenerator.StepMarketError(MarketOrder, solbot.Communication.Price.Current, solbot.Communication.Average.Current, change) }); }
public IRuleResult RuleExecuted(Solbot solbot) { _rules.Add(new StopLossStepMarketRule(_marketService)); _rules.Add(new StopLossExecuteMarketTestRule(_pushOverNotificationService)); _rules.Add(new SellStepMarketRule(_marketService)); _rules.Add(new SellExecuteMarketTestRule(_pushOverNotificationService)); _rules.Add(new BuyStepMarketRule(_marketService, false)); _rules.Add(new BuyExecuteMarketTestRule(_pushOverNotificationService)); Logger.Info(LogGenerator.ModeStart(ModeName)); foreach (var item in _rules) { var result = item.RuleExecuted(solbot); Logger.Info($"{result.Message}"); } Logger.Info(LogGenerator.ModeEnd(ModeName)); return new ModeRuleResult { Message = LogGenerator.ModeExecuted(ModeName), Success = true }; }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); try { var currentPrice = _tickerPriceService.GetPriceValue(solbot.Strategy.AvailableStrategy); if (currentPrice.Success) { solbot.Communication.Price = new PriceMessage { Current = currentPrice.Result }; result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{currentPrice.Result}"); } else { result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, currentPrice.Message); } } catch (Exception e) { result.Success = false; result.Message = LogGenerator.SequenceException(SequenceName, e); } return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); if (solbot.Actions.StopLossReached && solbot.Actions.BoughtPrice == 0 && solbot.Actions.StopLossCurrentCycle < solbot.Strategy.AvailableStrategy.StopLossPauseCycles) { solbot.Actions.StopLossCurrentCycle++; result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, $"{solbot.Actions.StopLossCurrentCycle}/{solbot.Strategy.AvailableStrategy.StopLossPauseCycles}"); } else if (!solbot.Actions.StopLossReached && solbot.Actions.BoughtPrice > 0) { result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{solbot.Actions.StopLossCurrentCycle}"); } else { solbot.Actions.StopLossCurrentCycle = 0; solbot.Actions.BoughtPrice = 0; solbot.Actions.StopLossReached = false; result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{solbot.Actions.StopLossCurrentCycle}"); } return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var response = solbot.Communication.Sell.PriceReached; var sellPriceChange = solbot.BoughtPrice() - solbot.Communication.Price.Current > 0 ? "falling" : "rising"; var result = solbot.BoughtPrice() > 0 ? $"100 - {solbot.Communication.Price.Current}(current) / {solbot.BoughtPrice()} * 100 = " + $"{Math.Round(100 - (solbot.Communication.Price.Current / solbot.BoughtPrice() * 100), GlobalConfig.RoundValue)}. (price {sellPriceChange})." + $" => sellup => {solbot.Strategy.AvailableStrategy.SellUp}%" : "LAST BUY => NO"; var sellPrice = solbot.Strategy.AvailableStrategy.CommissionType == CommissionType.VALUE ? $"{solbot.Communication.Price.Current}(current) - {solbot.BoughtPrice()} = " + $"{Math.Round(solbot.Communication.Price.Current - solbot.BoughtPrice(), GlobalConfig.RoundValue)}. (price {sellPriceChange})." + $" => sellup => {solbot.Strategy.AvailableStrategy.SellUp}" : result; return(new OrderRuleResult { Success = response, Message = response ? $"REACHED => {sellPrice}" : $"NOT REACHED => {sellPrice}" }); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); try { var count = _storageService.GetValues().Count; var storedPriceAverage = AverageContext.Average( solbot.Strategy.AvailableStrategy.AverageType, _storageService.GetValues(), solbot.Communication.Symbol.QuoteAssetPrecision, solbot.Strategy.AvailableStrategy.Average); solbot.Communication.Average = new PriceMessage { Current = storedPriceAverage, Count = count < solbot.Strategy.AvailableStrategy.Average ? count : solbot.Strategy.AvailableStrategy.Average }; result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{storedPriceAverage}"); } catch (Exception e) { result.Success = false; result.Message = LogGenerator.SequenceException(SequenceName, e); } return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = solbot.Communication.Buy.PriceReached && solbot.Actions.BoughtPrice == 0; if (result) { solbot.Actions.BoughtPrice = solbot.Communication.Price.Current; result = true; _pushOverNotificationService.Send( LogGenerator.NotificationTitle(WorkingType.TEST, MarketOrder, solbot.Strategy.AvailableStrategy.Symbol), LogGenerator.NotificationMessage( solbot.Communication.Average.Current, solbot.Communication.Price.Current, solbot.Communication.Buy.Change)); } return(new MarketRuleResult() { Success = result, Message = result ? LogGenerator.ExecuteMarketSuccess(MarketOrder, solbot.Actions.BoughtPrice) : LogGenerator.ExecuteMarketError(MarketOrder, solbot.Actions.BoughtPrice) }); }
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) }); }
public IRuleResult RuleExecuted(Solbot solbot) => new SequencedRuleResult { Success = Enum.IsDefined(typeof(AverageType), solbot.Strategy.AvailableStrategy.AverageType), Message = solbot.Strategy.AvailableStrategy.AverageType == AverageType.WITH_CURRENT ? LogGenerator.AverageTypeSuccess(SequenceName, solbot.Strategy.AvailableStrategy.AverageType.GetDescription()) : LogGenerator.AverageTypeError(SequenceName, solbot.Strategy.AvailableStrategy.AverageType.GetDescription()) };
public IRuleResult RuleExecuted(Solbot solbot) => new SequencedRuleResult { Success = solbot.Strategy.ModeType == ModeType.WORKING, Message = solbot.Strategy.ModeType == ModeType.WORKING ? LogGenerator.ModeTypeSuccess(SequenceName, solbot.Strategy.ModeType.GetDescription()) : LogGenerator.ModeTypeError(SequenceName, solbot.Strategy.ModeType.GetDescription()) };
public IRuleResult RuleExecuted(Solbot solbot) { var response = solbot.Actions.BoughtPrice > 0; return(new OrderRuleResult { Success = response, Message = response ? $"ABLE TO => LAST BUY => ({solbot.Communication.Symbol.QuoteAsset}:{solbot.Actions.BoughtPrice})" : $"NOT ABLE TO => LAST BUY => ({solbot.Communication.Symbol.QuoteAsset}:{solbot.Actions.BoughtPrice})" }); }
public IRuleResult RuleExecuted(Solbot solbot) { var response = solbot.Communication.Price.Current > solbot.Actions.BoughtPrice; return(new OrderRuleResult { Success = response, Message = response ? $"CURRENT PRICE => ({solbot.Communication.Price.Current}) > ({solbot.Actions.BoughtPrice})" : $"CURRENT PRICE => ({solbot.Communication.Price.Current}) < ({solbot.Actions.BoughtPrice})" }); }
public IRuleResult RuleExecuted(Solbot solbot) { var response = solbot.Actions.BoughtPrice == 0; return(new OrderRuleResult { Success = response, Message = response ? $"WAITING FOR SALE => NO => LAST BUY => ({solbot.Communication.Symbol.QuoteAsset}:{solbot.Actions.BoughtPrice})" : $"WAITING FOR SALE => YES => LAST BUY => ({solbot.Communication.Symbol.QuoteAsset}:{solbot.Actions.BoughtPrice})" }); }
public IRuleResult RuleExecuted(Solbot solbot) { if (solbot.Strategy.AvailableStrategy.StopLossDown == 0) { solbot.Communication.StopLoss = new ChangeMessage { Change = 0, PriceReached = false }; return(new MarketRuleResult() { Success = false, Message = LogGenerator.Off(MarketOrder) }); } else { var boughtPrice = solbot.BoughtPrice(); var result = new MarketResponse(); if (boughtPrice > 0) { result = _marketService.IsStopLossReached( solbot.Strategy.AvailableStrategy.CommissionType, solbot.Strategy.AvailableStrategy.StopLossDown, boughtPrice, solbot.Communication.Price.Current); } else { result.IsReadyForMarket = false; result.Changed = 0; } solbot.Communication.StopLoss = new ChangeMessage { Change = result.Changed, PriceReached = result.IsReadyForMarket }; var change = solbot.StopLossChange(); return(new MarketRuleResult() { Success = result.IsReadyForMarket, Message = result.Changed < 0 ? LogGenerator.StepMarketSuccess(MarketOrder, solbot.Communication.Price.Current, boughtPrice, change) : LogGenerator.StepMarketError(MarketOrder, solbot.Communication.Price.Current, boughtPrice, change) }); } }
public async Task <ConfigurationResponse> SetConfigAsync(string fileName, Solbot solbot) { var result = new ConfigurationResponse(); using (FileStream fs = File.Create(GlobalConfig.AppFile(fileName))) { await JsonSerializer.SerializeAsync(fs, solbot, options : _options); } result.WriteSuccess = true; return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var response = solbot.Communication.Buy.AvailableFund > solbot.Communication.Symbol.MinNotional; return(new OrderRuleResult { Success = response, Message = response ? $"QUOTE => ({solbot.Communication.Symbol.QuoteAsset}:{solbot.Communication.Buy.AvailableFund})" + $" => ENOUGH" : $"QUOTE => ({solbot.Communication.Symbol.QuoteAsset}:{solbot.Communication.Buy.AvailableFund})" + $" => NOT ENOUGH => MIN NEEDED => ({solbot.Communication.Symbol.QuoteAsset}:{solbot.Communication.Symbol.MinNotional})" }); }
public IRuleResult RuleExecuted(Solbot solbot) { BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(solbot.Exchange.ApiKey, solbot.Exchange.ApiSecret) }); using (var binanceClient = new BinanceClient()) { _rules.Add(new AccountExchangeRule(binanceClient)); if (solbot.Strategy.AvailableStrategy.IsStopLossOn && solbot.Actions.BoughtBefore) { _rules.Add(new StopLossStepMarketRule(_marketService)); _rules.Add(new StopLossPriceMarketRule()); _rules.Add(new StopLossExecuteMarketRule(binanceClient, _pushOverNotificationService)); } if (solbot.Actions.BoughtBefore) { _rules.Add(new SellStepMarketRule(_marketService)); _rules.Add(new SellPriceMarketRule()); _rules.Add(new SellExecuteMarketRule(binanceClient, _pushOverNotificationService)); } if (solbot.Actions.SellBefore) { _rules.Add(new BuyStepMarketRule(_marketService, true)); _rules.Add(new BuyPriceMarketRule()); _rules.Add(new BuyExecuteMarketRule(binanceClient, _pushOverNotificationService)); } Logger.Info(LogGenerator.ModeStart(ModeName)); foreach (var item in _rules) { var result = item.RuleExecuted(solbot); Logger.Info($"{result.Message}"); } Logger.Info(LogGenerator.ModeEnd(ModeName)); } return(new ModeRuleResult { Message = LogGenerator.ModeExecuted(ModeName), Success = true }); }
public IRuleResult RuleExecuted(Solbot solbot) { var boughtPrice = solbot.BoughtPrice(); var result = new MarketResponse(); if (boughtPrice > 0) { result = _marketService.IsGoodToSell( solbot.Strategy.AvailableStrategy.CommissionType, solbot.Strategy.AvailableStrategy.SellUp, boughtPrice, solbot.Communication.Price.Current); } else { result.IsReadyForMarket = false; result.Changed = 0; } solbot.Communication.Sell = new ChangeMessage { Change = result.Changed, PriceReached = result.IsReadyForMarket }; var change = solbot.SellChange(); var needed = solbot.NeededSellChange(); var priceUp = (solbot.Strategy.AvailableStrategy.CommissionType == CommissionType.PERCENTAGE && result.Changed > 0) || solbot.Strategy.AvailableStrategy.CommissionType == CommissionType.VALUE && result.Changed < 0; return(new MarketRuleResult() { Success = result.IsReadyForMarket, Message = priceUp ? LogGenerator.SellStepSuccess( solbot.Strategy.AvailableStrategy.SellType, solbot.Communication.Price.Current, boughtPrice, change) : LogGenerator.SellStepError( solbot.Strategy.AvailableStrategy.SellType, solbot.Communication.Price.Current, boughtPrice, change, needed) }); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); try { var exchangeInfo = _binanceClient.Spot.System.GetExchangeInfo(); if (exchangeInfo.Success) { var symbol = exchangeInfo .Data .Symbols .FirstOrDefault(e => e.Name == solbot.Strategy.AvailableStrategy.Symbol); if (!(symbol is null) && symbol.Status == SymbolStatus.Trading) { solbot.Communication = new Communication { Symbol = new SymbolMessage { BaseAsset = symbol.BaseAsset, QuoteAsset = symbol.QuoteAsset, QuoteAssetPrecision = symbol.QuoteAssetPrecision, MinNotional = symbol.MinNotionalFilter.MinNotional, StepSize = symbol.LotSizeFilter.StepSize, MaxQuantity = symbol.LotSizeFilter.MaxQuantity, MinQuantity = symbol.LotSizeFilter.MinQuantity, TickSize = symbol.PriceFilter.TickSize, MaxPrice = symbol.PriceFilter.MaxPrice, MinPrice = symbol.PriceFilter.MinPrice } }; result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, solbot.Strategy.AvailableStrategy.Symbol); } else { result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, solbot.Strategy.AvailableStrategy.Symbol); } } else { result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, exchangeInfo.Error.Message); } }
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) }); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); if (_exchange.Type.HasValue) { switch (_exchange.Type.Value) { case Domain.Enums.ExchangeType.Binance: { _rules.Add(new BinanceSymbolSequenceRule(_binanceClient)); _rules.Add(new BinanceGetPriceSequenceRule(_binanceTickerService)); } break; case Domain.Enums.ExchangeType.KuCoin: { _rules.Add(new KucoinSymbolSequenceRule(_kucoinClient)); _rules.Add(new KucoinGetPriceSequenceRule(_kucoinTickerService)); } break; } foreach (var item in _rules) { var res = item.RuleExecuted(solbot); if (res.Success) { result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, _exchange.Type.Value.GetDescription()); } else { result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, res.Message); break; } } } else { result.Success = false; result.Message = "No exchange type provided"; } return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); try { var exchangeInfo = _kucoinClient.GetSymbols(); if (exchangeInfo.Success) { var symbol = exchangeInfo .Data .FirstOrDefault(e => e.Symbol == solbot.Strategy.AvailableStrategy.Symbol); if (!(symbol is null) && symbol.EnableTrading) { solbot.Communication = new Communication { Symbol = new SymbolMessage { BaseAsset = symbol.BaseCurrency, QuoteAsset = symbol.QuoteCurrency, BasePrecision = symbol.BaseIncrement, QuotePrecision = symbol.QuoteIncrement, BaseAssetPrecision = BitConverter.GetBytes(decimal.GetBits(symbol.BaseIncrement)[3])[2], QuoteAssetPrecision = BitConverter.GetBytes(decimal.GetBits(symbol.QuoteIncrement)[3])[2], StepSize = symbol.PriceIncrement, MaxQuantity = symbol.QuoteMaxSize, MinQuantity = symbol.QuoteMinSize } }; result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, solbot.Strategy.AvailableStrategy.Symbol); } else { result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, solbot.Strategy.AvailableStrategy.Symbol); } } else { result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, exchangeInfo.Error.Message); } }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); try { _storageService.SaveValue(solbot.Communication.Price.Current); result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, $"{solbot.Communication.Price.Current}"); } catch (Exception e) { result.Success = false; result.Message = LogGenerator.SequenceException(SequenceName, e); } return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var result = new SequencedRuleResult(); switch (_exchange.Type.Value) { case Domain.Enums.ExchangeType.Binance: { _rules.Add(new BinanceModeProductionRule( _marketService, _pushOverNotificationService, _binanceClient)); } break; case Domain.Enums.ExchangeType.KuCoin: { _rules.Add(new KucoinModeProductionRule( _marketService, _pushOverNotificationService, _kucoinClient)); } break; } foreach (var item in _rules) { var res = item.RuleExecuted(solbot); if (res.Success) { result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, _exchange.Type.Value.GetDescription()); } else { result.Success = false; result.Message = LogGenerator.SequenceError(SequenceName, res.Message); break; } } return(result); }
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}") }); }
public IRuleResult RuleExecuted(Solbot solbot) { _rules.Add(new KucoinAccountExchangeRule(_kucoinClient)); if (solbot.Strategy.AvailableStrategy.IsStopLossOn && solbot.Actions.BoughtBefore) { _rules.Add(new StopLossStepMarketRule(_marketService)); _rules.Add(new StopLossPriceMarketRule()); _rules.Add(new KucoinStopLossExecuteMarketRule(_kucoinClient, _pushOverNotificationService)); } if (solbot.Actions.BoughtBefore) { _rules.Add(new SellStepMarketRule(_marketService)); _rules.Add(new SellPriceMarketRule()); _rules.Add(new KucoinSellExecuteMarketRule(_kucoinClient, _pushOverNotificationService)); } if (solbot.Actions.SellBefore) { _rules.Add(new BuyStepMarketRule(_marketService, true)); _rules.Add(new BuyPriceMarketRule()); _rules.Add(new KucoinBuyExecuteMarketRule(_kucoinClient, _pushOverNotificationService)); } Logger.Info(LogGenerator.ModeStart(ModeName)); foreach (var item in _rules) { var result = item.RuleExecuted(solbot); Logger.Info($"{result.Message}"); } Logger.Info(LogGenerator.ModeEnd(ModeName)); return(new ModeRuleResult { Message = LogGenerator.ModeExecuted(ModeName), Success = true }); }
public IRuleResult RuleExecuted(Solbot solbot) { var storagePath = GlobalConfig.PriceFile(solbot.Strategy.AvailableStrategy.Symbol); var result = new SequencedRuleResult(); try { _storageService.SetPath(storagePath); result.Success = true; result.Message = LogGenerator.SequenceSuccess(SequenceName, storagePath); } catch (Exception e) { result.Success = false; result.Message = LogGenerator.SequenceException(SequenceName, e); } return(result); }
public IRuleResult RuleExecuted(Solbot solbot) { var boughtBefore = solbot.Actions.BoughtPrice > 0; var response = boughtBefore ? solbot.Communication.AvailableAsset.Base > solbot.Communication.Symbol.MinNotional : false; return(new OrderRuleResult { Success = response, Message = response ? $"BASE => ({solbot.Communication.Symbol.BaseAsset}:{solbot.Communication.AvailableAsset.Base})" + $" => ENOUGH" : boughtBefore ? $"BASE => ({solbot.Communication.Symbol.BaseAsset}:{solbot.Communication.AvailableAsset.Base})" + $" => NOT ENOUGH => MIN NEEDED => ({solbot.Communication.Symbol.BaseAsset}:{solbot.Communication.Symbol.MinQuantity})" : $"BASE => NOT BOUGHT" }); }
public IRuleResult RuleExecuted(Solbot solbot) { var response = solbot.Communication.Buy.PriceReached; var buyPriceChange = solbot.Communication.Average.Current - solbot.Communication.Price.Current > 0 ? "falling" : "rising"; var buyPrice = solbot.Strategy.AvailableStrategy.CommissionType == CommissionType.VALUE ? $"{solbot.Communication.Average.Current} - {solbot.Communication.Price.Current}(current) = " + $"{solbot.Communication.Average.Current - solbot.Communication.Price.Current}. (price {buyPriceChange})." + $" => buydown => {solbot.Strategy.AvailableStrategy.BuyDown}" : $"100 - ({solbot.Communication.Price.Current} / {solbot.Communication.Average.Current} * 100) = " + $"{Math.Round(100 - (solbot.Communication.Price.Current / solbot.Communication.Average.Current * 100), 2)}. (price {buyPriceChange})." + $" => buydown => {solbot.Strategy.AvailableStrategy.BuyDown}%"; return(new OrderRuleResult { Success = response, Message = response ? $"REACHED => {buyPrice}" : $"NOT REACHED => {buyPrice}" }); }