From e42c8136d95056708cd8ec4dbb1aa517f4902cb3 Mon Sep 17 00:00:00 2001 From: Bian Jiang Date: Thu, 5 May 2016 14:23:55 +0800 Subject: [PATCH] FIX IB Next Month Bug --- vn.trader/ibGateway/ibGateway.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vn.trader/ibGateway/ibGateway.py b/vn.trader/ibGateway/ibGateway.py index e9a17ec2..12e9ae6a 100644 --- a/vn.trader/ibGateway/ibGateway.py +++ b/vn.trader/ibGateway/ibGateway.py @@ -188,7 +188,7 @@ class IbGateway(VtGateway): # 期货 如果没有设置过期时间, 默认设置为下个月 dt_obj = datetime.now() 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') self.connection.reqMktData(self.tickerId, contract, '', False)