Calculation Definitions
This page defines business meaning of key portfolio numbers. Formulas are aligned with current factory/service behavior.
Quote system
Most values are tracked in multiple quotes:
EURBTCETHUSD
Unless stated otherwise, formulas apply per quote.
Position calculations
1) Average price
Average price is the weighted acquisition cost per unit for a position.
Conceptually:
new_avg_price = (old_cost + new_order_cost) / new_total_quantity
2) Cost basis
Cost basis is capital committed for the current held quantity.
cost_basis = total_quantity * average_price
A fiat position (EUR, USD, CHF) is the exception: cash is carried at face value, so its cost basis equals its market value and it reports no ROI, UGL or realized gain. FX gain on cash is not tracked.
3) Market value
Market value is current valuation using latest available prices.
market_value = total_quantity * current_price
4) ROI
Position ROI expresses percentage change from average price to current price.
ROI(%) = ((current_price - average_price) / average_price) * 100
5) Unrealized and realized PnL
- UGL (unrealized gains/losses):
UGL = market_value - cost_basis- RGL (realized gains/losses):
- Updated when sells are processed; cumulative realized performance is stored per position
6) Weight in portfolio
Position weight shows portfolio share:
weight(%) = position_market_value / total_portfolio_market_value * 100
Portfolio snapshot calculations
1) Portfolio market value
Sum of market values for all positions.
2) Portfolio cost basis
Current implementation uses fiat cash-flow definition:
cost_basis = fiat_deposits - fiat_withdrawals- Supported fiat inputs in this flow:
EUR,USD,CHF
3) Portfolio UPL
UPL = portfolio_market_value - portfolio_cost_basis
4) Portfolio ROI
ROI(%) = ((portfolio_market_value - portfolio_cost_basis) / portfolio_cost_basis) * 100
5) Distribution outputs
- Instrument distribution: top N instruments +
Others - Category distribution:
BITCOIN,STABLE,MEMES,DEFI,OTHER
Fees
A transaction carries a fee quoted value, charged in one instrument, and the ledger makes it leave
the book in that instrument. Charged in a pair's quote currency it moves cash and the cost basis;
charged in the base currency it moves units; charged in a third instrument (a venue token, the
chain's gas coin) it is never debited, because the pair does not move that balance. A fee is taken
only when what is left of the balance covers it. A fiat deposit is credited net of the fee the venue
charged in that same currency, so what lands is the recorded amount less that fee, while a deposit
in another instrument arrives whole and its fee, the sender's gas, is never debited. The replay rule
is in Positions step 5.
What the fees have cost
A second reading of the same field answers a different question: not what the ledger moved, but what the trading cost. Here every recorded fee counts, including one charged in a third instrument the ledger never debits, and each fee is valued at its own day's close — a fee paid in BTC in 2019 is worth what that amount of BTC was worth then, never what it is worth today. A fee charged in a quote currency needs no conversion.
The figure is reported twice: per connexion (fees on the connexion snapshot, so the credential and
wallet cards show what that venue cost) and for the whole portfolio (fees on the portfolio snapshot,
cumulative up to the snapshot's timestamp). It is a lower bound for imported history: a CSV or
wallet-history import routinely carries a zero fee, so the number is what the records know, not what
the venue charged. A fee with no close on its day is left out of the total and logged.
Important caveats
- If price data is missing for some instruments/timestamps, processing continues with partial results and warnings.
- Coherence checks reject operations that would create impossible negative holdings.
Related: