[Add]change variable names

This commit is contained in:
vn.py 2019-05-03 15:17:32 +08:00
parent 4385dd871a
commit 6e3b7faae3
3 changed files with 76 additions and 568 deletions

View File

@ -10,12 +10,11 @@
"import multiprocessing\n", "import multiprocessing\n",
"import numpy as np\n", "import numpy as np\n",
"from deap import creator, base, tools, algorithms\n", "from deap import creator, base, tools, algorithms\n",
"from backtesting import BacktestingEngine,OptimizationSetting\n", "from vnpy.app.cta_strategy.backtesting import BacktestingEngine,OptimizationSetting\n",
"from boll_channel_strategy import BollChannelStrategy\n", "from vnpy.app.cta_strategy.strategies.boll_channel_strategy import BollChannelStrategy\n",
"from atr_rsi_strategy import AtrRsiStrategy\n", "from vnpy.app.cta_strategy.strategies.atr_rsi_strategy import AtrRsiStrategy\n",
"from datetime import datetime\n", "from datetime import datetime\n",
"import multiprocessing #多进程\n", "import multiprocessing #多进程\n",
"from scoop import futures #多进程\n",
"from functools import lru_cache" "from functools import lru_cache"
] ]
}, },
@ -89,7 +88,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"[22, 28, 22]" "[48, 6, 26]"
] ]
}, },
"execution_count": 5, "execution_count": 5,
@ -109,7 +108,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"{'boll_window': 24, 'cci_window': 14, 'atr_window': 28}" "{'boll_window': 16, 'cci_window': 48, 'atr_window': 6}"
] ]
}, },
"execution_count": 6, "execution_count": 6,
@ -171,10 +170,24 @@
"execution_count": 8, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2019-05-03 15:02:07.528909\t开始加载历史数据\n",
"2019-05-03 15:02:34.854177\t历史数据加载完成数据量175440\n",
"2019-05-03 15:02:34.877616\t策略初始化完成\n",
"2019-05-03 15:02:34.877616\t开始回放历史数据\n",
"2019-05-03 15:02:37.000744\t历史数据回放结束\n",
"2019-05-03 15:02:37.000744\t开始计算逐日盯市盈亏\n",
"2019-05-03 15:02:37.012463\t逐日盯市盈亏计算完成\n",
"2019-05-03 15:02:37.012463\t开始计算策略统计指标\n"
]
},
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"(-0.51, -0.28)" "(0.96, 0.38)"
] ]
}, },
"execution_count": 8, "execution_count": 8,
@ -224,8 +237,8 @@
" toolbox.register(\"mutate\", tools.mutUniformInt,low = 4,up = 40,indpb=1) \n", " toolbox.register(\"mutate\", tools.mutUniformInt,low = 4,up = 40,indpb=1) \n",
" toolbox.register(\"evaluate\", object_func) \n", " toolbox.register(\"evaluate\", object_func) \n",
" toolbox.register(\"select\", tools.selNSGA2) \n", " toolbox.register(\"select\", tools.selNSGA2) \n",
" #pool = multiprocessing.Pool()\n", " pool = multiprocessing.Pool(multiprocessing.cpu_count())\n",
" #toolbox.register(\"map\", pool.map)\n", " toolbox.register(\"map\", pool.map)\n",
" #toolbox.register(\"map\", futures.map)\n", " #toolbox.register(\"map\", futures.map)\n",
" \n", " \n",
" \n", " \n",
@ -266,7 +279,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"metadata": { "metadata": {
"scrolled": false "scrolled": false
}, },
@ -275,43 +288,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"开始运行遗传算法每代族群总数34, 优良品种筛选个数27迭代次数30交叉概率0.95突变概率0.05\n", "开始运行遗传算法每代族群总数34, 优良品种筛选个数27迭代次数30交叉概率0.95突变概率0.05\n"
"gen\tnevals\tmean \tstd \tmin \tmax \n",
"0 \t34 \t[0.08852941 0.00352941]\t[0.5373362 0.29107188]\t[-0.7 -0.63]\t[1.51 0.5 ]\n",
"1 \t34 \t[0.60148148 0.27518519]\t[0.31013383 0.08573734]\t[0.32 0.18] \t[1.51 0.5 ]\n",
"2 \t34 \t[0.79333333 0.33851852]\t[0.27758215 0.06742369]\t[0.47 0.25] \t[1.54 0.5 ]\n",
"3 \t34 \t[1.00888889 0.39777778]\t[0.3147525 0.06214281]\t[0.7 0.33] \t[1.54 0.5 ]\n",
"4 \t34 \t[1.41074074 0.47444444]\t[0.22881217 0.04661373]\t[0.96 0.36] \t[1.92 0.57]\n",
"5 \t34 \t[1.59666667 0.51222222]\t[0.14714568 0.0255797 ]\t[1.51 0.49] \t[1.92 0.57]\n",
"6 \t34 \t[1.66259259 0.52185185]\t[0.16585564 0.02981884]\t[1.52 0.49] \t[1.92 0.57]\n",
"7 \t34 \t[1.8737037 0.55666667]\t[0.07713135 0.01763834]\t[1.75 0.53] \t[1.95 0.57]\n",
"8 \t34 \t[1.93666667 0.57 ]\t[0.01490712 0. ]\t[1.92 0.57] \t[1.95 0.57]\n",
"9 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"10 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"11 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"12 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"13 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"14 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"15 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"16 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"17 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"18 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"19 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"20 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"21 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"22 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"23 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"24 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"25 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"26 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"27 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"28 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"29 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"30 \t34 \t[1.95 0.57] \t[0. 0.] \t[1.95 0.57] \t[1.95 0.57]\n",
"遗传算法优化完成耗时309秒\n",
"输出帕累托前沿解集:\n",
"{'boll_window': 48, 'cci_window': 40, 'atr_window': 22, 'return_drawdown_ratio': 1.95, 'sharpe_ratio': 0.57}\n",
"{'boll_window': 48, 'cci_window': 50, 'atr_window': 22, 'return_drawdown_ratio': 1.95, 'sharpe_ratio': 0.57}\n"
] ]
} }
], ],

