finmath / finmath-lib

Mathematical Finance Library: Algorithms and methodologies related to mathematical finance.
Apache License 2.0
488 stars 168 forks source link

Changes to Deposit #18

Closed BBreiden closed 7 years ago

BBreiden commented 7 years ago

Hi Christian,

while playing with the Deposit class I stumbled across several things, which I find suspicious. I wrote a test class to demonstrate, what kind of behaviour I would expect. It contains three tests - all of which fail with the current implementation.

I amended the Deposit class to fit my expectation and pass the tests. (I also changed some things in the documentation).

Let me know, what you think of it and if I am maybe mistaken!

BR Boris

The three issues are:

1) In the current implementation a deposit set up with the current market rate (as calculated by getRate) does not have getValue=0. This is because the rate calculation was slightly flawed (line 92).

2) The value of a deposit should be the present value of the payout cashflow (which I would expect to be at start date) and the payback cashflow at maturity. This was not the case.

3) The getValue function did not take into account the argument evaluationTime. The implementation provided in this change, asserts that the value after maturity is zero and neglects the payout cashflow once it is in the past.

These three things are checked by the DepositTest class.

cfries commented 7 years ago

I see the change. I am fine with it, but there should be a guideline that Deposit is only used for discount curves (OIS or Funding Curve) and never used to specify the fixing of a forward curve (e.g. 3M LIBOR). This should be done by a FRA using time 0 as fixing or by special "Fixing" product. Previously deposit was used in spreadsheet to set the fixing of a forward curve - but in my opinion this in unsafe and not consistent with a true multi-curve setup. I will check back with Niklas since the change originated from his fork.

BBreiden commented 7 years ago

A small modification to this pull request, as I realized that the check for matured deposits was not consistent.

cfries commented 7 years ago

Thank you.