IB TWS Trading Platform in Python 3 part 7 - profit and loss
In this tutorial lesson you will add labels and textboxes to hold the unrealized, realized, and total profit and loss
add code to calculate the marked profit and loss for both a long position and a short position
Add these variables to your project
self.unrealized = 0 # used in monitor position
self.realized = 0 # used in monitor position
self.unrealized_pnl = 0
self.realized_pnl = 0
self.marked_pnl = 0
Add this to the bottom of the create_widgets() function
add this code to the bottom of the cbSymbol_onEnter() function
they set the text boxes for Position, average price, unrealized, realized, and marked to zero, also the 2 variables realized_pnl, and marked_pnl to zero
No comments:
Post a Comment