Пример #1
0
        /// <summary>
        /// Check backtest result
        /// </summary>
        /// <param name="jsonBacktestResult">Backtest result json</param>
        /// <returns>true if found a better solution; otherwise false</returns>
        public bool MoveAhead(string jsonBacktestResult)
        {
            if (string.IsNullOrEmpty(jsonBacktestResult))
            {
                throw new ArgumentNullException(nameof(jsonBacktestResult), "Target.MoveAhead: backtest result can not be null or empty.");
            }

            var token = JObject.Parse(jsonBacktestResult).SelectToken(Target);

            if (token == null)
            {
                return(false);
            }
            var computedValue = token.Value <string>().ToNormalizedDecimal();

            if (!Current.HasValue || Extremum.Better(Current.Value, computedValue))
            {
                Current = computedValue;

                return(true);
            }

            return(false);
        }
Пример #2
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 public Target(string target, Extremum extremum, decimal?targetValue) : base(target, targetValue)
 {
     Extremum = extremum;
 }
Пример #3
0
 private bool IsComplied() => TargetValue.HasValue && Current.HasValue && (TargetValue.Value == Current.Value || Extremum.Better(TargetValue.Value, Current.Value));