No announcement yet.

Financial Formulas

  • Filter
  • Time
  • Show
Clear All
new posts

  • Financial Formulas

    Can someone point me, if it exists, to a library of financial formulas converted to Lua, please? I am working on a financial program and don't understand how to convert the financial formulas. I have attached a screen shot of a mortgage calculator I am building. I have the formula to calculate the monthly payment and it works perfectly. I am looking for the Lua formulas to solve for...

    1. Loan Amount
    2. Interest Rate
    3. Term
    4. Principal & Interest

    There will be other financial calculations performed elsewhere within the project. Having a complete library would be very helpful. Thank you in advance for any help that can be provided.

    Attached Files

  • #2
    I forgot to include the payment formula should anyone ever need it.

    -- Loan amount
    Pv = s2n(Input.GetText("Input2"));
    -- Interest rate
    Rate = Input.GetText("Input3")/1200;
    -- Amortization term months
    nPer = s2n(Input.GetText("Input4"));
    -- Calculate the P&I payment
    PiPMT = Math.Round((((Rate)+(Rate)/(Math.Pow(1+(Rate),nPer)-1))*Pv),2);
    Input.SetText("Input5", PiPMT);


    • #3
      have a look at -
      may help??
      I'm not good with finance maths


      • #4
        Thank you, colc! This is exactly what I was in need of. I will get a lot of use from the function!

        There is 1 functions that does not seem to be correct (rate) and I can't get the (nper) to go.

        function rate(fv, pv, n, type) - Missing a variable (pmt).

        function nper(i, pmt, pv, fv, type) - Returns 0. I am confident I am passing the correct variables.


        • #5
          My mistake. I guess I was getting bug eyed at 2 AM. The (nper) function works! The only loose end is the (rate) function. I need a bit of help with that one. Thanks gain!


          • #6
            Formula to solve for Present Value (Loan Amount). This works! I hope it helps someone.
            -- Interest rate
            nInt = s2n(Input.GetText("Input3")/1200);
            -- Amortization term months
            nPer = s2n(Input.GetText("Input4"));
            -- Monthly payment
            nPmt = s2n(Input.GetText("Input5"));
            Pv = nPmt/( nInt+(nInt/(Math.Pow(1+nInt,nPer)-1)))
            Input.SetText("Input2", Pv);


            • #7
              can i ask what font you are using on your project? Thanks


              • #8
                The font is Tahoma.