To calculate your pnl, all you have to do is:
PNL: position size * (sell price - buy price)
where position size is in number of coins. So if you buy 5 BTC futures at $10,000 and sell 5 BTC futures for $11,000, you made 5 * (11,000 - 10,000) = $5000.
If you haven't closed a trade yet, then:
PNL for open position: position size * (mark price - entry price) if you bought; position size * (entry price - mark price) if you sold. Mark price is the middle of bid, ask and last for the future.
If you traded perpetual futures you also have to add in any funding payments made or lost while the position was open.
Every thirty seconds (unless there are active liquidations), we automatically turn all unrealized pnl into realized pnl. Thus:
Unrealized PNL: position size * (mark price - mark price 30 seconds ago).
Realized PNL: PNL - unrealized PNL.
Fills modify position sizes and cost. Fills only affect unrealized pnl, not realized pnl.
Position entry price = cost / size
Unrealized pnl: position size * mark price - cost
Every 30 seconds, all unrealized pnl turns into realized pnl if there are no accounts being auto-closed.
(specifically, account collateral is modified by unrealized pnl and entry price is set to mark price)
FTX uses standard futures rather than inverted futures. This means that ultimately you can calculate your final PnL from quarterly futures, assuming no liquidations, as: PnL = Number of Futures * (exit price - entry price). So for instance if you bought 15 BTC futures at $5,000 and sold all 15 at $6,000, your USD collateral will increase by $15,000. If you hold a position until expiration you can treat the expiration price of the contract as your exit price.
Note that if you put on a position in a perpetual future, your PnL will be increased/decreased by the total funding payments you pay while holding the position. Each hour, there is a funding payment from longs to shorts of position size * TWAP of ((future mark price - index) / index) / 24.
See Non-USD Collateral for more details.
In the event that your USD balance falls too far below zero (see below for details), some of your balances in the above coins may be automatically traded into USD by sending market orders into the corresponding FTX spot markets. You can choose whether to use FTT as collateral on the settings page. By default your account will use FTT as collateral. Note that Weight (total) is used to determine collateral for the purpose of liquidations, and Weight (free) is for the purpose of opening new positions.
Any positive PnL will be paid out in USD regardless of which type of collateral you use.