erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.75k stars 723 forks source link

Allow download of expired futures historical data #43

Closed cwengc closed 6 years ago

cwengc commented 6 years ago

Allow setting of includeExpired in contract field

erdewit commented 6 years ago

It already works:

from ib_insync import *
import datetime

fut = Future('ES', '201609', 'GLOBEX', includeExpired=True)
bars = ib.reqHistoricalData(fut, 
        endDateTime=datetime.date(2016, 9, 1),
        durationStr='60 D',
        barSizeSetting='1 hour',
        whatToShow='TRADES',
        useRTH=True,
        formatDate=1)
print(util.df(bars))