Brendan is correct about the UNSET_DOUBLE or Double.MAX_VALUE the various languages use to indicate "undefined value". The same is true for integer fields where the Integer.MAX_VALUE (2^31)-1 = 2,147,483,647 is used as the UNSET_INTEGER indicator.
You should get "undefined realizedPNL" only for commission reports of entry trades, since there is no PNL from price changes yet. Commission reports for exit trades will show the actual realized PNL for that trade.
Depending on how you think about PNL, you could set "realizedPNL = -commission" for entry positions (when realizedPNL is undefined) since the commission you pay for entering into the position is a small loss right from the start.
闯ü谤驳别苍
toggle quoted message
Show quoted text
On Thu, Jul 21, 2022 at 12:37 PM, Brendan Caffrey wrote:
That value (1.797...e+308) is the maximum value a double can hold. IB uses that to indicate the value is unset. In the C++ API code, they have an UNSET_DOUBLE constant that you can compare against, there may be something similar in the python code.
?
Also, my python is a little rusty, but I think you need to pass an array to writerow, something like: writer.writerow([commissionReport.realizedPNL])
When I execute an order I get the?commissionReport.But I cannot read the?commissionReport.realizedPNL such like?1.7976931348623157e+308.
When I create a new position, the?commissionReport.realizedPNL shows?1.7976931348623157e+308.After the position closed,the?commissionReport.realizedPNL shows the normal profit and loss amount.
I'd like to export the Profit and loss to csv after every positions closed.But I don't know how to handle the??commissionReport.realizedPNL such like?1.7976931348623157e+308.
It cannot export?commissionReport.realizedPNL to csv by?writer.writerow(commissionReport.realizedPNL).It shows error message:csv.Error: iterable expected, not float
I don't know how to do? Any ideas is welcome.
--
------
Forex trader
David Liao
?
?