I have recently started coding in Python and am trying to accomplish the following using IbPy:
(1) create an option and ETF buy order
(2) execute the order
(4) read the portfolio positions
(3) track the PnL of the account every 5 min
I have been able to achieve (1) and (2) but I am not able to do the (3)
Currently I am using the code:
The line: tws_conn.reqAccountUpdates prints the position on the console but I will need to get the market information for each contract by reading their ticker (for ETF) and contract characteristics (for options).
Does anyone have a sample python code they can share.
(1) create an option and ETF buy order
(2) execute the order
(4) read the portfolio positions
(3) track the PnL of the account every 5 min
I have been able to achieve (1) and (2) but I am not able to do the (3)
Currently I am using the code:
tws_conn = conn.Connection.create(port=7497, clientId=100)
tws_conn.register( acct_update, msg.updateAccountValue,
msg.updateAccountTime, msg.updatePortfolio)
tws_conn.reqAccountUpdates(True,'DU15181')
tws_conn.register( acct_update, msg.updateAccountValue,
msg.updateAccountTime, msg.updatePortfolio)
tws_conn.reqAccountUpdates(True,'DU15181')
The line: tws_conn.reqAccountUpdates prints the position on the console but I will need to get the market information for each contract by reading their ticker (for ETF) and contract characteristics (for options).
Does anyone have a sample python code they can share.