Commit ec7f1234 authored by Dr.李's avatar Dr.李
parents 8b4ed382 92df02a2
...@@ -569,13 +569,7 @@ ...@@ -569,13 +569,7 @@
"2018-03-22 14:40:59,847 - ALPHA_MIND - INFO - 2017-11-14 00:00:00 full re-balance\n", "2018-03-22 14:40:59,847 - ALPHA_MIND - INFO - 2017-11-14 00:00:00 full re-balance\n",
"2018-03-22 14:40:59,872 - ALPHA_MIND - INFO - 2017-11-14 00:00:00 is finished\n", "2018-03-22 14:40:59,872 - ALPHA_MIND - INFO - 2017-11-14 00:00:00 is finished\n",
"2018-03-22 14:40:59,882 - ALPHA_MIND - INFO - 2017-11-28 00:00:00: 800\n", "2018-03-22 14:40:59,882 - ALPHA_MIND - INFO - 2017-11-28 00:00:00: 800\n",
"2018-03-22 14:40:59,889 - ALPHA_MIND - INFO - 2017-11-28 00:00:00 full re-balance\n" "2018-03-22 14:40:59,889 - ALPHA_MIND - INFO - 2017-11-28 00:00:00 full re-balance\n",
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2018-03-22 14:40:59,914 - ALPHA_MIND - INFO - 2017-11-28 00:00:00 is finished\n", "2018-03-22 14:40:59,914 - ALPHA_MIND - INFO - 2017-11-28 00:00:00 is finished\n",
"2018-03-22 14:40:59,926 - ALPHA_MIND - INFO - 2017-12-12 00:00:00: 799\n", "2018-03-22 14:40:59,926 - ALPHA_MIND - INFO - 2017-12-12 00:00:00: 799\n",
"2018-03-22 14:40:59,934 - ALPHA_MIND - INFO - 2017-12-12 00:00:00 full re-balance\n", "2018-03-22 14:40:59,934 - ALPHA_MIND - INFO - 2017-12-12 00:00:00 full re-balance\n",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"%matplotlib inline\n", "%matplotlib inline\n",
...@@ -31,14 +29,14 @@ ...@@ -31,14 +29,14 @@
"Back test parameter settings\n", "Back test parameter settings\n",
"\"\"\"\n", "\"\"\"\n",
"\n", "\n",
"start_date = '2010-01-01'\n", "start_date = '2016-01-01'\n",
"end_date = '2018-02-24'\n", "end_date = '2018-02-24'\n",
"\n", "\n",
"freq = '10b'\n", "freq = '10b'\n",
"industry_lower = 1.0\n", "industry_lower = 1.0\n",
"industry_upper = 1.0\n", "industry_upper = 1.0\n",
"neutralized_risk = industry_styles\n", "neutralized_risk = industry_styles\n",
"industry_name = 'sw_adj'\n", "industry_name = 'sw'\n",
"industry_level = 1\n", "industry_level = 1\n",
"turn_over_target_base = 0.4\n", "turn_over_target_base = 0.4\n",
"benchmark_total_lower = 0.8\n", "benchmark_total_lower = 0.8\n",
...@@ -46,7 +44,7 @@ ...@@ -46,7 +44,7 @@
"batch = 0\n", "batch = 0\n",
"horizon = map_freq(freq)\n", "horizon = map_freq(freq)\n",
"universe = Universe(\"custom\", ['zz800'])\n", "universe = Universe(\"custom\", ['zz800'])\n",
"data_source = 'postgres+psycopg2://postgres:we083826@192.168.0.102/alpha'\n", "data_source = 'postgres+psycopg2://postgres:A12345678!@10.63.6.220/alpha'\n",
"benchmark_code = 905\n", "benchmark_code = 905\n",
"method = 'tv'\n", "method = 'tv'\n",
"target_vol = 0.05\n", "target_vol = 0.05\n",
...@@ -75,49 +73,13 @@ ...@@ -75,49 +73,13 @@
"\"\"\"\n", "\"\"\"\n",
"\n", "\n",
"alpha_factors = {\n", "alpha_factors = {\n",
" 'f01': LAST('ep_q'),\n", " 'f01': LAST('CFO2EV'),\n",
" 'f02': LAST('roe_q'),\n", " 'f02': LAST('EPS'),\n",
" 'f03': LAST('market_confidence_25d'),\n",
" 'f04': LAST('ILLIQUIDITY'),\n",
" 'f05': LAST('cfinc1_q'),\n",
" 'f06': LAST('CFO2EV'),\n",
" 'f07': LAST('IVR'),\n",
" 'f08': LAST('con_pe_rolling_order'),\n",
" 'f09': LAST('con_pb_rolling_order')\n",
" }\n", " }\n",
"\n", "\n",
"\n", "\n",
"weights = dict(f01=1.,\n", "weights = dict(f01=1.,\n",
" f02=0.5,\n", " f02=1.)\n",
" f03=0.5,\n",
" f04=0.5,\n",
" f05=0.5,\n",
" f06=0.5,\n",
" f07=0.5,\n",
" f08=-0.5,\n",
" f09=-0.5)\n",
"\n",
"# alpha_factors = {\n",
"# 'f01': LAST('ep_q'),\n",
"# 'f02': LAST('roe_q'),\n",
"# 'f03': LAST('market_confidence_75d'),\n",
"# 'f04': LAST('DivP'),\n",
"# 'f05': LAST('val_q'),\n",
"# 'f06': LAST('con_np_rolling'),\n",
"# 'f07': LAST('GREV'),\n",
"# 'f08': LAST('con_pe_rolling_order'),\n",
"# 'f09': LAST('con_pb_rolling_order')\n",
"# }\n",
"\n",
"# weights = dict(f01=1.,\n",
"# f02=0.5,\n",
"# f03=0.5,\n",
"# f04=0.5,\n",
"# f05=0.5,\n",
"# f06=0.5,\n",
"# f07=0.5,\n",
"# f08=-0.5,\n",
"# f09=-0.5)\n",
"\n", "\n",
"alpha_model = ConstLinearModel(features=alpha_factors, weights=weights)\n", "alpha_model = ConstLinearModel(features=alpha_factors, weights=weights)\n",
"\n", "\n",
...@@ -136,21 +98,6 @@ ...@@ -136,21 +98,6 @@
" return er" " return er"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"\"\"\"\n",
"Training Phase\n",
"\"\"\"\n",
"\n",
"pass"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
...@@ -163,20 +110,13 @@ ...@@ -163,20 +110,13 @@
"Predicting Phase\n", "Predicting Phase\n",
"\"\"\"\n", "\"\"\"\n",
"\n", "\n",
"from dask.distributed import Client\n", "predicts = [predict_worker((d.strftime('%Y-%m-%d'), alpha_model)) for d in ref_dates]"
"client = Client('192.168.0.102:8786')\n",
"\n",
"tasks = client.map(predict_worker, [(d.strftime('%Y-%m-%d'), alpha_model) for d in ref_dates], pure=False)\n",
"predicts = client.gather(tasks)\n",
"client.close()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"\"\"\"\n", "\"\"\"\n",
...@@ -216,9 +156,7 @@ ...@@ -216,9 +156,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# rebalance\n", "# rebalance\n",
...@@ -334,9 +272,7 @@ ...@@ -334,9 +272,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"def create_report(ret_df, windows):\n", "def create_report(ret_df, windows):\n",
...@@ -380,7 +316,7 @@ ...@@ -380,7 +316,7 @@
" ret_df = create_scenario(weight_gap, target_vol=0.01, method='risk_neutral')\n", " ret_df = create_scenario(weight_gap, target_vol=0.01, method='risk_neutral')\n",
" res_df = create_report(ret_df, 25)\n", " res_df = create_report(ret_df, 25)\n",
" res_df.to_excel(writer, sheet_name=f'{i}')\n", " res_df.to_excel(writer, sheet_name=f'{i}')\n",
" alpha_logger.info(f\"{weight_gap} finished\")" " alpha_logger.info(f\"weight_gap: {weight_gap} finished\")"
] ]
}, },
{ {
...@@ -396,15 +332,20 @@ ...@@ -396,15 +332,20 @@
" ret_df = create_scenario(weight_gap=0.02, target_vol=target_vol, method='tv')\n", " ret_df = create_scenario(weight_gap=0.02, target_vol=target_vol, method='tv')\n",
" res_df = create_report(ret_df, 25)\n", " res_df = create_report(ret_df, 25)\n",
" res_df.to_excel(writer, sheet_name=f'{i}')\n", " res_df.to_excel(writer, sheet_name=f'{i}')\n",
" alpha_logger.info(f\"{target_vol:.4f} finished\")" " alpha_logger.info(f\"target_vol: {target_vol:.4f} finished\")"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true "outputs": [],
"source": []
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
} }
...@@ -425,7 +366,7 @@ ...@@ -425,7 +366,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.3" "version": "3.6.4"
}, },
"varInspector": { "varInspector": {
"cols": { "cols": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment