Message Boards Message Boards

1
|
2633 Views
|
8 Replies
|
5 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
8 Replies

How long after a release like 14.1 does it usually take to correct problems like the one with TimeValue[] discussed here? It makes sense that Wolfram does not want burden support by releasing fixes piecemeal. But the expected time for a fix is a key factor on whether I should reinstall an older version of Mathematica.

POSTED BY: Jay Gourley
Posted 1 month ago

I am the "Updating Name" below. I reported this for V14.1 and Win10 on 19 Aug and received this reply:

"It does appear that TimeValue has regressed in 14.1. I have forwarded an issue report to our developers with the information you provided, and added your contact information to the report so that you can be notified when it is resolved."

I have received no further communications from Wolfram.

POSTED BY: David Keith
Posted 3 months ago

Did something change? I believe the code below from Mariusz Iwaniuk executed correctly in earlier versions but doesn't since I updated to ver. 14.1.


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}]
POSTED BY: Jay Gourley
Posted 3 months ago

I reported this to tech support and received the response “It does appear that TimeValue has regressed in 14.1.” Case 5171437.

POSTED BY: Updating Name

Thanks, Updating Name. Is that number something I can use to follow the case?

POSTED BY: Jay Gourley
Posted 3 months ago

I suggest that you also report this to Wolfram. They will open a case for you and attach your contact info to the case. I would think this would get high priority since it will break a lot of stuff.

POSTED BY: David Keith

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