LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Npv

    Employee
    Posted 09-24-2013 00:14

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ThomasT

    Is there a function that calculates the NPV?
    (Net present value)

    AND

    How do i calculate the potentiation of a value in LAE?


  • 2.  RE: Npv

    Employee
    Posted 09-24-2013 03:37

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Hey,

    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


  • 3.  RE: Npv

    Employee
    Posted 09-24-2013 04:04

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ThomasT

    Great Tim, thank you so much!
    We will try find out how to use it.

    I guess there is no function for the potentiation?, i wish i could use the ^ sign...


  • 4.  RE: Npv

    Employee
    Posted 09-24-2013 04:51

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Hey,

    I'm not sure what you are referring to with potentiation - sorry if I'm missing something simple.
    Can you clarify?

    If you want to use the "^" sign, I'm assuming that what you want is the ability to raise another number to a different power - i.e. exponentiation (rather than a bitwise-xor - which some languages use the "^" sign for).

    If it's the former (raising a number to a power of another number) - you can use the pow function in BRAINscript - which i used in the previous example.
    If it's the latter (bitwise xor), then you can use the bitwiseXor function in BRAINscript.

    Regards,
    Tim.
    Tim.


  • 5.  RE: Npv

    Employee
    Posted 03-21-2014 07:40

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: simon.wilby

    hi,

    just to let you know we now have a node that calculates the NPV - this is part of the Analytics library and details can be found on the
    Updates to the LAL library page.

    the actual lal pack can be downloaded from our download page.

    Regards

    Simon