[Quantproject-developers] QuantProject/b4_Business/a2_Strategies/returnsManagement ReturnsManager.
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:18:15
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16161/returnsManagement Modified Files: ReturnsManager.cs Log Message: The new revision moves toward an intraday enabled framework. EndOfDayDate time has been removed, DateTime is used now. The code has been changed accordingly. Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ReturnsManager.cs 13 Nov 2007 19:10:28 -0000 1.9 --- ReturnsManager.cs 29 Sep 2008 21:17:39 -0000 1.10 *************** *** 39,46 **** /// by in sample optimizations) /// </summary> public class ReturnsManager { private ReturnIntervals returnIntervals; // a return for each interval ! private IHistoricalQuoteProvider historicalQuoteProvider; private Set tickersMissingQuotes; --- 39,47 ---- /// by in sample optimizations) /// </summary> + [Serializable] public class ReturnsManager { private ReturnIntervals returnIntervals; // a return for each interval ! private HistoricalMarketValueProvider historicalMarketValueProvider; private Set tickersMissingQuotes; *************** *** 78,87 **** /// n-1 elements</param> public ReturnsManager( ReturnIntervals returnIntervals , ! IHistoricalQuoteProvider historicalQuoteProvider ) { // TO DO: let WFLagEligibleTickers use this class also!!! this.returnIntervals = returnIntervals; this.commonInitialization(); ! this.historicalQuoteProvider = historicalQuoteProvider; } private void commonInitialization() --- 79,88 ---- /// n-1 elements</param> public ReturnsManager( ReturnIntervals returnIntervals , ! HistoricalMarketValueProvider historicalMarketValueProvider ) { // TO DO: let WFLagEligibleTickers use this class also!!! this.returnIntervals = returnIntervals; this.commonInitialization(); ! this.historicalMarketValueProvider = historicalMarketValueProvider; } private void commonInitialization() *************** *** 102,118 **** return this.tickersReturns.ContainsKey( ticker ); } #region setReturns private float selectReturnWithRespectToTheGivenIterval( ! EndOfDayHistory endOfDayQuotes , int i ) { ReturnInterval returnInterval = this.returnIntervals[ i ]; ! double firstQuote = (double)endOfDayQuotes[ returnInterval.Begin ]; ! double lastQuote = (double)endOfDayQuotes[ returnInterval.End ]; float intervalReturn = Convert.ToSingle( lastQuote / firstQuote - 1 ); return intervalReturn; } private float[] selectReturnsWithRespectToTheGivenIntervals( ! EndOfDayHistory endOfDayQuotes ) { // TO DO: this method is n log n, it could be implemented to --- 103,120 ---- return this.tickersReturns.ContainsKey( ticker ); } + #region setReturns private float selectReturnWithRespectToTheGivenIterval( ! History marketValues , int i ) { ReturnInterval returnInterval = this.returnIntervals[ i ]; ! double firstQuote = (double)marketValues[ returnInterval.Begin ]; ! double lastQuote = (double)marketValues[ returnInterval.End ]; float intervalReturn = Convert.ToSingle( lastQuote / firstQuote - 1 ); return intervalReturn; } private float[] selectReturnsWithRespectToTheGivenIntervals( ! History marketValues ) { // TO DO: this method is n log n, it could be implemented to *************** *** 122,141 **** for ( int i = 0 ; i < this.returnIntervals.Count ; i++ ) returnsWithRespectToTheGivenIntervals[ i ] = ! this.selectReturnWithRespectToTheGivenIterval( endOfDayQuotes , i ); return returnsWithRespectToTheGivenIntervals; } private void setReturnsActually( string ticker , ! EndOfDayHistory endOfDayQuotes ) { float[] arrayOfReturns = ! this.selectReturnsWithRespectToTheGivenIntervals( endOfDayQuotes ); this.tickersReturns.Add( ticker , arrayOfReturns ); } private void setReturns( string ticker , ! EndOfDayHistory endOfDayQuotes ) { if ( this.returnIntervals.AreIntervalBordersAllCoveredBy( ! endOfDayQuotes ) ) ! this.setReturnsActually( ticker , endOfDayQuotes ); else this.tickersMissingQuotes.Add( ticker ); --- 124,143 ---- for ( int i = 0 ; i < this.returnIntervals.Count ; i++ ) returnsWithRespectToTheGivenIntervals[ i ] = ! this.selectReturnWithRespectToTheGivenIterval( marketValues , i ); return returnsWithRespectToTheGivenIntervals; } private void setReturnsActually( string ticker , ! History marketValues ) { float[] arrayOfReturns = ! this.selectReturnsWithRespectToTheGivenIntervals( marketValues ); this.tickersReturns.Add( ticker , arrayOfReturns ); } private void setReturns( string ticker , ! History marketValues ) { if ( this.returnIntervals.AreIntervalBordersAllCoveredBy( ! marketValues ) ) ! this.setReturnsActually( ticker , marketValues ); else this.tickersMissingQuotes.Add( ticker ); *************** *** 143,152 **** private void setReturns( string ticker ) { ! EndOfDayHistory endOfDayQuotes = ! this.historicalQuoteProvider.GetEndOfDayQuotes( ticker , ! this.returnIntervals.BordersHistory ); ! this.setReturns( ticker , endOfDayQuotes ); } #endregion setReturns private float[] getAlreadySetReturns( string ticker ) { --- 145,156 ---- private void setReturns( string ticker ) { ! History marketValues = ! this.historicalMarketValueProvider.GetMarketValues( ! ticker , ! this.returnIntervals.BordersHistory ); ! this.setReturns( ticker , marketValues ); } #endregion setReturns + private float[] getAlreadySetReturns( string ticker ) { *************** *** 164,167 **** --- 168,172 ---- } #endregion GetReturns + #region GetReturn /// <summary> |