# 💰 Dividend Gains

It's not very linear to get the dividend gains as in the previous cases, because there are some factors that need to be considered.

* First step is to get the companies dividend history, which means, if a portfolio has AAPL and FB in it, only AAPL pays a dividend, so we have to get all the dividends AAPL has paid since the first transaction date from AAPL position.

Imagine if we bought AAPL at 03-02-2021, then we would have to get all the dividends since that date.

* Second step, is AAPL currency the same as the portfolio currency? If the portfolio is in EUR, and AAPL is in USD then we have to get the exchange rate from USD to EUR, for the dividend payment date, this to know how much we really received in dividends.
* Third step, run the historical data, and apply the following calculations:

**(Currency da Holding == Currency do Portfólio)**

$$
Dividend ~~Gains~~ For\~ Certain Date = Dividend~~Paid \* Total~~Shares~~To~~Date
$$

**(Currency da Holding != Currency do Portfólio)**

$$
Dividend ~~Gains~~ For\~ Certain ~~Date = \Dividend~~Paid \* Total~~Shares~~To~~Date \* Currency~~Price~~On~~Dividend~~Payment~~Date
$$

**Dividend Paid** - Dividend paid by the company at that date

**TotalSharesToDate** - It's the number of shares from the holding till the respetive dividend date

**Currency PriceOn Dividend Payment Date** - I'ts the exchange rate on the dividend payment date

**Total Dividend Gains** = Dividend Gains For Date X + Dividend Gains For Date Y + ....

***
