下订单而不用IBpy传输它们?(Placing orders without transmitting them with IBpy?)

编程入门 行业动态 更新时间:2024-10-22 15:30:15
订单而不用IBpy传输它们?(Placing orders without transmitting them with IBpy?)

我是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 enter image description here 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) enter image description here

更多推荐

本文发布于:2023-08-07 00:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457848.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:订单   IBpy   Placing   orders   transmitting

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!