简体   繁体   English

如何在 Interactive brokers python api 的括号订单中设置和应用偏移量到父订单设置?

[英]How to set and apply offset to parent order setting in bracket order for Interactive brokers python api?

From TWS, I can place a bracket order where I can place the takeprofit and stoploss order with a setting "apply offset to parent order".在 TWS 中,我可以下一个括号定单,我可以在其中下达止盈和止损定单,并设置“对父定单应用抵消”。 How do one apply same setting "apply offset to parent order" from python API while placing bracket order?如何在放置括号订单时从python API应用相同的设置“将偏移量应用于父订单”? My code我的代码

    parent.orderId = parentOrderId  
    parent.action = action
    parent.orderType = "STP LMT"
    parent.totalQuantity = quantity
    parent.auxPrice=auxPrice
    parent.lmtPrice = limitPrice  #upper price when stop trigerred
    #The parent and children orders will need this attribute set to False to prevent accidental executions.
    #The LAST CHILD will have it set to True, 
    parent.transmit = False

    takeProfit = Order()
    takeProfit.orderId = getNextOrderID()
    takeProfit.action = "SELL" if action == "BUY" else "BUY"
    takeProfit.orderType = "LMT"
    takeProfit.totalQuantity = quantity
    takeProfit.lmtPrice = takeProfitLimitPrice
    takeProfit.parentId = parentOrderId
    takeProfit.transmit = False

    stopLoss = Order()
    stopLoss.orderId = getNextOrderID()
    stopLoss.action = "SELL" if action == "BUY" else "BUY"
    stopLoss.orderType = "STP"
    #Stop trigger price
    stopLoss.auxPrice = stopLossPrice
    stopLoss.totalQuantity = quantity
    stopLoss.parentId = parentOrderId
    #In this case, the low side order will be the last child being sent. Therefore, it needs to set this attribute to True 
    #to activate all its predecessors
    stopLoss.transmit = True

I wrote to IB team.我写信给 IB 团队。 Got this reply收到了这个回复

Thank you for reaching out to Interactive Brokers.The said settings are related to presets and currently, there are no APIs which can configure the said settings.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 盈透证券通过python api的有效时间订单 - Interactive Brokers time-in-force order through python api 互动经纪商 api python - “上市前”期间发出订单 - interactive brokers api python - fire order during "pre market" 括号订单追踪止损Java交互式经纪人 - bracket order trailing stop loss java interactive brokers 使用 API 请求在盈透证券下订单 - Place an order in Interactive Brokers using API request 在 Python 中为盈透证券 API 响应设置变量 - Setting variables to Interactive Brokers API responses in Python 如何使用盈透证券 (IB) API (ib_insync) 为 Python 复制括号定单功能 - How to replicate bracket orders functionality using Interactive Brokers (IB) API (ib_insync) for Python Interactive Brokers TWS API 上的 IB 同步期货订单问题 - Problem with IB Insync Futures Order on Interactive Brokers TWS API 互动经纪商 python API 每个应用实例仅传输一个订单 - Interactive brokers python API only trasnmiting a single order per app instance 如何使用Interactive Brokers API将订单限制在特定时间内打开并在另一特定时间内关闭 - How to restrict order open to a certain time and close it in another certain time with Interactive Brokers API 下订单后如何在盈透证券新API(9.73)中获得交易价格和佣金? - How to get the trading price and commission in Interactive Brokers new API (9.73) after placing an order?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM