--- title: "How does LUSID calculate realised gain/loss?" slug: "how-does-lusid-calculate-realised-gainloss" updated: 2025-07-08T13:32:09Z published: 2025-07-08T13:32:09Z canonical: "support.lusid.com/how-does-lusid-calculate-realised-gainloss" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.lusid.com/llms.txt > Use this file to discover all available pages before exploring further. # How does LUSID calculate realised gain/loss? A transaction that decreases (that is, reduces or closes) a position may realise a gain or loss. LUSID automatically calculates a [running total of holding cost](/v1/docs/how-is-cost-calculated-in-lusid) from all transactions that contribute to that holding. A transaction that decreases a position reduces the total cost proportionally to the cost of the holding; note the precise impact depends upon the [tax lot accounting method](/v1/docs/what-are-the-supported-tax-lot-accounting-methods-in-lusid). The difference between the cost reduction and the transaction’s total consideration is the realised gain/loss. > **Note**: The ‘total consideration’ of a transaction is a subjective concept in LUSID. You can choose whether to capitalise fees or not, include or exclude bond accrued interest, and so on. ## Example: Reducing an equity position Consider the following example, of three consecutive transactions in a single `Equity` instrument: - The first transaction is a purchase of 200 units @ 10 that establishes a holding with a unit cost of `2000 / 200 = 10`. - The second transaction is a purchase of 500 units @ 11 that changes the unit cost to `7500 / 700 = 10.71`. - The third transaction is a sale of 300 @ 12 that reduces holding cost proportionally (by `300 × 10.71 = 3214.29`) and realises the difference to the total consideration as gain: | Transaction fields | Holding fields | | --- | --- | | `transactionId` | `type` | `units` | `transactionPrice.price` | `totalConsideration.amount` | `cost.amount` | `units` | | Txn01 | Buy | 200 | 10 | 2000 | 2000 | 200 | | Txn02 | Buy | 500 | 11 | 5500 | 7500 | 700 | | Txn03 | Sell | 300 | 12 | 3600 | 4285.71 | 400 | This example makes the following assumptions: - The containing portfolio uses the default `AverageCost` accounting method. - The transaction, settlement and portfolio currencies are all the same. - Both [transaction types](/v1/docs/what-is-a-transaction-type) have a `StockMovement` that uses the [built-in](/v1/docs/what-built-in-transaction-types-and-sides-are-provided-with-lusid#sides) `Side1` to convert total consideration to transaction currency (where different) and exclude bond interest (where applicable). LUSID calculates realised gain/loss for the Sell transaction as follows: `total consideration  - (transaction units * (holding cost / holding units))` In other words: `3600 - (300 * (7500 / 700)) = 385.71` ## Auditing the realised gain/loss calculation for a transaction You can examine the [output transaction](/v1/docs/input-and-output-transactions) automatically generated by LUSID to audit a realised gain/loss calculation. Where applicable, LUSID breaks the total realised gain/loss down into market, FX and amortisation components. To do this, call the [BuildTransactions](https://www.lusid.com/docs/api/lusid/endpoints/transaction-portfolios/BuildTransactions/) API, or navigate to **Portfolio Management > Transactions** in **Output** mode in the LUSID web app and examine the **Realised Gain&Loss** fields: ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(930).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A17Z&se=2026-11-04T02%3A47%3A17Z&sr=c&sp=r&sig=eozj4w65QUSYYuj2MBtX5gIXa%2BgpSYJkvC5RQCoSjHE%3D) ## Auditing cumulative realised gain/loss for a holding You can value a portfolio and specify the following [realised P&L metrics](/v1/docs/how-does-lusid-calculate-pl) to audit cumulative realised gain/loss over a particular period, for example year to date or from portfolio inception: - `ProfitAndLoss/Realised/Market`: Cumulative realised gain/loss from market price fluctuations. - `ProfitAndLoss/Realised/Fx/PortfolioCcy`: Cumulative realised gain/loss from exchange rate fluctuations. - `ProfitAndLoss/Realised/Amortisation`: Cumulative realised gain/loss from amortisation or accretion of bond instruments. > **Note**: There is no built-in metric to calculate total realised gain but you can create a [custom derived valuation metric](/v1/docs/including-properties-and-derived-properties-in-valuation-reports#belonging-to-the-special-derivedvaluation-domain) to aggregate these above. To do this, call the [GetValuation](https://www.lusid.com/docs/api/lusid/endpoints/aggregation/GetValuation/) API, or navigate to **Dashboard > Valuations** in the LUSID web app and click the **Configuration** cog (highlighted below) to add realised P&L metrics to the view, for example: ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(508).png?sv=2026-02-06&spr=https&st=2026-11-04T01%3A47%3A17Z&se=2026-11-04T02%3A47%3A17Z&sr=c&sp=r&sig=eozj4w65QUSYYuj2MBtX5gIXa%2BgpSYJkvC5RQCoSjHE%3D)