下订单而不用 IBpy 传输它们?

Placing orders without transmitting them with IBpy?

我是 IBpy 的新手,我想知道是否有任何方法可以在不发送订单并等待人工输入实际发送订单的情况下下订单?

我正在使用 placeOrder 下订单,但我找不到不传输订单的方法。

任何帮助将不胜感激。

在您的订单中将 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 传输,请注意传输按钮。

然后您可以使用相同的 orderId 重新发送相同的订单,但将 m_transmit 设置为 True。

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

然后它被传输,TWS 将显示填充,订单消息回调也将以简单的方式打印 def watchAll(msg)