title: Calculate the average value of a coin in possession
body: <p>The following Google sheet contains transactions in crypto currencies. One line can represent a &quot;buy&quot; or a &quot;sell&quot; of a crypto coin:
  <a href="https://i.stack.imgur.com/j81F5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j81F5.png" alt="image of transactions" /></a></p>
  <p>What I'm trying to achieve is to calculate the average price paid for a specific coin that is still in the wallet.</p>
  <p>In the example above that would be:</p>
  <ul>
  <li>Quantity: 0.74915977</li>
  <li>Average price: 133.15 EUR because we sold all coins before we bought new ones</li>
  </ul>
  <p>Simply calculating the average will result in 116.93 EUR which is incorrect.</p>
  <p>What is the correct formula to achieve the desired result of 133.15 EUR?</p>