Placing orders without handing them over to IBpy?

I'm new to IBpy

and I'm wondering if there is a way to place an order without submitting it and waiting for human input to actually transfer the order?

I am using placeOrder

to place orders, but I cannot find a way to place them without submitting them.

Any help would be appreciated.

+3


source to share


1 answer


Set m_transmit to False on 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 string like this enter image description here Please note the transfer button if you want to transfer from TWS.



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

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

      

It will then be transmitted and TWS will show filling, also the order message callbacks will be printed in a simple def watchAll(msg)

enter image description here

+3


source







All Articles