IFinance.Xnpv

Fore Syntax

Xnpv(Rate: Double; Values: Array; DateTimes: Array): Double;

Fore.NET Syntax

Xnpv(Rate: double; Values: System.Array; DateTimes: System.Array): double;

Parameters

Parameters Description Constraints
Rate Discount rate, applied to cash flows. Must be positive.
Values A set of cash flows, corresponding to the payment schedule, given in the date argument. The first payment is optional and corresponds to the starting investment payment. All the next payments are discounted on the basis of a 365-days year. It is required to use an array of the Double.
DateTimes A schedule of payment dates, which corresponds to the set of cash flows. The first date is the starting one in the payment schedule. All the other dates must be later than this date, but can have arbitrary order. It is required to use an array of the DateTime.

Description

The Xnpv method returns net present value for cash flows, which do not have to be regular.

Comments

The set of Values must contain at least one positive and one negative value.

The Xnpv function is calculated using the following formula:

Where:

Fore Example

To execute the example, add a link to the MathFin system assembly.

Sub UserProc;
Var
    r: Double;
    Values: Array[5Of Double;
    Dates: Array[5Of DateTime;
Begin
    Values[0] := -10000;
    Values[1] := 2750;
    Values[2] := 4250;
    Values[3] := 3250;
    Values[4] := 2750;
    Dates[0] := DateTime.parse("01.01.2008");
    Dates[1] := DateTime.parse("01.03.2008");
    Dates[2] := DateTime.parse("01.10.2008");
    Dates[3] := DateTime.parse("15.02.2009");
    Dates[4] := DateTime.parse("01.04.2009");
    r := Finance.
Xnpv(0.09, Values, Dates);
    Debug.WriteLine(r);

End Sub UserProc;

After executing the example the console window displays the present value equal to 2113.83.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.MathFin;

Public Shared Sub Main(Params: StartParams);
Var
    r: double;
    Finance: FinanceClass = New FinanceClass();
    Values: Array[5Of Double;
    Dates: Array[5Of DateTime;
Begin
    Values[0] := -10000;
    Values[1] := 2750;
    Values[2] := 4250;
    Values[3] := 3250;
    Values[4] := 2750;
    Dates[0] := DateTime.parse("01.01.2008");
    Dates[1] := DateTime.parse("01.03.2008");
    Dates[2] := DateTime.parse("01.10.2008");
    Dates[3] := DateTime.parse("15.02.2009");
    Dates[4] := DateTime.parse("01.04.2009");
    r := Finance.Xnpv(0.09, Values, Dates);
    System.Diagnostics.Debug.WriteLine(r);
End Sub;

See also:

IFinance