Message Boards Message Boards

1
|
1046 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Calculate present value of cashflow with irregular intervals

How do I calculate the present value of a cashflow with irregular intervals and amounts. I didn't find anything about this in TimeValue[] documentation. Say, the cashflow is...

cf = {{{2024, 1, 16}, 324.67`}, {{2024, 2, 6}, 634.09`}, {{2024, 11, 20}, 356.27`}, {{2023,12,31}, 0};

What functions would return the present value on 1/1/2023 assuming a 5 percent discount?

POSTED BY: Jay Gourley
2 Replies

I have generated code by AI-Chatsonic in Opera Browser.

I don't know if the code is correct.

 cf = {{{2024, 1, 16}, 324.67`}, {{2024, 2, 6}, 
     634.09`}, {{2024, 11, 20}, 356.27`}, {{2023, 12, 31}, 0}};
 discountRate = 0.05;

 presentValue = 0;
 referenceDate = DateObject[{2023, 1, 1}];
 numEntries = Length[cf];

 For[i = 1, i <= numEntries, i++, date = DateObject[cf[[i, 1]]];
  amount = cf[[i, 2]];
  timeDifference = DateDifference[referenceDate, date, "Day"];
  presentValue += 
   amount/(1 + discountRate)^QuantityMagnitude[timeDifference/365];]

 presentValue

  (*1234.51*)

Using Cashflow:

 TimeValue[ Cashflow[{{{2024, 1, 16}, 324.67`}, {{2024, 2, 6}, 634.09`}, {{2024, 11, 20}, 356.27`}, 
 {{2023, 12, 31},  0}}], .05, {2023, 1, 1}]
 (*1234.56*)

Regards M.I.

POSTED BY: Mariusz Iwaniuk

Very helpful, Mariusz. Thanks. The Cashflow[] example revealed my mistake.

POSTED BY: Jay Gourley
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract