Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
alpha-mind
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr.李
alpha-mind
Commits
0c4e1787
Commit
0c4e1787
authored
Mar 22, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update example 3
parent
f9c8bf91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
81 deletions
+22
-81
Example 3 - Multi Weight Gap Comparison.ipynb
notebooks/Example 3 - Multi Weight Gap Comparison.ipynb
+22
-81
No files found.
notebooks/Example 3 - Multi Weight Gap Comparison.ipynb
View file @
0c4e1787
...
...
@@ -3,9 +3,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
...
...
@@ -31,14 +29,14 @@
"Back test parameter settings\n",
"\"\"\"\n",
"\n",
"start_date = '201
0
-01-01'\n",
"start_date = '201
6
-01-01'\n",
"end_date = '2018-02-24'\n",
"\n",
"freq = '10b'\n",
"industry_lower = 1.0\n",
"industry_upper = 1.0\n",
"neutralized_risk = industry_styles\n",
"industry_name = 'sw
_adj
'\n",
"industry_name = 'sw'\n",
"industry_level = 1\n",
"turn_over_target_base = 0.4\n",
"benchmark_total_lower = 0.8\n",
...
...
@@ -46,7 +44,7 @@
"batch = 0\n",
"horizon = map_freq(freq)\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",
"method = 'tv'\n",
"target_vol = 0.05\n",
...
...
@@ -75,49 +73,13 @@
"\"\"\"\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",
" 'f01': LAST('CFO2EV'),\n",
" 'f02': LAST('EPS'),\n",
" }\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_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",
" f02=1.)\n",
"\n",
"alpha_model = ConstLinearModel(features=alpha_factors, weights=weights)\n",
"\n",
...
...
@@ -136,21 +98,6 @@
" return er"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"\"\"\"\n",
"Training Phase\n",
"\"\"\"\n",
"\n",
"pass"
]
},
{
"cell_type": "code",
"execution_count": null,
...
...
@@ -163,20 +110,13 @@
"Predicting Phase\n",
"\"\"\"\n",
"\n",
"from dask.distributed import Client\n",
"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()"
"predicts = [predict_worker((d.strftime('%Y-%m-%d'), alpha_model)) for d in ref_dates]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
...
...
@@ -216,9 +156,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"# rebalance\n",
...
...
@@ -334,9 +272,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"def create_report(ret_df, windows):\n",
...
...
@@ -380,7 +316,7 @@
" ret_df = create_scenario(weight_gap, target_vol=0.01, method='risk_neutral')\n",
" res_df = create_report(ret_df, 25)\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 @@
" 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.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",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
...
...
@@ -425,7 +366,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
4
"
},
"varInspector": {
"cols": {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment