(C) Copyright 2020 Everysk Technologies, Inc. This is an unpublished work containing confidential and proprietary information of Everysk Technologies, Inc. Disclosure, use, or reproduction without authorization of Everysk Technologies, Inc is prohibited.
In what follows we present a technical description of our Brazilian pricing models. This manual is divided in 6 sections, namely: 1) description of underlying risk factors, 2) pricing formulas for various local fixed income, futures and derivatives; 3) Formulas for sensitivities that will be required in the risk models, 4) Formulas for parametric risk measures, 5) Formulas and examples for stress tests and 6) liquidity measures.
SECTION 1: RISK FACTORS
The first step of the process is the decomposition of each security into their underlying risk factors in order to compute how these factors interact with each other.
Risk factors that can be reliably utilized for forecasting need to be independent and identically distributed (i.i.d.). For example: nonoverlapping compounded returns rather than closing prices should be used as the risk factor for a stock. In what follows we describe why:
The scatterplot below shows the daily closing prices of a stock in the xaxis with the 1day lagged prices in the yaxis. In red, we plot the locationdispersion ellipsoid to represent the covariance between the samples. It can be seen that there is a very uneven amount of variance projected to the principal axis of the ellipsoid. The series of closing prices cannot be considered independent.
Conversely, the 1day lagged scatterplot of nonoverlapping compounded returns is shown below. The corresponding locationdispersion ellipsoid is almost a circle, indicating that compounded returns are independently distributed and can be used as a risk factor in forecasting. Whereas compound returns are used for stocks, fx and indices (lognormal), absolute variations in level are used as risk factors for rates and credit spreads (normal)
Primitive risk factors (PRF) used by Everysk include:
 USDBRL spot exchange rate
 Spot Ibovespa index
 Constant Maturity DI1xPRE: We calculate on a daily basis the following key rate duration points in the DI1xPRE curve (business days, basis 252): 1 month, 6months, 1 year, 5 years, 10 years, 30 years
 Constant Maturity DI1xDOL: We calculate on a daily basis the following key rate duration points in the DI1xDOL curve (running days, basis 360): 1 month, 6months, 1 year, 5 years, 10 years, 30 years
 Constant Maturity DI1xIPCA: We calculate on a daily basis the following maturity points in the DI1xIPCA curve (business days, basis 252 days): 1 month, 6months, 1 year, 5 years, 10 years, 30 years
 Constant Maturity Ibovespa carry: We calculate on a daily basis the following maturity points in the Ibovespa carry cost curve: 1 month, 6months, 1 year, 5 years, 10 years, 30 years
Everysk treats the percent changes of the first 2 PRFs as the invariants and the absolute changes of the others as invariants, as follows:
$$\hat{r} = \begin{array}{cccc} log(f_{i})  log(f_{i1})&& \forall \ i \ {\small{\text{samples}}}\\ \\f_{i}  f_{i1} && \forall \ i \ {\small{\text{samples}}} \end{array} $$
So, the logdifferences of historical samples of spot FX and the index are considered as the risk factor and outright differences of the historical samples are considered invariants for the rates.
Similar to other practitioners we use an exponentially weighted moving average (EWMA) of squared returns (or absolute level variations) as an estimate of volatility for the primitive risk factors. For example: if we observe daily returns from time %%tk%% to time %%t%%, we can describe the oneday variance estimate as :
$$ \sigma^{2} = \large \left[\frac{1\lambda}{1\lambda^{k+1}}\right] \sum_{i=0}^{k} \lambda^{i} \ r_{ti}^{2}$$
The %%\lambda%% parameter is designed to put more emphasis on more recent data and will be described below. When we assume two risk factors, the above formula takes into account the correlation:
$$ \Sigma_{ij} = \large \left[\frac{1\lambda}{1\lambda^{k+1}}\right] \sum_{i=0}^{k} \lambda^{i} \ r_{ti}^{j} \ r_{ti}^{j}$$
Here we have substituted the squared returns by the product between returns from each asset. If the assets move in the same direction, the 2 assets amplify their risk when together in a portfolio. If the assets move in opposite directions, they buffer risk. The formula above is effectively the same as:
$$\Sigma_{ij} = \large \rho_{ij} \ \sigma_{i} \ \sigma_{j} $$
The covariance matrix is just an assembly of all the crossvolatilities and correlations from the above formula.
The optimal level of decay (%% \lambda %%) in the formulas above is found by minimizing the mean squared errors between the forecasted volatility (variance) and the actual realized squared returns each day. Practitioners have found that 0.94 is a good estimate for daily volatility and 0.97 for monthly. Using a 0.94 decay puts 90% of the weight in the last 38 days of historical returns (%%log(0.10)/log(0.94)%%).
SECTION 2: PRICING FORMULAS
Before we describe the portfolio risk statistics in part 3, we need to provide a mapping between risk factors and pricing formulas. We start with pricing formulas for publicly issued fixed income:
2.1) NTNB:
This is an inflationlinked bond issued by the National Treasury with a face value of R$1000 that pays semiannual coupons of 6%, with inflation correction by the IPCA index (Broad consumer price index, published by IBGE):
$$ \large \text{PU} = \sum_{i=1}^{n} \frac{\text{\small{IPCA}}_{total} \times \text{VNE} \times \left[(1.06)^{0.5}1\right]}{(1+ytm)^{\frac{DU_{i}}{252}}} + \frac{\text{\small{IPCA}}_{total} \times \text{VNE} }{(1+ytm)^{\frac{DU_{T}}{252}}}$$
where:
 PU: unit price
 VNE: Face value at issuance  R$1000
 ytm: yield that is found by equating the present value of cashflows to the PU
 DU: business days between pricing date and event date (coupon, amortization, maturity)
 %%\text{\small{IPCA}}_{total}%% is the inflation adjustment that depends on the date that the bond is being priced as follows:
1) Bond being priced on a date falling between the last published IPCA and the 15th of the month:
$$\text{\small{IPCA}}_{total} = \large \frac{\text{IPCA}_{t1}}{\text{IPCA}_{0}} \ \times \left[\frac{\text{IPCA}_{t1}}{\text{IPCA}_{t2}}\right]^{\frac{DU_{1}}{DU_{2}}} $$
where %%\text{IPCA}_{0} %% is the value of the index prevailing in the month prior to the bond issuance and %%\text{IPCA}_{t1} %% is the value of the index prevailing on the month prior to the calculation date and %%\text{IPCA}_{t2} %% is the value prevailing 2 months prior to calculation date. %%DU_{1} / DU_{2}%% is the prorata number of days between last and current 15th of the month.
2) Bond being priced on the 15th of the month:
$$\text{\small{IPCA}}_{total} = \large \frac{\text{IPCA}_{t}}{\text{IPCA}_{0}}$$
where %%\text{IPCA}_{0} %% is the value of the index prevailing in the month prior to the bond issuance and %%\text{IPCA}_{t} %% is the value of the index prevailing on the calculation date (15th).
3) Bond being priced on a date falling between the 15th of the month and next IPCA to be published
$$\text{\small{IPCA}}_{total} = \large \frac{\text{IPCA}_{t1}}{\text{IPCA}_{0}} \ \times \left[1+\text{IPCA}_{proj}\right]^{\frac{DU_{1}}{DU_{2}}}$$
where %%\text{IPCA}_{0} %% is the value of the index prevailing in the month prior to the bond issuance and %%\text{IPCA}_{t1} %% is the value of the index prevailing prior to the calculation date and %%\text{IPCA}_{proj} %% is the projected IPCA, published by ANBIMA. %%DU_{1} / DU_{2}%% is the prorata number of days between last and current 15th of the month.
The %%ytm%% in the %%\text{PU}%% formula above is found by a bisection method to equate the present value of cashflows to a given market price. Because the market price is inflationadjusted, the resulting %%ytm%% is equivalent to discounting the cashflows by real rates.

2.2) NTNC:
This is an inflationlinked bond issued by the National Treasury with a face value of R$1000 that pays semiannual coupons of 12%, with inflation correction by the IGPM index (market price index, published by Fundaçāo Getulio Vargas):
$$ \text{PU} = \large \sum_{i=1}^{n} \frac{\text{\small{IGPM}}_{total} \times \text{VNE} \times \left[(1.12)^{0.5}1\right]}{(1+ytm)^{\frac{DU_{i}}{252}}} + \frac{\text{\small{IGPM}}_{total} \times \text{VNE} }{(1+ytm)^{\frac{DU_{T}}{252}}}$$
where %%\text{\small{IGPM}}_{total}%% is calculated depending on the date that the bond is being priced, as follows:
1) Bond being priced on a date falling between the last published IGPM and the 1st of the month:
$$\text{\small{IGPM}}_{total} = \large \frac{\text{IGPM}_{t1}}{\text{IGPM}_{0}} \ \times \left[\frac{\text{IGPM}_{t}}{\text{IGPM}_{t1}}\right]^{\frac{DU_{1}}{DU_{2}}} $$
where %%\text{IGPM}_{0} %% is the value of the index prevailing in the month prior to the bond issuance and %%\text{IGPM}_{t1} %% is the value of the index prevailing on the month prior to the calculation date and %%\text{IGPM}_{t} %% is the value prevailing on the calculation date. %%DU_{1} %% represents the number of days between the first of the month to calculation date and %%DU_{2}%% is the number of days between the first day of the last month and current 1st of the month.
2) Bond being priced on the 1st of the month:
$$\text{\small{IGPM}}_{total} = \large \frac{\text{IGPM}_{t}}{\text{IGPM}_{0}}$$
3) Bond being priced on a date falling between the 1st of the month and next IGPM to be published
$$\text{\small{IPCA}}_{total} = \large \frac{\text{IGPM}_{t1}}{\text{IGPM}_{0}} \ \times \left[1+\text{IGPM}_{proj}\right]^{\frac{DU_{1}}{DU_{2}}}$$
where %%\text{IGPM}_{0} %% is the value of the index prevailing in the month prior to the bond issuance and %%\text{IGPM}_{t1} %% is the value of the index prevailing on the prior month and %%\text{IGPM}_{proj} %% is the value of the index forecasted by ANBIMA. %%DU_{1}%% represents the number of days from the first day of prior month and calculation date. %%DU_{2}%% is number of days between current and next 1st of the month.

2.3) NTNF:
This is an nominal bond issued by the National Treasury with a face value of R$1000 that pays semiannual coupons of 10%:
$$ \text{PU} = \large \sum_{i=1}^{n} \frac{ \text{VNE} \times \left[(1.10)^{0.5}1\right]}{(1+ytm)^{\frac{DU_{i}}{252}}} + \frac{ \text{VNE} }{(1+ytm)^{\frac{DU_{T}}{252}}}$$
where:
 PU: unit price
 VNE: Face value at issuance  R$1000
 ytm: yield that is found by equating the present value of cashflows to the PU
 DU: business days between pricing date and event date (coupon, amortization, maturity)

2.4) LTN:
This is a zero coupon bond issued by the National Treasury with face value of R$1000.
$$ \text{PU} = \large \frac{ \text{VNE} }{(1+ytm)^{\frac{DU_{T}}{252}}}$$
where:
 PU: unit price
 VNE: Face value at issuance  R$1000
 ytm: yield that is found by equating the present value of payout at maturity to the PU
 %%DU_{T}%%: business days between pricing date and maturity

2.5) LFT
This is a zero coupon floating bond issued by the National Treasury with face value of R$1000.
$$\text{PU} = \large \frac{ \text{VNE} \ \times \prod_{i=1}^{DU} \left[ (1+selic_{i})^{\frac{1}{252}}\right]}{(1+ytm)^{\frac{DU_{T}}{252}}}$$
where:
 PU: unit price
 VNE: Face value at issuance  R$1000
 ytm: yield that is found by equating the present value of payout at maturity to the PU
 %%DU_{T}%%: business days between pricing date and maturity
 selic: 100% of the inter bank rate accrued from issuance to calculation date

