Skip to content

Buy & Sell

The most fundamental transaction types: buying increases your holdings and decreases cash; selling does the reverse and realizes a profit or loss.


🔑 Key Properties

Property Buy Sell
Code BUY SELL
Cash effect ⬇️ Decreases ⬆️ Increases
Asset effect ⬆️ Increases holdings ⬇️ Decreases holdings
Tax event No Yes (realizes gain/loss)

📊 How It Works

🛒 Buy

When you buy an asset, a lot is created with:

  • Date: When the purchase occurred
  • Quantity: Number of shares/units bought
  • Unit price: Price per share at the time of purchase
  • Fees: Any transaction fees (commission, spread, etc.)
  • Total cost: quantity × unit_price + fees

💰 Sell

When you sell, LibreFolio matches the sale against existing lots using FIFO (First In, First Out) to determine:

\[ \text{Capital Gain} = (P_{sell} \times Q) - (P_{buy} \times Q) - \text{Fees} \]

FIFO Matching

LibreFolio computes lot matching at runtime — it's not persisted in the database. This allows for flexible what-if analysis and potential future support for other matching methods (LIFO, specific identification).