开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: About commissionReport.realizedPNL


 

开云体育

There is a ‘realizedPNL’ column you can view in TWS as well to see how it works. Basically yes I believe it is calculated for each closing trade, but not necessarily based on the average cost: if you specify ’tax lots’ it is based on the opening cost of the lot you matched the closing trade with. In absence of specifying lots, it will be based on your default setting (which is most likely FIFO if you didn’t change it in the config).

RealizedPNL does get reset every day. Unrealized PNL is your PNL to date on all open positions. So as you make dailyPNL (also reported in TWS) that adds to your unrealizedPNL. Then once you close the trade it goes from unrealizedPNL to realizedPNL but stays in your dailyPNL. ?RealizedPNL and obviously also dialyPNL get reset every day.?

Bart


On Jul 26, 2022, at 2:54 PM, 闯ü谤驳别苍 Reinold via groups.io <TwsApiOnGroupsIo@...> wrote:

The short answer is yes, realizedPNL in commissionReports for trades that reduce a position include (the loss from) commissions.

We do not use the realizedPNL field from comission reports so we have no practical experience of exactly how realizedPNL is calculated, especially if you have scenarios with multiple entry trades at different prices and an overlapping partial exit trade. But I assume it is based upon the "average cost" as reported by which does get adjusted at every trade. I also cannot say for sure whether the daily PNL reset applies to realizedPNL reported in commission reports.

I grabbed a quick example from our object log that shows trading one ES future contract each. Exit trades were made with 1 tick profit or loss (e.g. $12.50 profit or loss from price differences). Below the relevant commissionReport fields tor those? four trades.

闯ü谤驳别苍

Action Quantity Commission RealizedPNL
Entry 1 contract $2.15 UNSET
Exit with 1 tick profit 1 contract $2.15 $8.20
Entry 1 contract $2.15 UNSET
Exit with 1 tick loss 1 contract $2.15 -$16.80

Join [email protected] to automatically receive all group messages.