22 using System.Collections.Generic;
23 using System.Collections.Concurrent;
38 private readonly ConcurrentDictionary<Symbol, string> _numericalPrecisionLimitedWarnings;
39 private readonly
int _numericalPrecisionLimitedWarningsMaxCount = 10;
40 private readonly ConcurrentDictionary<Symbol, string> _startDateLimitedWarnings;
41 private readonly
int _startDateLimitedWarningsMaxCount = 10;
43 private readonly
bool _enablePriceScaling;
60 bool enablePriceScaling =
true
63 _algorithm = algorithm;
64 _resultHandler = resultHandler;
65 _mapFileProvider = mapFileProvider;
66 _factorFileProvider = factorFileProvider;
67 _dataCacheProvider = cacheProvider;
68 _numericalPrecisionLimitedWarnings =
new ConcurrentDictionary<Symbol, string>();
69 _startDateLimitedWarnings =
new ConcurrentDictionary<Symbol, string>();
70 _enablePriceScaling = enablePriceScaling;
87 _algorithm.ObjectStore);
89 dataReader.InvalidConfigurationDetected += (sender, args) => { _resultHandler.ErrorMessage(args.Message); };
90 dataReader.StartDateLimited += (sender, args) =>
93 if (_startDateLimitedWarnings.Count <= _startDateLimitedWarningsMaxCount)
95 _startDateLimitedWarnings.TryAdd(args.Symbol, args.Message);
98 dataReader.DownloadFailed += (sender, args) => { _resultHandler.ErrorMessage(args.Message, args.StackTrace); };
99 dataReader.ReaderErrorDetected += (sender, args) => { _resultHandler.RuntimeError(args.Message, args.StackTrace); };
100 dataReader.NumericalPrecisionLimited += (sender, args) =>
103 if (_numericalPrecisionLimitedWarnings.Count <= _numericalPrecisionLimitedWarningsMaxCount)
105 _numericalPrecisionLimitedWarnings.TryAdd(args.Symbol, args.Message);
109 IEnumerator<BaseData> enumerator = dataReader;
124 _enablePriceScaling);
136 if (!_numericalPrecisionLimitedWarnings.IsNullOrEmpty())
138 var message =
"Due to numerical precision issues in the factor file, data for the following" +
139 $
" symbols was adjust to a later starting date: {string.Join(",
", _numericalPrecisionLimitedWarnings.Values.Take(_numericalPrecisionLimitedWarningsMaxCount))}";
142 if (_numericalPrecisionLimitedWarnings.Count >= _numericalPrecisionLimitedWarningsMaxCount)
147 _resultHandler.DebugMessage(message);
151 if (!_startDateLimitedWarnings.IsNullOrEmpty())
153 var message =
"The starting dates for the following symbols have been adjusted to match their" +
154 $
" map files first date: {string.Join(",
", _startDateLimitedWarnings.Values.Take(_startDateLimitedWarningsMaxCount))}";
157 if (_startDateLimitedWarnings.Count >= _startDateLimitedWarningsMaxCount)
162 _resultHandler.DebugMessage(message);