And privately issued fixed income:
Formulas below assume the most generic case of amortizing principal:
$$ \text{\small{VNA}}_{i} = \large \text{\small{VNE}} \times \left[1 \sum_{t=0}^{i1} \small{\text{Amort}}_{t}\right] $$
where %%\text{Amort}_{i}%% are principal amortizations as percent of VNE. The initial VNA for calculating the bonds below, takes into account all the amortizations that occurred from issuance to the pricing date.
2.6) Debentures paying percent of DI (interbank deposit rates):
These debentures pay a percent (pct) of projected DI. The forwards are built using forward DI contracts at specific vertices.
$$ \text{PU} = \large \sum_{i=1}^{n} \frac{\text{\small{VNA}}_{i1} \times \text{cpn}_{i} + \left[\text{\small{VNA}}_{i1}  \text{\small{VNA}}_{i}\right] }{(1+ytm)^{\frac{DU_{i}}{252}}}$$
where:
For first coupon
$$ \text{cpn}_{1} = \large \left[\prod_{i=1}^{n} \left[1+\left[(1+\text{\small{DI1}}_{i})^{\frac{1}{252}} 1 \right] \times pct \right] \right]\times \left[ 1+\left[(1+fwd_{1})^{\frac{1}{252}}1\right]\times pct\right]^{DU_{1}} $$
where %%DI1%% is accrued from issuance to calculation date, and remaining coupons:
$$ \text{cpn}_{2 \dots n} = \large \frac{\left[ 1+\left[(1+fwd_{i})^{\frac{1}{252}}1\right]\times pct\right]^{DU_{i}}}{\left[ 1+\left[(1+fwd_{i1})^{\frac{1}{252}}1\right]\times pct\right]^{DU_{i1}}}$$

2.7) Debentures paying DI + spread:
These debentures pay a spread over projected DI. The forwards are built using forward DI contracts at specific vertices.
$$\text{PU} = \large \sum_{i=1}^{n} \frac{\text{\small{VNA}}_{i1} \times \text{cpn}_{i} + \left[\text{\small{VNA}}_{i1}  \text{\small{VNA}}_{i}\right] }{(1+ytm)^{\frac{DU_{i}}{252}}}$$
For first coupon:
$$ \text{cpn}_{1} = \large \left[\prod_{i=1}^{n} (1+\text{\small{DI1}}_{i})^{\frac{1}{252}}\right]\times (1+\text{spread})^{\frac{{DU}_{1}}{252}}$$
For remaining coupons:
$$ \text{cpn}_{2 \dots n} = \large (1+\text{spread})^{\frac{{DU}_{i}}{252}}$$

2.8) Debentures paying IPCA + spread:
These bonds pay a coupon and principal amortizations that are inflation adjusted with IPCA:
$$\text{PU} = \large \sum_{i=1}^{n} \frac{\text{\small{IPCA}}_{total} \times \left[\left[\text{VNA}_{i1} \ \times (1+ \text{spread})^{\frac{DU_{i}}{252}}\right] + \left[\text{VNA}_{i1}  \text{VNA}_{i1}\right]\right]}{(1+ytm)^{\frac{DU_{i}}{252}}} $$
where %%\text{\small{IPCA}}_{total}%% is computed similarly than NTNB above.

2.9) CRA paying DI + spread:
Pricing is very similar to debentures paying DI + spread. The only difference here is that because this is a securitized bond, it contains an offset for coupon payment that affects the first coupon as follows:
$$\text{cpn}_{1} = \large \left[\prod_{i=\text{def}}^{n} (1+\text{\small{DI1}}_{i})^{\frac{1}{252}}\right]\times \left[(1+fwd_{1})^{\frac{(DU_{1}\text{def})}{252}}\ \times(1+\text{spread})^{\frac{{DU}_{1}}{252}}\right]$$
where %%\bold{def}%% is the offset in days defined in the terms of the securitization.

2.10) CRA paying percent of DI:
Pricing is very similar to debentures paying a percent of DI. The only difference here is that because this is a securitized bond, it contains an offset for coupon payment that affects the first coupon as follows:
$$ \text{cpn}_{1} = \large \left[\prod_{i=\bold{\text{def}}}^{n} \left[1+\left[(1+\text{\small{DI1}}_{i})^{\frac{1}{252}} 1 \right] \times pct \right] \right]\times \left[ 1+\left[(1+fwd_{1})^{\frac{1}{252}}1\right]\times pct\right]^{(DU_{1}\text{def})}$$
where %%\bold{def}%% is the offset in days defined in the terms of the securitization.
2.11) DI1 Futures:
This cash settled future pays the capitalized daily Interbank Deposit (DI) rates verified on the period between the trading day, including, and the last trading day, including.
It's PU is:
$$\text{PU} = \large \frac{ \text{100000} }{(1+\text{rate})^{\frac{DU_{T}}{252}}}$$
where:
 PU: unit price
 rate: quoted rate
 %%DU_{T}%%: business days between pricing date and expiration of the contract
The multiplier for the contract is BRL 1.00

2.12) DDI Futures:
This cash settled future pays the difference between the capitalized daily Interbank Deposit (DI) rates and the FX variation verified on the period between the trading day, including, and the last trading day, including.
It's PU is:
$$\text{PU} = \large \frac{ \text{100000} }{(1+\text{CC} \times \frac{DC_{T}}{360})}$$
where:
 PU: unit price
 CC: quoted "coupon cambial"
 %%DC_{T}%%: running days between pricing date and expiration of the contract
and:
$$\text{CC} = \left[\frac{ \text{PTAX}_{T} }{\text{PTAX}_{0}} \times {(1+\text{rate})^{\frac{DU_{T}}{252}}}  1 \right] \times \frac{360}{DC_{T}}$$
 %%\text{PTAX}_{0}%%: spot exchange rate of Brazilian reais for US dollars, offer side, as quoted by the Brazilian Central Bank (Bacen)
 %%\text{PTAX}_{T}%%: forward exchange rate of Brazilian reais for US dollars as per FX futures contract
 rate: daily Interbank Deposit (DI) rates as per DI1 futures
The multiplier for the contract is USD 0.50

2.13) IND / WIN Futures:
These cash settled futures pay the price appreciation/depreciation of the Ibovespa index. The only difference between the contracts are the multipliers: BRL 1.00 for IND and BRL 0.20 for the WIN contract.
It's PU is:
$$\large \text{PU}_t = \text{BVSP}_{0} \times \frac{\text{PU}_{c\_bvsp}}{\text{PU}_{di1}} = \text{BVSP}_{0} \times \frac{(1+\text{rate})^{\frac{DU_{T}}{252}}}{(1+\text{c\_bvsp} \times \frac{DC_{T}}{360})}$$
where:
 %%\text{BVSP}_{0} %% is the spot Ibovespa
 %%\text{c\_bvsp} %% is the carry cost for the index
 %%\text{rate}%% is the oneday interbank for the period

2.14) ISP / WSP Futures:
These cash settled futures pay the price appreciation/depreciation of the SP500 index in Reais. The only difference between the contracts are the multipliers: USD 50.00 for ISP and USD 2.50 for the WSP contract.

2.14) DOL / WDO Futures:
These cash settled futures pay the difference between a USD settlement at a preagreed rate and the FX at expiration. The contract size is USD 50,000 and the mini contract, WDO, controls USD 10,000
$$\large \text{PU}_t = \text{PTAX}_{0} \times \frac{\text{PU}_{ddi}}{\text{PU}_{di1}} = \text{PTAX}_{0} \times \frac{(1+\text{rate})^{\frac{DU_{T}}{252}}}{(1+\text{CC} \times \frac{DC_{T}}{360})}$$
where:
 %%\text{PTAX}_{0} %% is the spot PTAX
 %%\text{CC} %% is the "coupon cambial"
 %%\text{rate}%% is the oneday interbank for the period

2.15) DAP Futures:
These cash settled futures pay the spread between the compounded DI rate, in the period between the calculation date, including, and the expiration date, excluding, and the IPCA variation verified in the period as of the calculation date until and including the expiration date. It compensates buyers from inflation erosion, paying a real interest rate.
$$\large \text{PU} = \frac{\text{100000}}{(1+\text{spread}_{\small{\text{DI1xIPCA}}})^{\frac{DU_{T}}{252}}}$$

The multiplier for this contract is BRL 0.00025.
2.16) Stock options:
Stock options are priced with the Black and Scholes equation:
$$ \large \text{PU} = \psi \ S \ \Phi (\psi \ d_1)  \psi \ K * e^{r(\text{T}t)} * \Phi (\psi [ d_1  \sigma \sqrt{\text{T}t}])$$
where
$$ \large d_1 = \frac{ln(S/K)+(r+0.5\overline{\sigma}^2)(Tt)}{\sigma\sqrt{\text{T}t}}$$
and: %%\Phi %% is cumulative function for a normal distribution and %%\psi %% is an indicator function equal to one for calls and 1 for puts

Options are converted to an equivalent delta, %%\Phi (\psi \ d_1)%%, of the underlying stock for purposes of calculating exposures to primitive risk factors (see section 4 below).
2.17) IDI options:
IDI options are priced with the Black 76 equation:
$$\large \text{PU} = (1 + \text{DI1})^{\frac{\text{DU}}{252}} \left[ \psi \ F \ \Phi (\psi \ d_1)  \psi \ K \Phi (\psi [ d_1  \sigma \sqrt{\text{T}t}]\right]$$
$$ \large d_1 = \frac{ln(F/K)+(r+0.5\overline{\sigma}^2)(Tt)}{\sigma\sqrt{\text{T}t}}$$
And the forward is:
$$ \large F = \text{IDI}_{t} \times (1 + \text{DI1})^{\frac{\text{DU}}{252}} $$
where: %% \text{IDI}_{t} %% is the spot DI index published by BMF, %%\Phi %% is the cumulative function for a normal distribution and %%\psi %% is an indicator function equal to one for calls and 1 for puts

Other pricing formulas including offshore instruments can be found in our white paper. More symbology examples can be found in symbology.
SECTION 3: SENSITIVITY MEASURES
We compute various sensitivity measures that are needed for parametric VaR and stress tests, namely:
3.1) MACAULAY DURATION:
$$ \text{Macaulay Duration} = \large \frac{\sum_{i=1}^{n} \ ({\text{CF}_{i} }/{DF_{i}}) \times DU_{i}}{Price} $$
%%\bold{CF}%% are the periodic bond cashflows, described in the previous chapter. %%\bold{DF}%% are the discount factors used to present value cashflows. For example, for the NTNB bond, the calculation of duration in fractional years:
$$\frac{\left[\sum_{i=1}^{n} \frac{\text{\small{IPCA}}_{total} \times \text{VNE} \times \left[(1.06)^{0.5}1\right]}{(1+ytm)^{\frac{DU_{i}}{252}}} \times \text{DU}_{i} \right] + \left[\frac{\text{\small{IPCA}}_{total} \times \text{VNE} }{(1+ytm)^{\frac{DU_{T}}{252}}} \times \text{DU}_{T}\right]}{(\text{PU} \times 252)}$$
3.2) MODIFIED DURATION:
$$\text{Modified Duration} = \large \frac{\small{\text{Macaulay Duration}}}{(1+\frac{\text{ytm}}{n})}$$
where:
 n is the number of cashflows
 ytm is the yield to maturity of the bond
