3

I am new to IBpy and I am wondering if there is any way to place an order without transmitting it and waiting for a human input to actually transmit the order?

I am using placeOrder to place orders but I can't find a way of placing them without transmitting them.

Any help will be appreciated.

JordanBelf
  • 3,208
  • 9
  • 47
  • 80

1 Answers1

5

Set m_transmit to False in your order.

from ib.ext.Contract import Contract
from ib.ext.Order import Order
from ib.opt import ibConnection, message
from time import sleep

def watchAll(msg):
    print(msg)

con = ibConnection(clientId=1)
con.registerAll(watchAll)
con.connect()
sleep(1)

fx = Contract()
fx.m_secType = "CASH" 
fx.m_symbol = "USD"
fx.m_currency = "CAD"
fx.m_exchange = "IDEALPRO"
con.reqMktData(1,fx,"",False)

ord = Order()
ord.m_orderType = 'MKT'
ord.m_totalQuantity = 100000
ord.m_action = 'BUY'
ord.m_transmit = False
con.placeOrder(1234,fx,ord)

Your TWS will have a row like this enter image description here Notice the transmit button if you want to transmit from TWS.

Then you can resend the same order using the same orderId but set m_transmit to True.

ord.m_transmit = True
con.placeOrder(1234,fx,ord)

Then it get's transmitted and TWS will show the fill, also the order message callbacks will get printed in the simple def watchAll(msg) enter image description here

brian
  • 10,619
  • 4
  • 21
  • 79