[Quantproject-developers] QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting Account
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:27:32
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13638/b4_Business/a1_Financial/a2_Accounting/h5_Reporting Modified Files: AccountReport.cs Log Message: an HistoricalAdjustedQuoteProvider is used to compute the portfolio value, if the current DateTime is out of market time Index: AccountReport.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AccountReport.cs 29 Sep 2008 21:13:46 -0000 1.23 --- AccountReport.cs 10 Dec 2008 19:27:19 -0000 1.24 *************** *** 63,66 **** --- 63,68 ---- private Tables.Summary summary; private Tables.StatisticsSummary statisticsSummary; + + private HistoricalMarketValueProvider historicalAdjustedQuoteProvider; public string Name *************** *** 161,164 **** --- 163,168 ---- this.historicalMarketValueProvider = historicalMarketValueProvider; this.dateTimeSelectorForEquityLine = dateTimeSelectorForEquityLine; + + this.historicalAdjustedQuoteProvider = new HistoricalAdjustedQuoteProvider(); } *************** *** 185,194 **** #region setRows private void addBalanceItems ( DateTime dateTime , DataRow dataRow ) { dataRow[ "AccountCash" ] = this.accountCopy.CashAmount; ! dataRow[ "PortfolioValue" ] = this.accountCopy.Portfolio.GetMarketValue( ! dateTime , this.historicalMarketValueProvider ); dataRow[ "AccountValue" ] = (double)dataRow[ "AccountCash" ] + --- 189,217 ---- #region setRows + + #region addBalanceItems + + private double getMarketValue( DateTime dateTime ) + { + double marketValue = double.MinValue; + if ( HistoricalEndOfDayTimer.IsMarketTime( dateTime ) ) + // market is open + marketValue = this.accountCopy.Portfolio.GetMarketValue( + dateTime , this.historicalMarketValueProvider ); + else + // instruments are not exchanged at dateTime + marketValue = this.accountCopy.Portfolio.GetMarketValue( + dateTime , this.historicalAdjustedQuoteProvider ); + return marketValue; + } + private void addBalanceItems ( DateTime dateTime , DataRow dataRow ) { dataRow[ "AccountCash" ] = this.accountCopy.CashAmount; ! dataRow[ "PortfolioValue" ] = this.getMarketValue( dateTime ); ! // this.accountCopy.Portfolio.GetMarketValue( ! // dateTime , this.historicalAdjustedQuoteProvider ); ! // dateTime , this.historicalMarketValueProvider ); dataRow[ "AccountValue" ] = (double)dataRow[ "AccountCash" ] + *************** *** 198,201 **** --- 221,225 ---- this.accountCopy.Transactions.TotalAddedCash; } + #endregion addBalanceItems #region setRows_addRowsForTransactionsBefore_nextDateTimeForEquityLine *************** *** 206,220 **** bool isToBeAdded = false; if ( indexForTheNextTransactionToBeAdded < ! this.account.Transactions.Count ) // not all transactions have been added, yet { DateTime dateTimeForTheNextTransactionToBeAdded = ! (DateTime)this.account.Transactions.GetKey( ! indexForTheNextTransactionToBeAdded ); isToBeAdded = ( dateTimeForTheNextTransactionToBeAdded <= nextDateTimeForEquityLine ); } return isToBeAdded; ! } #region addRowsForTransactionsAtTheGivenDateTime --- 230,244 ---- bool isToBeAdded = false; if ( indexForTheNextTransactionToBeAdded < ! this.account.Transactions.Count ) // not all transactions have been added, yet { DateTime dateTimeForTheNextTransactionToBeAdded = ! (DateTime)this.account.Transactions.GetKey( ! indexForTheNextTransactionToBeAdded ); isToBeAdded = ( dateTimeForTheNextTransactionToBeAdded <= nextDateTimeForEquityLine ); } return isToBeAdded; ! } #region addRowsForTransactionsAtTheGivenDateTime *************** *** 234,238 **** if ( transaction.Commission != null ) dataRow[ "Commission" ] = transaction.Commission.Value; ! addBalanceItems( transaction.DateTime , dataRow ); this.detailedDataTable.Rows.Add( dataRow ); } --- 258,262 ---- if ( transaction.Commission != null ) dataRow[ "Commission" ] = transaction.Commission.Value; ! this.addBalanceItems( transaction.DateTime , dataRow ); this.detailedDataTable.Rows.Add( dataRow ); } |