3.3) EFFECTIVE DURATION:
$$ \text{Effective Duration} = \large \frac{\text{P}_{\Delta \text{yield}}\text{P}_{+\Delta \text{yield}}}{2\text{P}\Delta_{\text{yield}}}$$
where the shift in yield, %%\Delta_{\text{yield}}%% is +1% for calculations. For a NTNF, the formula for PU becomes:
$$\text{PU}_{\Delta} = \large \sum_{i=1}^{n} \frac{ \text{VNE} \times \left[(1.10)^{0.5}1\right]}{(1+ytm+\Delta)^{\frac{DU_{i}}{252}}} + \frac{ \text{VNE} }{(1+ytm+\Delta)^{\frac{DU_{T}}{252}}}$$
3.4) CONVEXITY:
$$ \text{Convexity} = \large \frac{\text{P}_{\Delta \text{yield}} 2 \text{P} + \text{P}_{+\Delta \text{yield}}}{\overline{\Delta_{\text{yield}}}^{2}} $$
SECTION 4: RISK MEASURES
4.1) PARAMETRIC VAR
The calculation of parametric VaR requires 2 main steps, namely: a) calculation of portfolio's sensitivities to various primitive risk factors; and b) the risk of those primitive risk factors and how they comove. Let's start describing how the profit and loss (P&L) of a single security changes with changes in risk factors. For illustration purposes, lets assume that the security depends on a single risk factor:
$$ \text{P\&L} = \large \frac{\partial P}{\partial \text{f}} \ \Delta \text{f}$$
where %%\frac{\partial P}{\partial \text{f}}%% is the sensitivity of price %%\bold{P}%% to changes in the risk factor %%\bold{f}%%. If a security depends on multiple risk factors:
$$ \text{P\&L} = \large \sum_{i=0}^{n}\frac{\partial P}{\partial \text{f}_{i}} \ \Delta \text{f}_{i} $$
Or in matrix format:
$$ \text{P\&L} = \large \widetilde{P}^{T} \ \ \widetilde{f} $$
The equation above can be stated as the internal product of a vector of sensitivities (delta equivalents) and primitive risk factor returns. The portfolio P&L is obtained by simply adding the individual security P&Ls.
FROM P&L DISTRIBUTION TO VaR
The main objective of a parametric approach to VaR is to generate a distribution of P&L without the need of simulations and then infer statistical properties from the distribution. Because primitive risk factors are normally distributed and any linear combination of a normal distribution preserves normality (parametric model linearizes the relationship between risk factors and price variation), a reasonable P&L distribution can be drawn from the following normal distribution:
$$ \text{P\&L} \sim \large N(0 \ , \ \widetilde{P}^{T} \ \Sigma \ \widetilde{P}) $$
To calculate VaR using the parametric approach, we simply note that VaR is always a multiple of the standard deviation for a normal distribution:
$$ \text{VaR} = \large 1.64 \times \sqrt{\widetilde{P}^{T} \ \Sigma \ \widetilde{P}} \times \sqrt{T} $$
The above equation measures the "T" horizon value at risk with 95% confidence (1.64 is the 95% percentile)
Let's work an example from beginning to end, demonstrating how the parametric VaR is calculated. Assume we have a portfolio with BRL 3M in market value that holds BRL 1M worth of PETR4 stock, BRL 1M of NTNB, expiring on may 2035 and BRL 1M of LTN expiring on July 2022. The prices and quantities are as follows:
PETR4  LTN 2022  NTNB 2035  
Price (BRL)  20.25  930.30  4205.24 
Quantity  49382.72  1074.92  237.79 
Market Value (BRL)  1M  1M  1M 
This 3asset portfolio would contain 5 risk factors, namely:
 Petrobras returns
 2 constant maturity nominal rate durations: 1 and 5 years
 2 constant maturity real rate durations: 10 and 30 years
The vector of total portfolio sensitivities, %%\widetilde{P}%%, would be (columns are assets and rows are primitive risk factors):
PETR4  LTN 2022  NTNB 2035  %%\widetilde{P}%%  
PETR4  R$ 1,000,000  0  0  R$ 1,000,000 
1 year DIxPRE  0  R$ 830,000  0  R$ 830,000 
5 year DIxPRE  0  R$ 850,000  0  R$ 850,000 
10 year DIxIPCA  0  0  R$ 9,900,000  R$ 9,900,000 
30 year DIxIPCA  0  0  R$ 300,000  R$ 300,000 
Assume the duration of the bond in years is %% \small D %%, falling between 2 key rates durations, %% \small T_1 %% and %% \small T_2 %%. The linear interpolation is calculated as %% \alpha * \text{rate}_{T1} +(1\alpha) * \text{rate}_{T2}%%.
If the duration of the LTN is 1.68 years:
$$ \alpha = \frac{(T_2D)}{(T_2T_1)} = \frac{(5.01.68)}{(5.01.0)} = 83\%$$
We will map 83% of the $1M LTN to a constant maturity 1 year nominal rate and 17% to a 5 year. The entries in the sensitivity matrix are:
 R$ 830,000 = 1074.92(quantity) * R$ 930.30 (unit price) * 1 (sensitivity) * 83% (blend mapping) and
 R$ 850,000 = 1074.92(quantity) * R$ 930.30 (unit price) * 5 (sensitivity) * 17% (blend mapping).
(*) The sensitivities of the constant maturities in the example above, 1 and 5, are simplified for illustrative purposes. Please refer to Appendix A for a more detailed explanation.
If the duration of the NTNB is 10.20 years
$$ \alpha = \frac{(T_2D)}{(T_2T_1)} = \frac{(30.010.2)}{(30.010.0)} = 99\%$$
We will map 99% of the $1M NTNB to a constant maturity 10 year real rate and 1% to a 30 year. The entries in the sensitivity matrix are:
 R$ 9,900,000 = 237.79(quantity) * R$ 4205.24 (unit price) * 10 (sensitivity) * 99% (blend mapping) and
 R$ 300,000 = 237.79(quantity) * R$ 4205.24 (unit price) * 30 (sensitivity) * 1% (blend mapping).
