(Sorry for the rather abbreviated subject line, which I now find I cannot edit) I trade through IB, fully automated, using python code of my own design. Up to now I've used the following process to get contract expiries. - based on the liquid expiry cycle (quarterly, monthly or weird) get the next contract - create a contract with a 6 character expiry (eg "201510") - ask IB for the contract details. Obviously only one contract would match this specification. - receive back a contract object with an 8 character expiry However recently the exchange began listing VIX futures with weekly cycles. This means that 201510 is no longer a unique identifier for VIX; you need to specify which one. Assuming you want the normal monthly expiry this would be "20151021". If you don't specify this then step 3 will fail. (This isn't just me being dumb; there are quite a few threads for various products highlighting this problem - eg http://ninjatrader.com/support/forum/showthread.php?t=76470) As a result I've had to create a fairly ugly fix by including a hard coded list of expiry dates for each contract month. I've pored through the IB API documentation - nothing. I've also, and had a quick google, but I can't find anywhere that will provide me with the expiry calendar without writing some extremely ugly and involved scraping utility. Anyone here have any ideas? GAT
I'm not familiar with IBs API. Do they use the OCC OSI format? If they do, it would make sense to follow that. That way you will avoid issue in the future. It is a total of 21 characters. 6 for symbol, 6 for date, 1 for P/C, and 8 for the strike. http://www.theocc.com/components/docs/initiatives/symbology/symbology_initiative_v1_8.pdf
They don't use it, at least not for futures (I don't trade options) but that wouldn't help me. I could for example specify all expiry dates with an 8 character string. The issue I have is I need I nice way of getting those expiry dates to begin with. For every contract except VIX I just need to specify the 6 character YYYYMM date and ask IB to give me the 8 character date; and it's trivial to write code which says "I'm trading U5, Okay it's quarterly and all rolls are liquid, so the next contract is Z5'. GAT