public void GradientStrategyTest() { var data = CreateMarketData(); var parameters = new GradientParameters(); var target = SimulateStrategy(data, x => x.Create(parameters)); var actual = ToApprovedString(target); Approvals.Verify(actual); }
public GradientStrategy( IMarketDataCache marketDataCache, IStakingService stakingService, ISearcher searcher, GradientParameters parameters) { _marketDataCache = marketDataCache; _stakingService = stakingService; _searcher = searcher; _parameters = parameters; }
public void Optimise(DateTime fromDate, DateTime endDate) { _stakingService.Evaluate(fromDate, endDate); var potentials = Enumerable.Range(1, 10).SelectMany(x => { return(Enumerable.Range(20, 20).Select(window => { var threshold = -((decimal)x / 100); return new GradientParameters { Threshold = threshold, Window = window }; })); }); var optimum = _searcher.Maximum(potentials, fromDate, endDate); _parameters = (GradientParameters)optimum; }
public IStrategy Create(IParameters parameters) { return(parameters switch { LinearRegressionParameters p => Create(p), RelativeStrengthParameters p => Create(p), DeltaParameters p => Create(p), VolumeParameters p => Create(p), GradientParameters p => Create(p), EntropyParameters p => Create(p), StaticDatesParameters p => Create(p), MovingAverageParameters p => Create(p), HolidayEffectParameters p => Create(p), WeightedParameters p => Create(p), OptimalStoppingParameters p => Create(p), ProbabilityParameters p => Create(p), SpreadParameters p => Create(p), ClusteringParameters p => Create(p), _ => throw new NotImplementedException(), });