[Quantproject-developers] QuantProject/b1_ADT/Histories History.cs,1.5,1.6
Brought to you by:
glauco_1
|
From: <mi...@us...> - 2004-01-11 19:09:15
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Histories
In directory sc8-pr-cvs1:/tmp/cvs-serv11865/b1_ADT/Histories
Modified Files:
History.cs
Log Message:
Fixed some bugs in methods:
- GetFunctionHistory
- IsDecreased
Index: History.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Histories/History.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** History.cs 20 Dec 2003 18:37:43 -0000 1.5
--- History.cs 11 Jan 2004 19:09:11 -0000 1.6
***************
*** 90,99 ****
return (DateTime) this.GetKey( this.IndexOfKeyOrPrevious( dateTime ) + 1 );
}
! //millo
public DateTime GetDay( DateTime initialDateTime, int numberOfDaysAhead )
{
if ( this.IndexOfKey( initialDateTime ) >= ( this.Count - numberOfDaysAhead ) )
! // return the last dateTime in the history
! return (DateTime) this.GetKey(this.Count -1);
else
return (DateTime) this.GetKey( this.IndexOfKeyOrPrevious( initialDateTime ) + numberOfDaysAhead );
--- 90,103 ----
return (DateTime) this.GetKey( this.IndexOfKeyOrPrevious( dateTime ) + 1 );
}
! //millo - fixed method
public DateTime GetDay( DateTime initialDateTime, int numberOfDaysAhead )
{
if ( this.IndexOfKey( initialDateTime ) >= ( this.Count - numberOfDaysAhead ) )
! // initial dateTime + n° of days ahead > the last dateTime in History
! {
! DateTime dateTime;
! dateTime = (DateTime)this.GetKey(this.Count -1);
! return dateTime.AddDays(this.IndexOfKey(initialDateTime) + numberOfDaysAhead - this.Count);
! }
else
return (DateTime) this.GetKey( this.IndexOfKeyOrPrevious( initialDateTime ) + numberOfDaysAhead );
***************
*** 104,108 ****
/// <summary>
! /// Gets a History object base on a statistical available function
/// </summary>
/// <remarks>
--- 108,112 ----
/// <summary>
! /// Gets a History object based on a statistical available function
/// </summary>
/// <remarks>
***************
*** 139,143 ****
( ((IComparable)this.GetKey( currentHistoryIndex )).CompareTo( endDateTime ) <= 0 ) )
{
! DateTime dateTime = (DateTime)this.GetKey( currentHistoryIndex );
if (Math.Floor(currentHistoryIndex/onEachPeriodOf) == periodIndex &&
cursorThroughDataArray < onEachPeriodOf)
--- 143,147 ----
( ((IComparable)this.GetKey( currentHistoryIndex )).CompareTo( endDateTime ) <= 0 ) )
{
!
if (Math.Floor(currentHistoryIndex/onEachPeriodOf) == periodIndex &&
cursorThroughDataArray < onEachPeriodOf)
***************
*** 146,151 ****
data[cursorThroughDataArray] = Convert.ToDouble(this.GetByIndex(currentHistoryIndex));
cursorThroughDataArray++;
currentHistoryIndex++;
! //POSSIBLY: simpleAverage.Add(this.GetKey( currentHistoryIndex ), null);
}
else
--- 150,156 ----
data[cursorThroughDataArray] = Convert.ToDouble(this.GetByIndex(currentHistoryIndex));
cursorThroughDataArray++;
+ functionHistory.Add(this.GetKey( currentHistoryIndex ), null);
currentHistoryIndex++;
!
}
else
***************
*** 154,164 ****
{
cursorThroughDataArray = 0;
switch (functionToBeCalculated)
{
case Function.SimpleAverage:
! functionHistory.Add( dateTime , BasicFunctions.SimpleAverage(data) );
break;
case Function.StandardDeviation :
! functionHistory.Add( dateTime , BasicFunctions.StdDev(data) );
break;
}
--- 159,174 ----
{
cursorThroughDataArray = 0;
+ DateTime dateTime = (DateTime)this.GetKey( currentHistoryIndex - onEachPeriodOf);
switch (functionToBeCalculated)
{
case Function.SimpleAverage:
! functionHistory.SetByIndex(currentHistoryIndex - onEachPeriodOf,
! BasicFunctions.SimpleAverage(data));
! //functionHistory.Add( dateTime , BasicFunctions.SimpleAverage(data) );
break;
case Function.StandardDeviation :
! functionHistory.SetByIndex(currentHistoryIndex - onEachPeriodOf,
! BasicFunctions.StdDev(data));
! //functionHistory.Add( dateTime , BasicFunctions.StdDev(data) );
break;
}
***************
*** 173,199 ****
/// <summary>
! /// It returns true if the value of the current History item is
! /// less than the previous History item
/// </summary>
/// <param name="dateTime">The date key for current History item</param>
public bool IsDecreased(DateTime dateTime)
{
! bool isDecreased;
int index = this.IndexOfKey(dateTime);
! if ( index <= 0 )
isDecreased = false;
else
{
! isDecreased = Convert.ToDouble( this[ dateTime ]) <
! Convert.ToDouble( this.GetByIndex(index - 1) );
}
return isDecreased;
-
-
}
-
-
-
-
--- 183,212 ----
/// <summary>
! /// It returns true if the current History item value is not null
! /// and is less than the immediate previous History item whose value is not null
/// </summary>
/// <param name="dateTime">The date key for current History item</param>
public bool IsDecreased(DateTime dateTime)
{
! bool isDecreased = false;
int index = this.IndexOfKey(dateTime);
! int previousIndex = index - 1;
! if ( index <= 0)
isDecreased = false;
else
{
! if(this.GetByIndex(index) != null)
! {
! while (this.GetByIndex(previousIndex) == null)
! {
! previousIndex --;
! }
!
! isDecreased = Convert.ToDouble( this.GetByIndex(index)) <
! Convert.ToDouble( this.GetByIndex(previousIndex) );
! }
}
return isDecreased;
}
|