Anyone how to calculate rate of return in the following case?

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#11
(06-07-2014, 10:50 PM)tanjm Wrote:
(06-07-2014, 06:38 PM)AlphaQuant Wrote: The main problem with implementing this in code is perhaps the curse of dimensionality - if you have a lot of cashflows and is not using goalseek/solver, then you need to have to solve the IRR in the implicit equation using numerical analysis - not that difficult but quite a pain.

You are really having only a one dimensional problem (or to put it in another way - with a single degree of freedom) but with multiple inputs. You can do it very simply without resorting to a more difficult algo (like simulated annealing, newton-raphson, hill-climbing etc).

Supposing you have a function FV(x) in which all your cashflows forward valued to today using a common rate of return x, and you simply want to find a x such that FV(x) - Value of Portfolio = 0.

The simplest approach is given an initial guess of x, you perturb it up and perturb it down. You get

FV(x+perturbation) and FV(x-perturbation). Pick the pertubation that minimizes the difference between FV and the value of portfolio. Repeat until your difference changes sign, then you can then bracket the value of r and refine your search (by changing the perturbation value and repeating). Or even simpler, just choose a perturbation value that is to your desired accuracy (e.g. 0.1%) - then it boils down to a straightforward linear search.

And obviously your x, once found, can be saved as the initial guess, the next time you want to recalculate the return.

This is the same algo used for the XIRR in excel, IIRC.
“夏则资皮,冬则资纱,旱则资船,水则资车” - 范蠡
Reply
#12
If the economy stalls or enter into deflationary mode, time value of money will no longer be an important aspect.
Using Tapatalk
Reply
#13
It happened in 1929 in the US? That's why They say without QE & QE & QE 1929 will happen again?
WB:-

1) Rule # 1, do not lose money.
2) Rule # 2, refer to # 1.
3) Not until you can manage your emotions, you can manage your money.

Truism of Investments.
A) Buying a security is buying RISK not Return
B) You can control RISK (to a certain level, hopefully only.) But definitely not the outcome of the Return.

NB:-
My signature is meant for psychoing myself. No offence to anyone. i am trying not to lose money unnecessary anymore.
Reply
#14
(07-07-2014, 08:58 AM)CityFarmer Wrote: This is the same algo used for the XIRR in excel, IIRC.

Now that you've pointed it out, I see it on googling.

Yep, this method should work for IRR type root finding because there is only one variable to root find and the forward valuation is a simple, monotonically moving polynomial.

For unit testing purposes then, replicating goal seek on an excel should be the right approach, if you are replicating the linear search in code.

I suspect by now we are wildly out of topic for this forum.

Btw, IRR has nothing to do with time value of money. It is the constant return needed to replicate the portfolio total return and does not depend on anything external such as a deposit rate or discounting.
Reply
#15
Essentially, it is a single dimension optimization problem. Using a while loop with a goal of 10cts? will suffice. The only crux here is how many entries do you want to give to your user.

http://www.mathsisfun.com/money/internal...eturn.html

As the no. of entries increases, the computation will take more time.
Reply
#16
(07-07-2014, 01:34 PM)yeokiwi Wrote: Essentially, it is a single dimension optimization problem. Using a while loop with a goal of 10cts? will suffice. The only crux here is how many entries do you want to give to your user.

http://www.mathsisfun.com/money/internal...eturn.html

As the no. of entries increases, the computation will take more time.

The link you quoted is flawed in my opinion because it seems to imply it has something to do with time value of money, which it doesn't. The math is similar but not the conclusion. Time value of money is essentially about "what would someone give you now in return for getting a pile of money in the future". In a no arbitrage situation, it always boils down to what rate that someone can borrow money on. The math operations are similar but have a different meaning to the "rate" used.
Reply
#17
I fear I am starting to get too pedantic and I will stop.
Reply
#18
(07-07-2014, 04:14 PM)tanjm Wrote: The link you quoted is flawed in my opinion because it seems to imply it has something to do with time value of money, which it doesn't. The math is similar but not the conclusion. Time value of money is essentially about "what would someone give you now in return for getting a pile of money in the future". In a no arbitrage situation, it always boils down to what rate that someone can borrow money on. The math operations are similar but have a different meaning to the "rate" used.

Agree with you.Smile But it is meant for developer...I suppose he will know how to code after looking at the example.
Reply
#19
Hi AlphaQuant,

Thanks. I think I need some time to digest the idea behind XIRR. http://www.mathsisfun.com/money/internal...eturn.html

I have another idea come across my mind. Since there are 2 different individual transactions on the same stock. Each transactions yields different return. Does it make sense, if I calculate using

http://en.wikipedia.org/wiki/Rate_of_ret...le_periods

Transaction on 1st January
$2 * 1000 units = $1000 (1 + r0)
r0 = 1

Transaction on 1st March
$2 * 1000 units = $1000 (1 + r1)^(10/12)
r1 = 1.2974

r = (r0 + r1) / 2 = 1.1487

Of course, the final result isn't tally with XIRR's. But, is it something which makes sense to end users?
Reply
#20
(07-07-2014, 11:53 PM)yccheok Wrote: r = (r0 + r1) / 2 = 1.1487

Of course, the final result isn't tally with XIRR's. But, is it something which makes sense to end users?

I don't think your arithmetic mean method is meaningful. It might be useful where

exp (r1) exp (r2)...exp(rn) = exp( r1+r2+...rn) = exp (n* r')
so r' = 1/n * (r1+...rn)

so the individual returns are in sequence and not what your case is.

Ultimately i think you just need to spend sometime to think thru the concept.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)