question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot update limit price of Combo order

See original GitHub issue

Hi, I have no problem creating and cancelling a limit combo order. However, whenever I try to modify the price, I’m getting

Error 105, reqId 5: Order being modified does not match original order.

Here is a code snippet for reproducing the issue:

from ib_insync import *
import datetime
import logging

def update_order(ib):
  spxw_contracts = [
      Option('SPX', '20220617', 1100, 'P', 'SMART', tradingClass='SPXW'),
      Option('SPX', '20220617', 1000, 'P', 'SMART', tradingClass='SPXW'),
  ]
  spxw_contracts = ib.qualifyContracts(*spxw_contracts)
  combo = Contract(
      secType='BAG',
      symbol='SPX',
      exchange='SMART',
      currency='USD',
      tradingClass='SPXW',
      comboLegs=[
          ComboLeg(
              conId=spxw_contracts[0].conId,
              ratio=1,
              action='SELL',
              exchange='SMART'),
          ComboLeg(
              conId=spxw_contracts[1].conId,
              ratio=1,
              action='BUY',
              exchange='SMART'),
      ])
  order = LimitOrder(action='BUY', totalQuantity=1, lmtPrice=-1.45, orderRef='spread_p_0.02_sto')
  trade = ib.placeOrder(combo, order)
  ib.sleep(5)
  order.lmtPrice = -1.40
  trade = ib.placeOrder(combo, order)
  ib.sleep(10)
  print(trade)


ib = IB()
ib.connect('127.0.0.1', 4001, clientId=37)
util.logToConsole(logging.DEBUG)

update_order(ib)

Even if I commented out the line of order.lmtPrice = -1.40 I still got the error message.

I’m using

ib_insync: 0.9.70 (this is also replicable in 0.9.66) tws_gateway: 10.15 (this is also replicable in 10.12)

Any thoughts? Thanks!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
volconstcommented, May 31, 2022

@4everlove , comment/remove the line specifying tradingClass=‘SPXW’ for the BAG contract

2reactions
rundefcommented, Jun 30, 2022

@volconst 's solution works

Here’s my code:

order.lmtPrice = -1.40
trade = ib.placeOrder(dataclasses.replace(combo, tradingClass=''), order)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Combo orders with stock and option legs. - IB Knowledge Base
Please note that although it is possible that both orders will be executed simultaneously at the combo price, there is no guarantee of...
Read more >
Limit Order: What It Is, How It Works & Examples - Seeking Alpha
Tip: A limit order guarantees a specified maximum price for purchases or a specified minimum price for sells. Trade execution, however, may not ......
Read more >
If a Stop-Limit Is Reached, Will It Always Sell? - Investopedia
In short, a stop-limit order doesn't guarantee you will sell, but it does guarantee you'll get the price you want if you can...
Read more >
Order Approving a Proposed Rule Change to Add a ... - SEC.gov
When the price of a D-Limit order is adjusted, the order will receive a new time priority. If multiple D-Limit orders are adjusted...
Read more >
Stock Order Types and Conditions: An Overview
A limit order is an order to buy or sell a stock with a restriction on the maximum price to be paid or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found