How is capital (realized) gain/loss calculated?

Asset's market value (when the asset is sold) minus the asset's original cost when it was purchased.