quantproject-developers Mailing List for QuantProject (Page 151)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <mi...@us...> - 2003-11-10 19:05:49
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1:/tmp/cvs-serv22990/b2_DataAccess Added Files: DataBaseLocator.cs Log Message: For the selection of the db file during run - time --- NEW FILE: DataBaseLocator.cs --- using System; using System.Xml; using System.IO; using System.Windows.Forms; namespace QuantProject.DataAccess { /// <summary> /// Locate the database /// </summary> public class DataBaseLocator { private string dataBaseType; private StreamReader stream; private XmlTextReader xmlTextReader; private string path; public DataBaseLocator(string fileExtension) { try { this.dataBaseType = fileExtension; //it looks for the file in the application directory if (!File.Exists("DataBase.xml")) createXmlFile(); this.stream = new StreamReader(Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf('\\')) + @"\DataBase.xml"); this.xmlTextReader = new XmlTextReader(this.stream); while(xmlTextReader.Read()) { if (xmlTextReader.LocalName.ToString() == this.dataBaseType) { //gets full path of the file that contains the database this.Path = xmlTextReader.GetAttribute(0); } } xmlTextReader.Close(); stream.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); xmlTextReader.Close(); stream.Close(); } } public string Path { get { return path; } set { path = value; } } /// <summary> /// create xmlFile in the application directory /// where to store name and path for the mdb file /// selected by the user /// </summary> private void createXmlFile() { string path; string xmlPath; string selectionByUser; selectionByUser = selectDataBase(); if (selectionByUser == "") { MessageBox.Show("With no selection application won't run!"); Application.Exit(); } else { path = selectionByUser; xmlPath = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf('\\')) + @"\DataBase.xml"; XmlTextWriter xmlTextWriter = new XmlTextWriter(xmlPath, null); xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.WriteStartDocument(); xmlTextWriter.WriteStartElement("FILES"); xmlTextWriter.WriteStartElement("MDB"); xmlTextWriter.WriteAttributeString("fullpath",path); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndDocument(); xmlTextWriter.Flush(); xmlTextWriter.Close(); } } private string selectDataBase() { string fileName = ""; switch (this.dataBaseType) { case "MDB": fileName = "QuantProject.mdb"; break; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Select " + fileName + " please ..."; openFileDialog.Multiselect = false; openFileDialog.CheckFileExists = true; openFileDialog.Filter = fileName + "|" + fileName; openFileDialog.ShowDialog(); return openFileDialog.FileName; } } } |
|
From: <gla...@us...> - 2003-11-09 21:12:04
|
Update of /cvsroot/quantproject/QuantProject/b4_Business
In directory sc8-pr-cvs1:/tmp/cvs-serv29442/b4_Business
Modified Files:
b4_Business.csproj
Log Message:
Updated the Account Report Summary object:
- Added the Max equity drawdown
- 'Total number of trades' now is computed by a
devoted object (it was a delegate before this revision)
Index: b4_Business.csproj
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** b4_Business.csproj 8 Nov 2003 20:54:41 -0000 1.2
--- b4_Business.csproj 9 Nov 2003 21:12:00 -0000 1.3
***************
*** 197,200 ****
--- 197,215 ----
/>
<File
+ RelPath = "a1_Financial\a2_Accounting\h5_Reporting\SummaryRows\MaxEquityDrawDown.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "a1_Financial\a2_Accounting\h5_Reporting\SummaryRows\SummaryRow.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "a1_Financial\a2_Accounting\h5_Reporting\SummaryRows\TotalNumberOfTrades.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "a1_Financial\a2_Accounting\h5_Reporting\Tables\Equity.cs"
SubType = "Code"
|
|
From: <gla...@us...> - 2003-11-09 19:46:41
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows
In directory sc8-pr-cvs1:/tmp/cvs-serv13476/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows
Added Files:
TotalNumberOfTrades.cs
Log Message:
Computes the total number of trades for the
account report summary object
--- NEW FILE: TotalNumberOfTrades.cs ---
using System;
using System.Data;
using QuantProject.Business.Financial.Accounting.Reporting.Tables;
namespace QuantProject.Business.Financial.Accounting.Reporting.SummaryRows
{
/// <summary>
/// Summary description for TotalNumberOfTrades.
/// </summary>
public class TotalNumberOfTrades : SummaryRow
{
public TotalNumberOfTrades( Summary summary )
{
double totalROA = summary.TotalPnl / ( summary.FinalAccountValue - summary.TotalPnl );
this.rowDescription = "Total # of trades";
DataRow[] DataRows =
summary.AccountReport.RoundTrades.DataTable.Select( "(ExitPrice is not null)" );
this.rowValue = DataRows.Length;
}
}
}
|
|
From: <gla...@us...> - 2003-11-09 19:44:43
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows
In directory sc8-pr-cvs1:/tmp/cvs-serv13129/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows
Added Files:
MaxEquityDrawDown.cs
Log Message:
First version for the max drawdown calculation
--- NEW FILE: MaxEquityDrawDown.cs ---
using System;
using System.Data;
using QuantProject.Business.Financial.Accounting.Reporting.Tables;
namespace QuantProject.Business.Financial.Accounting.Reporting.SummaryRows
{
/// <summary>
/// Summary description for TotalNumberOfTrades.
/// </summary>
public class MaxEquityDrawDown : SummaryRow
{
private Summary summary;
private double drawDown;
private double maxEquityValue;
private void updateDrawDownForCurrentRow( DataRow dataRow )
{
this.maxEquityValue = Math.Max( this.maxEquityValue , (double)dataRow[ "AccountValue" ] );
this.drawDown =
Math.Max( this.drawDown , this.maxEquityValue - (double)dataRow[ "AccountValue" ] );
}
private void setDrawDown()
{
drawDown = 0.0;
maxEquityValue = double.MinValue;
foreach ( DataRow row in summary.AccountReport.Equity.DataTable.Rows )
updateDrawDownForCurrentRow( row );
}
public MaxEquityDrawDown( Summary summary )
{
this.summary = summary;
this.rowDescription = "Max equity drawdown (%)";
setDrawDown();
this.rowValue = this.drawDown/this.maxEquityValue*100;
}
}
}
|
|
From: <gla...@us...> - 2003-11-09 19:43:06
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows
In directory sc8-pr-cvs1:/tmp/cvs-serv12798/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows
Added Files:
SummaryRow.cs
Log Message:
Base class for Summary rows
--- NEW FILE: SummaryRow.cs ---
using System;
namespace QuantProject.Business.Financial.Accounting.Reporting.SummaryRows
{
/// <summary>
/// Summary description for SummaryRow.
/// </summary>
public class SummaryRow
{
internal string rowDescription;
internal object rowValue;
public string Description
{
get { return rowDescription; }
// set { rowDescription = value; }
}
public object Value
{
get { return rowValue; }
// set { rowValue = value; }
}
public SummaryRow()
{
//
// TODO: Add constructor logic here
//
}
}
}
|
|
From: <gla...@us...> - 2003-11-09 19:42:18
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
In directory sc8-pr-cvs1:/tmp/cvs-serv12653/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
Modified Files:
Summary.cs
Log Message:
- Added the Max equity drawdown.
- 'Total number of trades' now is computed by a
devoted object (it was a delegate before this revision)
Index: Summary.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/Summary.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Summary.cs 8 Nov 2003 20:57:54 -0000 1.1
--- Summary.cs 9 Nov 2003 19:42:15 -0000 1.2
***************
*** 4,7 ****
--- 4,8 ----
using QuantProject.Business.Financial.Instruments;
using QuantProject.Business.Financial.Accounting.Reporting;
+ using QuantProject.Business.Financial.Accounting.Reporting.SummaryRows;
namespace QuantProject.Business.Financial.Accounting.Reporting.Tables
***************
*** 10,15 ****
/// Summary description for Summary.
/// </summary>
! public class Summary : ReportTable
! {
private AccountReport accountReport;
private double totalPnl;
--- 11,16 ----
/// Summary description for Summary.
/// </summary>
! public class Summary : ReportTable
! {
private AccountReport accountReport;
private double totalPnl;
***************
*** 17,20 ****
--- 18,33 ----
private double finalAccountValue;
private long intervalDays;
+ public AccountReport AccountReport
+ {
+ get { return accountReport; }
+ }
+ public double TotalPnl
+ {
+ get { return totalPnl; }
+ }
+ public double FinalAccountValue
+ {
+ get { return finalAccountValue; }
+ }
public Summary( AccountReport accountReport ) :
base( accountReport.Name + " - Summary" )
***************
*** 65,83 ****
// r = [(1+T)^(1/n)]-1
}
- private void getSummaryTable_setRow_MaxEquityDrawdown( DataRow summary )
- {
- // double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
- // summary[ "Information" ] = "Annual system % return";
- // summary[ "Value" ] = ( ( Math.Pow( 1 + totalROA ,
- // 1.0 / ( (double)this.intervalDays/365.0 ) ) ) - 1 ) * 100;
- // // r = [(1+T)^(1/n)]-1
- }
- private void getSummaryTable_setRow_TotalNumberOfTrades( DataRow summary )
- {
- double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
- summary[ "Information" ] = "Total # of trades";
- DataRow[] DataRows = this.accountReport.RoundTrades.DataTable.Select( "(ExitPrice is not null)" );
- summary[ "Value" ] = DataRows.Length;
- }
private void getSummaryTable_setRow_NumberWinningTrades( DataRow summary )
{
--- 78,81 ----
***************
*** 153,156 ****
--- 151,161 ----
summaryDataTable.Rows.Add( summary );
}
+ private void getSummary_setRow( SummaryRow summaryRow , DataTable summaryDataTable )
+ {
+ DataRow summary = summaryDataTable.NewRow();
+ summary[ "Information" ] = summaryRow.Description;
+ summary[ "Value" ] = summaryRow.Value;
+ summaryDataTable.Rows.Add( summary );
+ }
private void getSummaryTable_setRows( DataTable summaryDataTable )
{
***************
*** 163,170 ****
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AnnualSystemPercentageReturn ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_MaxEquityDrawdown ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfTrades ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningTrades ) );
--- 168,173 ----
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AnnualSystemPercentageReturn ) );
! getSummary_setRow( new MaxEquityDrawDown( this ) , summaryDataTable );
! getSummary_setRow( new TotalNumberOfTrades( this ) , summaryDataTable );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningTrades ) );
|
|
From: <gla...@us...> - 2003-11-09 19:12:03
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows In directory sc8-pr-cvs1:/tmp/cvs-serv8102/SummaryRows Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/SummaryRows added to the repository |
|
From: <gla...@us...> - 2003-11-08 20:58:50
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
In directory sc8-pr-cvs1:/tmp/cvs-serv13402
Added Files:
Transactions.cs
Log Message:
Computes the transactions report table
--- NEW FILE: Transactions.cs ---
using System;
using System.Data;
using QuantProject.Business.Financial.Accounting.Reporting;
namespace QuantProject.Business.Financial.Accounting.Reporting.Tables
{
/// <summary>
/// Summary description for Transactions.
/// </summary>
public class Transactions : ReportTable
{
public Transactions( string reportName , DataTable detailedDataTable ) :
base( reportName + " - Transactions" )
{
this.DataTable = this.getTransactionTable_actually( detailedDataTable );
}
private void getTransactionTable_setColumns( DataTable detailedDataTable ,
DataTable transactionsDataTable )
{
transactionsDataTable.Columns.Add( "DateTime" , Type.GetType( "System.DateTime" ) );
transactionsDataTable.Columns.Add( "BarComponent" , Type.GetType( "System.String" ) );
transactionsDataTable.Columns.Add( "TransactionType" , Type.GetType( "System.String" ) );
transactionsDataTable.Columns.Add( "InstrumentKey" , Type.GetType( "System.String" ) );
transactionsDataTable.Columns.Add( "Quantity" , Type.GetType( "System.Int32" ) );
transactionsDataTable.Columns.Add( "Price" , Type.GetType( "System.Double" ) );
transactionsDataTable.Columns.Add( "TransactionAmount" , Type.GetType( "System.Double" ) );
transactionsDataTable.Columns.Add( "AccountCash" , Type.GetType( "System.Double" ) );
transactionsDataTable.Columns.Add( "PortfolioValue" , Type.GetType( "System.Double" ) );
transactionsDataTable.Columns.Add( "AccountValue" , Type.GetType( "System.Double" ) );
transactionsDataTable.Columns.Add( "PnL" , Type.GetType( "System.Double" ) );
}
private void getTransactionTable_setRows( DataTable detailedDataTable ,
DataTable transactionsDataTable )
{
foreach ( DataRow detailedRow in detailedDataTable.Rows )
if ( detailedRow[ "TransactionType" ] != System.DBNull.Value )
// current detailed row reports a transaction
{
DataRow dataRow = transactionsDataTable.NewRow();
dataRow[ "DateTime" ] = detailedRow[ "DateTime" ];
dataRow[ "BarComponent" ] = detailedRow[ "BarComponent" ];
dataRow[ "TransactionType" ] = detailedRow[ "TransactionType" ];
dataRow[ "InstrumentKey" ] = detailedRow[ "InstrumentKey" ];
dataRow[ "Quantity" ] = detailedRow[ "Quantity" ];
dataRow[ "Price" ] = detailedRow[ "Price" ];
dataRow[ "TransactionAmount" ] = detailedRow[ "TransactionAmount" ];
dataRow[ "AccountCash" ] = detailedRow[ "AccountCash" ];
dataRow[ "PortfolioValue" ] = detailedRow[ "PortfolioValue" ];
dataRow[ "AccountValue" ] = detailedRow[ "AccountValue" ];
dataRow[ "PnL" ] = detailedRow[ "PnL" ];
transactionsDataTable.Rows.Add( dataRow );
}
}
private DataTable getTransactionTable_actually( DataTable detailedDataTable )
{
DataTable transactionsDataTable = new DataTable();
getTransactionTable_setColumns( detailedDataTable , transactionsDataTable );
getTransactionTable_setRows( detailedDataTable , transactionsDataTable );
return transactionsDataTable;
}
// private ReportTable getTransactionTable( string reportName , DataTable detailedDataTable )
// {
// DataTable transactionsDataTable = getTransactionTable_actually( detailedDataTable );
// return new ReportTable( reportName + " - Transactions" ,
// transactionsDataTable );
// //ExcelManager.Add( reportTable ); daCanc
// }
}
}
|
|
From: <gla...@us...> - 2003-11-08 20:57:57
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
In directory sc8-pr-cvs1:/tmp/cvs-serv13260/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
Added Files:
Summary.cs
Log Message:
Computes the summary report table
--- NEW FILE: Summary.cs ---
using System;
using System.Data;
using QuantProject.ADT;
using QuantProject.Business.Financial.Instruments;
using QuantProject.Business.Financial.Accounting.Reporting;
namespace QuantProject.Business.Financial.Accounting.Reporting.Tables
{
/// <summary>
/// Summary description for Summary.
/// </summary>
public class Summary : ReportTable
{
private AccountReport accountReport;
private double totalPnl;
private double buyAndHoldPercentageReturn;
private double finalAccountValue;
private long intervalDays;
public Summary( AccountReport accountReport ) :
base( accountReport.Name + " - Summary" )
{
this.accountReport = accountReport;
this.getSummary();
}
#region "getSummary"
private void getSummaryTable_setColumns( DataTable equityDataTable )
{
equityDataTable.Columns.Add( "Information" , Type.GetType( "System.String" ) );
equityDataTable.Columns.Add( "Value" , Type.GetType( "System.Double" ) );
}
#region "getSummaryTable_setRows"
private delegate void getSummaryTable_setRow( DataRow summary );
private void getSummaryTable_setRow_TotalNetProfit( DataRow summary )
{
summary[ "Information" ] = "Total net profit";
summary[ "Value" ] = this.totalPnl;
}
private void getSummaryTable_setRow_ReturnOnAccount( DataRow summary )
{
summary[ "Information" ] = "Return on account";
summary[ "Value" ] = this.totalPnl / ( this.finalAccountValue - this.totalPnl ) * 100;
}
private void getSummaryTable_setRow_BuyAndHoldPercentageReturn( DataRow summary )
{
if ( this.accountReport.BuyAndHoldTicker != "" )
{
// the report has to compare to a buy and hold benchmark
Instrument buyAndHoldInstrument = new Instrument( this.accountReport.BuyAndHoldTicker );
this.buyAndHoldPercentageReturn =
( buyAndHoldInstrument.GetMarketValue( this.accountReport.EndDateTime ) -
buyAndHoldInstrument.GetMarketValue(
new ExtendedDateTime( this.accountReport.StartDateTime , BarComponent.Open ) ) ) /
buyAndHoldInstrument.GetMarketValue(
new ExtendedDateTime( this.accountReport.StartDateTime , BarComponent.Open ) ) * 100;
summary[ "Information" ] = "Buy & hold % return";
summary[ "Value" ] = this.buyAndHoldPercentageReturn;
}
}
private void getSummaryTable_setRow_AnnualSystemPercentageReturn( DataRow summary )
{
double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
summary[ "Information" ] = "Annual system % return";
summary[ "Value" ] = ( ( Math.Pow( 1 + totalROA ,
1.0 / ( (double)this.intervalDays/365.0 ) ) ) - 1 ) * 100;
// r = [(1+T)^(1/n)]-1
}
private void getSummaryTable_setRow_MaxEquityDrawdown( DataRow summary )
{
// double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
// summary[ "Information" ] = "Annual system % return";
// summary[ "Value" ] = ( ( Math.Pow( 1 + totalROA ,
// 1.0 / ( (double)this.intervalDays/365.0 ) ) ) - 1 ) * 100;
// // r = [(1+T)^(1/n)]-1
}
private void getSummaryTable_setRow_TotalNumberOfTrades( DataRow summary )
{
double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
summary[ "Information" ] = "Total # of trades";
DataRow[] DataRows = this.accountReport.RoundTrades.DataTable.Select( "(ExitPrice is not null)" );
summary[ "Value" ] = DataRows.Length;
}
private void getSummaryTable_setRow_NumberWinningTrades( DataRow summary )
{
summary[ "Information" ] = "Number winning trades";
DataRow[] DataRows = this.accountReport.RoundTrades.DataTable.Select( "([%Profit] > 0)" );
summary[ "Value" ] = DataRows.Length;
}
private void getSummaryTable_setRow_AverageTradePercentageReturn( DataRow summary )
{
summary[ "Information" ] = "Average trade % Return";
double avgReturn = (double) this.accountReport.RoundTrades.DataTable.Compute( "avg([%Profit])" , "true" );
summary[ "Value" ] = avgReturn;
}
private void getSummaryTable_setRow_LargestWinningTradePercentage( DataRow summary )
{
summary[ "Information" ] = "Largest winning trade";
summary[ "Value" ] =
(double) this.accountReport.RoundTrades.DataTable.Compute( "max([%Profit])" , "([%Profit]>0)" );
}
private void getSummaryTable_setRow_LargestLosingTradePercentage( DataRow summary )
{
summary[ "Information" ] = "Largest losing trade";
summary[ "Value" ] =
(double) this.accountReport.RoundTrades.DataTable.Compute( "min([%Profit])" , "([%Profit]<0)" );
}
private void getSummaryTable_setRow_TotalNumberOfLongTrades( DataRow summary )
{
double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
summary[ "Information" ] = "Total # of long trades";
DataRow[] DataRows =
this.accountReport.RoundTrades.DataTable.Select( "((Trade='Long')and(ExitPrice is not null))" );
summary[ "Value" ] = DataRows.Length;
}
private void getSummaryTable_setRow_NumberWinningLongTrades( DataRow summary )
{
summary[ "Information" ] = "Number winning long trades";
DataRow[] DataRows = this.accountReport.RoundTrades.DataTable.Select( "((Trade='Long')and([%Profit] > 0))" );
summary[ "Value" ] = DataRows.Length;
}
private void getSummaryTable_setRow_AverageLongTradePercentageReturn( DataRow summary )
{
summary[ "Information" ] = "Average long trade % Return";
double avgReturn =
(double) this.accountReport.RoundTrades.DataTable.Compute( "avg([%Profit])" , "(Trade='Long')" );
summary[ "Value" ] = avgReturn;
}
private void getSummaryTable_setRow_TotalNumberOfShortTrades( DataRow summary )
{
double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
summary[ "Information" ] = "Total # of short trades";
DataRow[] DataRows =
this.accountReport.RoundTrades.DataTable.Select( "((Trade='Short')and(ExitPrice is not null))" );
summary[ "Value" ] = DataRows.Length;
}
private void getSummaryTable_setRow_NumberWinningShortTrades( DataRow summary )
{
summary[ "Information" ] = "Number winning short trades";
DataRow[] DataRows = this.accountReport.RoundTrades.DataTable.Select( "((Trade='Short')and([%Profit] > 0))" );
summary[ "Value" ] = DataRows.Length;
}
private void getSummaryTable_setRow_AverageShortTradePercentageReturn( DataRow summary )
{
summary[ "Information" ] = "Average short trade % Return";
double avgReturn =
(double) this.accountReport.RoundTrades.DataTable.Compute( "avg([%Profit])" , "(Trade='Short')" );
summary[ "Value" ] = avgReturn;
}
private void getSummary_setRow( DataTable summaryDataTable ,
getSummaryTable_setRow getSummaryTable_setRow_object )
{
DataRow summary = summaryDataTable.NewRow();
getSummaryTable_setRow_object( summary );
summaryDataTable.Rows.Add( summary );
}
private void getSummaryTable_setRows( DataTable summaryDataTable )
{
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_TotalNetProfit ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_ReturnOnAccount ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_BuyAndHoldPercentageReturn ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AnnualSystemPercentageReturn ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_MaxEquityDrawdown ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfTrades ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningTrades ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AverageTradePercentageReturn ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_LargestWinningTradePercentage ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_LargestLosingTradePercentage ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfLongTrades ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningLongTrades ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AverageLongTradePercentageReturn ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfShortTrades ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningShortTrades ) );
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AverageShortTradePercentageReturn ) );
}
#endregion
private DataTable getSummaryDataTable()
{
DataTable summaryDataTable = new DataTable();
getSummaryTable_setColumns( summaryDataTable );
getSummaryTable_setRows( summaryDataTable );
return summaryDataTable;
}
private void getSummary()
{
this.totalPnl =
(double)this.accountReport.Equity.DataTable.Rows[ this.accountReport.Equity.DataTable.Rows.Count - 1 ][ "PnL" ];
this.finalAccountValue =
(double)this.accountReport.Equity.DataTable.Rows[ this.accountReport.Equity.DataTable.Rows.Count - 1 ][ "AccountValue" ];
this.intervalDays =
((TimeSpan)((DateTime)this.accountReport.Equity.DataTable.Rows[ this.accountReport.Equity.DataTable.Rows.Count - 1 ][ "Date" ] -
(DateTime)this.accountReport.Equity.DataTable.Rows[ 0 ][ "Date" ])).Days;
this.DataTable = getSummaryDataTable();
}
#endregion
}
}
|
|
From: <gla...@us...> - 2003-11-08 20:57:19
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
In directory sc8-pr-cvs1:/tmp/cvs-serv13175/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
Added Files:
RoundTrades.cs
Log Message:
Computes the round trades report table
--- NEW FILE: RoundTrades.cs ---
using System;
using System.Data;
using QuantProject.Business.Financial.Accounting.Reporting;
namespace QuantProject.Business.Financial.Accounting.Reporting.Tables
{
/// <summary>
/// Summary description for RoundTrades.
/// </summary>
public class RoundTrades : ReportTable
{
private ReportTable transactionTable;
public RoundTrades( string reportName , ReportTable transactionTable ) :
base( reportName + " - Round Trades" )
{
this.transactionTable = transactionTable;
this.DataTable = this.getRoundTrades();
}
#region "getRoundTrades"
private void getRoundTradeTable_setColumns( DataTable roundTradeDataTable )
{
roundTradeDataTable.Columns.Add( "Trade" , Type.GetType( "System.String" ) );
roundTradeDataTable.Columns.Add( "EntryDate" , Type.GetType( "System.DateTime" ) );
roundTradeDataTable.Columns.Add( "EntryPrice" , Type.GetType( "System.Double" ) );
roundTradeDataTable.Columns.Add( "ExitDate" , Type.GetType( "System.DateTime" ) );
roundTradeDataTable.Columns.Add( "ExitPrice" , Type.GetType( "System.Double" ) );
roundTradeDataTable.Columns.Add( "%chg" , Type.GetType( "System.Double" ) );
roundTradeDataTable.Columns.Add( "Profit" , Type.GetType( "System.Double" ) );
roundTradeDataTable.Columns.Add( "%Profit" , Type.GetType( "System.Double" ) );
roundTradeDataTable.Columns.Add( "#bars" , Type.GetType( "System.Int32" ) );
roundTradeDataTable.Columns.Add( "ProfitPerBar" , Type.GetType( "System.Double" ) );
//roundTradeDataTable.Columns.Add( "AccountValue" , Type.GetType( "System.Double" ) );
//roundTradeDataTable.Columns.Add( "PnL" , Type.GetType( "System.Double" ) );
}
private void getRoundTradeTable_setRow( DataRow dataRow , DataTable roundTradeDataTable )
{
DataRow roundTrade;
switch ( (string)dataRow[ "TransactionType" ] )
{
case "BuyLong":
roundTrade = roundTradeDataTable.NewRow();
roundTrade[ "Trade" ] = "Long";
roundTrade[ "EntryDate" ] = dataRow[ "DateTime" ];
roundTrade[ "EntryPrice" ] = dataRow[ "Price" ];
roundTradeDataTable.Rows.Add( roundTrade );
break;
case "Sell":
roundTrade = roundTradeDataTable.Rows[ roundTradeDataTable.Rows.Count - 1 ];
roundTrade[ "ExitDate" ] = dataRow[ "DateTime" ];
roundTrade[ "ExitPrice" ] = dataRow[ "Price" ];
roundTrade[ "%chg" ] =
((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/
((double)roundTrade[ "EntryPrice" ])*100;
roundTrade[ "%Profit" ] = roundTrade[ "%chg" ];
roundTrade[ "#bars" ] =
((TimeSpan)((DateTime)roundTrade[ "ExitDate" ] - (DateTime)roundTrade[ "EntryDate" ])).Days;
roundTrade[ "ProfitPerBar" ] = (double)roundTrade[ "%chg" ] / (int)roundTrade[ "#bars" ];
break;
case "SellShort":
roundTrade = roundTradeDataTable.NewRow();
roundTrade[ "Trade" ] = "Short";
roundTrade[ "EntryDate" ] = dataRow[ "DateTime" ];
roundTrade[ "EntryPrice" ] = dataRow[ "Price" ];
roundTradeDataTable.Rows.Add( roundTrade );
break;
case "Cover":
roundTrade = roundTradeDataTable.Rows[ roundTradeDataTable.Rows.Count - 1 ];
roundTrade[ "ExitDate" ] = dataRow[ "DateTime" ];
roundTrade[ "ExitPrice" ] = dataRow[ "Price" ];
roundTrade[ "%chg" ] =
((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/
((double)roundTrade[ "EntryPrice" ])*100;
roundTrade[ "%Profit" ] = - ((double)roundTrade[ "%chg" ]);
roundTrade[ "#bars" ] =
((TimeSpan)((DateTime)roundTrade[ "ExitDate" ] - (DateTime)roundTrade[ "EntryDate" ])).Days;
roundTrade[ "ProfitPerBar" ] = (double)roundTrade[ "%chg" ] / (int)roundTrade[ "#bars" ];
break;
}
}
private void getRoundTradeTable_setRows( DataTable roundTradeDataTable )
{
foreach (DataRow dataRow in this.transactionTable.DataTable.Rows )
getRoundTradeTable_setRow( dataRow , roundTradeDataTable );
}
private DataTable getRoundTrades()
{
DataTable roundTradeDataTable = new DataTable();
getRoundTradeTable_setColumns( roundTradeDataTable );
getRoundTradeTable_setRows( roundTradeDataTable );
return roundTradeDataTable;
}
#endregion
}
}
|
|
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
}
}
|
|
From: <gla...@us...> - 2003-11-08 20:55:57
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
In directory sc8-pr-cvs1:/tmp/cvs-serv12933/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
Modified Files:
ReportTable.cs
Log Message:
Base class for report tables (like Transactions, RoundTrades,
Equity and Summary)
Index: ReportTable.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/ReportTable.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ReportTable.cs 13 Oct 2003 21:59:01 -0000 1.1.1.1
--- ReportTable.cs 8 Nov 2003 20:55:54 -0000 1.2
***************
*** 41,44 ****
--- 41,45 ----
{
get { return dataTable; }
+ set { dataTable = value; }
}
***************
*** 47,50 ****
--- 48,55 ----
this.name = name;
this.dataTable = dataTable;
+ }
+ public ReportTable( string name )
+ {
+ this.name = name;
}
}
|
|
From: <gla...@us...> - 2003-11-08 20:54:59
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
In directory sc8-pr-cvs1:/tmp/cvs-serv12622/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
Modified Files:
AccountReport.cs
Log Message:
Added Report.Tables objects: splitted the AccountReport object in one
table object for Transactions, RoundTrades, Equity and Summary.
Index: AccountReport.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** AccountReport.cs 3 Nov 2003 22:26:35 -0000 1.5
--- AccountReport.cs 8 Nov 2003 20:54:41 -0000 1.6
***************
*** 39,53 ****
private Account account;
private Account accountCopy = new Account( "AccountCopy" );
private ExtendedDateTime endDateTime;
private string buyAndHoldTicker;
! private double totalPnl;
! private double finalAccountValue;
! private double buyAndHoldPercentageReturn;
! private long intervalDays;
! private ReportTable transactionTable;
private ReportTable roundTrades;
private ReportTable equity;
private ReportTable summary;
public ReportTable TransactionTable
{
--- 39,72 ----
private Account account;
private Account accountCopy = new Account( "AccountCopy" );
+ private string reportName;
private ExtendedDateTime endDateTime;
private string buyAndHoldTicker;
! //private long numDaysForInterval;
! private DataTable detailedDataTable;
! private Tables.Transactions transactionTable;
private ReportTable roundTrades;
private ReportTable equity;
private ReportTable summary;
+ public string Name
+ {
+ get { return reportName; }
+ }
+ public ExtendedDateTime EndDateTime
+ {
+ get { return endDateTime; }
+ }
+ public string BuyAndHoldTicker
+ {
+ get { return buyAndHoldTicker; }
+ }
+ // public long NumDaysForInterval
+ // {
+ // get { return numDaysForInterval; }
+ // }
+ public DataTable DetailedDataTable
+ {
+ get { return detailedDataTable; }
+ }
public ReportTable TransactionTable
{
***************
*** 147,151 ****
detailedDataTable.Rows.Add( dataRow );
}
! private void addRowForPnl( int numDaysForInterval , DateTime currentDate ,
System.Data.DataTable detailedDataTable )
{
--- 166,170 ----
detailedDataTable.Rows.Add( dataRow );
}
! private void addRowForPnl( long numDaysForInterval , DateTime currentDate ,
System.Data.DataTable detailedDataTable )
{
***************
*** 155,159 ****
addRowForPnl_actually( currentDate , detailedDataTable );
}
! private void setRows( int numDaysForInterval , System.Data.DataTable detailedDataTable )
{
DateTime currentDate = (DateTime) account.Transactions.GetKey( 0 );
--- 174,178 ----
addRowForPnl_actually( currentDate , detailedDataTable );
}
! private void setRows( long numDaysForInterval , System.Data.DataTable detailedDataTable )
{
DateTime currentDate = (DateTime) account.Transactions.GetKey( 0 );
***************
*** 177,181 ****
}
#endregion
! private System.Data.DataTable getDetailedDataTable( int numDaysForInterval )
{
System.Data.DataTable detailedDataTable = new System.Data.DataTable();
--- 196,200 ----
}
#endregion
! private System.Data.DataTable getDetailedDataTable( long numDaysForInterval )
{
System.Data.DataTable detailedDataTable = new System.Data.DataTable();
***************
*** 185,556 ****
}
#endregion
- #region "getTransactionTable"
- private void getTransactionTable_setColumns( DataTable detailedDataTable ,
- DataTable transactionsDataTable )
- {
- transactionsDataTable.Columns.Add( "DateTime" , Type.GetType( "System.DateTime" ) );
- transactionsDataTable.Columns.Add( "BarComponent" , Type.GetType( "System.String" ) );
- transactionsDataTable.Columns.Add( "TransactionType" , Type.GetType( "System.String" ) );
- transactionsDataTable.Columns.Add( "InstrumentKey" , Type.GetType( "System.String" ) );
- transactionsDataTable.Columns.Add( "Quantity" , Type.GetType( "System.Int32" ) );
- transactionsDataTable.Columns.Add( "Price" , Type.GetType( "System.Double" ) );
- transactionsDataTable.Columns.Add( "TransactionAmount" , Type.GetType( "System.Double" ) );
- transactionsDataTable.Columns.Add( "AccountCash" , Type.GetType( "System.Double" ) );
- transactionsDataTable.Columns.Add( "PortfolioValue" , Type.GetType( "System.Double" ) );
- transactionsDataTable.Columns.Add( "AccountValue" , Type.GetType( "System.Double" ) );
- transactionsDataTable.Columns.Add( "PnL" , Type.GetType( "System.Double" ) );
- }
- private void getTransactionTable_setRows( DataTable detailedDataTable ,
- DataTable transactionsDataTable )
- {
- foreach ( DataRow detailedRow in detailedDataTable.Rows )
- if ( detailedRow[ "TransactionType" ] != System.DBNull.Value )
- // current detailed row reports a transaction
- {
- DataRow dataRow = transactionsDataTable.NewRow();
- dataRow[ "DateTime" ] = detailedRow[ "DateTime" ];
- dataRow[ "BarComponent" ] = detailedRow[ "BarComponent" ];
- dataRow[ "TransactionType" ] = detailedRow[ "TransactionType" ];
- dataRow[ "InstrumentKey" ] = detailedRow[ "InstrumentKey" ];
- dataRow[ "Quantity" ] = detailedRow[ "Quantity" ];
- dataRow[ "Price" ] = detailedRow[ "Price" ];
- dataRow[ "TransactionAmount" ] = detailedRow[ "TransactionAmount" ];
- dataRow[ "AccountCash" ] = detailedRow[ "AccountCash" ];
- dataRow[ "PortfolioValue" ] = detailedRow[ "PortfolioValue" ];
- dataRow[ "AccountValue" ] = detailedRow[ "AccountValue" ];
- dataRow[ "PnL" ] = detailedRow[ "PnL" ];
- transactionsDataTable.Rows.Add( dataRow );
- }
- }
- private DataTable getTransactionTable_actually( DataTable detailedDataTable )
- {
- DataTable transactionsDataTable = new DataTable();
- getTransactionTable_setColumns( detailedDataTable , transactionsDataTable );
- getTransactionTable_setRows( detailedDataTable , transactionsDataTable );
- return transactionsDataTable;
- }
- private ReportTable getTransactionTable( string reportName , DataTable detailedDataTable )
- {
- DataTable transactionsDataTable = getTransactionTable_actually( detailedDataTable );
- return new ReportTable( reportName + " - Transactions" ,
- transactionsDataTable );
- //ExcelManager.Add( reportTable ); daCanc
- }
#endregion
- #region "getRoundTrades"
- private void getRoundTradeTable_setColumns( DataTable roundTradeDataTable )
- {
- roundTradeDataTable.Columns.Add( "Trade" , Type.GetType( "System.String" ) );
- roundTradeDataTable.Columns.Add( "EntryDate" , Type.GetType( "System.DateTime" ) );
- roundTradeDataTable.Columns.Add( "EntryPrice" , Type.GetType( "System.Double" ) );
- roundTradeDataTable.Columns.Add( "ExitDate" , Type.GetType( "System.DateTime" ) );
- roundTradeDataTable.Columns.Add( "ExitPrice" , Type.GetType( "System.Double" ) );
- roundTradeDataTable.Columns.Add( "%chg" , Type.GetType( "System.Double" ) );
- roundTradeDataTable.Columns.Add( "Profit" , Type.GetType( "System.Double" ) );
- roundTradeDataTable.Columns.Add( "%Profit" , Type.GetType( "System.Double" ) );
- roundTradeDataTable.Columns.Add( "#bars" , Type.GetType( "System.Int32" ) );
- roundTradeDataTable.Columns.Add( "ProfitPerBar" , Type.GetType( "System.Double" ) );
- //roundTradeDataTable.Columns.Add( "AccountValue" , Type.GetType( "System.Double" ) );
- //roundTradeDataTable.Columns.Add( "PnL" , Type.GetType( "System.Double" ) );
- }
- private void getRoundTradeTable_setRow( DataRow dataRow , DataTable roundTradeDataTable )
- {
- DataRow roundTrade;
- switch ( (string)dataRow[ "TransactionType" ] )
- {
- case "BuyLong":
- roundTrade = roundTradeDataTable.NewRow();
- roundTrade[ "Trade" ] = "Long";
- roundTrade[ "EntryDate" ] = dataRow[ "DateTime" ];
- roundTrade[ "EntryPrice" ] = dataRow[ "Price" ];
- roundTradeDataTable.Rows.Add( roundTrade );
- break;
- case "Sell":
- roundTrade = roundTradeDataTable.Rows[ roundTradeDataTable.Rows.Count - 1 ];
- roundTrade[ "ExitDate" ] = dataRow[ "DateTime" ];
- roundTrade[ "ExitPrice" ] = dataRow[ "Price" ];
- roundTrade[ "%chg" ] =
- ((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/
- ((double)roundTrade[ "EntryPrice" ])*100;
- roundTrade[ "%Profit" ] = roundTrade[ "%chg" ];
- roundTrade[ "#bars" ] =
- ((TimeSpan)((DateTime)roundTrade[ "ExitDate" ] - (DateTime)roundTrade[ "EntryDate" ])).Days;
- roundTrade[ "ProfitPerBar" ] = (double)roundTrade[ "%chg" ] / (int)roundTrade[ "#bars" ];
- break;
- case "SellShort":
- roundTrade = roundTradeDataTable.NewRow();
- roundTrade[ "Trade" ] = "Short";
- roundTrade[ "EntryDate" ] = dataRow[ "DateTime" ];
- roundTrade[ "EntryPrice" ] = dataRow[ "Price" ];
- roundTradeDataTable.Rows.Add( roundTrade );
- break;
- case "Cover":
- roundTrade = roundTradeDataTable.Rows[ roundTradeDataTable.Rows.Count - 1 ];
- roundTrade[ "ExitDate" ] = dataRow[ "DateTime" ];
- roundTrade[ "ExitPrice" ] = dataRow[ "Price" ];
- roundTrade[ "%chg" ] =
- ((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/
- ((double)roundTrade[ "EntryPrice" ])*100;
- roundTrade[ "%Profit" ] = - ((double)roundTrade[ "%chg" ]);
- roundTrade[ "#bars" ] =
- ((TimeSpan)((DateTime)roundTrade[ "ExitDate" ] - (DateTime)roundTrade[ "EntryDate" ])).Days;
- roundTrade[ "ProfitPerBar" ] = (double)roundTrade[ "%chg" ] / (int)roundTrade[ "#bars" ];
- break;
- }
! }
! private void getRoundTradeTable_setRows( DataTable roundTradeDataTable )
! {
! foreach (DataRow dataRow in this.transactionTable.DataTable.Rows )
! getRoundTradeTable_setRow( dataRow , roundTradeDataTable );
! }
! private DataTable getRoundTradeDataTable()
! {
! DataTable roundTradeDataTable = new DataTable();
! getRoundTradeTable_setColumns( roundTradeDataTable );
! getRoundTradeTable_setRows( roundTradeDataTable );
! return roundTradeDataTable;
! }
! private ReportTable getRoundTrades( string reportName )
! {
! DataTable roundTradeDataTable = getRoundTradeDataTable();
! return new ReportTable( reportName + " - Round Trades" ,
! roundTradeDataTable );
! }
! #endregion
! #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 getEquityDataTable( DataTable detailedDataTable )
! {
! DataTable equityDataTable = new DataTable();
! getEquityTable_setColumns( equityDataTable );
! getEquityTable_setRows( equityDataTable , detailedDataTable );
! return equityDataTable;
! }
! private ReportTable getEquity( string reportName , DataTable detailedDataTable )
! {
! DataTable equityDataTable = getEquityDataTable( detailedDataTable );
! return new ReportTable( reportName + " - Equity" ,
! equityDataTable );
! }
!
! #endregion
! #region "getSummary"
! private void getSummaryTable_setColumns( DataTable equityDataTable )
! {
! equityDataTable.Columns.Add( "Information" , Type.GetType( "System.String" ) );
! equityDataTable.Columns.Add( "Value" , Type.GetType( "System.Double" ) );
! }
! #region "getSummaryTable_setRows"
! private delegate void getSummaryTable_setRow( DataRow summary );
! private void getSummaryTable_setRow_TotalNetProfit( DataRow summary )
! {
! summary[ "Information" ] = "Total net profit";
! summary[ "Value" ] = this.totalPnl;
! }
! private void getSummaryTable_setRow_ReturnOnAccount( DataRow summary )
! {
! summary[ "Information" ] = "Return on account";
! summary[ "Value" ] = this.totalPnl / ( this.finalAccountValue - this.totalPnl ) * 100;
! }
! private void getSummaryTable_setRow_BuyAndHoldPercentageReturn( DataRow summary )
! {
! if ( this.buyAndHoldTicker != "" )
! {
! // the report has to compare to a buy and hold benchmark
! Instrument buyAndHoldInstrument = new Instrument( this.buyAndHoldTicker );
! this.buyAndHoldPercentageReturn =
! ( buyAndHoldInstrument.GetMarketValue( this.endDateTime ) -
! buyAndHoldInstrument.GetMarketValue(
! new ExtendedDateTime( this.StartDateTime , BarComponent.Open ) ) ) /
! buyAndHoldInstrument.GetMarketValue(
! new ExtendedDateTime( this.StartDateTime , BarComponent.Open ) ) * 100;
! summary[ "Information" ] = "Buy & hold % return";
! summary[ "Value" ] = this.buyAndHoldPercentageReturn;
! }
! }
! private void getSummaryTable_setRow_AnnualSystemPercentageReturn( DataRow summary )
! {
! double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
! summary[ "Information" ] = "Annual system % return";
! summary[ "Value" ] = ( ( Math.Pow( 1 + totalROA ,
! 1.0 / ( (double)this.intervalDays/365.0 ) ) ) - 1 ) * 100;
! // r = [(1+T)^(1/n)]-1
! }
! private void getSummaryTable_setRow_TotalNumberOfTrades( DataRow summary )
! {
! double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
! summary[ "Information" ] = "Total # of trades";
! DataRow[] DataRows = this.roundTrades.DataTable.Select( "(ExitPrice is not null)" );
! summary[ "Value" ] = DataRows.Length;
! }
! private void getSummaryTable_setRow_NumberWinningTrades( DataRow summary )
! {
! summary[ "Information" ] = "Number winning trades";
! DataRow[] DataRows = this.roundTrades.DataTable.Select( "([%Profit] > 0)" );
! summary[ "Value" ] = DataRows.Length;
! }
! private void getSummaryTable_setRow_AverageTradePercentageReturn( DataRow summary )
! {
! summary[ "Information" ] = "Average trade % Return";
! double avgReturn = (double) this.roundTrades.DataTable.Compute( "avg([%Profit])" , "true" );
! summary[ "Value" ] = avgReturn;
! }
! private void getSummaryTable_setRow_LargestWinningTradePercentage( DataRow summary )
! {
! summary[ "Information" ] = "Largest winning trade";
! summary[ "Value" ] =
! (double) this.roundTrades.DataTable.Compute( "max([%Profit])" , "([%Profit]>0)" );
! }
! private void getSummaryTable_setRow_LargestLosingTradePercentage( DataRow summary )
! {
! summary[ "Information" ] = "Largest losing trade";
! summary[ "Value" ] =
! (double) this.roundTrades.DataTable.Compute( "min([%Profit])" , "([%Profit]<0)" );
! }
! private void getSummaryTable_setRow_TotalNumberOfLongTrades( DataRow summary )
! {
! double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
! summary[ "Information" ] = "Total # of long trades";
! DataRow[] DataRows =
! this.roundTrades.DataTable.Select( "((Trade='Long')and(ExitPrice is not null))" );
! summary[ "Value" ] = DataRows.Length;
! }
! private void getSummaryTable_setRow_NumberWinningLongTrades( DataRow summary )
! {
! summary[ "Information" ] = "Number winning long trades";
! DataRow[] DataRows = this.roundTrades.DataTable.Select( "((Trade='Long')and([%Profit] > 0))" );
! summary[ "Value" ] = DataRows.Length;
! }
! private void getSummaryTable_setRow_AverageLongTradePercentageReturn( DataRow summary )
! {
! summary[ "Information" ] = "Average long trade % Return";
! double avgReturn =
! (double) this.roundTrades.DataTable.Compute( "avg([%Profit])" , "(Trade='Long')" );
! summary[ "Value" ] = avgReturn;
! }
! private void getSummaryTable_setRow_TotalNumberOfShortTrades( DataRow summary )
! {
! double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
! summary[ "Information" ] = "Total # of short trades";
! DataRow[] DataRows =
! this.roundTrades.DataTable.Select( "((Trade='Short')and(ExitPrice is not null))" );
! summary[ "Value" ] = DataRows.Length;
! }
! private void getSummaryTable_setRow_NumberWinningShortTrades( DataRow summary )
! {
! summary[ "Information" ] = "Number winning short trades";
! DataRow[] DataRows = this.roundTrades.DataTable.Select( "((Trade='Short')and([%Profit] > 0))" );
! summary[ "Value" ] = DataRows.Length;
! }
! private void getSummaryTable_setRow_AverageShortTradePercentageReturn( DataRow summary )
! {
! summary[ "Information" ] = "Average short trade % Return";
! double avgReturn =
! (double) this.roundTrades.DataTable.Compute( "avg([%Profit])" , "(Trade='Short')" );
! summary[ "Value" ] = avgReturn;
! }
! private void getSummary_setRow( DataTable summaryDataTable ,
! getSummaryTable_setRow getSummaryTable_setRow_object )
! {
! DataRow summary = summaryDataTable.NewRow();
! getSummaryTable_setRow_object( summary );
! summaryDataTable.Rows.Add( summary );
! }
! private void getSummaryTable_setRows( DataTable summaryDataTable )
! {
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_TotalNetProfit ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_ReturnOnAccount ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_BuyAndHoldPercentageReturn ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_AnnualSystemPercentageReturn ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfTrades ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningTrades ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_AverageTradePercentageReturn ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_LargestWinningTradePercentage ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_LargestLosingTradePercentage ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfLongTrades ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningLongTrades ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_AverageLongTradePercentageReturn ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfShortTrades ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningShortTrades ) );
! getSummary_setRow( summaryDataTable ,
! new getSummaryTable_setRow( getSummaryTable_setRow_AverageShortTradePercentageReturn ) );
! }
! #endregion
! private DataTable getSummaryDataTable()
! {
! DataTable summaryDataTable = new DataTable();
! getSummaryTable_setColumns( summaryDataTable );
! getSummaryTable_setRows( summaryDataTable );
! return summaryDataTable;
! }
! private ReportTable getSummary( string reportName )
! {
! this.totalPnl =
! (double)this.equity.DataTable.Rows[ this.equity.DataTable.Rows.Count - 1 ][ "PnL" ];
! this.finalAccountValue =
! (double)this.equity.DataTable.Rows[ this.equity.DataTable.Rows.Count - 1 ][ "AccountValue" ];
! this.intervalDays =
! ((TimeSpan)((DateTime)this.equity.DataTable.Rows[ this.equity.DataTable.Rows.Count - 1 ][ "Date" ] -
! (DateTime)this.equity.DataTable.Rows[ 0 ][ "Date" ])).Days;
! DataTable summaryDataTable = getSummaryDataTable();
! return new ReportTable( reportName + " - Summary" ,
! summaryDataTable );
! }
!
! #endregion
! public AccountReport Create( string reportName , int numDaysForInterval ,
ExtendedDateTime endDateTime , string buyAndHoldTicker )
{
this.endDateTime = endDateTime;
this.buyAndHoldTicker = buyAndHoldTicker;
! DataTable detailedDataTable = getDetailedDataTable( numDaysForInterval );
! this.transactionTable = getTransactionTable( reportName , detailedDataTable );
! this.roundTrades = getRoundTrades( reportName );
! this.equity = getEquity( reportName , detailedDataTable );
! this.summary = getSummary( reportName );
return this;
}
- #endregion
! public AccountReport Create( string reportName , int numDaysForInterval ,
ExtendedDateTime endDateTime )
{
--- 204,227 ----
}
#endregion
#endregion
! public AccountReport Create( string reportName , long numDaysForInterval ,
ExtendedDateTime endDateTime , string buyAndHoldTicker )
{
+ this.reportName = reportName;
this.endDateTime = endDateTime;
this.buyAndHoldTicker = buyAndHoldTicker;
! detailedDataTable = getDetailedDataTable( numDaysForInterval );
! this.transactionTable = new Tables.Transactions( reportName , detailedDataTable );
! // this.transactionTable = getTransactionTable( reportName , detailedDataTable );
! this.roundTrades = new Tables.RoundTrades( reportName , this.transactionTable );
! this.equity = new Tables.Equity( reportName , detailedDataTable );
! //this.equity = getEquity( reportName , detailedDataTable );
! //this.summary = getSummary( reportName );
! this.summary = new Tables.Summary( this );
return this;
}
! public AccountReport Create( string reportName , long numDaysForInterval ,
ExtendedDateTime endDateTime )
{
|
|
From: <gla...@us...> - 2003-11-08 20:54:58
|
Update of /cvsroot/quantproject/QuantProject/b4_Business
In directory sc8-pr-cvs1:/tmp/cvs-serv12622/b4_Business
Modified Files:
b4_Business.csproj
Log Message:
Added Report.Tables objects: splitted the AccountReport object in one
table object for Transactions, RoundTrades, Equity and Summary.
Index: b4_Business.csproj
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** b4_Business.csproj 13 Oct 2003 21:58:20 -0000 1.1.1.1
--- b4_Business.csproj 8 Nov 2003 20:54:41 -0000 1.2
***************
*** 197,200 ****
--- 197,220 ----
/>
<File
+ RelPath = "a1_Financial\a2_Accounting\h5_Reporting\Tables\Equity.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "a1_Financial\a2_Accounting\h5_Reporting\Tables\RoundTrades.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "a1_Financial\a2_Accounting\h5_Reporting\Tables\Summary.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "a1_Financial\a2_Accounting\h5_Reporting\Tables\Transactions.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "a1_Financial\a3_Ordering\Order.cs"
SubType = "Code"
|
|
From: <gla...@us...> - 2003-11-08 20:54:00
|
Update of /cvsroot/quantproject/QuantProject In directory sc8-pr-cvs1:/tmp/cvs-serv12449 Modified Files: QuantProject.suo Log Message: Added Report.Tables objects: splitted the AccountReport object in one table object for Transactions, RoundTrades, Equity and Summary. Index: QuantProject.suo =================================================================== RCS file: /cvsroot/quantproject/QuantProject/QuantProject.suo,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 Binary files /tmp/cvs9D4qhi and /tmp/cvs47NJcq differ |
|
From: <gla...@us...> - 2003-11-08 20:47:01
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory sc8-pr-cvs1:/tmp/cvs-serv11358/Tables Log Message: Directory /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables added to the repository |
|
From: <gla...@us...> - 2003-11-03 22:28:08
|
Update of /cvsroot/quantproject/QuantProject In directory sc8-pr-cvs1:/tmp/cvs-serv20134 Modified Files: QuantProject.suo Log Message: no message Index: QuantProject.suo =================================================================== RCS file: /cvsroot/quantproject/QuantProject/QuantProject.suo,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 Binary files /tmp/cvsoE4ik6 and /tmp/cvsyYOml2 differ |
|
From: <gla...@us...> - 2003-11-03 22:26:39
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
In directory sc8-pr-cvs1:/tmp/cvs-serv19812/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
Modified Files:
AccountReport.cs
Log Message:
Summary report has been enhanced:
- 'Larges winning trade' added
- 'Largest losing trade' added
- 'Total number of long trades' added
- 'Number winning long trades' added
- 'Average long trade % return' added
- 'Total number of short trades' added
- 'Number winning short trades' added
- 'Average short trade % return' added
Index: AccountReport.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** AccountReport.cs 2 Nov 2003 18:26:04 -0000 1.4
--- AccountReport.cs 3 Nov 2003 22:26:35 -0000 1.5
***************
*** 421,424 ****
--- 421,478 ----
summary[ "Value" ] = avgReturn;
}
+ private void getSummaryTable_setRow_LargestWinningTradePercentage( DataRow summary )
+ {
+ summary[ "Information" ] = "Largest winning trade";
+ summary[ "Value" ] =
+ (double) this.roundTrades.DataTable.Compute( "max([%Profit])" , "([%Profit]>0)" );
+ }
+ private void getSummaryTable_setRow_LargestLosingTradePercentage( DataRow summary )
+ {
+ summary[ "Information" ] = "Largest losing trade";
+ summary[ "Value" ] =
+ (double) this.roundTrades.DataTable.Compute( "min([%Profit])" , "([%Profit]<0)" );
+ }
+ private void getSummaryTable_setRow_TotalNumberOfLongTrades( DataRow summary )
+ {
+ double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
+ summary[ "Information" ] = "Total # of long trades";
+ DataRow[] DataRows =
+ this.roundTrades.DataTable.Select( "((Trade='Long')and(ExitPrice is not null))" );
+ summary[ "Value" ] = DataRows.Length;
+ }
+ private void getSummaryTable_setRow_NumberWinningLongTrades( DataRow summary )
+ {
+ summary[ "Information" ] = "Number winning long trades";
+ DataRow[] DataRows = this.roundTrades.DataTable.Select( "((Trade='Long')and([%Profit] > 0))" );
+ summary[ "Value" ] = DataRows.Length;
+ }
+ private void getSummaryTable_setRow_AverageLongTradePercentageReturn( DataRow summary )
+ {
+ summary[ "Information" ] = "Average long trade % Return";
+ double avgReturn =
+ (double) this.roundTrades.DataTable.Compute( "avg([%Profit])" , "(Trade='Long')" );
+ summary[ "Value" ] = avgReturn;
+ }
+ private void getSummaryTable_setRow_TotalNumberOfShortTrades( DataRow summary )
+ {
+ double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
+ summary[ "Information" ] = "Total # of short trades";
+ DataRow[] DataRows =
+ this.roundTrades.DataTable.Select( "((Trade='Short')and(ExitPrice is not null))" );
+ summary[ "Value" ] = DataRows.Length;
+ }
+ private void getSummaryTable_setRow_NumberWinningShortTrades( DataRow summary )
+ {
+ summary[ "Information" ] = "Number winning short trades";
+ DataRow[] DataRows = this.roundTrades.DataTable.Select( "((Trade='Short')and([%Profit] > 0))" );
+ summary[ "Value" ] = DataRows.Length;
+ }
+ private void getSummaryTable_setRow_AverageShortTradePercentageReturn( DataRow summary )
+ {
+ summary[ "Information" ] = "Average short trade % Return";
+ double avgReturn =
+ (double) this.roundTrades.DataTable.Compute( "avg([%Profit])" , "(Trade='Short')" );
+ summary[ "Value" ] = avgReturn;
+ }
private void getSummary_setRow( DataTable summaryDataTable ,
getSummaryTable_setRow getSummaryTable_setRow_object )
***************
*** 444,447 ****
--- 498,517 ----
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AverageTradePercentageReturn ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_LargestWinningTradePercentage ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_LargestLosingTradePercentage ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfLongTrades ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningLongTrades ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_AverageLongTradePercentageReturn ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfShortTrades ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningShortTrades ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_AverageShortTradePercentageReturn ) );
}
#endregion
|
|
From: <gla...@us...> - 2003-11-02 18:30:39
|
Update of /cvsroot/quantproject/QuantProject In directory sc8-pr-cvs1:/tmp/cvs-serv26250 Modified Files: QuantProject.suo Log Message: no message Index: QuantProject.suo =================================================================== RCS file: /cvsroot/quantproject/QuantProject/QuantProject.suo,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Binary files /tmp/cvs4lHwsk and /tmp/cvsUDcKzu differ |
|
From: <gla...@us...> - 2003-11-02 18:29:50
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting
In directory sc8-pr-cvs1:/tmp/cvs-serv26065/b4_Business/a1_Financial/a2_Accounting
Modified Files:
Account.cs
Log Message:
The CreateReport method has been overridden to (optionally) add
the Buy and Hold percentage return benchmark to the report
summary table
Index: Account.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/Account.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Account.cs 13 Oct 2003 21:58:29 -0000 1.1.1.1
--- Account.cs 2 Nov 2003 18:29:47 -0000 1.2
***************
*** 176,179 ****
--- 176,186 ----
return accountReport.Create( reportName , numDaysForInterval , extendedDateTime );
}
+ public AccountReport CreateReport( string reportName ,
+ int numDaysForInterval , ExtendedDateTime extendedDateTime , string buyAndHoldTicker )
+ {
+ AccountReport accountReport = new AccountReport( this );
+ return accountReport.Create( reportName , numDaysForInterval ,
+ extendedDateTime , buyAndHoldTicker );
+ }
public void Serialize( string filePathAndName )
{
|
|
From: <gla...@us...> - 2003-11-02 18:26:07
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
In directory sc8-pr-cvs1:/tmp/cvs-serv24939/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
Modified Files:
AccountReport.cs
Log Message:
- Fixed %return in round trade table: as a consequence, the average
profit per trade now is fixed
- Added Buy and Hold percentage return to the report summary table
(this is an optional information, got by overriding
the create method)
Index: AccountReport.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AccountReport.cs 30 Oct 2003 22:06:51 -0000 1.3
--- AccountReport.cs 2 Nov 2003 18:26:04 -0000 1.4
***************
*** 29,33 ****
using QuantProject.ADT;
using QuantProject.ADT.Histories;
!
namespace QuantProject.Business.Financial.Accounting.Reporting
{
--- 29,33 ----
using QuantProject.ADT;
using QuantProject.ADT.Histories;
! using QuantProject.Business.Financial.Instruments;
namespace QuantProject.Business.Financial.Accounting.Reporting
{
***************
*** 39,44 ****
--- 39,47 ----
private Account account;
private Account accountCopy = new Account( "AccountCopy" );
+ private ExtendedDateTime endDateTime;
+ private string buyAndHoldTicker;
private double totalPnl;
private double finalAccountValue;
+ private double buyAndHoldPercentageReturn;
private long intervalDays;
private ReportTable transactionTable;
***************
*** 63,66 ****
--- 66,76 ----
get { return summary; }
}
+ public DateTime StartDateTime
+ {
+ get
+ {
+ return (DateTime) account.Transactions.GetKey( 0 );
+ }
+ }
/// <summary>
***************
*** 145,155 ****
addRowForPnl_actually( currentDate , detailedDataTable );
}
! private void setRows( int numDaysForInterval ,
! ExtendedDateTime endDateTime, System.Data.DataTable detailedDataTable )
{
DateTime currentDate = (DateTime) account.Transactions.GetKey( 0 );
try
{
! while ( currentDate < endDateTime.DateTime )
{
//addTransactionsToAccountCopy( currentDate );
--- 155,164 ----
addRowForPnl_actually( currentDate , detailedDataTable );
}
! private void setRows( int numDaysForInterval , System.Data.DataTable detailedDataTable )
{
DateTime currentDate = (DateTime) account.Transactions.GetKey( 0 );
try
{
! while ( currentDate < this.endDateTime.DateTime )
{
//addTransactionsToAccountCopy( currentDate );
***************
*** 168,177 ****
}
#endregion
! private System.Data.DataTable getDetailedDataTable( int numDaysForInterval ,
! ExtendedDateTime endDateTime )
{
System.Data.DataTable detailedDataTable = new System.Data.DataTable();
setColumns( detailedDataTable );
! setRows( numDaysForInterval , endDateTime , detailedDataTable );
return detailedDataTable;
}
--- 177,185 ----
}
#endregion
! private System.Data.DataTable getDetailedDataTable( int numDaysForInterval )
{
System.Data.DataTable detailedDataTable = new System.Data.DataTable();
setColumns( detailedDataTable );
! setRows( numDaysForInterval , detailedDataTable );
return detailedDataTable;
}
***************
*** 282,286 ****
roundTrade[ "ExitPrice" ] = dataRow[ "Price" ];
roundTrade[ "%chg" ] =
! ((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/100;
roundTrade[ "%Profit" ] = - ((double)roundTrade[ "%chg" ]);
roundTrade[ "#bars" ] =
--- 290,295 ----
roundTrade[ "ExitPrice" ] = dataRow[ "Price" ];
roundTrade[ "%chg" ] =
! ((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/
! ((double)roundTrade[ "EntryPrice" ])*100;
roundTrade[ "%Profit" ] = - ((double)roundTrade[ "%chg" ]);
roundTrade[ "#bars" ] =
***************
*** 303,307 ****
return roundTradeDataTable;
}
! public ReportTable getRoundTrades( string reportName )
{
DataTable roundTradeDataTable = getRoundTradeDataTable();
--- 312,316 ----
return roundTradeDataTable;
}
! private ReportTable getRoundTrades( string reportName )
{
DataTable roundTradeDataTable = getRoundTradeDataTable();
***************
*** 343,347 ****
return equityDataTable;
}
! public ReportTable getEquity( string reportName , DataTable detailedDataTable )
{
DataTable equityDataTable = getEquityDataTable( detailedDataTable );
--- 352,356 ----
return equityDataTable;
}
! private ReportTable getEquity( string reportName , DataTable detailedDataTable )
{
DataTable equityDataTable = getEquityDataTable( detailedDataTable );
***************
*** 369,372 ****
--- 378,397 ----
summary[ "Value" ] = this.totalPnl / ( this.finalAccountValue - this.totalPnl ) * 100;
}
+ private void getSummaryTable_setRow_BuyAndHoldPercentageReturn( DataRow summary )
+ {
+ if ( this.buyAndHoldTicker != "" )
+ {
+ // the report has to compare to a buy and hold benchmark
+ Instrument buyAndHoldInstrument = new Instrument( this.buyAndHoldTicker );
+ this.buyAndHoldPercentageReturn =
+ ( buyAndHoldInstrument.GetMarketValue( this.endDateTime ) -
+ buyAndHoldInstrument.GetMarketValue(
+ new ExtendedDateTime( this.StartDateTime , BarComponent.Open ) ) ) /
+ buyAndHoldInstrument.GetMarketValue(
+ new ExtendedDateTime( this.StartDateTime , BarComponent.Open ) ) * 100;
+ summary[ "Information" ] = "Buy & hold % return";
+ summary[ "Value" ] = this.buyAndHoldPercentageReturn;
+ }
+ }
private void getSummaryTable_setRow_AnnualSystemPercentageReturn( DataRow summary )
{
***************
*** 386,394 ****
private void getSummaryTable_setRow_NumberWinningTrades( DataRow summary )
{
- double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
summary[ "Information" ] = "Number winning trades";
DataRow[] DataRows = this.roundTrades.DataTable.Select( "([%Profit] > 0)" );
summary[ "Value" ] = DataRows.Length;
}
private void getSummary_setRow( DataTable summaryDataTable ,
getSummaryTable_setRow getSummaryTable_setRow_object )
--- 411,424 ----
private void getSummaryTable_setRow_NumberWinningTrades( DataRow summary )
{
summary[ "Information" ] = "Number winning trades";
DataRow[] DataRows = this.roundTrades.DataTable.Select( "([%Profit] > 0)" );
summary[ "Value" ] = DataRows.Length;
}
+ private void getSummaryTable_setRow_AverageTradePercentageReturn( DataRow summary )
+ {
+ summary[ "Information" ] = "Average trade % Return";
+ double avgReturn = (double) this.roundTrades.DataTable.Compute( "avg([%Profit])" , "true" );
+ summary[ "Value" ] = avgReturn;
+ }
private void getSummary_setRow( DataTable summaryDataTable ,
getSummaryTable_setRow getSummaryTable_setRow_object )
***************
*** 405,408 ****
--- 435,440 ----
new getSummaryTable_setRow( getSummaryTable_setRow_ReturnOnAccount ) );
getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_BuyAndHoldPercentageReturn ) );
+ getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AnnualSystemPercentageReturn ) );
getSummary_setRow( summaryDataTable ,
***************
*** 410,413 ****
--- 442,447 ----
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningTrades ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_AverageTradePercentageReturn ) );
}
#endregion
***************
*** 419,423 ****
return summaryDataTable;
}
! public ReportTable getSummary( string reportName )
{
this.totalPnl =
--- 453,457 ----
return summaryDataTable;
}
! private ReportTable getSummary( string reportName )
{
this.totalPnl =
***************
*** 435,441 ****
#endregion
public AccountReport Create( string reportName , int numDaysForInterval ,
! ExtendedDateTime endDateTime )
{
! DataTable detailedDataTable = getDetailedDataTable( numDaysForInterval , endDateTime );
this.transactionTable = getTransactionTable( reportName , detailedDataTable );
this.roundTrades = getRoundTrades( reportName );
--- 469,477 ----
#endregion
public AccountReport Create( string reportName , int numDaysForInterval ,
! ExtendedDateTime endDateTime , string buyAndHoldTicker )
{
! this.endDateTime = endDateTime;
! this.buyAndHoldTicker = buyAndHoldTicker;
! DataTable detailedDataTable = getDetailedDataTable( numDaysForInterval );
this.transactionTable = getTransactionTable( reportName , detailedDataTable );
this.roundTrades = getRoundTrades( reportName );
***************
*** 446,450 ****
#endregion
!
}
}
--- 482,490 ----
#endregion
! public AccountReport Create( string reportName , int numDaysForInterval ,
! ExtendedDateTime endDateTime )
! {
! return Create( reportName , numDaysForInterval , endDateTime , "" );
! }
}
}
|
|
From: <gla...@us...> - 2003-11-02 18:18:50
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/MSFTsimpleTest
In directory sc8-pr-cvs1:/tmp/cvs-serv23448/b7_Scripts/MSFTsimpleTest
Modified Files:
RunMSFTsimpleTest.cs
Log Message:
Changed report creation call, to add Buy and Hold benchmark
Index: RunMSFTsimpleTest.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/MSFTsimpleTest/RunMSFTsimpleTest.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** RunMSFTsimpleTest.cs 13 Oct 2003 22:00:07 -0000 1.1.1.1
--- RunMSFTsimpleTest.cs 2 Nov 2003 18:18:47 -0000 1.2
***************
*** 83,87 ****
AccountReport accountReport = tester.Account.CreateReport( "MSFT" , 7 ,
! new ExtendedDateTime( endDateTime , BarComponent.Close ) );
ExcelManager.Add( accountReport );
ExcelManager.ShowReport();
--- 83,87 ----
AccountReport accountReport = tester.Account.CreateReport( "MSFT" , 7 ,
! new ExtendedDateTime( endDateTime , BarComponent.Close ) , "MSFT" );
ExcelManager.Add( accountReport );
ExcelManager.ShowReport();
|
|
From: <gla...@us...> - 2003-10-30 22:06:56
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
In directory sc8-pr-cvs1:/tmp/cvs-serv932/b4_Business/a1_Financial/a2_Accounting/h5_Reporting
Modified Files:
AccountReport.cs
Log Message:
Improved Summary report:
- Added %Profit calculation.
- Annual system return now is normalized to 100%
- Added total number of trades statistics
- Added number of winning trades statistics
Some variable names have been fixed
Index: AccountReport.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AccountReport.cs 25 Oct 2003 16:48:58 -0000 1.2
--- AccountReport.cs 30 Oct 2003 22:06:51 -0000 1.3
***************
*** 265,268 ****
--- 265,269 ----
((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/
((double)roundTrade[ "EntryPrice" ])*100;
+ roundTrade[ "%Profit" ] = roundTrade[ "%chg" ];
roundTrade[ "#bars" ] =
((TimeSpan)((DateTime)roundTrade[ "ExitDate" ] - (DateTime)roundTrade[ "EntryDate" ])).Days;
***************
*** 282,285 ****
--- 283,287 ----
roundTrade[ "%chg" ] =
((double)roundTrade[ "ExitPrice" ] - (double)roundTrade[ "EntryPrice" ])/100;
+ roundTrade[ "%Profit" ] = - ((double)roundTrade[ "%chg" ]);
roundTrade[ "#bars" ] =
((TimeSpan)((DateTime)roundTrade[ "ExitDate" ] - (DateTime)roundTrade[ "EntryDate" ])).Days;
***************
*** 371,377 ****
double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
summary[ "Information" ] = "Annual system % return";
! summary[ "Value" ] = ( Math.Pow( 1 + totalROA ,
! 1.0 / ( (double)this.intervalDays/365.0 ) ) ) - 1;
! // r = [(1+T)^(1/n)]-1
}
private void getSummary_setRow( DataTable summaryDataTable ,
--- 373,393 ----
double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
summary[ "Information" ] = "Annual system % return";
! summary[ "Value" ] = ( ( Math.Pow( 1 + totalROA ,
! 1.0 / ( (double)this.intervalDays/365.0 ) ) ) - 1 ) * 100;
! // r = [(1+T)^(1/n)]-1
! }
! private void getSummaryTable_setRow_TotalNumberOfTrades( DataRow summary )
! {
! double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
! summary[ "Information" ] = "Total # of trades";
! DataRow[] DataRows = this.roundTrades.DataTable.Select( "(ExitPrice is not null)" );
! summary[ "Value" ] = DataRows.Length;
! }
! private void getSummaryTable_setRow_NumberWinningTrades( DataRow summary )
! {
! double totalROA = this.totalPnl / ( this.finalAccountValue - this.totalPnl );
! summary[ "Information" ] = "Number winning trades";
! DataRow[] DataRows = this.roundTrades.DataTable.Select( "([%Profit] > 0)" );
! summary[ "Value" ] = DataRows.Length;
}
private void getSummary_setRow( DataTable summaryDataTable ,
***************
*** 390,393 ****
--- 406,413 ----
getSummary_setRow( summaryDataTable ,
new getSummaryTable_setRow( getSummaryTable_setRow_AnnualSystemPercentageReturn ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_TotalNumberOfTrades ) );
+ getSummary_setRow( summaryDataTable ,
+ new getSummaryTable_setRow( getSummaryTable_setRow_NumberWinningTrades ) );
}
#endregion
***************
*** 408,414 ****
((TimeSpan)((DateTime)this.equity.DataTable.Rows[ this.equity.DataTable.Rows.Count - 1 ][ "Date" ] -
(DateTime)this.equity.DataTable.Rows[ 0 ][ "Date" ])).Days;
! DataTable equityDataTable = getSummaryDataTable();
return new ReportTable( reportName + " - Summary" ,
! equityDataTable );
}
--- 428,434 ----
((TimeSpan)((DateTime)this.equity.DataTable.Rows[ this.equity.DataTable.Rows.Count - 1 ][ "Date" ] -
(DateTime)this.equity.DataTable.Rows[ 0 ][ "Date" ])).Days;
! DataTable summaryDataTable = getSummaryDataTable();
return new ReportTable( reportName + " - Summary" ,
! summaryDataTable );
}
|
|
From: <gla...@us...> - 2003-10-30 22:06:56
|
Update of /cvsroot/quantproject/QuantProject In directory sc8-pr-cvs1:/tmp/cvs-serv932 Modified Files: QuantProject.suo Log Message: Improved Summary report: - Added %Profit calculation. - Annual system return now is normalized to 100% - Added total number of trades statistics - Added number of winning trades statistics Some variable names have been fixed Index: QuantProject.suo =================================================================== RCS file: /cvsroot/quantproject/QuantProject/QuantProject.suo,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvs74SZub and /tmp/cvs8rrJWe differ |
|
From: <gla...@us...> - 2003-10-27 19:13:44
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv28621/b7_Scripts
Modified Files:
b7_Scripts.csproj
Log Message:
Fixed ResultOk.txt warning
Index: b7_Scripts.csproj
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/b7_Scripts.csproj,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** b7_Scripts.csproj 25 Oct 2003 16:54:21 -0000 1.3
--- b7_Scripts.csproj 27 Oct 2003 19:12:24 -0000 1.4
***************
*** 118,125 ****
/>
<File
- RelPath = "MSFTsimpleTest\ResultOk.txt"
- BuildAction = "Content"
- />
- <File
RelPath = "MSFTsimpleTest\RunMSFTsimpleTest.cs"
SubType = "Code"
--- 118,121 ----
|