loan_calculator.grossup package¶
Submodules¶
loan_calculator.grossup.functions module¶
Provide functions implementation of different grossup cases.
The grossup of a net principal is an augmented principal value whose net value corresponds to the given net principal. The net value of a principal is the one obtained after subtracting due taxes and service fees according to very specific mathematical rule.
-
loan_calculator.grossup.functions.
br_iof_constant_amortization_grossup
(net_principal, daily_interest_rate, daily_iof_fee, complementary_iof_fee, return_days, service_fee)[source]¶ Calculate the grossup of the principal and given parameters.
This implements a grossup for which
- the principal is amortized according to a constant amortization schedule
- the principal and the payments are taxed with IOF,
- a service fee is applied over the principal.
If \(s\) is the principal, \(d\) is the daily interest rate, \(I^*\) is the daily IOF fee, \(I^{**}\) is the complementary IOF fee, \(g\) is the service fee and \((n_1,n_2,\ldots,n_k)\) is the vector with the return dates, then the grossup is given by
\[\mathrm{GROSSUP}(s, d, I^*, I^{**}, (n_1,\ldots,n_k), g) = \frac{s} {1 - \alpha - I^{**} - g},\]where
\[\alpha := \frac{1}{k} \frac{\displaystyle\sum_{j=1}^k \min(n_j\ I^*, 0.015)} {\displaystyle\sum_{j=1}^k\frac{1}{(1+d)^{n_j}}}.\]
-
loan_calculator.grossup.functions.
br_iof_progressive_price_grossup
(net_principal, daily_interest_rate, daily_iof_fee, complementary_iof_fee, return_days, service_fee)[source]¶ Calculate the grossup of the principal for the given parameters.
This implements a grossup for which
- the principal is amortized according to a progressive Price schedule,
- the principal is taxed, as well as its payments, by IOF
- a fee is applied over the principal
If \(s\) is the principal, \(d\) is the daily interest rate, \(I^*\) is the daily IOF fee, \(I^{**}\) is the complementary IOF fee, \(g\) is the service fee and \((n_1,n_2,\ldots,n_k)\) is the vector with the return dates, then the grossup is given by
\[\mathrm{GROSSUP}(s, d, I^*, I^{**}, (n_1,\ldots,n_k), g) = \frac{s}{1 - \alpha - I^{**} - g },\]where
\[\alpha := \frac { \displaystyle \sum_{j=1}^k\frac{\min(n_j\ I^*, 0.015)}{(1+d)^{n_j}}} { \displaystyle\sum_{j=1}^k\frac{1}{(1+d)^{n_j}}}.\]- net_principal : float, required
- The principal to be “grossed up”.
- daily_interest_rate : float, required
- The rate at which the principal grows over time.
- daily_iof_fee : float, required
- Daily tax due to brazilian tax IOF.
- complementary_iof_fee : float, required
- Complementary tax due to brazilian tax IOF.
- return_days : list, required
- List containing the number of days since the start reference date.
- service_fee : float, optional
- Eventual service fee. It is assumed to be an aliquot applied on the principal
The grossed up principal.
-
loan_calculator.grossup.functions.
br_iof_regressive_price_grossup
(net_principal, daily_interest_rate, daily_iof_fee, complementary_iof_fee, return_days, service_fee)[source]¶ Calculate the grossup of the given principal.
This function implements a grossup for which - the principal is amortized according to a regressive Price schedule, - the principal and the payments are taxed by IOF, - a fee is calculated over the principal.
If \(s\) is the principal, \(d\) is the daily interest rate, \(I^*\) is the daily IOF fee, \(I^{**}\) is the complementary IOF fee, \(g\) is the service fee and \((n_1,n_2,\ldots,n_k)\) is the vector with the return dates, then the grossup is given by
\[\mathrm{GROSSUP}\ (s, d, I^*, I^{**}, (n_1,\ldots,n_k), g) =\frac{s}{1 - \alpha - I^{**} - g},\]where
\[\alpha := \frac{ \displaystyle\sum_{j=1}^k\frac{\min(n_{k-j+1}\ I^*, 0.015)} {(1+d)^{n_j}}} {\displaystyle\sum_{j=1}^k\frac{1}{(1+d)^{n_j}}}.\]- net_principal : float, required
- The principal to be “grossed up”.
- daily_interest_rate : float, required
- The rate at which the principal grows over time.
- daily_iof_fee : float, required
- Daily tax due to brazilian tax IOF.
- complementary_iof_fee : float, required
- Complementary tax due to brazilian tax IOF.
- return_days : list, required
- List containing the number of days since the start reference date.
- service_fee : float, optional
- Eventual service fee. It is assumed to be an aliquot applied on the principal
The grossed up principal.
loan_calculator.grossup.iof_tax module¶
Calculate the Brazilian IOF tax on loan operations.
The IOF tax (Imposto sobre Operações de Crédito, Câmbio e Seguro ou relativas a Títulos ou Valores Mobiliários) is a Brazilian tax incident over many financial operations. In particular, they apply on loan operations, the borrower being either a legal or natural person. It is institutionalized by the law-decree Nº 6.306, from December 14th, 2007, as in its text.
This tax is composed by two parts: the tax over the principal and the tax over the amortizations.
- The IOF aliquot over amortizations is
- in proportion to the number of days since the loan was granted,
- in proportion to a fixed reduced aliquot with its value defined by law,
- limited to 1.5%.
The IOF aliquot over the principal, called the complementary IOF aliquot, is a fixed aliquot with its value defined by law.
-
loan_calculator.grossup.iof_tax.
amortization_iof
(amortization, num_days, daily_iof_aliquot=8.2e-05)[source]¶ IOF tax over amortization.
If \(A\) is the amortization, \(I^*\) is the daily IOF fee and \(n\) is the number of days since taxable event, then the due IOF tax over the amortization is
\[A\ \min(nI^*, 0.015).\]- amortization: float, required
- The amortization, i.e., principal payment, which is the basis for the amortization IOF tax.
- daily_iof_aliquot: float, required
- Aliquot applied over the amortization with its value define by law.
- num_days: int, required
- Number of days since the taxable event.
-
loan_calculator.grossup.iof_tax.
amortization_schedule_iof
(amortizations, return_days, daily_iof_aliquot=8.2e-05)[source]¶ IOF tax over an amortization schedule.
If \(A_1,A_2\ldots,A_k\) are the amortizations, \(n_1,n_2,\ldots,n_k\) the return days and \(I^*\) the daily IOF aliquot, then the due IOF tax is
\[\sum_{i=1}^k A_i \min(n_i I^*, 0.015).\]- amortizations: list, required
- Sequence of amortizations.
- return_days: list, required
- Sequence of assumed return days.
- daily_iof_aliquot: float, required
- The daily IOF aliquot, defined by law.
The due IOF tax on the amortizations in the given days.
-
loan_calculator.grossup.iof_tax.
complementary_iof
(principal, complementary_iof_fee=0.0038)[source]¶ Complementary IOF tax over the principal.
If \(s\) is the principal and \(I^{**}\) is the complementary IOF fee, then the due complementary IOF tax over the principal is
\[s\ I^{**}.\]- principal: float, required
- The loan principal, which is the basis for the complementary IOF tax.
- complementary_iof_fee: float, required
- Aliquot applied over the principal. Its value is defined by law.
-
loan_calculator.grossup.iof_tax.
loan_iof
(principal, amortizations, return_days, daily_iof_aliquot, complementary_iof_aliquot)[source]¶ The total IOF of a loan.
If \(s\) is the principal, \(A_i\) is the \(i\)-th amortization, \(n_1,\ldots,n_k\) are the return days, \(I^*\) is the daily IOF aliquot and \(I^{**}\) is the complementary IOF aliquot, then the loan IOF tax amount is
\[\mathrm{IOF}(s, I^*, I^{**}, (A_1,\ldots,A_k),(n_1,\ldots,n_k)) = sI^{**} + \sum_{i=1}^k A_i \min(n_i I^*,0.015)\]- principal: float, required
- Loan principal.
- amortizations: list, required
- List of floats providing the amortization due to each payment.
- return_days: list, required
- List of integers with the numbers of days since the loan was granted.
- daily_iof_aliquot: float, required
- Daily IOF aliquot. Its value is defined by law.
- complementary_iof_aliquot: float, required
- Complementary IOF aliquot. Its value is defined by law.