FIX IB Next Month Bug

This commit is contained in:
Bian Jiang 2016-05-05 14:23:55 +08:00
parent adaf10c96e
commit e42c8136d9

View File

@ -188,7 +188,7 @@ class IbGateway(VtGateway):
# 期货 如果没有设置过期时间, 默认设置为下个月 # 期货 如果没有设置过期时间, 默认设置为下个月
dt_obj = datetime.now() dt_obj = datetime.now()
days = calendar.monthrange(dt_obj.year, dt_obj.month)[1] days = calendar.monthrange(dt_obj.year, dt_obj.month)[1]
nextMonth = dt_obj + timedelta(days=days) nextMonth = dt_obj + timedelta(days=(days - dt_obj.day + 1))
contract.m_expiry = nextMonth.strftime('%Y%m') contract.m_expiry = nextMonth.strftime('%Y%m')
self.connection.reqMktData(self.tickerId, contract, '', False) self.connection.reqMktData(self.tickerId, contract, '', False)