# Position realized profits
The realized net profit, realized commission and realized swap of a position can be calculated with its closing trades.
- Example
import { decimal, MidaTradePurpose, } from "@reiryoku/mida";
const positionId = myPosition.id;
const trades = await myAccount.getTrades(myPosition.symbol);
const positionClosingTrades = trades.filter((trade) => {
return trade.positionId === positionId && trade.purpose === MidaTradePurpose.CLOSE;
});
// If the gross profit, commission and swap are applied on the same asset
// then the totals can be directly calculated
let totalGrossProfit = decimal(0);
let totalCommission = decimal(0);
let totalSwap = decimal(0);
for (const trade of positionClosingTrades) {
totalGrossProfit = totalGrossProfit.add(trade.grossProfit);
totalCommission = totalCommission.add(trade.commission);
totalSwap = totalSwap.add(trade.swap);
}
const netProfit = totalGrossProfit.add(totalCommission).add(totalSwap);