option spreads in Ib using API

Discussion in 'Order Execution' started by MushinSeeker, Jul 18, 2008.

  1. Hi. I am trying to submit a calendar equity option trade using the API and have been getting 2 kinds of errors-duplicate ID which is strange because I increment the id every time I submit an order. In addition, I also get a " security definition not found" even though I get the contract ID from TWs using the .reqcontractdetailsEx method. Here is my code in VB 6. I would sincerely appreciate any suggestions on how I can fire off a simple buy order of a calendar spread. I am a mid level Vb6 programmer but am pretty new w/ TWS.

    Private Sub Command2_Click()
    Dim x As Integer

    Set SpreadList = Tws1.createComboLegList

    Dim leg As twslib.IComboLeg
    Set leg = SpreadList.Add()
    leg.conId = 47857680
    leg.ratio = 1
    leg.Action = "BUY"
    leg.exchange = "SMART"
    leg.openClose = 0

    'Dim leg As twslib.IComboLeg
    Set leg = SpreadList.Add()
    leg.conId = 47857767
    leg.ratio = 1
    leg.Action = "SELL"
    leg.exchange = "SMART"
    leg.openClose = 0

    Set x_contInfo = Tws1.createContract
    x_contInfo.symbol = "QQQQ"
    x_contInfo.secType = "BAG"
    x_contInfo.exchange = "SMART"
    x_contInfo.comboLegs = SpreadList
    Set x_OrderTix = Tws1.createOrder
    x_OrderTix.Action = "BUY"
    x_contInfo.conId = 0

    x_OrderTix.lmtPrice = 0.04
    x_OrderTix.totalQuantity = 1
    x_OrderTix.orderType = "LMT"
    x_OrderTix.timeInForce = "GTC"
    x_OrderTix.orderId = txtRow.Text
    Call Tws1.placeOrderEx(txtRow.Text, x_contInfo, x_OrderTix)



    End Sub
     
  2. I don't know if this would help you or not. In case you are programatically placing option orders, I read today that is not possible since against the exchange rules and must manually hit an OK button to place the order.
    HTH
     
  3. That rule has been around for a long time. This code portion just loads up the spread order onto TWS where I have to manually hit the "T"ransmit button . I just find TWS combo order modules too cumbersome ( I have to manually enter the strike prices, the months,etc. I just want to enter 2 legs, enter the spreads limit price then transmit. Is there any other way to load a combo such as a vertical/calendar on TWS using another front end. The ones I saw like buttontrader does not encompass options. Thanks.
     
  4. If you're in the OptionTrader of TWS and you open the "Option Spreads" interface (button of the same name), you can drag and drop options and create any arbitrary spread.

    You don't have to manually type in strikes, etc.