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

时间:2015-04-26 03:40:34

标签: interactive-brokers ibpy

我是this的新手,我想知道是否有任何方式下订单而不传输它并等待人工输入实际传输订单?

我使用IBpy下订单,但我找不到放置它们的方法而不传输它们。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:4)

在您的订单中将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将有这样的一行 enter image description here 如果要从TWS发送,请注意发送按钮。

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

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

然后它会被传输,TWS将显示填充,订单消息回调也将打印在简单的def watchAll(msg)enter image description here