The negative signs indicate the the price of the bond is inversely related to rates. If the absolute level of rates contract, the bond appreciates.
Those individual sensitivities are joined via the covariance of primitive risk factors, %%\Sigma_{f}%%, which takes into account the correlations and variances.
The correlation using the returns from the risk factors and EWMA decay is :
PETR4  1 year DIxPRE 
5 year DIxPRE 
10 year DIxIPCA 
30 year DIxIPCA 

PETR4  1.00  0.28  0.37  0.49  0.47 
1 year DIxPRE  0.28  1.00  0.75  0.51  0.46 
5 year DIxPRE  0.37  0.75  1.00  0.85  0.77 
10 year DIxIPCA  0.49  0.51  0.85  1.00  0.91 
30 year DIxIPCA  0.47  0.46  0.77  0.91  1.00 
PETR4  1 year DIxPRE 
5 year DIxPRE 
10 year DIxIPCA 
30 year DIxIPCA 

Volatilities  4.70%  0.10%  0.21%  0.12%  0.11% 
4.2) COMPONENT VAR
Another important measure for portfolio risk management is component VaR. In the context of parametric models, it measures the changes in portfolio VaR to changes in the factor exposures. The formula is:
$$ \text{ComponentVaR} = \left[ \begin{array}{cccc} R\$ \ 75,160.16 && R\$ \ 2,219.57 && R\$ \ 13,617.25\end{array}\right]$$
4.2) INCREMENTAL VAR
$$ \text{P\&L} = \large \widetilde{P}^{T} \ \ \widetilde{f} $$
If %%\widetilde{P}^{T}%% is a vector with dimensions %%1 \times m%%, where m is the number of primitive risk factors. %%\widetilde{f}%% is a matrix of dimensions %%m \times n%% with risk factor returns where the rows are factors and columns are historical dates going back %%\bold{n}%% days.
$$ \large \text{E}\left[\text{P\&L} \  \ \text{P\&L}>\text{VaR}\right]$$
PETR4  LTN 2022  NTNB 2035  %%\widetilde{P}%%  
IBOV  R$ 1,260,000  0  0  R$ 1,260,000 
1 year DIxPRE  0  R$ 830,000  0  R$ 830,000 
5 year DIxPRE  0  R$ 850,000  0  R$ 850,000 
10 year DIxIPCA  0  0  R$ 9,900,000  R$ 9,900,000 
30 year DIxIPCA  0  0  R$ 300,000  R$ 300,000 
5.1) B3 SHOCK MATRIX
1. Retrieve the bearish and bullish shocks for the 5 primitive risk factors from our example, namely: [IBOV, 1YR DIxPRE, 5YR DIxPRE, 10YR DIxIPCA , 30YR DIxIPCA]:
[(32.4%, 27.6%), (2.74%, 3.6%), (2.74%, 3.6%), (1.68%, 1.85%), (1.68%, 1.85%)]
Where each tuple is a bearish and bullish scenario.
2. Then perform the cartesian product of these tuples, generating 32 (%%2^5%%)combinations (in a real example the combinations are much higher):
Combination 1: [32.4%, 2.74%, 2.74%, 1.68%, 1.68%]
Combination 2: [32.4%, 2.74%, 2.74%, 1.68%, 1.85%]
...
Combination 32: [27.6%, 3.6%, 3.6%, 1.85%, 1.85%]
3. Finally we compute 32 P&Ls resulting from the internal product of portfolio sensitivities and each combination above:
$$\begin{array}{ccc} \text{PL}_{st} = \left[R\$ 1,260,000 \  R\$ 830,000 \  R\$ \ 850,000 \  R\$ \ 9,900,000 \  R\$ \ 300,000 \right] \times \\ \\ \\ \\\left[ \begin{array}{cccc} 32.4\% && \dots && +27.6\% \\ 2.74\% && \dots &&+3.6\%\\ 2.74\% && \dots &&+3.6\%\\ 1.68\%&& \dots &&+1.85\%\\ 1.68\% &&\dots && +1.85\%\end{array}\right]\end{array}$$
where the first matrix of dimensions %% 1 \times 5 %% are the portfolio sensitivities to the Ibovespa, the 1 and 5 year real rates, and the 10 and 30 year nominal rates, in that order. The second matrix with dimensions %%5 \times 32%% represent all the combinations of B3 shocks for this portfolio.
The matrix multiplication results on a vector of 32 P&Ls that can expressed as a percentage of portfolio NAV:
$$\text{PL}_{st} = \left[6.36\% , \ \dots \ ,\ +3.28\% \right]$$
The largest negative P&L is used as the final result. Certain combinations that might generate large negative P&Ls might have low probability to occur.
Our example above is simple (only 32 combinations) because only 5 primitive risk factors were affected. The schematic below shows the vector of expected P&Ls for each B3 shock, bearish shocks in the left and bullish shocks in the right. The bars are split in areas: the first is for the 2 spot shocks (USDBRL and Ibovespa), then there are 16 constant maturity entries for DIxPRE shocks (1 day, 1 month, 3 months,...., 40 years), 16 for DIxDOL and 16 for DIxIPCA. The numbered gray boxes indicate the only expected PLs that are non zero for our illustrative example:
Because we don't know beforehand if a bullish or bearish shock will be more detrimental to the portfolio, we need to find the worst combination. There are 32 such combinations where bear/bull shocks are alternated: [1,3,5,7,9] is the first, then [1,3,5,7,10] and so forth.
In a complex portfolio, many risk factors might be affected yielding an unreasonable amount of combinations. Everysk uses a simplifying clustering as follows:
 We combine the short term PLs (<= 1 year) for each curve (DIxPRE, DIxDOL, DIxIPCA) into a single PL
 Similarly we combine the long term PLs (> 1 year) for each curve
