Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: Tim MeagherHey,
There is no BRAINscript function which will perform this operation directly.
However, I've attached a graph which contains a couple of nodes to do this.
I'm just using the formula referenced on the wikipedia entry (
http://en.wikipedia.org/wiki/Net_present_value):
t is the time of the cash flow
i is � the discount rate (the rate of return that could be earned on an investment in the financial markets with similar risk.); the opportunity cost of capital
Rt is the net cash flow i.e. cash inflow � cash outflow, at time
t.
So I've parameterized "
i" in the node - you can just set this value and re-run the node.
The values of the net cash flows are provided as inputs to the node.
The first record is assumed to have a "
t" of 0, then 1, 2, etc.
The calculation of each of the present values is done in a filter node.
You'll see this is pretty simply to do using standard BRAINscript numeric operators (pow, and '/', +, etc) and results in:
presentValue = 'CashFlow' / pow((1 + {{^i^}}), execCount-1)
Where
{{^i^}} is the substitution of the parameter "
i" discussed previously, and
execCount is effectively the "
t" value for each of the records.
In order to perform the sum, this is a simple Agg node, where the groupSum is calculated and output.
In general, you'll probably find that there isn't a corresponding BRAINscript function for these financial formulas.
However, like in this example, writing something to do the same thing in BRAINscript doesn't require much effort and is often just a combination of a few of the "Numeric Operators" that you can find in the BRAINscript help.
Hope this helps,
Tim.
Attachments:
npv.brg