我是IBpy的新手,我想知道是否有任何方法可以在不发送命令的情况下下订单,并等待人工输入来真正传递命令?
我正在使用placeOrder下订单,但我无法找到一种方法,在不发送他们的情况下。
任何帮助都将不胜感激。
发布于 2015-05-11 22:11:09
在您的命令中将m_transmit设置为False。
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)你的TWS会有这样的一排

如果要从TWS发送,请注意发送按钮。
然后可以使用相同的orderId重新发送相同的订单,但将m_transmit设置为True。
ord.m_transmit = True
con.placeOrder(1234,fx,ord)然后进行传输,TWS将显示填充,订单消息回调也将在简单的def watchAll(msg)中打印

https://stackoverflow.com/questions/29873455
复制相似问题