Open noob-tubem opened 2 months ago
Yeah, that will not show correct results because of how IBKR reports those values.
Short version: you have to compare a live quote against your average cost of each position then calculate your current PnL value if you need updates faster than every couple minutes.
There's a couple problems:
marketPrice
field for each position in your portfolio, but the value only updates maybe once per minute or slower.$0
. It will still consider your old position too.
I am using ib.portfolio() to view the unrealized pnl of each of my positions in real time, but the pnl does not update anywhere near as fast as TWS itself updates - often it takes on the order of minutes to update my position's pnl. Here is a snippet of my code:
`
that file write statement shows the same exact pnl for minutes at a time even as I'm watching it update on TWS, and even if I kill the code and restart it it shows the same pnl as before. Is this a problem I can fix or could it be an ibkr problem?