Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently, I'm implementing a feature of an open source project (https://github.com/yccheok/jstock/issues/7), which requires me to calculate the rate of return of a stock.

Let's take the following scenario.

User purchased 1000 units stock with unit price 1 dollar at 1st January 2013. He didn't perform any sell transaction & buy transaction in between. At 31st December 2013, the stock price reached 2 dollar.

The rate of return of the stock for year 2013 is 100%

(Value of investment at 31st December 2013 - Cost of investment at 1st January 2013) / (Cost of investment at 1st January 2013) * 100%

(1000 * $2 - 1000 * $1) / (1000 * $1) * 100% = 100%

But, what if the user had purchased another 1000 units of same stock with unit price 1 dollar at 1st March 2013. What should be the rate of return of the stock for year 2013?

share|improve this question
up vote 1 down vote accepted

That is what XIRR does or can you read this answer.

Basically it tries to find an interest rate that works out to the same numbers.

I think Excel and Google Docs use the Newton approximation


There's also a java implementation available on github called jxirr.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.