Commit c6d7f90c authored by Dr.李's avatar Dr.李

update example

parent 40967ae5
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 54, "execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 55, "execution_count": 28,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
"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:A12345678!@10.63.6.220/alpha'\n", "data_source = 'postgres+psycopg2://postgres:A12345678!@10.63.6.220/alpha'\n",
"benchmark_code = 905\n", "benchmark_code = 300\n",
"\n", "\n",
"executor = NaiveExecutor()\n", "executor = NaiveExecutor()\n",
"ref_dates = makeSchedule(start_date, end_date, freq, 'china.sse')\n", "ref_dates = makeSchedule(start_date, end_date, freq, 'china.sse')\n",
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 56, "execution_count": 29,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -62,39 +62,16 @@ ...@@ -62,39 +62,16 @@
"Factor Model\n", "Factor Model\n",
"\"\"\"\n", "\"\"\"\n",
"\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_factors = {\n", "alpha_factors = {\n",
" 'f01': LAST('ep_q'),\n", " 'f01': LAST('ep_q'),\n",
" 'f02': LAST('roe_q'),\n", " 'f02': LAST('roe_q'),\n",
" 'f03': LAST('market_confidence_25d'),\n", " 'f03': LAST('market_confidence_75d'),\n",
" 'f04': LAST('ILLIQUIDITY'),\n", " 'f04': LAST('DivP'),\n",
" 'f05': LAST('cfinc1_q'),\n", " 'f05': LAST('val_q'),\n",
" 'f06': LAST('CFO2EV'),\n", " 'f06': LAST('con_np_rolling'),\n",
" 'f07': LAST('IVR'),\n", " 'f07': LAST('GREV'),\n",
" 'f08': LAST('con_pe_rolling_order'),\n", " 'f08': LAST('con_pe_rolling_order'),\n",
" 'f09': LAST('con_pb_rolling_order'),\n", " 'f09': LAST('con_pb_rolling_order')\n",
"}\n", "}\n",
"\n", "\n",
"weights = dict(f01=1.,\n", "weights = dict(f01=1.,\n",
...@@ -107,6 +84,29 @@ ...@@ -107,6 +84,29 @@
" f08=-0.5,\n", " f08=-0.5,\n",
" f09=-0.5)\n", " f09=-0.5)\n",
"\n", "\n",
"\n",
"# alpha_factors = {\n",
"# 'f01': LAST('ep_q'),\n",
"# 'f02': LAST('roe_q'),\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",
"# 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",
"alpha_model = ConstLinearModel(features=alpha_factors, weights=weights)\n", "alpha_model = ConstLinearModel(features=alpha_factors, weights=weights)\n",
"\n", "\n",
"def predict_worker(params):\n", "def predict_worker(params):\n",
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 57, "execution_count": 30,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -149,14 +149,14 @@ ...@@ -149,14 +149,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 58, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Wall time: 6.91 s\n" "Wall time: 6.83 s\n"
] ]
} }
], ],
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 59, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -198,11 +198,7 @@ ...@@ -198,11 +198,7 @@
" b_type.append(BoundaryType.RELATIVE)\n", " b_type.append(BoundaryType.RELATIVE)\n",
" l_val.append(benchmark_total_lower)\n", " l_val.append(benchmark_total_lower)\n",
" u_val.append(benchmark_total_upper)\n", " u_val.append(benchmark_total_upper)\n",
" if name == 'total':\n", " elif name in {'SIZE', 'SIZENL', 'BETA', 'total'}:\n",
" b_type.append(BoundaryType.RELATIVE)\n",
" l_val.append(1.0)\n",
" u_val.append(1.0)\n",
" elif name in {'SIZE', 'SIZENL', 'BETA'}:\n",
" b_type.append(BoundaryType.ABSOLUTE)\n", " b_type.append(BoundaryType.ABSOLUTE)\n",
" l_val.append(0.0)\n", " l_val.append(0.0)\n",
" u_val.append(0.0)\n", " u_val.append(0.0)\n",
...@@ -220,7 +216,7 @@ ...@@ -220,7 +216,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 60, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -362,21 +358,7 @@ ...@@ -362,21 +358,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stderr",
"output_type": "stream",
"text": [
"d:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipykernel_launcher.py:39: FutureWarning: \n",
"Passing list-likes to .loc or [] with any missing label will raise\n",
"KeyError in the future, you can use .reindex() as an alternative.\n",
"\n",
"See the documentation here:\n",
"http://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate-loc-reindex-listlike\n",
"2018-03-02 18:18:22,979 - ALPHA_MIND - INFO - 0.005 finished\n"
]
}
],
"source": [ "source": [
"weight_gaps = [0.005, 0.010, 0.015, 0.020]\n", "weight_gaps = [0.005, 0.010, 0.015, 0.020]\n",
"\n", "\n",
......
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