0
$\begingroup$

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?

$\endgroup$

1 Answer 1

1
$\begingroup$

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

http://www.mftransparency.org/calculating-interest-rates-using-newtons-method/

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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