[Quantproject-developers] QuantProject/b4_Business/a07_DataProviders HistoricalMarketValueProvider.
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:30:50
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24380/a07_DataProviders Modified Files: HistoricalMarketValueProvider.cs Log Message: The interface IHistoricalMarketValueProvider is now implemented A new public method WereAllExchanged( ICollection<string> tickers , DateTime dateTime ) has been added. It returns true iif all the given tickers were traded at the given DateTime. A new public method GetDateTimesWithMarketValues( string ticker , History history ) has been added It returns the subset of DateTimes when ticker is exchanged Index: HistoricalMarketValueProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalMarketValueProvider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoricalMarketValueProvider.cs 20 Nov 2008 20:49:58 -0000 1.2 --- HistoricalMarketValueProvider.cs 28 Mar 2010 14:30:42 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.Collections.Generic; using QuantProject.ADT.Histories; *************** *** 34,38 **** /// </summary> [Serializable] ! public abstract class HistoricalMarketValueProvider : ILogDescriptor { public string Description --- 35,40 ---- /// </summary> [Serializable] ! public abstract class HistoricalMarketValueProvider : ! IHistoricalMarketValueProvider , ILogDescriptor { public string Description *************** *** 76,79 **** --- 78,101 ---- public abstract bool WasExchanged( string ticker , DateTime dateTime ); + /// <summary> + /// True iif all the given tickers were traded at the given DateTime + /// </summary> + /// <param name="tickers"></param> + /// <param name="dateTime"></param> + /// <returns></returns> + public virtual bool WereAllExchanged( ICollection<string> tickers , DateTime dateTime ) + { + IEnumerator<string> tickersEnumerator = tickers.GetEnumerator(); + tickersEnumerator.Reset(); + bool wereAllExchanged = true; + bool isEndOfCollection = !tickersEnumerator.MoveNext(); + while ( wereAllExchanged && !isEndOfCollection ) + { + wereAllExchanged = this.WasExchanged( tickersEnumerator.Current , dateTime ); + isEndOfCollection = !tickersEnumerator.MoveNext(); + } + return wereAllExchanged; + } + #region GetQuotes *************** *** 95,99 **** private void addMarketValue( string ticker , int historyIndex , ! History history , History quotes ) { DateTime currentDateTime = --- 117,121 ---- private void addMarketValue( string ticker , int historyIndex , ! History history , History quotes ) { DateTime currentDateTime = *************** *** 109,113 **** } public History GetMarketValues( string ticker , ! History history ) { History quotes = new History(); --- 131,135 ---- } public History GetMarketValues( string ticker , ! History history ) { History quotes = new History(); *************** *** 117,120 **** --- 139,159 ---- } #endregion GetQuotes + + #region GetDateTimesWithMarketValues + /// <summary> + /// returns the subset of DateTimes when ticker is exchanged + /// </summary> + /// <param name="ticker"></param> + /// <param name="history">DateTimes returned are a subset of this parameter</param> + /// <returns></returns> + public History GetDateTimesWithMarketValues( string ticker , History history ) + { + History dateTimesWithMarketValues = new History(); + foreach( DateTime dateTime in history.Keys ) + if ( this.WasExchanged( ticker , dateTime ) ) + dateTimesWithMarketValues.Add( dateTime , dateTime ); + return dateTimesWithMarketValues; + } + #endregion GetDateTimesWithMarketValues } } |