Skip to content

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 + Σ markUsd
pnl = equity − starting cash
unrealized = Σ (markUsd − costUsd)

Realized profit comes from a sell:

realized = netUsd − costUsd × fraction sold

Cost 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.

FieldMeaning
equityUsdCash plus all marks
pnlUsd, pnlPctChange from the start, signed
realizedPnlUsdSum of closed profit and loss
unrealizedPnlUsdOpen marks minus cost
peakUsdHighest equity seen
maxDrawdownPctLargest fall from a peak, percent
wins, lossesSells 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.

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.

Read the rules in order.