API IB TWS Python 支架问题
API IB TWS Python Bracket Problems
订单被放入 tws,但在激活时它只是取消了自身以及附加的止损和目标。让我没有订单没有 pos。这是因为我附加父级而不是将传输设置为 false 直到目标的方式吗?我无法在 tws 指南中使用 transmit = false 然后最后一个 true 找出示例。这就是它不起作用的原因吗?
###################################Place Buy /BUY Bracket
if direction == "BUY":
app.reqGlobalCancel()
Entry = Order()
Entry.action = 'BUY'
Entry.orderId = app.nextorderId
Entry.orderType = 'STP LMT'
Entry.auxPrice = price + .25
Entry.lmtPrice = price + .25
Entry.totalQuantity = lotsize
Entry.outsideRth = True
Entry.tif = 'GTC'
app.placeOrder(Entry.orderId, contract, Entry)
###################################Place Stop /BUY Bracket
app.nextorderId += 1
stop_order = Order()
stop_order.parentId = Entry.orderId
stop_order.action = 'SELL'
stop_order.orderType = 'STP'
stop_order.auxPrice = buystop + .25
stop_order.totalQuantity = lotsize
stop_order.orderId= Entry.orderId +1
stop_order.outsideRth = True
stop_order.tif = 'GTC'
app.placeOrder(stop_order.orderId, contract, stop_order)
stopid=str(stop_order.orderId)
###################################Store Stop Id for stop adjustments
if path.exists("StopOrder.txt"):
os.remove("StopOrder.txt")
file = open("StopOrder.txt","w")
file.write(stopid)
file.close()
###################################Place Target /BUY Bracket
app.nextorderId += 1
target_order = Order()
target_order.parentId = Entry.orderId
target_order.action = 'SELL'
target_order.orderType = 'LMT'
target_order.lmtPrice = buytar + .25
target_order.totalQuantity = lotsize
target_order.outsideRth = True
target_order.tif = 'GTC'
app.placeOrder(app.nextorderId, contract, target_order)
问题是有很多大小限制,超过了 40 个。
订单被放入 tws,但在激活时它只是取消了自身以及附加的止损和目标。让我没有订单没有 pos。这是因为我附加父级而不是将传输设置为 false 直到目标的方式吗?我无法在 tws 指南中使用 transmit = false 然后最后一个 true 找出示例。这就是它不起作用的原因吗?
###################################Place Buy /BUY Bracket
if direction == "BUY":
app.reqGlobalCancel()
Entry = Order()
Entry.action = 'BUY'
Entry.orderId = app.nextorderId
Entry.orderType = 'STP LMT'
Entry.auxPrice = price + .25
Entry.lmtPrice = price + .25
Entry.totalQuantity = lotsize
Entry.outsideRth = True
Entry.tif = 'GTC'
app.placeOrder(Entry.orderId, contract, Entry)
###################################Place Stop /BUY Bracket
app.nextorderId += 1
stop_order = Order()
stop_order.parentId = Entry.orderId
stop_order.action = 'SELL'
stop_order.orderType = 'STP'
stop_order.auxPrice = buystop + .25
stop_order.totalQuantity = lotsize
stop_order.orderId= Entry.orderId +1
stop_order.outsideRth = True
stop_order.tif = 'GTC'
app.placeOrder(stop_order.orderId, contract, stop_order)
stopid=str(stop_order.orderId)
###################################Store Stop Id for stop adjustments
if path.exists("StopOrder.txt"):
os.remove("StopOrder.txt")
file = open("StopOrder.txt","w")
file.write(stopid)
file.close()
###################################Place Target /BUY Bracket
app.nextorderId += 1
target_order = Order()
target_order.parentId = Entry.orderId
target_order.action = 'SELL'
target_order.orderType = 'LMT'
target_order.lmtPrice = buytar + .25
target_order.totalQuantity = lotsize
target_order.outsideRth = True
target_order.tif = 'GTC'
app.placeOrder(app.nextorderId, contract, target_order)
问题是有很多大小限制,超过了 40 个。