# How to calculate the APY of an investment account?

I find it helpful to view every kind of account in terms of its current value and APY rate. I know it doesn't technically make sense for an investment account that holds unpredictable stocks and thus the "APY" would be unstable. But I would still find it helpful to have a number that indicates how well the totality of my stock holdings and cash have been doing in relation to simpler accounts.

I can calculate a simple interest as long as the principal is obvious. e.g. I invest 10k into a new account January 1st. After dividends and reinvestments and trades I end up with a total account value of 12k on December 31st. The APY rate is then `r=(1/t)(A/P-1)=(1/1)(12/10-1)=0.2=20%`.

But I'm not sure what to do when more principal amounts are added to the account at different dates. In the above example, if I added \$500 of principal in March, how do I get an answer that still makes sense? What additional information if any do I need to make the calculation?

In reality I am creating a script to help calculate, so it is fine if the equation needs to sum a lot of historical data. I could potentially find all these variables:

• List of dates and amounts of principal added to the account
• The current total value of the account
• List every transaction with date, the status of all cash and stock holdings at any given time
• Potentially the total account value at any given time if I look up historical quotes
• Have a look at the calculations here. Between valuations the return is calculated by money-weighted return (internal rate of return). If you have valuations you can calculate the time-weighted return (which is more accurate). May 31, 2023 at 9:58

## 1 Answer

If you want to calculate the effective yield of a portfolio, two common methods are Time-Weighted Return and Money-Weighted Return.

Money-Weighted Return is essentially the IRR of the portfolio, which can easily be computed in Excel (or scripted in most computer languages) if you have the beginning balance, cash inflows and outflows (and dates), and the ending balance. It basically answers the question "At what constant interest rate could I borrow/invest the initial balance, inflows, and outflows, and get the same result in the end." So the timing of inflows and outflows can affect the result, which means that it is more appropriate if you make active investment decisions and want to evaluate the performance of those decisions.

Time-Weighted Return answers a similar question, but is more of an "average" return over various time periods (accounting for inflows and outflows). IT can also be done easily in Excel, but you need the total account balance before and after each inflow/outflow (but not the dates, ironically). It is more appropriate if you're periodically adding funds but investing in roughly the same things. So it's more appropriate to evaluate what you're invested in, rather than when you invest, or when you change investments.