/// <summary> /// Prepares the collection of the quotes stored in the Quotes Manager cache. /// </summary> ///<param name="quotesManager">QuotesManager instance</param> public static IQMDataCollection PrepareListOfQMData(QuotesManager quotesManager) { QMDataCollection collection = new QMDataCollection(); BaseTimeframes timeframes = quotesManager.getBaseTimeframes(); Instruments instruments = quotesManager.getInstruments(); int instrumentCount = instruments.size(); for (int i = 0; i < instrumentCount; i++) { Instrument instrument = instruments.get(i); int timeframeCount = timeframes.size(); for (int j = 0; j < timeframeCount; j++) { string timeframe = timeframes.get(j); int y1 = instrument.getOldestQuoteDate(timeframe).Year; int y2 = instrument.getLatestQuoteDate(timeframe).Year; if (y2 >= y1) { for (int y = y1; y <= y2; y++) { long size = quotesManager.getDataSize(instrument.getName(), timeframe, y); if (size > 0) { collection.Add(new QMData(instrument.getName(), timeframe, y, size)); } } } } } return(collection); }
/// <summary> /// Prepares the collection of the instruments stored in the Quotes Manager and sends it /// to the application via OnListPreparedEvent /// </summary> private void PrepareListOfInstruments() { QMDataCollection collection = new QMDataCollection(); BaseTimeframes timeframes = mMgr.getBaseTimeframes(); Instruments instruments = mMgr.getInstruments(); for (int i = 0; i < instruments.size(); i++) { for (int j = 0; j < timeframes.size(); j++) { Instrument instrument = instruments.get(i); int y1, y2; y1 = instrument.getOldestQuoteDate(timeframes.get(j)).Year; y2 = instrument.getLatestQuoteDate(timeframes.get(j)).Year; if (y2 >= y1) { for (int y = y1; y <= y2; y++) { //for (int j = 0; j < timeframes.size(); j++) { long size = mMgr.getDataSize(instrument.getName(), timeframes.get(j), y); if (size > 0) { collection.Add(new QMData(instrument.getName(), timeframes.get(j), y, size)); } } } } } } if (OnListPreparedEvent != null) { OnListPreparedEvent(collection); } }
/// <summary> /// Fills QuotesManager data for the specified instrument and year. /// </summary> /// <param name="quotesManager">QuotesManager instance</param> /// <param name="instrument">Instrument name</param> /// <param name="year">Year</param> /// <returns>Collection of quotes manager storage data</returns> static ICollection <IQMData> GetQuotes(QuotesManager quotesManager, string instrument, int year) { BaseTimeframes baseTimeframes = quotesManager.getBaseTimeframes(); int timeframesCount = baseTimeframes.size(); List <IQMData> quotes = new List <IQMData>(timeframesCount); for (int i = 0; i < timeframesCount; ++i) { string timeframe = baseTimeframes.get(i); long size = quotesManager.getDataSize(instrument, timeframe, year); if (size > 0) { quotes.Add(new QMData(instrument, timeframe, year, size)); } } return(quotes); }