19 using System.Threading.Tasks;
21 using System.Collections.Generic;
30 private readonly
object _lock;
33 private Dictionary<AuxiliaryDataKey, bool> _seededMarket;
34 private readonly Dictionary<Symbol, IFactorProvider> _factorFiles;
45 if (dueTime > TimeSpan.FromMinutes(10))
48 return dueTime - TimeSpan.FromMinutes(10);
59 _factorFiles =
new Dictionary<Symbol, IFactorProvider>();
60 _seededMarket =
new Dictionary<AuxiliaryDataKey, bool>();
72 if (_mapFileProvider !=
null || _dataProvider !=
null)
77 _mapFileProvider = mapFileProvider;
78 _dataProvider = dataProvider;
89 symbol = symbol.GetFactorFileSymbol();
93 if (!_seededMarket.ContainsKey(key))
95 HydrateFactorFileFromLatestZip(key);
96 _seededMarket[key] =
true;
100 if (!_factorFiles.TryGetValue(symbol, out factorFile))
103 Log.
Error($
"LocalZipFactorFileProvider.Get({symbol}): No factor file found.");
104 _factorFiles[symbol] = factorFile = symbol.GetEmptyFactorFile();
118 _seededMarket =
new Dictionary<AuxiliaryDataKey, bool>();
129 var date = todayNewYork.AddDays(-1);
138 var stream = _dataProvider.
Fetch(factorFilePath);
143 var mapFileResolver = _mapFileProvider.
Get(key);
147 _factorFiles[keyValuePair.Key] = keyValuePair.Value;
149 stream.DisposeSafely();
150 Log.
Trace($
"LocalZipFactorFileProvider.Get({market}): Fetched factor files for: {date.ToShortDateString()} NY");
156 Log.
Debug($
"LocalZipFactorFileProvider.Get({market}): No factor file found for date {date.ToShortDateString()}");
161 throw new InvalidOperationException($
"LocalZipFactorFileProvider.Get(): Could not find any factor files going all the way back to {date} for {market}");
164 date = date.AddDays(-1);