View File

@ -61,517 +61,33 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"2019-05-02 22:29:22.289010\t开始运行遗传算法每代族群总数100, 优良品种筛选个数80迭代次数300交叉概率0.95突变概率0.05\n", "2019-05-03 14:58:44.510371\t开始运行遗传算法每代族群总数20, 优良品种筛选个数16迭代次数300交叉概率0.95突变概率0.05\n"
"2019-05-02 22:29:22.289010\t开始加载历史数据\n",
"2019-05-02 22:29:24.103532\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:24.173848\t策略初始化完成\n",
"2019-05-02 22:29:24.173848\t开始回放历史数据\n",
"2019-05-02 22:29:24.788129\t历史数据回放结束\n",
"2019-05-02 22:29:24.789106\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:24.789106\t成交记录为空无法计算\n",
"2019-05-02 22:29:24.789106\t开始计算策略统计指标\n",
"2019-05-02 22:29:24.789106\t开始加载历史数据\n",
"2019-05-02 22:29:24.789106\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:24.867234\t策略初始化完成\n",
"2019-05-02 22:29:24.868210\t开始回放历史数据\n",
"2019-05-02 22:29:25.834068\t历史数据回放结束\n",
"2019-05-02 22:29:25.835044\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:25.839927\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:25.840904\t开始计算策略统计指标\n",
"2019-05-02 22:29:25.856529\t开始加载历史数据\n",
"2019-05-02 22:29:25.857506\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:25.939540\t策略初始化完成\n",
"2019-05-02 22:29:25.939540\t开始回放历史数据\n",
"2019-05-02 22:29:27.055794\t历史数据回放结束\n",
"2019-05-02 22:29:27.056771\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:27.062630\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:27.062630\t开始计算策略统计指标\n",
"2019-05-02 22:29:27.074350\t开始加载历史数据\n",
"2019-05-02 22:29:27.074350\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:27.156384\t策略初始化完成\n",
"2019-05-02 22:29:27.156384\t开始回放历史数据\n",
"2019-05-02 22:29:28.159352\t历史数据回放结束\n",
"2019-05-02 22:29:28.160329\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:28.165212\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:28.165212\t开始计算策略统计指标\n",
"2019-05-02 22:29:28.176931\t开始加载历史数据\n",
"2019-05-02 22:29:28.176931\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:28.260919\t策略初始化完成\n",
"2019-05-02 22:29:28.260919\t开始回放历史数据\n",
"2019-05-02 22:29:29.418190\t历史数据回放结束\n",
"2019-05-02 22:29:29.418190\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:29.424049\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:29.424049\t开始计算策略统计指标\n",
"2019-05-02 22:29:29.436745\t开始加载历史数据\n",
"2019-05-02 22:29:29.436745\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:29.521709\t策略初始化完成\n",
"2019-05-02 22:29:29.522686\t开始回放历史数据\n",
"2019-05-02 22:29:30.513935\t历史数据回放结束\n",
"2019-05-02 22:29:30.514911\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:30.519794\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:30.519794\t开始计算策略统计指标\n",
"2019-05-02 22:29:30.531514\t开始加载历史数据\n",
"2019-05-02 22:29:30.531514\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:30.611595\t策略初始化完成\n",
"2019-05-02 22:29:30.611595\t开始回放历史数据\n",
"2019-05-02 22:29:31.729802\t历史数据回放结束\n",
"2019-05-02 22:29:31.730778\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:31.735661\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:31.735661\t开始计算策略统计指标\n",
"2019-05-02 22:29:31.747381\t开始加载历史数据\n",
"2019-05-02 22:29:31.747381\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:31.825509\t策略初始化完成\n",
"2019-05-02 22:29:31.826485\t开始回放历史数据\n",
"2019-05-02 22:29:32.840196\t历史数据回放结束\n",
"2019-05-02 22:29:32.840196\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:32.846056\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:32.847032\t开始计算策略统计指标\n",
"2019-05-02 22:29:32.858751\t开始加载历史数据\n",
"2019-05-02 22:29:32.858751\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:32.936879\t策略初始化完成\n",
"2019-05-02 22:29:32.936879\t开始回放历史数据\n",
"2019-05-02 22:29:34.065829\t历史数据回放结束\n",
"2019-05-02 22:29:34.066806\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:34.071689\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:34.072665\t开始计算策略统计指标\n",
"2019-05-02 22:29:34.085361\t开始加载历史数据\n",
"2019-05-02 22:29:34.085361\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:34.161536\t策略初始化完成\n",
"2019-05-02 22:29:34.162512\t开始回放历史数据\n",
"2019-05-02 22:29:35.174270\t历史数据回放结束\n",
"2019-05-02 22:29:35.175247\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:35.180130\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:35.180130\t开始计算策略统计指标\n",
"2019-05-02 22:29:35.192825\t开始加载历史数据\n",
"2019-05-02 22:29:35.192825\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:35.274860\t策略初始化完成\n",
"2019-05-02 22:29:35.274860\t开始回放历史数据\n",
"2019-05-02 22:29:35.918439\t历史数据回放结束\n",
"2019-05-02 22:29:35.918439\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:35.918439\t成交记录为空无法计算\n",
"2019-05-02 22:29:35.918439\t开始计算策略统计指标\n",
"2019-05-02 22:29:35.918439\t开始加载历史数据\n",
"2019-05-02 22:29:35.918439\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:35.999497\t策略初始化完成\n",
"2019-05-02 22:29:35.999497\t开始回放历史数据\n",
"2019-05-02 22:29:36.671398\t历史数据回放结束\n",
"2019-05-02 22:29:36.671398\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:36.672374\t成交记录为空无法计算\n",
"2019-05-02 22:29:36.672374\t开始计算策略统计指标\n",
"2019-05-02 22:29:36.673351\t开始加载历史数据\n",
"2019-05-02 22:29:36.673351\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:36.761245\t策略初始化完成\n",
"2019-05-02 22:29:36.762222\t开始回放历史数据\n",
"2019-05-02 22:29:37.830622\t历史数据回放结束\n",
"2019-05-02 22:29:37.831599\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:37.837458\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:37.837458\t开始计算策略统计指标\n",
"2019-05-02 22:29:37.849177\t开始加载历史数据\n",
"2019-05-02 22:29:37.849177\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:37.926329\t策略初始化完成\n",
"2019-05-02 22:29:37.927305\t开始回放历史数据\n",
"2019-05-02 22:29:38.877537\t历史数据回放结束\n",
"2019-05-02 22:29:38.878514\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:38.884373\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:38.884373\t开始计算策略统计指标\n",
"2019-05-02 22:29:38.895116\t开始加载历史数据\n",
"2019-05-02 22:29:38.896093\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:38.974221\t策略初始化完成\n",
"2019-05-02 22:29:38.974221\t开始回放历史数据\n",
"2019-05-02 22:29:40.131492\t历史数据回放结束\n",
"2019-05-02 22:29:40.131492\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:40.137351\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:40.137351\t开始计算策略统计指标\n",
"2019-05-02 22:29:40.149070\t开始加载历史数据\n",
"2019-05-02 22:29:40.149070\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:40.234035\t策略初始化完成\n",
"2019-05-02 22:29:40.235011\t开始回放历史数据\n",
"2019-05-02 22:29:41.257511\t历史数据回放结束\n",
"2019-05-02 22:29:41.258488\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:41.263371\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:41.263371\t开始计算策略统计指标\n",
"2019-05-02 22:29:41.275090\t开始加载历史数据\n",
"2019-05-02 22:29:41.275090\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:41.353218\t策略初始化完成\n",
"2019-05-02 22:29:41.353218\t开始回放历史数据\n",
"2019-05-02 22:29:42.819095\t历史数据回放结束\n",
"2019-05-02 22:29:42.819095\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:42.823978\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:42.823978\t开始计算策略统计指标\n",
"2019-05-02 22:29:42.835697\t开始加载历史数据\n",
"2019-05-02 22:29:42.836674\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:42.917731\t策略初始化完成\n",
"2019-05-02 22:29:42.917731\t开始回放历史数据\n",
"2019-05-02 22:29:43.901168\t历史数据回放结束\n",
"2019-05-02 22:29:43.901168\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:43.907027\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:43.908004\t开始计算策略统计指标\n",
"2019-05-02 22:29:43.920700\t开始加载历史数据\n",
"2019-05-02 22:29:43.921676\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:44.004687\t策略初始化完成\n",
"2019-05-02 22:29:44.005664\t开始回放历史数据\n",
"2019-05-02 22:29:45.120941\t历史数据回放结束\n",
"2019-05-02 22:29:45.121918\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:45.126801\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:45.126801\t开始计算策略统计指标\n",
"2019-05-02 22:29:45.137543\t开始加载历史数据\n",
"2019-05-02 22:29:45.138520\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:45.216648\t策略初始化完成\n",
"2019-05-02 22:29:45.217624\t开始回放历史数据\n",
"2019-05-02 22:29:46.272352\t历史数据回放结束\n",
"2019-05-02 22:29:46.272352\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:46.277235\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:46.278212\t开始计算策略统计指标\n",
"2019-05-02 22:29:46.289931\t开始加载历史数据\n",
"2019-05-02 22:29:46.289931\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:46.372942\t策略初始化完成\n",
"2019-05-02 22:29:46.372942\t开始回放历史数据\n",
"2019-05-02 22:29:47.500915\t历史数据回放结束\n",
"2019-05-02 22:29:47.501892\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:47.507751\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:47.507751\t开始计算策略统计指标\n",
"2019-05-02 22:29:47.519471\t开始加载历史数据\n",
"2019-05-02 22:29:47.519471\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:47.590762\t策略初始化完成\n",
"2019-05-02 22:29:47.590762\t开始回放历史数据\n",
"2019-05-02 22:29:48.230435\t历史数据回放结束\n",
"2019-05-02 22:29:48.231412\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:48.231412\t成交记录为空无法计算\n",
"2019-05-02 22:29:48.231412\t开始计算策略统计指标\n",
"2019-05-02 22:29:48.231412\t开始加载历史数据\n",
"2019-05-02 22:29:48.231412\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:48.315400\t策略初始化完成\n",
"2019-05-02 22:29:48.315400\t开始回放历史数据\n",
"2019-05-02 22:29:49.317391\t历史数据回放结束\n",
"2019-05-02 22:29:49.317391\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:49.323251\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:49.323251\t开始计算策略统计指标\n",
"2019-05-02 22:29:49.335947\t开始加载历史数据\n",
"2019-05-02 22:29:49.335947\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:49.416028\t策略初始化完成\n",
"2019-05-02 22:29:49.416028\t开始回放历史数据\n",
"2019-05-02 22:29:50.513726\t历史数据回放结束\n",
"2019-05-02 22:29:50.513726\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:50.519586\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:50.519586\t开始计算策略统计指标\n",
"2019-05-02 22:29:50.531305\t开始加载历史数据\n",
"2019-05-02 22:29:50.531305\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:50.610410\t策略初始化完成\n",
"2019-05-02 22:29:50.611386\t开始回放历史数据\n",
"2019-05-02 22:29:51.688576\t历史数据回放结束\n",
"2019-05-02 22:29:51.689553\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:51.694436\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:51.695412\t开始计算策略统计指标\n",
"2019-05-02 22:29:51.707131\t开始加载历史数据\n",
"2019-05-02 22:29:51.708108\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:51.804791\t策略初始化完成\n",
"2019-05-02 22:29:51.807721\t开始回放历史数据\n",
"2019-05-02 22:29:53.077301\t历史数据回放结束\n",
"2019-05-02 22:29:53.078278\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:53.083161\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:53.083161\t开始计算策略统计指标\n",
"2019-05-02 22:29:53.094880\t开始加载历史数据\n",
"2019-05-02 22:29:53.094880\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:53.182774\t策略初始化完成\n",
"2019-05-02 22:29:53.183751\t开始回放历史数据\n",
"2019-05-02 22:29:54.420126\t历史数据回放结束\n",
"2019-05-02 22:29:54.421103\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:54.425986\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:54.425986\t开始计算策略统计指标\n",
"2019-05-02 22:29:54.437705\t开始加载历史数据\n",
"2019-05-02 22:29:54.437705\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:54.517786\t策略初始化完成\n",
"2019-05-02 22:29:54.517786\t开始回放历史数据\n"
] ]
}, },
{ {
"name": "stdout", "ename": "AttributeError",
"output_type": "stream", "evalue": "Can't pickle local object 'create_ga_optimize.<locals>.ga_optimize'",
"text": [
"2019-05-02 22:29:55.671151\t历史数据回放结束\n",
"2019-05-02 22:29:55.672127\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:55.677010\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:55.677987\t开始计算策略统计指标\n",
"2019-05-02 22:29:55.689706\t开始加载历史数据\n",
"2019-05-02 22:29:55.689706\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:55.767834\t策略初始化完成\n",
"2019-05-02 22:29:55.767834\t开始回放历史数据\n",
"2019-05-02 22:29:56.790334\t历史数据回放结束\n",
"2019-05-02 22:29:56.790334\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:56.796194\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:56.796194\t开始计算策略统计指标\n",
"2019-05-02 22:29:56.806937\t开始加载历史数据\n",
"2019-05-02 22:29:56.807913\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:56.889948\t策略初始化完成\n",
"2019-05-02 22:29:56.890924\t开始回放历史数据\n",
"2019-05-02 22:29:57.607749\t历史数据回放结束\n",
"2019-05-02 22:29:57.608725\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:57.608725\t成交记录为空无法计算\n",
"2019-05-02 22:29:57.608725\t开始计算策略统计指标\n",
"2019-05-02 22:29:57.608725\t开始加载历史数据\n",
"2019-05-02 22:29:57.609702\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:57.698572\t策略初始化完成\n",
"2019-05-02 22:29:57.699549\t开始回放历史数据\n",
"2019-05-02 22:29:58.882212\t历史数据回放结束\n",
"2019-05-02 22:29:58.882212\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:29:58.888071\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:29:58.888071\t开始计算策略统计指标\n",
"2019-05-02 22:29:58.898814\t开始加载历史数据\n",
"2019-05-02 22:29:58.898814\t历史数据加载完成数据量18240\n",
"2019-05-02 22:29:58.986708\t策略初始化完成\n",
"2019-05-02 22:29:58.987684\t开始回放历史数据\n",
"2019-05-02 22:30:00.071710\t历史数据回放结束\n",
"2019-05-02 22:30:00.072687\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:00.077570\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:00.081476\t开始计算策略统计指标\n",
"2019-05-02 22:30:00.092219\t开始加载历史数据\n",
"2019-05-02 22:30:00.095149\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:00.173277\t策略初始化完成\n",
"2019-05-02 22:30:00.174253\t开始回放历史数据\n",
"2019-05-02 22:30:00.906703\t历史数据回放结束\n",
"2019-05-02 22:30:00.907680\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:00.907680\t成交记录为空无法计算\n",
"2019-05-02 22:30:00.908657\t开始计算策略统计指标\n",
"2019-05-02 22:30:00.908657\t开始加载历史数据\n",
"2019-05-02 22:30:00.908657\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:01.018036\t策略初始化完成\n",
"2019-05-02 22:30:01.019012\t开始回放历史数据\n",
"2019-05-02 22:30:02.128430\t历史数据回放结束\n",
"2019-05-02 22:30:02.135266\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:02.141126\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:02.141126\t开始计算策略统计指标\n",
"2019-05-02 22:30:02.151868\t开始加载历史数据\n",
"2019-05-02 22:30:02.152845\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:02.229020\t策略初始化完成\n",
"2019-05-02 22:30:02.229020\t开始回放历史数据\n",
"2019-05-02 22:30:03.410706\t历史数据回放结束\n",
"2019-05-02 22:30:03.411682\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:03.416565\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:03.416565\t开始计算策略统计指标\n",
"2019-05-02 22:30:03.428285\t开始加载历史数据\n",
"2019-05-02 22:30:03.429261\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:03.533757\t策略初始化完成\n",
"2019-05-02 22:30:03.533757\t开始回放历史数据\n",
"2019-05-02 22:30:04.638292\t历史数据回放结束\n",
"2019-05-02 22:30:04.638292\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:04.643175\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:04.644152\t开始计算策略统计指标\n",
"2019-05-02 22:30:04.654894\t开始加载历史数据\n",
"2019-05-02 22:30:04.654894\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:04.738882\t策略初始化完成\n",
"2019-05-02 22:30:04.738882\t开始回放历史数据\n",
"2019-05-02 22:30:05.721341\t历史数据回放结束\n",
"2019-05-02 22:30:05.722318\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:05.728178\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:05.728178\t开始计算策略统计指标\n",
"2019-05-02 22:30:05.739897\t开始加载历史数据\n",
"2019-05-02 22:30:05.739897\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:05.824861\t策略初始化完成\n",
"2019-05-02 22:30:05.825838\t开始回放历史数据\n",
"2019-05-02 22:30:06.928419\t历史数据回放结束\n",
"2019-05-02 22:30:06.928419\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:06.933302\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:06.934279\t开始计算策略统计指标\n",
"2019-05-02 22:30:06.945998\t开始加载历史数据\n",
"2019-05-02 22:30:06.945998\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:07.024126\t策略初始化完成\n",
"2019-05-02 22:30:07.025102\t开始回放历史数据\n",
"2019-05-02 22:30:08.041743\t历史数据回放结束\n",
"2019-05-02 22:30:08.042720\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:08.048579\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:08.048579\t开始计算策略统计指标\n",
"2019-05-02 22:30:08.062252\t开始加载历史数据\n",
"2019-05-02 22:30:08.062252\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:08.145263\t策略初始化完成\n",
"2019-05-02 22:30:08.145263\t开始回放历史数据\n",
"2019-05-02 22:30:09.292768\t历史数据回放结束\n",
"2019-05-02 22:30:09.293744\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:09.298627\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:09.298627\t开始计算策略统计指标\n",
"2019-05-02 22:30:09.311323\t开始加载历史数据\n",
"2019-05-02 22:30:09.311323\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:09.393357\t策略初始化完成\n",
"2019-05-02 22:30:09.393357\t开始回放历史数据\n",
"2019-05-02 22:30:10.363121\t历史数据回放结束\n",
"2019-05-02 22:30:10.363121\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:10.368981\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:10.369957\t开始计算策略统计指标\n",
"2019-05-02 22:30:10.380700\t开始加载历史数据\n",
"2019-05-02 22:30:10.381677\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:10.459805\t策略初始化完成\n",
"2019-05-02 22:30:10.459805\t开始回放历史数据\n",
"2019-05-02 22:30:11.536994\t历史数据回放结束\n",
"2019-05-02 22:30:11.536994\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:11.542854\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:11.542854\t开始计算策略统计指标\n",
"2019-05-02 22:30:11.554573\t开始加载历史数据\n",
"2019-05-02 22:30:11.554573\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:11.638561\t策略初始化完成\n",
"2019-05-02 22:30:11.639537\t开始回放历史数据\n",
"2019-05-02 22:30:12.632740\t历史数据回放结束\n",
"2019-05-02 22:30:12.633716\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:12.638599\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:12.639576\t开始计算策略统计指标\n",
"2019-05-02 22:30:12.650318\t开始加载历史数据\n",
"2019-05-02 22:30:12.651295\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:12.733329\t策略初始化完成\n",
"2019-05-02 22:30:12.734306\t开始回放历史数据\n",
"2019-05-02 22:30:13.352494\t历史数据回放结束\n",
"2019-05-02 22:30:13.353470\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:13.353470\t成交记录为空无法计算\n",
"2019-05-02 22:30:13.353470\t开始计算策略统计指标\n",
"2019-05-02 22:30:13.354447\t开始加载历史数据\n",
"2019-05-02 22:30:13.354447\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:13.436481\t策略初始化完成\n",
"2019-05-02 22:30:13.436481\t开始回放历史数据\n",
"2019-05-02 22:30:14.540039\t历史数据回放结束\n",
"2019-05-02 22:30:14.541016\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:14.546876\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:14.546876\t开始计算策略统计指标\n",
"2019-05-02 22:30:14.558595\t开始加载历史数据\n",
"2019-05-02 22:30:14.558595\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:14.650395\t策略初始化完成\n",
"2019-05-02 22:30:14.650395\t开始回放历史数据\n",
"2019-05-02 22:30:15.294951\t历史数据回放结束\n",
"2019-05-02 22:30:15.294951\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:15.294951\t成交记录为空无法计算\n",
"2019-05-02 22:30:15.294951\t开始计算策略统计指标\n",
"2019-05-02 22:30:15.294951\t开始加载历史数据\n",
"2019-05-02 22:30:15.294951\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:15.377962\t策略初始化完成\n",
"2019-05-02 22:30:15.377962\t开始回放历史数据\n",
"2019-05-02 22:30:16.346749\t历史数据回放结束\n",
"2019-05-02 22:30:16.346749\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:16.352609\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:16.352609\t开始计算策略统计指标\n",
"2019-05-02 22:30:16.365305\t开始加载历史数据\n",
"2019-05-02 22:30:16.365305\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:16.445386\t策略初始化完成\n",
"2019-05-02 22:30:16.446363\t开始回放历史数据\n",
"2019-05-02 22:30:17.544061\t历史数据回放结束\n",
"2019-05-02 22:30:17.545038\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:17.550897\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:17.550897\t开始计算策略统计指标\n",
"2019-05-02 22:30:17.563593\t开始加载历史数据\n",
"2019-05-02 22:30:17.563593\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:17.640744\t策略初始化完成\n",
"2019-05-02 22:30:17.640744\t开始回放历史数据\n",
"2019-05-02 22:30:18.641759\t历史数据回放结束\n",
"2019-05-02 22:30:18.642736\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:18.647619\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:18.647619\t开始计算策略统计指标\n",
"2019-05-02 22:30:18.659338\t开始加载历史数据\n",
"2019-05-02 22:30:18.660315\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:18.736490\t策略初始化完成\n",
"2019-05-02 22:30:18.736490\t开始回放历史数据\n",
"2019-05-02 22:30:19.827352\t历史数据回放结束\n",
"2019-05-02 22:30:19.828328\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:19.833211\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:19.833211\t开始计算策略统计指标\n",
"2019-05-02 22:30:19.844931\t开始加载历史数据\n",
"2019-05-02 22:30:19.845907\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:19.927942\t策略初始化完成\n",
"2019-05-02 22:30:19.928918\t开始回放历史数据\n",
"2019-05-02 22:30:20.916261\t历史数据回放结束\n",
"2019-05-02 22:30:20.916261\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:20.922120\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:20.922120\t开始计算策略统计指标\n",
"2019-05-02 22:30:20.934816\t开始加载历史数据\n",
"2019-05-02 22:30:20.935793\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:21.010991\t策略初始化完成\n",
"2019-05-02 22:30:21.011968\t开始回放历史数据\n",
"2019-05-02 22:30:22.131151\t历史数据回放结束\n",
"2019-05-02 22:30:22.131151\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:22.137011\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:22.137011\t开始计算策略统计指标\n",
"2019-05-02 22:30:22.149707\t开始加载历史数据\n",
"2019-05-02 22:30:22.149707\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:22.227835\t策略初始化完成\n",
"2019-05-02 22:30:22.228811\t开始回放历史数据\n",
"2019-05-02 22:30:23.201505\t历史数据回放结束\n",
"2019-05-02 22:30:23.202481\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:23.207364\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:23.207364\t开始计算策略统计指标\n",
"2019-05-02 22:30:23.219084\t开始加载历史数据\n",
"2019-05-02 22:30:23.219084\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:23.295258\t策略初始化完成\n",
"2019-05-02 22:30:23.295258\t开始回放历史数据\n",
"2019-05-02 22:30:24.418348\t历史数据回放结束\n",
"2019-05-02 22:30:24.418348\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:24.423231\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:24.424208\t开始计算策略统计指标\n",
"2019-05-02 22:30:24.437880\t开始加载历史数据\n",
"2019-05-02 22:30:24.437880\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:24.517962\t策略初始化完成\n",
"2019-05-02 22:30:24.517962\t开始回放历史数据\n",
"2019-05-02 22:30:25.200605\t历史数据回放结束\n",
"2019-05-02 22:30:25.201582\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:25.201582\t成交记录为空无法计算\n",
"2019-05-02 22:30:25.202558\t开始计算策略统计指标\n",
"2019-05-02 22:30:25.202558\t开始加载历史数据\n",
"2019-05-02 22:30:25.203535\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:25.275803\t策略初始化完成\n",
"2019-05-02 22:30:25.276780\t开始回放历史数据\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"2019-05-02 22:30:25.947704\t历史数据回放结束\n",
"2019-05-02 22:30:25.948681\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:25.948681\t成交记录为空无法计算\n",
"2019-05-02 22:30:25.949657\t开始计算策略统计指标\n",
"2019-05-02 22:30:25.949657\t开始加载历史数据\n",
"2019-05-02 22:30:25.949657\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:26.027785\t策略初始化完成\n",
"2019-05-02 22:30:26.027785\t开始回放历史数据\n",
"2019-05-02 22:30:27.024894\t历史数据回放结束\n",
"2019-05-02 22:30:27.025870\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:27.030753\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:27.030753\t开始计算策略统计指标\n",
"2019-05-02 22:30:27.042473\t开始加载历史数据\n",
"2019-05-02 22:30:27.042473\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:27.127437\t策略初始化完成\n",
"2019-05-02 22:30:27.128413\t开始回放历史数据\n",
"2019-05-02 22:30:28.317912\t历史数据回放结束\n",
"2019-05-02 22:30:28.317912\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:28.323772\t逐日盯市盈亏计算完成\n",
"2019-05-02 22:30:28.324748\t开始计算策略统计指标\n",
"2019-05-02 22:30:28.335491\t开始加载历史数据\n",
"2019-05-02 22:30:28.336468\t历史数据加载完成数据量18240\n",
"2019-05-02 22:30:28.412642\t策略初始化完成\n",
"2019-05-02 22:30:28.413619\t开始回放历史数据\n",
"2019-05-02 22:30:29.072824\t历史数据回放结束\n",
"2019-05-02 22:30:29.072824\t开始计算逐日盯市盈亏\n",
"2019-05-02 22:30:29.072824\t成交记录为空无法计算\n",
"2019-05-02 22:30:29.072824\t开始计算策略统计指标\n",
"gen\tnevals\tmean \tstd \tmin \tmax \n",
"0 \t100 \t[1.24452619]\t[2.90495733]\t[-3.24204978]\t[8.88922512]\n"
]
},
{
"ename": "ValueError",
"evalue": "empty range for randrange() (1,1, 0)",
"output_type": "error", "output_type": "error",
"traceback": [ "traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-3-4726e35b67fb>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0msetting\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0madd_parameter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"atr_length\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m3\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m105\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mengine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrun_ga_optimization\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msetting\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;32m<ipython-input-3-d83ea019c683>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0msetting\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0madd_parameter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"atr_ma_length\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m10\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m80\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m \u001b[0mengine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrun_ga_optimization\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msetting\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32mC:\\Github\\vnpy\\vnpy\\app\\cta_strategy\\backtesting.py\u001b[0m in \u001b[0;36mrun_ga_optimization\u001b[1;34m(self, optimization_setting, output)\u001b[0m\n\u001b[0;32m 602\u001b[0m \u001b[0mNGEN\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 603\u001b[0m \u001b[0mstats\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 604\u001b[1;33m \u001b[0mhalloffame\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mhof\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 605\u001b[0m ) \n\u001b[0;32m 606\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mC:\\Github\\vnpy\\vnpy\\app\\cta_strategy\\backtesting.py\u001b[0m in \u001b[0;36mrun_ga_optimization\u001b[1;34m(self, optimization_setting, output)\u001b[0m\n\u001b[0;32m 601\u001b[0m \u001b[0mngen\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 602\u001b[0m \u001b[0mstats\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 603\u001b[1;33m \u001b[0mhalloffame\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mhof\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 604\u001b[0m ) \n\u001b[0;32m 605\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\miniconda3\\lib\\site-packages\\deap\\algorithms.py\u001b[0m in \u001b[0;36meaMuPlusLambda\u001b[1;34m(population, toolbox, mu, lambda_, cxpb, mutpb, ngen, stats, halloffame, verbose)\u001b[0m\n\u001b[0;32m 316\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mgen\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mngen\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 317\u001b[0m \u001b[1;31m# Vary the population\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 318\u001b[1;33m \u001b[0moffspring\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mvarOr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpopulation\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtoolbox\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlambda_\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcxpb\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmutpb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 319\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 320\u001b[0m \u001b[1;31m# Evaluate the individuals with an invalid fitness\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mc:\\miniconda3\\lib\\site-packages\\deap\\algorithms.py\u001b[0m in \u001b[0;36meaMuPlusLambda\u001b[1;34m(population, toolbox, mu, lambda_, cxpb, mutpb, ngen, stats, halloffame, verbose)\u001b[0m\n\u001b[0;32m 301\u001b[0m \u001b[1;31m# Evaluate the individuals with an invalid fitness\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 302\u001b[0m \u001b[0minvalid_ind\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mind\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mind\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mpopulation\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mind\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfitness\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalid\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 303\u001b[1;33m \u001b[0mfitnesses\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtoolbox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtoolbox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mevaluate\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0minvalid_ind\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 304\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mind\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfit\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mzip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minvalid_ind\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfitnesses\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 305\u001b[0m \u001b[0mind\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfitness\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalues\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfit\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\miniconda3\\lib\\site-packages\\deap\\algorithms.py\u001b[0m in \u001b[0;36mvarOr\u001b[1;34m(population, toolbox, lambda_, cxpb, mutpb)\u001b[0m\n\u001b[0;32m 234\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mop_choice\u001b[0m \u001b[1;33m<\u001b[0m \u001b[0mcxpb\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;31m# Apply crossover\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 235\u001b[0m \u001b[0mind1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mind2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtoolbox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msample\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpopulation\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 236\u001b[1;33m \u001b[0mind1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mind2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtoolbox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mind1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mind2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 237\u001b[0m \u001b[1;32mdel\u001b[0m \u001b[0mind1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfitness\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 238\u001b[0m \u001b[0moffspring\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mind1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mc:\\miniconda3\\lib\\multiprocessing\\pool.py\u001b[0m in \u001b[0;36mmap\u001b[1;34m(self, func, iterable, chunksize)\u001b[0m\n\u001b[0;32m 288\u001b[0m \u001b[1;32min\u001b[0m \u001b[0ma\u001b[0m \u001b[0mlist\u001b[0m \u001b[0mthat\u001b[0m \u001b[1;32mis\u001b[0m \u001b[0mreturned\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 289\u001b[0m '''\n\u001b[1;32m--> 290\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_map_async\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfunc\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0miterable\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmapstar\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mchunksize\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 291\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 292\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mstarmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfunc\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0miterable\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mchunksize\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\miniconda3\\lib\\site-packages\\deap\\tools\\crossover.py\u001b[0m in \u001b[0;36mcxTwoPoint\u001b[1;34m(ind1, ind2)\u001b[0m\n\u001b[0;32m 42\u001b[0m \u001b[0msize\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mind1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mind2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 43\u001b[0m \u001b[0mcxpoint1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msize\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 44\u001b[1;33m \u001b[0mcxpoint2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msize\u001b[0m \u001b[1;33m-\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 45\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mcxpoint2\u001b[0m \u001b[1;33m>=\u001b[0m \u001b[0mcxpoint1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 46\u001b[0m \u001b[0mcxpoint2\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mc:\\miniconda3\\lib\\multiprocessing\\pool.py\u001b[0m in \u001b[0;36mget\u001b[1;34m(self, timeout)\u001b[0m\n\u001b[0;32m 681\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_value\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 682\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 683\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_value\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 684\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 685\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_set\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\miniconda3\\lib\\random.py\u001b[0m in \u001b[0;36mrandint\u001b[1;34m(self, a, b)\u001b[0m\n\u001b[0;32m 220\u001b[0m \"\"\"\n\u001b[0;32m 221\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 222\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 223\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 224\u001b[0m def _randbelow(self, n, int=int, maxsize=1<<BPF, type=type,\n", "\u001b[1;32mc:\\miniconda3\\lib\\multiprocessing\\pool.py\u001b[0m in \u001b[0;36m_handle_tasks\u001b[1;34m(taskqueue, put, outqueue, pool, cache)\u001b[0m\n\u001b[0;32m 455\u001b[0m \u001b[1;32mbreak\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 456\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 457\u001b[1;33m \u001b[0mput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtask\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 458\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 459\u001b[0m \u001b[0mjob\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0midx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtask\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\miniconda3\\lib\\random.py\u001b[0m in \u001b[0;36mrandrange\u001b[1;34m(self, start, stop, step, _int)\u001b[0m\n\u001b[0;32m 198\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mistart\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_randbelow\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mwidth\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 199\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mstep\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 200\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"empty range for randrange() (%d,%d, %d)\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mistart\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mistop\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mwidth\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 201\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 202\u001b[0m \u001b[1;31m# Non-unit step argument supplied.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mc:\\miniconda3\\lib\\multiprocessing\\connection.py\u001b[0m in \u001b[0;36msend\u001b[1;34m(self, obj)\u001b[0m\n\u001b[0;32m 204\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_check_closed\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 205\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_check_writable\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 206\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_send_bytes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0m_ForkingPickler\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdumps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 207\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 208\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mrecv_bytes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmaxlength\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mValueError\u001b[0m: empty range for randrange() (1,1, 0)" "\u001b[1;32mc:\\miniconda3\\lib\\multiprocessing\\reduction.py\u001b[0m in \u001b[0;36mdumps\u001b[1;34m(cls, obj, protocol)\u001b[0m\n\u001b[0;32m 49\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdumps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mprotocol\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 50\u001b[0m \u001b[0mbuf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mio\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mBytesIO\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 51\u001b[1;33m \u001b[0mcls\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbuf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mprotocol\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdump\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 52\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mbuf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetbuffer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 53\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mAttributeError\u001b[0m: Can't pickle local object 'create_ga_optimize.<locals>.ga_optimize'"
] ]
} }
], ],
"source": [ "source": [
"setting = OptimizationSetting()\n", "setting = OptimizationSetting()\n",
"setting.set_target(\"total_return\")\n", "setting.set_target(\"sharpe_ratio\")\n",
"setting.add_parameter(\"atr_length\", 3, 105, 1)\n", "setting.add_parameter(\"atr_length\", 3, 105, 1)\n",
"setting.add_parameter(\"atr_ma_length\", 10, 80, 1)\n",
"\n", "\n",
"engine.run_ga_optimization(setting)" "engine.run_ga_optimization(setting)"
] ]

