diff --git a/vnpy/trader/app/ctaStrategy/ctaGridTrade.py b/vnpy/trader/app/ctaStrategy/ctaGridTrade.py index 2c09f7a2..1972b7a0 100644 --- a/vnpy/trader/app/ctaStrategy/ctaGridTrade.py +++ b/vnpy/trader/app/ctaStrategy/ctaGridTrade.py @@ -1,7 +1,7 @@ # encoding: UTF-8 -import os +import os,sys from datetime import datetime import json import uuid @@ -298,8 +298,8 @@ class CtaGridTrade(object): # 状态一致,价格大于最低价格 if direction == DIRECTION_LONG: - if begin == EMPTY_FLOAT: begin = 99999 - if end == EMPTY_FLOAT: end = -99999 + if begin == EMPTY_FLOAT: begin = sys.maxint + if end == EMPTY_FLOAT: end = 0-sys.maxint grids = [x for x in self.dnGrids if x.orderStatus == ordered and x.openStatus == opened @@ -312,8 +312,8 @@ class CtaGridTrade(object): # 状态一致,开仓价格小于最高价格 if direction == DIRECTION_SHORT: - if begin == EMPTY_FLOAT: begin = -99999 - if end == EMPTY_FLOAT: end = 99999 + if begin == EMPTY_FLOAT: begin = 0-sys.maxint + if end == EMPTY_FLOAT: end = sys.maxint grids = [x for x in self.upGrids if x.orderStatus == ordered and x.openStatus == opened @@ -632,10 +632,10 @@ class CtaGridTrade(object): """计算网格的平均开仓价""" up_open_list = [x for x in self.upGrids if x.openStatus] - self.max_up_open_price = -99999 - self.avg_up_open_price = -99999 - self.min_dn_open_price = 99999 - self.avg_dn_open_price = 99999 + self.max_up_open_price = 0 - sys.maxint + self.avg_up_open_price = 0 - sys.maxint + self.min_dn_open_price = sys.maxint + self.avg_dn_open_price = sys.maxint total_price = EMPTY_FLOAT total_volume = EMPTY_INT