Beispiel #1
0
        protected override string RunLean(ParameterSet parameterSet)
        {
            var id = Guid.NewGuid().ToString();

            _backtests.Add(id);

            Task.Delay(100).ContinueWith(task =>
            {
                try
                {
                    var sum = parameterSet.Value.Sum(s => s.Value.ToDecimal());
                    if (sum != 29)
                    {
                        NewResult(BacktestResult.Create(sum, sum / 100).ToJson(), id);
                    }
                    else
                    {
                        // fail some backtests by passing empty json
                        NewResult(string.Empty, id);
                    }
                }
                catch
                {
                }
            });

            return(id);
        }
Beispiel #2
0
        protected override string RunLean(ParameterSet parameterSet)
        {
            var id = Guid.NewGuid().ToString();

            _backtests.Add(id);

            Timer timer = null;

            timer = new Timer(y =>
            {
                try
                {
                    var sum = parameterSet.Value.Sum(s => s.Value.ToDecimal());
                    if (sum != 29)
                    {
                        NewResult(BacktestResult.Create(sum, sum / 100).ToJson(), id);
                    }
                    else
                    {
                        // fail some backtests by passing empty json
                        NewResult(string.Empty, id);
                    }

                    timer.Dispose();
                }
                catch
                {
                }
            });
            timer.Change(100, Timeout.Infinite);

            return(id);
        }