We then have 16 PLs (8 bear and 8 bull), namely: USDBRL, IBOV, Short term DIxPRE, Long term DIxPRE, ... , Short term DIxIPCA, Long term DIxIPCA. There are 256 combinations of 8 elements from those 16, whereby a bear and bull for the same factor, IBOV for example, cannot both appear in the same combination (%%256 = 2^{8}%%).
This simple clustering drastically reduces the complexity of the problem without compromising the stress test: we still can reflect a portfolio that is positioned for a curve steepening or flattening, for example.
5.2) HISTORICAL STRESS TESTS
Historical stress tests are designed to probe adverse historical market events in order to model how the current portfolio might withstand similar situations in the future. For example: in general when risky assets like the Ibovespa index decline, there is a flight to quality and rates contract (prices of fixed income assets go up).
Therefore, rates spreads and the index are positively correlated. Sometimes though, this correlation breaks: more recently in midJanuary 2020 the IBovespa declined 45% and instead of experiencing a contraction, the 10 year constant maturity point of the curve widened. Bonds and the index both declined, offering no diversification when together in a portfolio:
From mid January to mid March 2020, the IBovespa experienced a 46% decline:
During the same period, other primitive risk factors affecting our illustrative portfolio also widened as per graphs below:
The moves are summarized in the table below:
01/15/20  03/23/20  Shock  Shock type  
IBOV  116,414  63,570  45.39%  percent 
1 year DIxPRE  4.40%  4.04%  0.36%  absolute 
5 year DIxPRE  6.31%  8.78%  +2.47%  absolute 
10 year DIxIPCA  3.30%  4.86%  +1.56%  absolute 
30 year DIxIPCA  3.62%  5.24%  +1.62%  absolute 
This historical scenario above would be very detrimental to our illustrative portfolio with 3 assets, Petrobras, LTN and NTNB as follows:
When evaluating the effect of historical stress tests that span a period of many months (or years), users should be careful when drawing direct comparisons with a B3 shock, projected from 1 to 10 days.
SECTION 6: LIQUIDITY
ASSET LIQUIDITY:
Everysk calculates what percentage of portfolio can be unwound at various userdefined liquidity vertices. The process has two steps. namely: 1) the days to unwind (DTU) is calculated for each security; and 2) the market value of the security is bucketed on the closest liquidity vertex greater or equal than the DTU:
For example: In the schematic above it takes 15 days to unwind (see formulas below) a security with BRL 1M in market value. That amount would be bucketed in the next liquidity vertex, 21 days.
DTU Calculations:
6.1) Equity
The days to unwind is calculated as:
$$ \text{DTU} = \large \frac{\text{quantity}}{\text{participation} \times \text{ADTV}} $$
where:
 quantity is the number of shares held in the portfolio
 ADTV is the average daily trading volume computed in a window of Xdays, where X can be specified by user and defaults to 20 days.
 participation is a percent of total volume assumed to be available to unwind the position in full. Can be specified by user and defaults to 20%
6.2) Public Bonds
The days to unwind is calculated as:
$$ \text{DTU} = \large \frac{\text{quantity}}{\text{participation} \times \text{ADTV}} $$
where:
 quantity is the number of bonds held in the portfolio
 ADTV is the average daily trading volume computed in a window of Xdays, where X can be specified by user and defaults to 20 days. ADTV published by Brazilian Central Bank on a daily basis
 participation is a percent of total volume assumed to be available to unwind the position in full. Can be specified by user and defaults to 10%
