我是Python和ibpy的新手,但我能够使用这两种方法测试运行我的策略。我的问题是,当市场开放时,我不能在正常交易时间(RTH)之外发送订单,但ib并不认为它们是“正常交易时间”。
下面是我如何发出这些命令。
from ib.opt import Connection
from ib.ext.Contract import Contract
from ib.ext.Order import Order
import time
port = 7496
client = 1
account = "XXXXX"
newContract = Contract()
newContract.m_symbol = "CL"
newContract.m_secType = "FUT"
newContract.m_exchange = "NYMEX"
newContract.m_currency = "USD"
newContract.m_expiry = "201806"
newOrder = Order()
newOrder.m_orderType = "LMT"
newOrder.m_totalQuantity = 1
newOrder.m_action = "BUY"
newOrder.m_lmtPrice = "65"
tws_conn = Connection.create(port=port, clientId=client)
print("------ Connecting.... --------")
tws_conn.connect()
time.sleep(1)
#to simplify I am using a number, but this needs to be updated every new order.
orderId = 1
tws_conn.placeOrder(orderId, newContract, newOrder)
在RTH期间,订单进行得很好,但是当我们在RTH之外时,我会收到这样的消息:
07:45:45:392 -> 4-2-1-399-Order Message:
BUY 1 CL JUN'18 (CLM8)
Warning: your order will not be placed at the exchange until 2018-05-14 09:30:00 US/Eastern-
是否有办法启用RTH订单?
发布于 2018-05-18 14:21:35
阅读文档以获取订单,有大量有用的信息。1Order.html#a60dcca6e3c3ae6ae6e0c5f3fdffc5a4a
bool OutsideRth get,如果设置为true,则允许订单在正常交易时间之外触发或填充。
这看起来像C#文档,但在ibpy中也是如此。如果您检查源代码,Order有一个字段m_outsideRth = bool()
。就让它变成真的。
https://stackoverflow.com/questions/50336302
复制相似问题