From bef9248e7e4db5f36007e57360758c48cfe7963a Mon Sep 17 00:00:00 2001 From: chenxy123 Date: Tue, 22 Nov 2016 21:35:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0cta=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=82=E6=95=B0=E6=97=B6=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E5=8F=82=E6=95=B0=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/ctaAlgo/ctaBacktesting.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vn.trader/ctaAlgo/ctaBacktesting.py b/vn.trader/ctaAlgo/ctaBacktesting.py index f00d2cf9..95e042d6 100644 --- a/vn.trader/ctaAlgo/ctaBacktesting.py +++ b/vn.trader/ctaAlgo/ctaBacktesting.py @@ -764,6 +764,7 @@ class BacktestingEngine(object): # 多进程优化,启动一个对应CPU核心数量的进程池 pool = multiprocessing.Pool(multiprocessing.cpu_count()) l = [] + for setting in settingList: l.append(pool.apply_async(optimize, (strategyClass, setting, targetName, self.mode, @@ -817,10 +818,14 @@ class OptimizationSetting(object): self.optimizeTarget = '' # 优化目标字段 #---------------------------------------------------------------------- - def addParameter(self, name, start, end, step): + def addParameter(self, name, start, end=None, step=None): """增加优化参数""" - if end <= start: - print u'参数起始点必须小于终止点' + if end is None and step is None: + self.paramDict[name] = [start] + return + + if end < start: + print u'参数起始点必须不大于终止点' return if step <= 0: