Ejemplo n.º 1
0
        /// <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);
            }
        }