# 📃 Holdings

A Holding is a group of transactions associated to a ticker, which means you can have several BUY and SELL transactions from a certain company, but you only have 1 position in that company.

**Exemplo:**

```tsx
Transaction 1: {
	Ticker: AAPL;
	Type: BUY;
	Shares: 2;
	Price: 100$;
	Date: 02-02-2022;
}

Transaction 2: {
	Ticker: AAPL;
	Type: BUY;
	Shares: 4;
	Price: 120$;
	Date: 10-02-2022;
}

Holding AAPL: {
	Shares: 4;
	Avg. Price: $113;
	Total Invested: $680; 
}
```

### Holdings Metrics

$$
Total~~Shares ~~(apreciação~~de~~ capital) = Total~~Purchased~~Shares - Total~~Sold~~Shares
$$

* **TotalPurchasedShares** - It's the current number of shares for BUY transactions from the respective holding.
* **TotalSoldShares** - It's the current number of shares for SELL transactions from the respective holding.

$$
Total~~Invested ~~(apreciação~~de~~ capital) = Total~~Purchased~~Invested - Total~~Sold~~Invested
$$

<details>

<summary><strong>Total Purchased Invested (formula inside)</strong></summary>

* **(Currency of Holding === Currency of Portfólio)**

**Total Purchased Invested** = TransactionShares \* TransactionPrice;

* **(Currency of Holding !== Currency of Portfólio)**

**Total Purchased Invested** = TransactionShares \* TransactionPrice \* CurrencyPrice;

</details>

**Total Sold Invested** - It's the same as the Total Purchased Invested, but for transactions type SELL.

$$
Avg. Price~~in~~  the\~ Holding Currency\~=~~Total~~Foreign\~Invested \~/ ~~Total~~Shares;
$$

$$
Avg. Price ~~(Portfolio~~ Currency)=~~Total~~Invested \~/ ~~Total~~Shares;
$$
