code: def get_avg_price_stat(self) -> Decimal:
          
          avg_price = Decimal(0)
  
          price_total = Decimal(0)
          price_count = 0
  
          for account in self.security.accounts:
              # Ignore trading accounts.
              if account.type == AccountType.TRADING.name:
                  continue
  
              for split in account.splits:
                  # Don't count the non-transactions.
                  if split.quantity == 0:
                      continue
  
                  price = split.value / split.quantity
                  price_count += 1
                  price_total += price
  
          if price_count:
              avg_price = price_total / price_count
          return avg_price
docs: Calculates the statistical average price for the security,
          by averaging only the prices paid. Very simple first implementation.