[Quantproject-developers] QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Eq
Brought to you by:
glauco_1
|
From: <gla...@us...> - 2003-11-08 20:56:43
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
In directory sc8-pr-cvs1:/tmp/cvs-serv13063/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
Added Files:
Equity.cs
Log Message:
Computes the equity report table
--- NEW FILE: Equity.cs ---
using System;
using System.Data;
using QuantProject.Business.Financial.Accounting.Reporting;
namespace QuantProject.Business.Financial.Accounting.Reporting.Tables
{
/// <summary>
/// Summary description for Equity.
/// </summary>
public class Equity : ReportTable
{
public Equity( string reportName , DataTable detailedDataTable ) :
base( reportName + " - Equity" )
{
this.DataTable = this.getEquity( detailedDataTable );
}
#region "getEquity"
private void getEquityTable_setColumns( DataTable equityDataTable )
{
equityDataTable.Columns.Add( "Date" , Type.GetType( "System.DateTime" ) );
equityDataTable.Columns.Add( "PnL" , Type.GetType( "System.Double" ) );
equityDataTable.Columns.Add( "AccountValue" , Type.GetType( "System.Double" ) );
equityDataTable.Columns.Add( "%chg" , Type.GetType( "System.Double" ) );
}
private void getEquityTable_setRows( DataTable equityDataTable , DataTable detailedDataTable )
{
foreach (DataRow detailedRow in detailedDataTable.Rows )
if ( detailedRow[ "TransactionType" ] == System.DBNull.Value )
// current detailed row reports an equity row
{
DataRow dataRow = equityDataTable.NewRow();
dataRow[ "Date" ] = detailedRow[ "DateTime" ];
dataRow[ "PnL" ] = detailedRow[ "PnL" ];
dataRow[ "AccountValue" ] = detailedRow[ "AccountValue" ];
if ( equityDataTable.Rows.Count > 0 )
dataRow[ "%chg" ] = ((double)dataRow[ "AccountValue" ] -
(double)equityDataTable.Rows[ equityDataTable.Rows.Count - 1 ][ "AccountValue" ])/
(double)equityDataTable.Rows[ equityDataTable.Rows.Count - 1 ][ "AccountValue" ]*
100;
equityDataTable.Rows.Add( dataRow );
}
}
private DataTable getEquity( DataTable detailedDataTable )
{
DataTable equityDataTable = new DataTable();
getEquityTable_setColumns( equityDataTable );
getEquityTable_setRows( equityDataTable , detailedDataTable );
return equityDataTable;
}
#endregion
}
}
|