Entry Price and PnL
Your Entry Price determines the baseline for calculating profit and loss (PnL). TxFlow tracks two types of PnL:
Unrealized PnL — Floating profit/loss based on current Mark Price (not yet locked in)
Realized PnL — Locked-in profit/loss from closed or reduced positions
Understanding how Entry Price updates and PnL is calculated is crucial for managing risk and tracking performance.
Entry Price
Entry Price is the weighted average price at which you opened or added to your position. It serves as the reference point for all PnL calculations.
How It's Calculated
Entry Price = ∑(Fill Price × Fill Size) ÷ Total Position Size
Key Rules:
Increases when you add to a position (same direction)
Recalculates when you flip the position (from long to short or vice versa)
Does NOT change when you reduce or partially close a position
Resets to 0 when the position is fully closed
Entry Price Update Scenarios
Open Position
Set to fill price
Buy 1 BTC @ 50,000 → Entry=50,000
Add to Position (same direction)
Recalculate weighted average
Hold 1 BTC @ $50,000, buy 1 BTC @ $51,000 → Entry = $50,500
Reduce Position (partial close)
No change
Hold 2 BTC @ $50,500, sell 1 BTC → Entry stays $50,500
Flip Position (reverse direction)
Recalculate for new position
Hold 1 BTC long @ $50,000, sell 3 BTC → Close long, open 2 BTC short @ new entry
Unrealized PnL
Unrealized PnL is your floating profit/loss based on the current Mark Price. It changes in real-time with market movements.
For Long Positions:
Unrealized PnL = (Mark Price − Entry Price) × Position
For Short Positions:
Unrealized PnL = (Entry Price − Mark Price) × Position
Closed PnL
Realized PnL is the profit or loss locked in when you reduce or close a position. It can no longer change.
For Long Positions:
Realized PnL = (Exit Price − Entry Price) × Size
For Short Positions:
Realized PnL = (Entry Price − Exit Price) × Size
Net Closed PnL (after fees):
Net Closed PnL = Gross PnL − Trading Fees − Funding Fees Paid
Return on Equity (ROE)
ROE measures your profit relative to the initial margin (capital) used:
ROE = PnL ÷ Initial Margin Fees × 100%
Related Pages
Calculation of Mark Price and Oracle Price
Funding fees
Last updated
