Calendar spreads on TWS API?

Discussion in 'Retail Brokers' started by TraDaToR, Nov 17, 2008.

  1. TraDaToR

    TraDaToR

    Hello,

    I think I 've already posted this one time before, but does someone know if we can get futures calendar spreads quotes on TWS API( excel )?

    I am talking about the real exchange calendar spread market and not the combination of expiry( like I think we get using "combo legs" to get quotes ).

    Should someone from IB answer this?

    Thanks a lot.
     
  2. Tums

    Tums

    what is real exchange calendar spread market?
     
  3. TraDaToR

    TraDaToR

    A calendar spread market with a distinct order book from the 2 outright expiry markets.

    I believe that if you use Combo legs in TWS API to buy a spread, they give you the further expiry ask minus front month bid instead of the "real exchange calendat spread"( LOL ) ask.

    Capiche?:)
     
  4. ryker

    ryker

    Hi,

    I realize this is an old thread but haven't found anything more recent on this. Does anyone know anything about this by any chance?
    I am looking at trading and getting market data for calendar spreads through the TWS API.

    Thanks
     
  5. 2rosy

    2rosy

    create a BAG instrument

    Code:
        def createBag( conidOne,  conidTwo, symbol, exchange='NYMEX'):
            leg1 =  ComboLeg()
            leg2 =  ComboLeg()
            addAllLegs = []
    
            print "conid in bag %s" % (conidOne)
            leg1.m_conId = conidOne
            leg1.m_ratio = 1
            leg1.m_action = "BUY"
            leg1.m_exchange = exchange
            leg1.m_openClose = 0
            leg1.m_shortSaleSlot = 0
            leg1.m_designatedLocation = ""
    
            leg2.m_conId = conidTwo
            leg2.m_ratio = 1
            leg2.m_action = "SELL"
            leg2.m_exchange = exchange
            leg2.m_openClose = 0
            leg2.m_shortSaleSlot = 0
            leg2.m_designatedLocation = ""
    
            addAllLegs.append(leg1)
            addAllLegs.append(leg2)
    
            contract = Contract()
            contract.m_symbol = "USD"     # For combo order use ?USD? as the symbol value all the time
            contract.m_secType = "BAG"   # BAG is the security type for COMBO order
            contract.m_exchange = exchange
            contract.m_currency = "USD"
            contract.m_comboLegs = addAllLegs #including combo order in contract object
            contract.m_symbol = symbol
            return contract
     
    TraDaToR likes this.
  6. ryker

    ryker

    Great thanks, will give this a try.
    Do you know by any chance if it is possible to get market data for this also? I looked in the API and it seems that getting data for BAG is not supported?
    Although I might be wrong...
     
  7. TraDaToR

    TraDaToR

    I was definitely getting the native spread datas through the excel DDE API. It was really long to gather all the conid ids though...