/// <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); }
/// <summary> /// Creates a new instance /// </summary> public Target(string target, Extremum extremum, decimal?targetValue) : base(target, targetValue) { Extremum = extremum; }
private bool IsComplied() => TargetValue.HasValue && Current.HasValue && (TargetValue.Value == Current.Value || Extremum.Better(TargetValue.Value, Current.Value));