Analysis of cashflows

Overview

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.

Functions in this module

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 (float, pandas.Series) – Periodic interest rate.
  • cflo (pandas.Series) – Generic cashflow.
  • base_date (int, list) – Time.
Returns:

Float or list of floats.

Examples.

>>> prate = interest_rate([2]*9, start='2000Q1', freq='Q')
>>> cflo = cashflow([-717.01] + [100]*8, start='2000Q1', freq='Q')
>>> benefit_cost_ratio(cflo, prate) 
1.02...
>>> prate = interest_rate([12]*5, start='2000Q1', freq='Q')
>>> cflo = cashflow([-200] + [100]*4, start='2000Q1', freq='Q')
>>> benefit_cost_ratio(cflo, prate) 
1.518...
>>> benefit_cost_ratio([cflo, cflo], prate) 
0    1.518675
1    1.518675
dtype: float64
cashflows.analysis.irr(cflo)[source]

Computes the internal rate of return of a generic cashflow as a periodic interest rate.

Parameters:cflo (pandas.Series) – Generic cashflow.
Returns:Float or list of floats.

Examples.

>>> cflo = cashflow([-200] + [100]*4, start='2000Q1', freq='Q')
>>> irr(cflo) 
34.90...
>>> irr([cflo, cflo]) 
0    34.90...
1    34.90...
dtype: float64
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 (pandas.Series) – 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, start='2000Q1', freq='Q')
>>> mirr(cflo) 
18.92...
>>> mirr([cflo, cflo]) 
0    18.920712
1    18.920712
dtype: float64
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 (pandas.Series) – Generic cashflow.
  • prate (pandas.Series) – Periodic interest rate.
  • nper (int, list) – Number of equivalent payment periods.
Returns:

Float or list of floats.

Examples.

>>> prate = interest_rate([2]*9, start='2000Q1', freq='Q')
>>> cflo = cashflow([-732.54] + [100]*8, start='2000Q1', freq='Q')
>>> net_uniform_series(cflo, prate) 
0.00...
>>> prate = interest_rate([12]*5, start='2000Q1', freq='Q')
>>> cflo = cashflow([-200] + [100]*4, start='2000Q1', freq='Q')
>>> net_uniform_series(cflo, prate) 
116.18...
>>> net_uniform_series([cflo, cflo], prate) 
0    116.183127
1    116.183127
dtype: float64
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 (pandas.Series, list of pandas.Series) – Generic cashflow.
  • prate (pandas.Series) – 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, start='2000Q1', freq='Q')
>>> prate = interest_rate([2]*9, start='2000Q1', freq='Q')
>>> timevalue(cflo, prate) 
0.00...
>>> prate = interest_rate([12]*5, start='2000Q1', freq='Q')
>>> cflo = cashflow([-200]+[100]*4, start='2000Q1', freq='Q')
>>> timevalue(cflo, prate) 
103.73...
>>> timevalue(cflo, prate, 4) 
163.22...
>>> prate = interest_rate([12]*5, start='2000Q1', freq='Q')
>>> cflo = cashflow([-200] + [100]*4, start='2000Q1', freq='Q')
>>> timevalue(cflo=cflo, prate=prate) 
103.73...
>>> timevalue(cflo=[cflo, cflo], prate=prate) 
0    103.734935
1    103.734935
dtype: float64