[Quantproject-developers] QuantDownloader/Downloader/Validate QuotesToBeValidated.cs,1.1,1.2
Brought to you by:
glauco_1
|
From: <gla...@us...> - 2003-12-12 00:16:17
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/Validate
In directory sc8-pr-cvs1:/tmp/cvs-serv5122/Downloader/Validate
Modified Files:
QuotesToBeValidated.cs
Log Message:
Data validation has been moved to this object.
Every suspicious data rows fires the event SuspiciousDataRow.
Index: QuotesToBeValidated.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/Validate/QuotesToBeValidated.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** QuotesToBeValidated.cs 9 Dec 2003 22:20:10 -0000 1.1
--- QuotesToBeValidated.cs 12 Dec 2003 00:16:14 -0000 1.2
***************
*** 29,32 ****
--- 29,82 ----
}
}
+
+ public delegate void SuspiciousDataRowEventHandler(
+ Object sender , SuspiciousDataRowEventArgs eventArgs );
+
+ public event SuspiciousDataRowEventHandler SuspiciousDataRow;
+
+ #region "Validate"
+ #region "validate_currentQuotesRow_checkLogicalErrors"
+ /// <summary>
+ /// Adds a row if not ((Low <= Open) and (Open <= High) and (Low <= Close) and (Close <= High))
+ /// </summary>
+ /// <param name="quotesRow">Row of quotes to be checked</param>
+ private void validate_currentQuotesRow_checkLogicalErrors_checkOHLC( DataRow quotesRow )
+ {
+ if (!
+ ( ( Convert.ToDouble( quotesRow[ "quLow" ] ) <=
+ ( Convert.ToDouble( quotesRow[ "quOpen" ] ) ) ) &&
+ ( Convert.ToDouble( quotesRow[ "quOpen" ] ) <=
+ ( Convert.ToDouble( quotesRow[ "quHigh" ] ) ) ) &&
+ ( Convert.ToDouble( quotesRow[ "quLow" ] ) <=
+ ( Convert.ToDouble( quotesRow[ "quClose" ] ) ) ) &&
+ ( Convert.ToDouble( quotesRow[ "quClose" ] ) <=
+ ( Convert.ToDouble( quotesRow[ "quHigh" ] ) ) )
+ )
+ )
+ SuspiciousDataRow( this , new SuspiciousDataRowEventArgs( quotesRow ) );
+ }
+ /// <summary>
+ /// Adds an error row if quotesRow doesn't respect logical constraints
+ /// </summary>
+ /// <param name="quotesRow">Row of quotes to be checked</param>
+ private void validate_currentQuotesRow_checkLogicalErrors( DataRow quotesRow )
+ {
+ validate_currentQuotesRow_checkLogicalErrors_checkOHLC( quotesRow );
+ }
+ #endregion
+ /// <summary>
+ /// Adds errors for the current quotesRow (if any)
+ /// </summary>
+ /// <param name="quotesRow">Row of quotes to be checked</param>
+ private void validate_currentQuotesRow( DataRow quotesRow )
+ {
+ validate_currentQuotesRow_checkLogicalErrors( quotesRow );
+ }
+ public void Validate()
+ {
+ foreach ( DataRow quotesRow in this.Rows )
+ this.validate_currentQuotesRow( quotesRow );
+ }
}
+ #endregion
}
|