View File

@ -565,41 +565,40 @@ class BacktestingEngine:
toolbox.register("evaluate", object_func) toolbox.register("evaluate", object_func)
toolbox.register("select", tools.selNSGA2) toolbox.register("select", tools.selNSGA2)
# pool = multiprocessing.Pool(multiprocessing.cpu_count()) pool = multiprocessing.Pool(multiprocessing.cpu_count())
# toolbox.register("map", pool.map) toolbox.register("map", pool.map)
MU = 80 # 设置每一代选择的个体数 mu = 16 # number of individuals to select for the next generation
LAMBDA = 100 # 设置每一代产生的子女数 lambda_ = 20 # number of children to produce at each generation
POP = 100 cxpb = 0.95 # probability that an offspring is produced by crossover
CXPB = 0.95 # 交叉概率 mutpb = 0.05 # probability that an offspring is produced by mutation
MUTPB = 0.05 # 变异概率 ngen = 300 # number of generation
NGEN = 300 # 种群代数
pop = toolbox.population(POP) # 设置族群里面的个体数量 pop_size = 20 # number of individuals in each generation
hof = tools.ParetoFront() # 解的集合:帕累托前沿(非占优最优集) pop = toolbox.population(pop_size)
hof = tools.ParetoFront() # end result of pareto front
stats = tools.Statistics(lambda ind: ind.fitness.values) stats = tools.Statistics(lambda ind: ind.fitness.values)
np.set_printoptions(suppress=True) # 对numpy默认输出的科学计数法转换 np.set_printoptions(suppress=True)
stats.register("mean", np.mean, axis=0) # 统计目标优化函数结果的平均值 stats.register("mean", np.mean, axis=0)
stats.register("std", np.std, axis=0) # 统计目标优化函数结果的标准差 stats.register("std", np.std, axis=0)
stats.register("min", np.min, axis=0) # 统计目标优化函数结果的最小值 stats.register("min", np.min, axis=0)
stats.register("max", np.max, axis=0) # 统计目标优化函数结果的最大值 stats.register("max", np.max, axis=0)
msg = "开始运行遗传算法,每代族群总数:%s, 优良品种筛选个数:%s,迭代次数:%s,交叉概率:%s,突变概率:%s" %(POP,MU,NGEN,CXPB,MUTPB) msg = "开始运行遗传算法,每代族群总数:%s, 优良品种筛选个数:%s,迭代次数:%s,交叉概率:%s,突变概率:%s" %(pop_size, mu, ngen, cxpb, mutpb)
self.output(msg) self.output(msg)
# Run ga optimization # Run ga optimization
# esMuPlusLambda是一种基于(μ+λ)选择策略的多目标优化分段遗传算法
start = time() start = time()
algorithms.eaMuPlusLambda( algorithms.eaMuPlusLambda(
pop, pop,
toolbox, toolbox,
MU, mu,
LAMBDA, lambda_,
CXPB, cxpb,
MUTPB, mutpb,
NGEN, ngen,
stats, stats,
halloffame=hof halloffame=hof
) )
@ -1139,3 +1138,19 @@ def load_tick_data(
return database_manager.load_tick_data( return database_manager.load_tick_data(
symbol, exchange, start, end symbol, exchange, start, end
) )
# GA related global value
ga_target_name = None
ga_strategy_class = None
ga_setting = None
ga_vt_symbol = None
ga_interval = None
ga_start = None
ga_rate = None
ga_slippage = None
ga_size = None
ga_pricetick = None
ga_capital = None
ga_end = None
ga_mode = None