Cash Flow (IRR, MIRR, NPV)
|
05-21-2015, 03:49 PM
(This post was last modified: 05-27-2015 05:42 PM by salvomic.)
Post: #1
|
|||
|
|||
Cash Flow (IRR, MIRR, NPV)
hi all,
here a program to calculate Cash Flow operations with the Prime (IRR, MIRR, NPV). The program is presented in two version: the first give three routines to calculate (Net Present Value, Internal Rate of Return and Modified Internal Rate of Return, like that in the HP 12C); the second will follow with a "Drawmenu" version with only a command, Cash_Flow that executes the same routines internally. NPV included is the nice program by Eddie W. Shore (here in the Forum). I would like to thank who has helped me to do this program: Dale (DRD), Cyrille de Brébisson, Akmon, Didier Lachiese, kharpster, who has transformed the program into "menu-ized" version...) Warning: both version use list L1 or matrix M1 to store data, so, if you have important data in there, please, first save them otherwhere... I advice to use the list for series of cash flow with few data to treat or edit {CF0, CF1, CF2, ... CFj...}, and a matrix when there are more data with frequency repeated (i.e [CF0, 1], [CF1, 2], [CF2, 1], [CF3, 8], ...,[CFj],... [CF last, 1]). You can store data into list (or matrix) first of use the program, or inside the program, editing them. Enjoy! Salvo Micciché (salvomic) Version with commands separately exported Code:
Here Cash_Flows, the version with Drawmenu, every functions inside the program... This version exports variables in CF_IRR, CF_MIRR, CF_NPV inside Vars->User->Cash_Flow Code:
∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-21-2015, 10:27 PM
Post: #2
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
Great, Salvo, very attractive environment. Thank you for the credits. ;-)
|
|||
05-21-2015, 10:43 PM
Post: #3
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
(05-21-2015 10:27 PM)akmon Wrote: Great, Salvo, very attractive environment. Thank you for the credits. ;-) you're welcome! :-) I'm glad to have been useful. Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-27-2015, 05:22 PM
Post: #4
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
Salvo, this is fantastic! I do have a question, I'm getting a syntax error after I do a check after importing the script. Any suggestions ?
|
|||
05-27-2015, 05:45 PM
Post: #5
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
(05-27-2015 05:22 PM)gregnbrown Wrote: Salvo, this is fantastic! I do have a question, I'm getting a syntax error after I do a check after importing the script. Any suggestions ? thank you for compliments! For the sake of precision, I've put the working code again on the post above ("Cash Flow" with drawmenu)... However, if you get any errors, go to Programs, open cashflow program, hit check, then observe where is the cursor: it indicates that first there is an error; perhaps it helps... First, try to copy again the code above. Tell me if it works Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-27-2015, 06:08 PM
(This post was last modified: 05-27-2015 06:14 PM by gregnbrown.)
Post: #6
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
Thanks! The error is at EDITLIST(L1,
I am new to the HP Prime programming. Some background. I created a new program, and copied pasted the code into the program. |
|||
05-27-2015, 06:16 PM
Post: #7
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
(05-27-2015 06:08 PM)gregnbrown Wrote: Thanks! The error is at EDITLIST(L1, do you copied *this* code? It should works, almost, here it works well in the real calculator (now I'm trying in the emulator)... Copy it via Connection Kit into the program. Code:
∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-27-2015, 06:28 PM
Post: #8
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
Thanks. Same error, however, I am trying it on the emulator. Just to make sure, it is a complete copy and paste into a new document? Overwrite the default syntax:
EXPORT program() BEGIN END; |
|||
05-27-2015, 06:32 PM
Post: #9
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
(05-27-2015 06:28 PM)gregnbrown Wrote: Thanks. Same error, however, I am trying it on the emulator. Just to make sure, it is a complete copy and paste into a new document? Overwrite the default syntax: you must overwrite those lines and paste code (without [code] and [ / code]) into the blank text. Here it works also in emulator (and ...in Parallels emulator Windows 7 into Mac OS X, hi)... The program begins with export(); and ends with END; don't copy other lines first and after. Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-28-2015, 12:27 AM
Post: #10
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
(05-27-2015 06:32 PM)salvomic Wrote: you must overwrite those lines and paste code (without [code] and [ / code]) into the blank text. Don't forget to add the "pragma" line to make sure it will work properly on systems with other comma/hex settings! TW Although I work for HP, the views and opinions I post here are my own. |
|||
05-28-2015, 03:48 AM
Post: #11
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
Works great, no errors. Thanks. Last question, I now see it in vars-->user. What is the exact syntax I would use to calculate the IRR ?
|
|||
05-28-2015, 07:56 AM
(This post was last modified: 05-28-2015 08:06 AM by salvomic.)
Post: #12
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
(05-28-2015 12:27 AM)Tim Wessman Wrote: Don't forget to add the "pragma" line to make sure it will work properly on systems with other comma/hex settings! you're are right, Tim. I should see how it's its syntax for this program, then add it. Is only this ok? Code: #pragma mode(separator(.,;) integer(h32)) (05-28-2015 03:48 AM)gregnbrown Wrote: Works great, no errors. Thanks. Last question, I now see it in vars-->user. What is the exact syntax I would use to calculate the IRR ? great! Var -> user -> cash flow: click on CF_IRR to get IRR, on CF_MIRR to get modified IRR, CF_NPV to get Net Present Value of the last calculations (after using the program), no parenthesis, no other... To calculate IRR you need to have a list or a matrix (inside the program) with the cash flows (CF0, CFj...) and an interest rate, the first is generally negative (expense), the others flows are or negative or positive; IRR will have more values for more changement of sign or only one, not always it's possible to calculate it and in some cases financially is more suitable to calculate MIRR (see here, i.e.). IRR is obtained setting NPV to 0 in the equation... An example to test: -80000, -500, 4500 (3 times), 130000 You buy a mansion 80000$, the second year pay 500 (tax...), 3rd-5th year to get 4500 from rent, then sell to 130000$ at 13% of rate of yield preview. You should get NPV +212.18. Then try IRR with the same cashflow, the program gives you 13.72% (about the previewed one) Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-28-2015, 08:20 AM
Post: #13
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
I've added pragma, now:
Code:
∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
05-28-2015, 09:39 AM
(This post was last modified: 05-28-2015 09:43 AM by fhub.)
Post: #14
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
(05-28-2015 07:56 AM)salvomic Wrote: An example to test: -80000, -500, 4500 (3 times), 130000Don't confuse the users of your program with wrong results, Salvo! I tried to get your 'results' with my TVM/Cashflow program, but no matter how I entered these values, I just couldn't get your NPV or IRR results. And since I've checked my program (when I wrote it) against ALL examples that I've found in any of the HP financial calculator manuals (and of course they were all correct), I'm sure that there are no bugs in my program. For your conditions (given above) the results should be NPV=-480.87 and IRR=12.8575%. But after a short look at the HP12 manual I saw that you've just used an example from there, but instead of 3-times 4500 the cashflows are in fact 4500/5500/4500 - this would give your NPV=212.18 (and an IRR=13.0629%). And your IRR=13.72% is from the following example (in the manual) with completely different cashflows ... Franz |
|||
05-28-2015, 09:47 AM
(This post was last modified: 05-28-2015 09:48 AM by salvomic.)
Post: #15
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
(05-28-2015 09:39 AM)fhub Wrote: ... right, Franz I was aware of the error (too hurry...), but I hadn't time to correct it... yes, the right example is this, I wrote without attention. Anyway, that is the way how the program works. And your programs are also correct! Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
04-23-2016, 03:07 PM
Post: #16
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
New Version (2.0) after firmware 10077.
This version doesn't works with the previous firmwares. Code:
∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
08-22-2017, 08:42 AM
Post: #17
|
|||
|
|||
RE: Cash Flow (IRR, MIRR, NPV)
Hi Salvomic,
Thank you for your program which could be very interesting for me as I'm a finance student. I've tried it but I don't know how to create a list in order to calculate the IRR. For example, I want to calculate the IRR of these Cash Flows : -1 000 000 (Investment in O, which is CF0) + 272 092 (CF1) + 232 165 (CF2) + 237 569 (CF3) + 243 524 (CF4) + 250 016 (CF5). Actually I don't know how to write these Cash Flows on your program in the window "Listes" after having selected "IRR" in your program. This window : [attachment=5134] Thank you for your help. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)