6.3) Debentures
Liquidity for debentures is based on traded volume. If a debenture hardly trades (definition of threshold below), then Everysk uses cashflow events and reduces the amount paid by the reductions published by ANBIMA:
For liquid debentures (at least 20 bonds traded on a 20 day window, i.e. averaging one trade a day), Everysk uses the average volume information instead of a liquidity reduction:
$$ \text{DTU} = \large \frac{\text{quantity}}{\text{participation} \times \text{ADTV}} $$
FLIQ1 = FLIQ2 = 0%
For illiquid debentures (less than 20 bonds traded on a 20 day window, i.e. averaging less than one trade a day), Everysk uses the maturity in fractional years times 252 days:
$$ \text{DTU} = \large \text{DU}_{T} \times 252 $$
And the amount of cash generated is multiplied by the liquidity reduction
$$\large \text{CF}_{T} \times (1\text{FLIQ1}) \times (1\text{FLIQ2})$$
Except for some Debentures (currently around 60) that have FLIQ2=50%, all others are considered with FLIQ2=0%
6.4) Funds
Supplied by user as a lookup between the fund CNPJ (EIN) and days to unwind
Mapping to a liquidity vertex:
Assume that a position of $1M in a security can be unwound in 6.8 days (DTU=6.8 calculated as per above) and the vertices are 1,5,21,42,63,126, 252 and 252+ days. Further assume that the portfolio has $2M net asset value, the row corresponding to this security in the liquidity vector would be:
1d  5d  21d  42d  63d  126d  252d  252+ 
0%  0%  50%  50%  50%  50%  50%  50% 
Thus, 50% of portfolio can be unwound in 21 days or longer, which is the nearest vertex greater or equal to 6.8 days. If the other $1M was represented by an illiquid debenture, with maturity in 5 years, the total liquidity matrix would be:
1d  5d  21d  42d  63d  126d  252d  252+  
liquid  0%  0%  50%  50%  50%  50%  50%  50% 
illiquid  0%  0%  0%  0%  0%  0%  0%  25% 
Total  0%  0%  50%  50%  50%  50%  50%  75% 
The 25% for the illiquid asset takes into account the liquidity reduction of 50% for FLIQ1 and 0% for FLIQ2 as follows:
$$ \frac{\text{CF}_{i} \times (1\text{FLIQ1}) \times (1\text{FLIQ2})}{\text{NAV}} = \frac{\$ 1\text{M} \times (10.5) \times (1 0.0)}{\$2\text{M}} = 25\%$$
LIABILITY PROJECTIONS:
On the liability side we use historical redemption statistics to compute daily net redemptions (redemption minus contribution) as a percent of the portfolio's net asset value  NAV ("Patrimonio Liquido") of the fund from prior date:
$$ \text{Net Redemption}_{i} = \large \frac{\text{redemptions}_{i}\text{subscriptions}_{i}}{\text{NAV}_{i1}}$$
Then, we compute various averages going back: 5 days, 21 days and the other vertices we used in the asset side liquidity:
$$ \text{ANRV}_{5d} = \large \frac{1}{5} \ \times \sum_{i=today5}^{today}\frac{\text{redemptions}_{i}\text{subscriptions}_{i}}{\text{NAV}_{i1}}$$
Finally the values that are used in the vertices are the cumulative sums of average redemptions to that point, so the redemption at the 21 days includes all the redemptions as a percent of NAV for 5 days and 21 days and so forth.
ASSETLIABILITY COVERAGE:
Once we have calculated the liquidity in the portfolio at various vertices (1d,5d,21d,...) and redemption forecasts in the same vertices, we can compute the assetliability coverage on each vertex:
$$\large \text{Coverage}_{5d} = \large \text{Liquidity}_{5d}\text{Projected Redemptions}_{5d}$$
Appendix A: Factor sensitivities
The Macaulay duration of a zero coupon synthetic instrument is used to measure the sensitivity of each constant maturity vertex. Caution is required to properly compute the sensitivity of compounded rates (PRE and IPCA) and linear rates (DOL):
For compounded rates, the sensitivity of the node is simply:
$$\frac{\text{T}_{d}}{(1+\text{r}_{t})}$$
where %%\text{T}_{d}%% is fractional year to the vertex using business days in the domestic calendar and 252 basis. %%\text{r}_{t} %% is the flat forward exponentially interpolated rate on that vertex.
For linear rates the sensitivity of the node is simply:
$$\frac{\text{T}_{f}}{(1+\text{T}_{f} \times\text{r}_{f})}$$
where %%\text{T}_{f}%% is fractional year to the vertex using business days in the foreign calendar and 360 basis. %%\text{r}_{f} %% is the flat forward linearly interpolated rate on that vertex.
The sensitivity of a security that does not have any coupons and settles at a constant maturity vertex, a future contract for example, should coincide with the sensitivity of that vertex. We will analyze a dollar future because it has exposures both to a compounded rate (domestic interbank rate) and a linear rate ("coupon cambial"). Assuming a generic formula:
$$P(S,r_{d},r_{f}) = S_{0} \ \frac{(1+\text{r}_{d})^{t_{d}}}{(1+\text{t}_{f} \times\text{r}_{f})}$$
The sensitivities are:
$$dP = \frac{\partial P}{\partial S} dS + \frac{\partial P}{\partial r_{d}} dr_{d} + \frac{\partial P}{\partial r_{f}} dr_{f}$$
which after some algebraic manipulation yields:
$$dP = P(S,r_{d},r_{f}) \frac{1}{S} dS + P(S,r_{d},r_{f}) \left[\frac{\text{t}_{d}}{(1+\text{r}_{d})}\right] dr_{d} +P(S,r_{d},r_{f}) \left[\frac{\text{t}_{f}}{(1+\text{t}_{f}\text{r}_{f})}\right] dr_{f} $$
The terms in brackets above represent the duration in the domestic market (PRE) and the duration in the foreign market (COUPON CAMBIAL), which coincide with the formulas above.
For a DI1 future, the price and sensitivities are:
$$P(r_{d}) =\frac{1}{(1+\text{r}_{d})^{t_{d}}}$$
and:
$$dP =\frac{\partial P}{\partial r_{d}} dr_{d} = P(r_{d}) \left[\frac{\text{t}_{d}}{(1+\text{r}_{d})}\right] dr_{d} $$
Appendix B: Factor rate or price volatilities
The first formula below illustrates a portfolio volatility, %%\sqrt{\widetilde{P}^{T} \ \Sigma \ \widetilde{P}} %%, computed when rate volatilities are used. The vectors %%\widetilde{P}%% already contain the durations of key vertices in each curve (as per Appendix A).
Conversely the second formula measures the price deviations of key vertices using zero coupons. Therefore the factor volatilities, %%\sigma^{*}%%, contain the durations (%%\Delta%%). The vectors that multiply the covariance are pure financial exposures.
Both approaches are equivalent:
$$\begin{array}{llll} \sqrt{\widetilde{P}^{T} \ \Sigma \ \widetilde{P}} = && \sqrt{\left[ \Delta_{1} F_{1} \ \ \ \ \ \ \Delta_{2} F_{2}\right] \times\left[ \begin{array}{cccc} \sigma_{1}^{2} && 0\\ \\ 0 && \sigma_{2}^{2} \end{array}\right]\times\left[ \begin{array}{cccc} \Delta_{1} F_{1}\\ \\ \Delta_{2} F_{2}\end{array}\right]} \\ \\ \\ \sqrt{\widetilde{P}^{*T} \ \Sigma \ \widetilde{P}^{*}} = &&\sqrt{\left[ F_{1} \ \ \ \ \ \ F_{2}\right] \times\left[ \begin{array}{cccc} \sigma_{1}^{*2} = \Delta^{2}_{1} \sigma_{1}^{2} && 0\\ \\ 0 && \sigma_{2}^{*2}=\Delta^{2}_{2} \sigma_{2}^{2} \end{array}\right]\times\left[ \begin{array}{cccc} F_{1}\\ \\ F_{2}\end{array}\right]} \\ \\ \\ \\ && =\sqrt{(\Delta_1F_1\sigma_{1})^{2} + (\Delta_2F_2\sigma_{2})^{2} }\end{array}$$