簡體   English   中英

嘗試使用ibpy在正常交易時間(rth)之外發送訂單

[英]trying to send order outside regular trading hours (rth) using ibpy

我是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訂單的方法?

閱讀文檔以了解有很多有用的信息。 http://interactivebrokers.github.io/tws-api/classIBApi_1_1Order.html#a60dcca6e3c3ae6ae6e0c5f3fdffc5a4a

bool OutsideRth [get,set]如果設置為true,則允許訂單也可以在正常交易時間之外觸發或執行。

看起來像C#文檔,但在ibpy中也是如此。 如果您檢查源代碼,則Order的字段為m_outsideRth = bool() 只需將其設置為true。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM