Solved

xirr in coldfusion or php

Posted on 2010-08-16
4
466 Views
Last Modified: 2012-05-10
how do i calculate xirr in coldfusion or in php
0
Comment
Question by:mugsinc
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
nitinsawhney earned 250 total points
ID: 33444939
There is a class in php that can handle excel functions  http://www.phpclasses.org/package/892-PHP-Financial-functions-with-the-Excel-function-names-.html

You will have to implement this in order to cater to your needs.
0
 
LVL 1

Author Comment

by:mugsinc
ID: 33445072
nitinsawhney: do you know how to use that class?
0
 
LVL 6

Expert Comment

by:nitinsawhney
ID: 33445320
I am assuming you know basic PHP scripting here.

Basically you need to download the code from the link i provided and then include in the script where you would like to do the calculation.

Here is a sample code picked from there.
<?php

/**

 * Case use of financial class.

 * 

 * @version   $Id: financial_example.php,v 1.0.5 2004-06-23 09:03:56-05 egarcia Exp $

 * @author    Enrique Garcia M. <egarcia@egm.as>

 * @copyright (c) 2002-2004 EGM :: Ingenieria sin fronteras

 * @since     Saturday, November 30, 2002

 **/



/***************************************************************************

 *

 *   This program is free software; you can redistribute it and/or modify

 *   it under the terms of the GNU General Public License as published by

 *   the Free Software Foundation; either version 2 of the License, or

 *   (at your option) any later version.

 *

 ***************************************************************************/



include('financial_class.php');



/***********************************************************************************/



$f = new Financial;

echo 'FV: ' . $f->FV(1.1, 1/360, 0, -100) . "\n";

echo 'PV: ' . $f->PV(1.1, 1/360, 0, -100.206306226) . "\n";

echo 'PMT: ' . $f->PMT(1.1, 1/360, -100) . "\n";

echo 'PMT: ' . $f->PMT(1.1, 1/360, 0, -100.206306226) . "\n";

echo 'NPER: ' . $f->NPER(1.1, 53428.7980679, -100) . "\n";

echo 'NPER: ' . $f->NPER(1.1, 0, -100, -100.206306226) . "\n";

echo 'FV: ' . $f->FV(0.1, 1/360, 0, -100) . "\n";

echo 'PV: ' . $f->PV(0.1, 1/360, 0, -100.026478555) . "\n";

echo 'PMT: ' . $f->PMT(0.1, 1/360, -100) . "\n";

echo 'PMT: ' . $f->PMT(0.1, 1/360, 0, -100.026478555) . "\n";

echo 'NPER: ' . $f->NPER(1.1, 37776.4114948, -100) . "\n";

echo 'NPER: ' . $f->NPER(1.1, 0, -100, -100.026478555) . "\n";

echo 'EFFECT: ' . $f->EFFECT(0.0525, 4) . "\n";

echo 'NOMINAL: ' . $f->NOMINAL(0.053543, 4) . "\n";

echo 'NPV: ' . $f->NPV(0.1, array(-10000,3000,4200,6800)) . "\n";

echo 'XNPV: ' . $f->XNPV(0.09, array(-10000,2750,4250,3250,2750), array(

    mktime(0,0,0,1,1,2008),

    mktime(0,0,0,3,1,2008),

    mktime(0,0,0,10,30,2008),

    mktime(0,0,0,2,15,2009),

    mktime(0,0,0,4,1,2009),

    )) . "\n";

echo 'XIRR: ' . $f->XIRR(array(-10000,2750,4250,3250,2750), array(

    mktime(0,0,0,1,1,2008),

    mktime(0,0,0,3,1,2008),

    mktime(0,0,0,10,30,2008),

    mktime(0,0,0,2,15,2009),

    mktime(0,0,0,4,1,2009),

    ), 0.1) . "\n";

echo 'IRR: ' . $f->IRR(array(-70000,12000,15000,18000,21000)) . "\n";

echo 'DISC: ' . $f->DISC(

    mktime(0,0,0,1,25,2007),

    mktime(0,0,0,6,15,2007),

    97.975,

    100,

    0) . "\n";

echo 'DISC: ' . $f->DISC(

    mktime(0,0,0,1,25,2007),

    mktime(0,0,0,6,15,2009),

    97.975,

    100,

    1) . "\n";

