Beispiel #1
0
        public void ThrowIfNoStepProvidedWhenNoSegmentValue()
        {
            var optimizationParameter = new OptimizationStepParameter("ema-fast", 1, 100);

            Assert.Throws <ArgumentException>(() =>
            {
                _strategy.Initialize(
                    new Target("Profit", new Maximization(), null),
                    new List <Constraint>(),
                    new HashSet <OptimizationParameter> {
                    optimizationParameter
                },
                    new StepBaseOptimizationStrategySettings());
            });
        }
            public void SinglePoint(decimal step)
            {
                var args = new HashSet <OptimizationParameter>()
                {
                    new OptimizationStepParameter("ema-fast", 0, 0, step),
                    new OptimizationStepParameter("ema-slow", 0, 0, step),
                    new OptimizationStepParameter("ema-custom", 1, 1, step)
                };

                _strategy.Initialize(new Target("Profit", new Maximization(), null), new List <Constraint>(), args, new StepBaseOptimizationStrategySettings());

                _strategy.NewParameterSet += (s, parameterSet) =>
                {
                    Assert.AreEqual(0, parameterSet.Value["ema-fast"].ToDecimal());
                    Assert.AreEqual(0, parameterSet.Value["ema-slow"].ToDecimal());
                    Assert.AreEqual(1, parameterSet.Value["ema-custom"].ToDecimal());
                };

                _strategy.PushNewResults(OptimizationResult.Initial);
            }