Loading [MathJax]/extensions/tex2jax.js
MRFFL: MR Fortran Finance Library 2024-12-28
Computational Tools For Finance
All Namespaces Files Functions Variables
mrffl_tvm12 Module Reference

Provides a TVM solver with functionality similar to modern financial calculators. More...

Functions/Subroutines

subroutine, public tvm12_solve (n, i, pv, pmt, fv, pmt_time, unknown, status)
 Solve TVM Equation.
 
subroutine, public tvm12_print (n, i, pv, pmt, fv, pmt_time, print_out)
 Print TVM Problem (variables and/or table)
 

Variables

integer(kind=ik), parameter, public pmt_at_beginning = 1
 
integer(kind=ik), parameter, public pmt_at_end = 0
 

Detailed Description

Provides a TVM solver with functionality similar to modern financial calculators.

Most financial calculators use the following relationship to implement TVM functionality:

\[ 0=PV+(1+i\cdot b)\cdot\frac{PMT}{i}\cdot\left(1-\frac{1}{(1+i)^n}\right)+\frac{FV}{(1+i)^n} \]

This single equation defines several relationships, and can be used to solve a great many different kinds of TVM problems.

The modular approach taken in tvm.f90 and cashflows.f90 is a far more flexible to and powerful way to solve TVM problems; however, the simplicity and familiarity of the classical calculator approach is sometimes more comfortable and direct.

Function/Subroutine Documentation

◆ tvm12_solve()

subroutine, public mrffl_tvm12::tvm12_solve ( integer(kind=ik), intent(inout) n,
real(kind=rk), intent(inout) i,
real(kind=rk), intent(inout) pv,
real(kind=rk), intent(inout) pmt,
real(kind=rk), intent(inout) fv,
integer(kind=ik), intent(in) pmt_time,
integer(kind=ik), intent(in) unknown,
integer(kind=ik), intent(out) status )

Solve TVM Equation.

Value returned in status:

  • 0 - Everything worked
  • 1 - ERROR(tvm_solve): n==0!
  • 2 - ERROR(tvm_solve): n<0!
  • 3 - ERROR(tvm_solve): Unsupported value for pmt_time (must be one of pmt_at_beginning or pmt_at_end)
  • 4 - ERROR(tvm_solve): Unsupported value for action!
  • 5 - ERROR(tvm_solve): Unable to solve for i
  • 6 - ERROR(tvm_solve): Can not solve for n!
  • 7 - ERROR(tvm_solve): i near -1!
  • 8 - ERROR(tvm_solve): i near zero!
  • 9 - Reserved

WARNING: Solving for i is not entirely reliable. Only values between -1 and 1 may be found. Additionally it is possible a solution in that range might not be found.

Parameters
nNumber of compounding periods
iInterest as a fraction (not a percentage)
pvPresent Value
pmtPayment
fvFuture Value
pmt_timePayments at beginning or end of period. Allowed parameters: pmt_at_beginning or pmt_at_end
unknownThe unknown variable to solve for. Allowed parameters: var_pmt var_i, var_n, var_pv, or var_fv.
statusReturns status of computation. 0 if everything worked. Range: 0 & 3001-3032.

Definition at line 94 of file mrffl_tvm12.f90.

References i_slv_func(), mrffl_solver::multi_bisection(), pmt_at_beginning, pmt_at_end, mrffl_var_sets::var_fv, mrffl_var_sets::var_i, mrffl_var_sets::var_n, mrffl_var_sets::var_pmt, mrffl_var_sets::var_pv, and mrffl_config::zero_epsilon.

Here is the call graph for this function:

◆ tvm12_print()

subroutine, public mrffl_tvm12::tvm12_print ( integer(kind=ik), intent(in) n,
real(kind=rk), intent(in) i,
real(kind=rk), intent(in) pv,
real(kind=rk), intent(in) pmt,
real(kind=rk), intent(in) fv,
integer(kind=ik), intent(in) pmt_time,
integer(kind=ik), intent(in) print_out )

Print TVM Problem (variables and/or table)

Parameters
nNumber of compounding periods
iInterest as a fraction (not a percentage)
pvPresent Value
pmtPayment
fvFuture Value
pmt_timePayments at beginning or end of period. Allowed parameters: pmt_at_beginning or pmt_at_end
print_outSet made from the following constants: prt_param, prt_table, prt_title

Definition at line 218 of file mrffl_tvm12.f90.

References mrffl_bitset::bitset_intersectp(), mrffl_bitset::bitset_subsetp(), pmt_at_beginning, pmt_at_end, mrffl_prt_sets::prt_param, mrffl_prt_sets::prt_table, and mrffl_prt_sets::prt_title.

Here is the call graph for this function:

Variable Documentation

◆ pmt_at_beginning

integer(kind=ik), parameter, public mrffl_tvm12::pmt_at_beginning = 1

Definition at line 60 of file mrffl_tvm12.f90.

Referenced by tvm12_print(), and tvm12_solve().

◆ pmt_at_end

integer(kind=ik), parameter, public mrffl_tvm12::pmt_at_end = 0

Definition at line 61 of file mrffl_tvm12.f90.

Referenced by tvm12_print(), and tvm12_solve().