首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >API IB TWS Python支架问题

API IB TWS Python支架问题
EN

Stack Overflow用户
提问于 2020-07-22 08:22:08
回答 1查看 126关注 0票数 0

订单被放置到tws中,但在激活时,它只是取消自身以及附加的停止和目标。留下我没有命令,没有位置。这是不是因为我附加父级的方式,并且在目标之前没有将transmit设置为false?在tws指南中,我无法通过使用transmit = false然后最后一个true来理解这个示例。这是不起作用的原因吗?

代码语言:javascript
复制
###################################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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-23 01:01:35

问题是有很多大小的限制,40个超过了它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63024913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档