[Quantproject-developers] QuantDownloader/Downloader/Validate/Validators OHLCvalidator.cs,NONE,1.1
Brought to you by:
glauco_1
|
From: <gla...@us...> - 2003-12-16 16:24:12
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/Validate/Validators
In directory sc8-pr-cvs1:/tmp/cvs-serv25430/Validate/Validators
Added Files:
OHLCvalidator.cs
Log Message:
Searches for inconsistent values among Open, High, Low and Close
--- NEW FILE: OHLCvalidator.cs ---
using System;
using System.Data;
using QuantProject.Applications.Downloader.Validate;
namespace QuantProject.Applications.Downloader.Validate.Validators
{
/// <summary>
/// Validates OHLC quotes values
/// </summary>
public class OHLCvalidator : IValidator
{
public event SuspiciousDataRowEventHandler SuspiciousDataRow;
public OHLCvalidator()
{
//
// TODO: Add constructor logic here
//
}
#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 );
}
/// <summary>
/// Validates Open High Low Close consistencies
/// </summary>
/// <param name="dataTable">Quote rows to be validated</param>
public void Validate( DataTable dataTable )
{
foreach ( DataRow quotesRow in dataTable.Rows )
this.validate_currentQuotesRow( quotesRow );
}
}
#endregion
}
|