ranaroussi / ezibpy

ezIBpy, a Pythonic Client for Interactive Brokers API
Apache License 2.0
327 stars 116 forks source link

Place Order for a specify order #25

Closed rapidmoves closed 5 years ago

rapidmoves commented 5 years ago

How do I set the order to be placed to a specific account?

I have 2 accounts under the same TWS login. (Taxable and Retirement/IRA A/c) The code below does not have an Account# to be sent as parameter. Need help!

stk_contract = ibConn.createStockContract("SDS")

# create an order
order = ibConn.createOrder(quantity=1000, price =39.13) 

# submit an order (returns order id)
orderId = ibConn.placeOrder(stk_contract, order)
ranaroussi commented 5 years ago

Starting with version 1.12.67, you can now use

stk_contract = ibConn.createStockContract("SDS")

# create an order
order = ibConn.createOrder(quantity=1000, price =39.13) 

# submit an order (returns order id)
orderId = ibConn.placeOrder(stk_contract, order, account="DUXXXXXX")