17 using System.Collections.Generic;
20 using Newtonsoft.Json;
37 private static readonly
object DataFolderMarketHoursDatabaseLock =
new object();
39 private Dictionary<SecurityDatabaseKey, Entry> _entries;
40 private readonly Dictionary<SecurityDatabaseKey, Entry> _customEntries =
new();
54 if (_alwaysOpenMarketHoursDatabase ==
null)
56 _alwaysOpenMarketHoursDatabase =
new AlwaysOpenMarketHoursDatabaseImpl();
59 return _alwaysOpenMarketHoursDatabase;
69 _entries = exchangeHours;
114 lock (DataFolderMarketHoursDatabaseLock)
116 _dataFolderMarketHoursDatabase =
null;
123 internal void ReloadEntries()
125 lock (DataFolderMarketHoursDatabaseLock)
128 var fileEntries =
FromDataFolder()._entries.Where(x => !_customEntries.ContainsKey(x.Key));
129 var newEntries = fileEntries.Concat(_customEntries).ToDictionary();
130 _entries = newEntries;
141 var result = _dataFolderMarketHoursDatabase;
144 lock (DataFolderMarketHoursDatabaseLock)
146 if (_dataFolderMarketHoursDatabase ==
null)
149 _dataFolderMarketHoursDatabase =
FromFile(path);
151 result = _dataFolderMarketHoursDatabase;
181 dataTimeZone = dataTimeZone ?? exchangeHours.
TimeZone;
183 var entry =
new Entry(dataTimeZone, exchangeHours);
184 lock (DataFolderMarketHoursDatabaseLock)
186 _entries[key] = entry;
187 _customEntries[key] = entry;
221 if (!
TryGetEntry(market, symbol, securityType, out entry))
224 Log.
Error($
"MarketHoursDatabase.GetExchangeHours(): {Messages.MarketHoursDatabase.ExchangeHoursNotFound(key, _entries.Keys)}");
235 throw new ArgumentException(exception);
268 return _entries.TryGetValue(symbolKey, out entry)
270 || _entries.TryGetValue(symbolKey.CreateCommonKey(), out entry)
276 && _entries.TryGetValue(
new SecurityDatabaseKey(market, $
"TYPE.{customType}", securityType), out entry));
301 stringSymbol =
string.Empty;
319 stringSymbol = symbol.
Value;
334 return _entries.ContainsKey(key);
368 ? base.GetEntry(market, symbol, securityType).ExchangeHours.TimeZone
374 public AlwaysOpenMarketHoursDatabaseImpl()