我是IBpy ,我想知道是否有任何方式下订单而不传输它并等待人工输入实际传输订单?
我正在使用placeOrder下订单,但我找不到放置它们而不传输它们的方法。
任何帮助将不胜感激。
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.
最满意答案
在您的订单中将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)打印
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 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)
更多推荐
发布评论