How are positions marked?
Each open position is marked every cycle. The mark asks one thing. What would the whole lot sell for now? It uses the chain price. It takes off impact and the fee. The field is markUsd.
A second mark uses the base price. It is qty × basePrice. The field is markVsBaseUsd. It shows the stock-side value.
equity = cash + Σ markUsdpnl = equity − starting cashunrealized = Σ (markUsd − costUsd)Realized profit comes from a sell:
realized = netUsd − costUsd × fraction soldCost includes fees. A win is a sell with profit above zero. A loss is a sell below zero.
If a price is stale, the last mark is kept. The state is set to old. The last good equity is kept and flagged. If no good equity exists yet, it is null. The current inventory value is null until all marks are fresh.
| Field | Meaning |
|---|---|
equityUsd | Cash plus all marks |
pnlUsd, pnlPct | Change from the start, signed |
realizedPnlUsd | Sum of closed profit and loss |
unrealizedPnlUsd | Open marks minus cost |
peakUsd | Highest equity seen |
maxDrawdownPct | Largest fall from a peak, percent |
wins, losses | Sells with profit above or below zero |
An equity point is stored when it changes. Or at least once a minute. Points older than 30 days are pruned.
Sample
Section titled “Sample”You hold 10 tokens. Cost was $1,000. They would sell for $1,050 now. Unrealized PnL is +$50. The base value is $1,100. The gap is still open.