(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 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