public DatedDataCollectionGen<double> GetGenericSeries(DBFut_Chain chain_, uint numDaysBefore_ = 10, bool immOnly_ = true) { var key = getKey(chain_, numDaysBefore_, immOnly_); if (m_cache.ContainsKey(key)) return m_cache[key]; lock (m_lockObject) { if (!m_cache.ContainsKey(key)) { // attempt to get from disk cache else construct from scratch var series = Singleton<DiscCache>.Instance.Read<DatedDataCollectionGen<double>>(key, DIR, false) ?? DBFut_Helper.RolledGenericFromReturns( immOnly_ ? chain_.IMM_Contracts : chain_.ContractMetas, numDaysBefore_).CopyForwardZeros(); m_cache[key] = series; Singleton<DiscCache>.Instance.Write(key, DIR, series); } return m_cache[key]; } }
private string getKey(DBFut_Chain chain_, uint numDaysBefore_, bool immOnly_) { return string.Format("FutGeneric_{0}_NumDays_{1}_IMMOnly_{2}", chain_.Name, numDaysBefore_, immOnly_); }