Accounting
This page documents the accounting approach used by the simulation engine.
Daily Position Stats Accounting
On a daily basis, engine computes an end-of-day overview of each asset held within a portfolio , as long as closing price on date(t) is available.
Close Quantity
Quantity of asset at market close.
(+ve) LONG
(-ve) SHORT
Value (USD)
By Default:
Value = Quantity * Price(t)
Unrealized Pnl
Unrealized Pnl (t) = Position Value(t) - Average Cost Basis (t) * Quantity
Portfolio Weight
Weight = Position Value(t) / Total Value(t)
Note:
Total Value (t) is Portfolio Value at date (t) with closing price (t)
Tax Lot Accounting
This simulated taxable gains/loss for the portfolio, similar to how most brokerages handle transactions. Each new accumulating position will create a new Tax Lot entry. Engine uses FIFO tax lot selection where oldest purchases are liquidated first.
Each Tax Lot keeps track of:
Total Realized Pnl
Cost basis per unit
Example:
Position with 3 lots:
Lot 1: +100 qty @ $50 (purchased Jan 1)
Lot 2: +100 qty @ $60 (purchased Feb 1)
Lot 3: +100 @ $40 (purchased Mar 1)
Sell 150 shares at $55:
FIFO sells Lot 1 (100 shares) + 50 shares from Lot 2
Total Realized Pnl
Realized PnL (Profit and Loss) is the actual profit/loss that an investment makes upon liquidation.
For tax lot, a:
Realized Pnl = (Exit Price - Cost Basis Per Unit) * Redeem Quantity
Cost Unit Per Unit
Last updated