public BotSettingViewModel(LeverageType leverageType, int customLeverageValue, decimal stopLossPercentage, StopLossType stopLossType, bool stopLossTimeoutEnabled, int stopLossTimeoutInSeconds, bool checkForExistingBots, bool checkForBlacklistedPairs, bool checkForBaseStablecoin, string quoteCurrency, Strategy strategy, StartOrderType startOrderType, int maxSafetyOrders, int activeSafetyOrdersCount, decimal safetyOrderStepPercentage, decimal martingaleVolumeCoefficient, decimal martingaleStepCoefficient, decimal takeProfitPercentage, bool trailingEnabled, decimal trailingDeviation, string nameFormula, decimal baseOrderVolume, decimal safetyOrderVolume, List <BotStrategy> dealStartConditions, int cooldownBetweenDeals, int accountId, decimal amountToBuyInQuoteCurrency) { LeverageType = leverageType; LeverageCustomValue = customLeverageValue; StopLossPercentage = stopLossPercentage; StopLossAction = stopLossType; StopLossTimeoutEnabled = stopLossTimeoutEnabled; StopLossTimeout = stopLossTimeoutInSeconds; SkipExistingPairs = checkForExistingBots; QuoteCurrency = quoteCurrency; Strategy = strategy; StartOrderType = startOrderType; MaxSafetyTradesCount = maxSafetyOrders; MaxActiveSafetyTradesCount = activeSafetyOrdersCount; PriceDeviationToOpenSafetyOrders = safetyOrderStepPercentage; SafetyOrderVolumeScale = martingaleVolumeCoefficient; SafetyOrderStepScale = martingaleStepCoefficient; TargetProfit = takeProfitPercentage; TrailingEnabled = trailingEnabled; TrailingDeviation = trailingDeviation; Botname = nameFormula; BaseOrderSize = baseOrderVolume; SafetyOrderSize = safetyOrderVolume; DealStartConditions = dealStartConditions; CooldownBetweenDeals = cooldownBetweenDeals; ExchangeAccountId = accountId; BaseCurrencyToBuy = amountToBuyInQuoteCurrency; SkipBlacklistedPairs = checkForBlacklistedPairs; SkipBaseStablecoin = checkForBaseStablecoin; }
private Bot CreateBot(string botName, bool enabled, string symbol, BotSettingViewModel request) { var bot = new Bot(); // Main Settings bot.Name = botName; bot.IsEnabled = enabled; bot.Type = ""; // Pairs bot.Pairs = new[] { symbol }; bot.MaxActiveDeals = 1; // Strategy bot.Strategy = request.Strategy; bot.ProfitCurrency = request.ProfitCurrency; bot.BaseOrderVolume = request.BaseOrderSize; bot.BaseOrderVolumeType = request.BaseOrderSizeType; bot.SafetyOrderVolume = request.SafetyOrderSize; bot.SafetyOrderVolumeType = request.SafetyOrderSizeType; bot.StartOrderType = request.StartOrderType; // Leverage bot.LeverageType = request.LeverageType; if (request.LeverageType != LeverageType.NotSpecified) { bot.LeverageCustomValue = request.LeverageCustomValue; } // Signals bot.Strategies = request.DealStartConditions; // Stop Loss decimal stopLossPercentage = 0; StopLossType stopLossType = StopLossType.StopLoss; bool stopLossTimeoutEnabled = false; int stopLossTimeoutInSeconds = 0; if (request.StopLossEnabled) { stopLossPercentage = request.StopLossPercentage; stopLossType = request.StopLossAction; stopLossTimeoutEnabled = request.StopLossTimeoutEnabled; stopLossTimeoutInSeconds = request.StopLossTimeout; } bot.StopLossPercentage = stopLossPercentage; bot.StopLossType = stopLossType; bot.StopLossTimeoutEnabled = stopLossTimeoutEnabled; bot.StopLossTimeoutInSeconds = stopLossTimeoutInSeconds; // TP bot.TakeProfitType = TakeProfitType.Total; bot.TakeProfit = request.TargetProfit; // Trailing bot.TrailingEnabled = request.TrailingEnabled; bot.TrailingDeviation = request.TrailingDeviation; // Safety orders bot.MaxSafetyOrders = request.MaxSafetyTradesCount; bot.ActiveSafetyOrdersCount = request.MaxActiveSafetyTradesCount; bot.SafetyOrderStepPercentage = request.PriceDeviationToOpenSafetyOrders; bot.MartingaleVolumeCoefficient = request.SafetyOrderVolumeScale; bot.MartingaleStepCoefficient = request.SafetyOrderStepScale; // Advanced bot.Cooldown = request.CooldownBetweenDeals; return(bot); }