コード例 #1
0
ファイル: Dynasty.cs プロジェクト: jameschch/LeanOptimization
        public void Optimize()
        {
            _config = JsonConvert.DeserializeObject <DynastyConfiguration>(_file.File.ReadAllText("dynasty.json"));

            var segmenter = new DynastySegmenter(_config);

            var settings = new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            for (var i = _config.StartDate; i <= _config.EndDate; i = segmenter.GetNext(i))
            {
                if (_current == null)
                {
                    _current = JsonConvert.DeserializeObject <OptimizerConfiguration>(_file.File.ReadAllText(_configFilename));
                }

                _current.StartDate = i;
                var endDate = segmenter.PeekNext(i);

                _current.EndDate = AdjustEndDate(endDate);

                string json = JsonConvert.SerializeObject(_current, settings);

                _file.File.WriteAllText(_configFilename, json);

                _logWrapper.Result($"For period: {_current.StartDate} {_current.EndDate}");

                var initializer = new OptimizerInitializer(_file, _managerFactory.Create());
                initializer.Initialize(new[] { _configFilename });
            }
        }
コード例 #2
0
 public DynastySegmenter(DynastyConfiguration config)
 {
     _config = config;
 }