# AcctReturns: Calculate account returns In blotter: Tools for Transaction-Oriented Trading Systems Development

## Description

Similar to the PortfReturns function, but gives returns for the entire account and takes into account external cashflows. External cashflows are defined as contributions to or withdrawals from the account. Allows selecting between time-weighted returns and linked modified Dietz approach. If time-weighted method is selected, returns at time t are computed using:

r_{t}=\frac{V_{t}}{V_{t-1}+C_{t}}-1

where V_{t} - account value at time t, C_{t} - cashflow at time t. The implicit assumption made here is that the cash flow is available for the portfolio manager to invest from the beginning of the day. These returns then can be chain linked with geometric compounding (for instance using Return.cumulative function from the PerformanceAnalytics package) to yield cumulative multi-period returns:

1+r=∏_{t=1}^{T}(1+r_{t})=∏_{t=1}^{T}\frac{V_{t}}{V_{t-1}+C_{t}}

In the case if there were no cashflows, the result reduces to simple one-period returns. Time-weighted returns has also an interpretation in terms of unit value pricing. If Modified Dietz method is selected, monthly returns are computed taking into account cashflows within each month:

r = \frac{V_{t}-V_{t-1}-C}{V_{t-1}+∑_{t}C_{t}\times W_{t}}

where C - total external cash flows within a month, C_{t} - external cashflow at time t,

W_{t}=\frac{TD-D_{t}}{TD}

- weighting ratio to be applied to external cashflow on day t, TD - total number of days within the month, D_{t} - number of days since the beginning of the month including weekends and public holidays. Finally monthly Modified Dietz returns can also be linked geometrically.

## Usage

 1 2 AcctReturns(Account, Dates = NULL, Portfolios = NULL, method = c("timeweighted", "dietz"), ...) 

## Arguments

 Account string name of the account to generate returns for Dates xts style ISO 8601 date subset to retrieve, default NULL (all dates) Portfolios concatenated string vector for portfolio names to retrieve returns on, default NULL (all portfolios) method Used to select between time-weighted and linked modified Dietz returns. May be any of: timeweighted dietz By default time-weighted is selected ... any other passthru parameters (like native for .getBySymbol

## Value

returns xts with account returns

## Note

TODO handle portfolio and account in different currencies (not hard, just not done)

TODO explicitly handle portfolio weights

TODO support additions and withdrawals to available capital

## Author(s)

Brian Peterson, Andrii Babii

## References

Christopherson, Jon A., Carino, David R., Ferson, Wayne E. Portfolio Performance Measurement and Benchmarking. McGraw-Hill. 2009. Chapter 5
Bacon, C. Practical Portfolio Performance Measurement and Attribution. Wiley. 2004. Chapter 2