private void AddIndicator(ParameterizedIndicator indicator, InvestmentStrategy investmentStrategy)
        {
            if (!indicator.IndicatorType.HasValue)
            {
                throw new BusinessException("Wrong indicator value");
            }

            var strategyIndicator = new StrategyIndicator
            {
                IndicatorType = (int)indicator.IndicatorType.Value,
                Strategy      = investmentStrategy,
                Properties    = new List <StrategyIndicatorProperty>()
            };

            foreach (var indicatorProperty in indicator.Properties)
            {
                if (
                    _indicatorsService.GetPropertiesForIndicator(indicator.IndicatorType.Value)
                    .All(item => item.Name != indicatorProperty.Name))
                {
                    continue;
                }
                strategyIndicator.Properties.Add(new StrategyIndicatorProperty
                {
                    Indicator = strategyIndicator,
                    Name      = indicatorProperty.Name,
                    Value     = indicatorProperty.Value
                });
            }
            investmentStrategy.Indicators.Add(strategyIndicator);
        }
Ejemplo n.º 2
0
 /// <inheritdoc />
 public void DeleteIndicator(StrategyIndicator strategyIndicator)
 {
     foreach (var property in strategyIndicator.Properties.ToList())
     {
         Context.StrategyIndicatorProperties.Remove(property);
     }
     Context.StrategyIndicators.Remove(strategyIndicator);
 }