CashFlow times in chap. 7

This forum is to discuss the book "C++ design patterns and derivatives pricing."

CashFlow times in chap. 7

Postby dam » Thu Oct 24, 2013 9:35 am

Dear M.Joshi,

I am confused to ask, but I have to say I am a bit lost in Chap. 7 with all the cash flow times appearing. Could you explain what will be the differences between :
- the returned value of the method MaxNumberOfCashFlows (p. 106 in 2nd ed.)
- the size of the array returned by PossiblCashFlowTimes (p. 107 in 2nd ed.)
- the returned value of the method CashFlows (p. 106, 2nd ed.)
They all seem to return the number of cash flows, and I'm particularly wondering why it was thus important to have a returned value for the method CashFlows, since one could have used MaxNumberOfCashFlows (except for the fact that, while CashFlows actually has the purpose of constructing the Cash Flows array, when you call it in the method DoOnePath p. 111, by having such a return, you don't need a further call to MaxNumberOfCashFlows).

Posts: 1
Joined: Thu Oct 24, 2013 9:18 am

Re: CashFlow times in chap. 7

Postby mj » Fri Oct 25, 2013 3:00 am

Bear in mind that array creation destruction and resizing is slow. The code is designed to minimize these.

the idea is that MaxNumberOfCashFlows tells the calling code what size to set the cash-flow vector to.
This happens once and once only.

PossibleCashFlowTimes -- you could have more than one cash flow occuring at a given time. This actually happens a lot
with interest rate derivatives.

CashFlows returns the actual number of cash-flows that occurred which could be zero, if an option knocks out or finished out the money.

Another point to realize is that the code designed to help the user avoid looping over lots of cash-flows which have zero size.
Site Admin
Posts: 1380
Joined: Fri Jul 27, 2007 7:21 am

Return to C++ design patterns and derivatives pricing

Who is online

Users browsing this forum: No registered users and 2 guests