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
058b7552
Commit
058b7552
authored
May 29, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update example
parent
070d867a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
525 deletions
+34
-525
Example 1 - Factor IC analysis.ipynb
notebooks/Example 1 - Factor IC analysis.ipynb
+9
-495
Example 5 - Style Factor Analysis.ipynb
notebooks/Example 5 - Style Factor Analysis.ipynb
+0
-7
Example 6 - Target Volatility Builder.ipynb
notebooks/Example 6 - Target Volatility Builder.ipynb
+25
-23
No files found.
notebooks/Example 1 - Factor IC analysis.ipynb
View file @
058b7552
This diff is collapsed.
Click to expand it.
notebooks/Example 5 - Style Factor Analysis.ipynb
View file @
058b7552
...
...
@@ -118,13 +118,6 @@
"df[['factor', 'abs t.']].groupby('factor').mean().sort_values('abs t.', ascending=False).head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
...
...
notebooks/Example 6 - Target Volatility Builder.ipynb
View file @
058b7552
...
...
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
1
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
2
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -47,7 +47,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
3
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -58,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
4
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -68,17 +68,6 @@
"special_risk = factor['srisk'].values"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sec_cov = risk_exposure @ risk_cov @ risk_exposure.T / 10000 + np.diag(special_risk ** 2) / 10000\n",
"sec_cov_df = pd.DataFrame(sec_cov, index=codes, columns=codes)\n",
"sec_cov_df.iloc[:5, :5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
...
...
@@ -92,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
5
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -103,16 +92,29 @@
"cons_mat = np.ones((len(er), 1))\n",
"risk_targets = (bm.sum(), bm.sum())\n",
"target_vol = 0.025\n",
"risk_model = dict(cov=None, factor_cov=risk_cov/10000, factor_loading=risk_exposure, idsync=special_risk ** 2 / 10000.)\n",
"\n",
"status, p_er, p_weight = \\\n",
" target_vol_builder(er, sec_cov, bm, lbound, ubound, cons_mat, risk_targets, target_vol, target_vol)"
" target_vol_builder(er, risk_model, bm, lbound, ubound, cons_mat, risk_targets, target_vol)\n",
" \n",
"sec_cov = risk_exposure @ risk_cov @ risk_exposure.T / 10000. + np.diag(special_risk ** 2) / 10000"
]
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
6
,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total weight is 1.0000\n",
"portfolio activate weight forecasting vol is 0.0250\n",
"portfolio er: 2.2232 comparing with benchmark er: 1.2359\n"
]
}
],
"source": [
"# check the result\n",
"print(f\"total weight is {p_weight.sum(): .4f}\")\n",
...
...
@@ -130,7 +132,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
7
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -157,7 +159,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
8
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -182,7 +184,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
9
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -217,7 +219,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
10
,
"metadata": {},
"outputs": [],
"source": [
...
...
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