Closed greg2paris closed 5 years ago
I just found out how to do, if you have at least opened position: print(ib.portfolio()) will display all currently opened position details. If you have no position opened it will print a empty array: []
If you want to know the unrealized pnl of the 1st position you have to use this code: unrealized_pnl = ib.portfolio()[0][5]
If you want the total realized pnl for the security, use this: realized_pnl = ib.portfolio()[0][6]
print("unrealized pnl: ", unrealized_pnl, "realized pnl: ", realized_pnl) # show portofolio
I tried this but I cant do it.