Analysis of cashflows¶
This module implements the following functions for financial analysis of cashflows:
timevalue
: computes the equivalent net value of a cashflow in a specified time moment.net_uniform_series
: computes the periodic equivalent net value of a cashflow for a specified number of payments.benefit_cost_ratio
: computes the benefit cost ratio of a cashflow using a periodic interest rate for discounting the cashflow.irr
: calculates the periodic internal rate of return of a cashflow.mirr
: calculates the periodic modified internal rate of return of a cashflow.list_as_table
: prints a list as a table. This function is useful for comparing financial indicators for different alternatives.
-
cashflows.analysis.
benefit_cost_ratio
(cflo, prate, base_date=0)[source]¶ Computes a benefit cost ratio at time base_date of a discounted cashflow using the periodic interest rate prate.
Parameters: - prate (int float, Rate) – Periodic interest rate.
- cflo (cashflow, list) – Generic cashflow.
- base_date (int, list) – Time.
Returns: Float or list of floats.
Examples.
>>> prate = interest_rate([2]*9, pyr=4) >>> cflo = cashflow([-717.01] + [100]*8, pyr=4) >>> benefit_cost_ratio(cflo, prate) 1.02...
>>> prate = interest_rate([12]*5) >>> cflo = cashflow([-200] + [100]*4) >>> benefit_cost_ratio(cflo, prate) 1.518...
>>> benefit_cost_ratio([cflo, cflo], prate) [1.518..., 1.518...]
>>> benefit_cost_ratio(cflo, [prate, prate]) [1.518..., 1.518...]
>>> benefit_cost_ratio([cflo, cflo], [prate, prate]) [1.518..., 1.518...]
>>> benefit_cost_ratio([cflo, cflo], [prate, prate], [0, 0]) [1.518..., 1.518...]
-
cashflows.analysis.
irr
(cflo)[source]¶ Computes the internal rate of return of a generic cashflow as a periodic interest rate.
Parameters: cflo (TimeSeries) – Generic cashflow. Returns: Float or list of floats. Examples.
>>> cflo = cashflow([-717.01] + [100]*8, pyr=4) >>> irr(cflo) 2.50...
>>> cflo = cashflow([-200] + [100]*4) >>> irr(cflo) 34.90...
>>> irr([cflo, cflo]) [34.90..., 34.90...]
-
cashflows.analysis.
list_as_table
(data)[source]¶ Prints the list data as a table. This function is used to produce a human-readable format of a table for comparing financial indicators.
Parameters: data (list) – List of numeric values. Returns: None Example.
>>> list_as_table(data=[1, 2, 3, 4]) # Value ------------------------ 0 1.0000 1 2.0000 2 3.0000 3 4.0000
>>> prate = interest_rate([12]*5) >>> cflo = cashflow([-200] + [100]*4) >>> list_as_table(timevalue(cflo=[cflo, cflo, cflo], prate=prate)) # Value ------------------------ 0 103.7349 1 103.7349 2 103.7349
-
cashflows.analysis.
mirr
(cflo, finance_rate=0, reinvest_rate=0)[source]¶ Computes the modified internal rate of return of a generic cashflow as a periodic interest rate.
Parameters: - cflo (list, cashflow) – Generic cashflow.
- finance_rate (float) – Periodic interest rate applied to negative values of the cashflow.
- reinvest_rate (float) – Periodic interest rate applied to positive values of the cashflow.
Returns: Float or list of floats.
Examples.
>>> cflo = cashflow([-200] + [100]*4) >>> mirr(cflo) 18.92...
>>> mirr([cflo, cflo]) [18.92..., 18.92...]
-
cashflows.analysis.
net_uniform_series
(cflo, prate, nper=1)[source]¶ Computes a net uniform series equivalent of a cashflow. This is, a fixed periodic payment during nper periods that is equivalent to the cashflow cflo at the periodic interest rate prate.
Parameters: - cflo (cashflow) – Generic cashflow.
- prate (TimeSeries) – Periodic interest rate.
- nper (int, list) – Number of equivalent payment periods.
Returns: Float or list of floats.
Examples.
>>> prate = interest_rate([2]*9, pyr=4) >>> cflo = cashflow([-732.54] + [100]*8, pyr=4) >>> net_uniform_series(cflo, prate) 0.00...
>>> prate = interest_rate([12]*5) >>> cflo = cashflow([-200] + [100]*4) >>> net_uniform_series(cflo, prate) 116.18...
>>> net_uniform_series([cflo, cflo], prate) [116.18..., 116.18...]
>>> net_uniform_series(cflo, [prate, prate]) [116.18..., 116.18...]
>>> net_uniform_series([cflo, cflo], [prate, prate]) [116.18..., 116.18...]
>>> net_uniform_series([cflo, cflo], [prate, prate], nper=5) [28.77..., 28.77...]
>>> net_uniform_series([cflo, cflo], [prate, prate], nper=[5, 5]) [28.77..., 28.77...]
-
cashflows.analysis.
timevalue
(cflo, prate, base_date=0, utility=None)[source]¶ Computes the equivalent net value of a generic cashflow at time base_date using the periodic interest rate prate. If base_date is 0, timevalue computes the net present value of the cashflow. If base_date is the index of the last element of cflo, this function computes the equivalent future value.
Parameters: - cflo (TimeSeries, list of TimeSeries) – Generic cashflow.
- prate (TimeSeries) – Periodic interest rate.
- base_date (int, tuple) – Time.
- utility (function) – Utility function.
Returns: Float or list of floats.
Examples.
>>> cflo = cashflow([-732.54] + [100]*8, pyr=4) >>> prate = interest_rate([2]*9, pyr=4) >>> timevalue(cflo, prate) 0.00...
>>> prate = interest_rate([12]*5) >>> cflo = cashflow([100]*5, spec = (0, -200)) >>> timevalue(cflo, prate) 103.73...
>>> timevalue(cflo, prate, 4) 163.22...
>>> timevalue(cflo, prate, base_date=0, utility=exp_utility_fun(200)) -84.15...
>>> timevalue(cflo, prate, base_date=0, utility=log_utility_fun(210)) 369092793...
>>> timevalue(cflo, prate, base_date=0, utility=sqrt_utility_fun(210)) 2998.12...
>>> prate = interest_rate([12]*5) >>> cflo = cashflow([-200] + [100]*4) >>> timevalue(cflo=cflo, prate=prate) 103.73...
>>> timevalue(cflo=[cflo, cflo], prate=prate) [103.73..., 103.73...]
>>> timevalue(cflo=cflo, prate=[prate, prate]) [103.73..., 103.73...]
>>> timevalue(cflo=[cflo, cflo], prate=[prate, prate]) [103.73..., 103.73...]
>>> timevalue(cflo=[cflo, cflo], prate=[prate, prate], base_date=[4, 4]) [163.22..., 163.22...]