Did the market move for or against you between entry and exit?
What you paid (or rebates you got) on fills.
All the small hourly payments you paid or received before closing.
net = Σ closedPnl − Σ trading fees + Σ funding received − Σ funding paid
(If funding is stored as one signed number — positive = received, negative = paid — just add Σ funding.)