Merge pull request #1119 from nanoric/extract_outputOptimizeResult
[Add] 将ctaBacktesting.outputOptimizeResult分离了出来
This commit is contained in:
commit
0e28c30b31
@ -48,6 +48,7 @@ if __name__ == '__main__':
|
||||
#engine.runOptimization(AtrRsiStrategy, setting)
|
||||
|
||||
# 多进程优化,耗时:89秒
|
||||
engine.runParallelOptimization(AtrRsiStrategy, setting)
|
||||
result = engine.runParallelOptimization(AtrRsiStrategy, setting)
|
||||
engine.outputOptimizeResult(result)
|
||||
|
||||
print(u'耗时:%s' %(time.time()-start))
|
@ -921,12 +921,8 @@ class BacktestingEngine(object):
|
||||
|
||||
# 显示结果
|
||||
resultList.sort(reverse=True, key=lambda result:result[1])
|
||||
self.output('-' * 30)
|
||||
self.output(u'优化结果:')
|
||||
for result in resultList:
|
||||
self.output(u'参数:%s,目标:%s' %(result[0], result[1]))
|
||||
return resultList
|
||||
|
||||
return self.outputOptimizeResult(resultList)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def runParallelOptimization(self, strategyClass, optimizationSetting):
|
||||
"""并行优化参数"""
|
||||
@ -954,11 +950,13 @@ class BacktestingEngine(object):
|
||||
# 显示结果
|
||||
resultList = [res.get() for res in l]
|
||||
resultList.sort(reverse=True, key=lambda result:result[1])
|
||||
return resultList
|
||||
|
||||
def outputOptimizeResult(self, resultList):
|
||||
self.output('-' * 30)
|
||||
self.output(u'优化结果:')
|
||||
for result in resultList:
|
||||
self.output(u'参数:%s,目标:%s' %(result[0], result[1]))
|
||||
|
||||
self.output(u'参数:%s,目标:%s' % (result[0], result[1]))
|
||||
return resultList
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -1379,4 +1377,4 @@ def optimize(strategyClass, setting, targetName,
|
||||
except KeyError:
|
||||
targetValue = 0
|
||||
return (str(setting), targetValue, d)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user