MRFFL: MR Fortran Finance Library 2024-12-28
Computational Tools For Finance
|
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 |
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.
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:
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.
n | Number of compounding periods |
i | Interest as a fraction (not a percentage) |
pv | Present Value |
pmt | Payment |
fv | Future Value |
pmt_time | Payments at beginning or end of period. Allowed parameters: pmt_at_beginning or pmt_at_end |
unknown | The unknown variable to solve for. Allowed parameters: var_pmt var_i, var_n, var_pv, or var_fv. |
status | Returns 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.
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)
n | Number of compounding periods |
i | Interest as a fraction (not a percentage) |
pv | Present Value |
pmt | Payment |
fv | Future Value |
pmt_time | Payments at beginning or end of period. Allowed parameters: pmt_at_beginning or pmt_at_end |
print_out | Set 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.
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().
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().