echo 'DISC: ' . $f->DISC(

    mktime(0,0,0,1,25,2007),

    mktime(0,0,0,6,15,2007),

    97.975,

    100,

    2) . "\n";

echo 'DISC: ' . $f->DISC(

    mktime(0,0,0,1,25,2007),

    mktime(0,0,0,6,15,2007),

    97.975,

    100,

    3) . "\n";

echo 'DISC: ' . $f->DISC(

    mktime(0,0,0,1,25,2007),

    mktime(0,0,0,6,15,2007),

    97.975,

    100,

    4) . "\n";

echo 'INTRATE: ' . $f->INTRATE(

    mktime(0,0,0,2,15,2008),

    mktime(0,0,0,5,15,2008),

    1000000,

    1014420,

    2) . "\n";

echo 'IPMT: ' . $f->IPMT(0.1/12, 3, 3, 8000) . "\n";

echo 'IPMT: ' . $f->IPMT(0.1, 3, 3, 8000) . "\n";

echo 'RECEIVED: ' . $f->RECEIVED(

    mktime(0,0,0,2,15,2008),

    mktime(0,0,0,5,15,2008),

    1000000,

    0.0575,

    2) . "\n";

echo 'DOLLARDE: ' . $f->DOLLARDE(1.02, 16) . "\n";

echo 'DOLLARDE: ' . $f->DOLLARDE(1.1, 32) . "\n";

echo 'DOLLARFR: ' . $f->DOLLARFR(1.125, 16) . "\n";

echo 'DOLLARFR: ' . $f->DOLLARFR(1.125, 32) . "\n";

echo 'FVSCHEDULE: ' . $f->FVSCHEDULE(1, array(0.09,0.11,0.1)) . "\n";

echo 'PPMT: ' . $f->PPMT(0.1/12, 1, 2*12, 2000) . "\n";

echo 'PPMT: ' . $f->PPMT(0.08, 10, 10, 200000) . "\n";

echo 'RATE: ' . $f->RATE(4*12,-200, 8000) . "\n";

echo 'RATE: ' . $f->RATE(4*12,-200, 8000)*12 . "\n";

echo 'SYD: ' . $f->SYD(30000, 7500, 10, 10) . "\n";

echo 'SLN: ' . $f->SLN(30000, 7500, 10) . "\n";

echo 'DDB: ' . $f->DDB(1000000, 100000, 10, 4) . "\n";

echo 'DELTA: ' . $f->DELTA(5, 4) . "\n";

echo 'DELTA: ' . $f->DELTA(5, 5) . "\n";

echo 'PRICEDISC: ' . $f->PRICEDISC(mktime(0,0,0,2,16,2008), mktime(0,0,0,3,1,2008), 0.0525, 100, 2) . "\n";

echo 'YIELDDISC: ' . $f->YIELDDISC(mktime(0,0,0,2,16,2008), mktime(0,0,0,3,1,2008), 99.795, 100, 2) . "\n";

echo 'COUPNUM: ' . $f->COUPNUM(mktime(0,0,0,1,25,2007), mktime(0,0,0,11,15,2008), 2, 1) . "\n";

echo 'COUPDAYBS: ' . $f->COUPDAYBS(mktime(0,0,0,1,25,2007), mktime(0,0,0,11,17,2008), 1, 1) . "\n";

echo 'VDB: ' . $f->VDB(2400,300,10*365,0,1) . "\n";

echo 'VDB: ' . $f->VDB(2400,300,10*12,0,1) . "\n";

echo 'VDB: ' . $f->VDB(2400,300,10,0,1) . "\n";

echo 'VDB: ' . $f->VDB(2400,300,10*12,6,18) . "\n";

echo 'VDB: ' . $f->VDB(2400,300,10*12,6,18,1.5) . "\n";

echo 'VDB: ' . $f->VDB(2400,300,10,0,0.875,1.5) . "\n";

echo 'MIRR: ' . $f->MIRR(array(-120000,39000,30000,21000,37000,46000), 0.1, 0.12) . "\n";

echo 'MIRR: ' . $f->MIRR(array(-120000,39000,30000,21000), 0.1, 0.12) . "\n";

echo 'MIRR: ' . $f->MIRR(array(-120000,39000,30000,21000,37000,46000), 0.1, 0.14) . "\n";



?> 

Open in new window

0
 
LVL 1

Author Comment

by:mugsinc
ID: 33445365
i am better with coldfusion, which is why i asked for it first
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now