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
d8390b86
Commit
d8390b86
authored
May 22, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update examples
parent
65c347f3
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
22 deletions
+35
-22
Example 1 - Factor IC analysis.ipynb
notebooks/Example 1 - Factor IC analysis.ipynb
+11
-4
Example 2 - Strategy Analysis.ipynb
notebooks/Example 2 - Strategy Analysis.ipynb
+3
-3
Example 3 - Multi Weight Gap Comparison.ipynb
notebooks/Example 3 - Multi Weight Gap Comparison.ipynb
+5
-5
Example 4 - Single Factor Analysis.ipynb
notebooks/Example 4 - Single Factor Analysis.ipynb
+3
-4
Example 5 - Style Factor Analysis.ipynb
notebooks/Example 5 - Style Factor Analysis.ipynb
+9
-2
Example 6 - Target Volatility Builder.ipynb
notebooks/Example 6 - Target Volatility Builder.ipynb
+4
-4
No files found.
notebooks/Example 1 - Factor IC analysis.ipynb
View file @
d8390b86
...
...
@@ -50,8 +50,8 @@
"horizon = map_freq(frequency)\n",
"weight_gap = 0.01\n",
"benchmark_code = 905\n",
"universe_name =
['zz800']
\n",
"universe = Universe(
'custom',
universe_name)\n",
"universe_name =
'zz800'
\n",
"universe = Universe(universe_name)\n",
"ref_dates = makeSchedule(start_date, end_date, frequency, 'china.sse')\n",
"\n",
"executor = NaiveExecutor()\n",
...
...
@@ -279,13 +279,20 @@
"metadata": {},
"outputs": [],
"source": [
"with pd.ExcelWriter(f'{universe_name
[0]
}_{benchmark_code}.xlsx', engine='xlsxwriter') as writer:\n",
"with pd.ExcelWriter(f'{universe_name}_{benchmark_code}.xlsx', engine='xlsxwriter') as writer:\n",
" factor_df.to_excel(writer, sheet_name='ret')\n",
" ic_df.to_excel(writer, sheet_name='ic')\n",
" factor_res.to_excel(writer, sheet_name='ret_stat')\n",
" ic_res.to_excel(writer, sheet_name='ic_stat')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
...
...
@@ -310,7 +317,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
5
"
},
"varInspector": {
"cols": {
...
...
notebooks/Example 2 - Strategy Analysis.ipynb
View file @
d8390b86
...
...
@@ -42,7 +42,7 @@
"batch = 1\n",
"horizon = map_freq(freq)\n",
"weights_bandwidth = 0.01\n",
"universe = Universe(
\"custom\", ['zz800']
)\n",
"universe = Universe(
'zz800'
)\n",
"data_source = os.environ['DB_URI']\n",
"benchmark_code = 905\n",
"method = 'risk_neutral'"
...
...
@@ -83,7 +83,7 @@
"# Constraintes settings\n",
"\n",
"industry_names = industry_list(industry_name, industry_level)\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA']
+ industry_names
\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA']\n",
"total_risk_names = constraint_risk + ['benchmark', 'total']\n",
"all_styles = risk_styles + industry_styles + macro_styles\n",
"\n",
...
...
@@ -171,7 +171,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
5
"
},
"varInspector": {
"cols": {
...
...
notebooks/Example 3 - Multi Weight Gap Comparison.ipynb
View file @
d8390b86
...
...
@@ -40,10 +40,10 @@
"\"\"\"\n",
"\n",
"benchmark_code = 905\n",
"universe = Universe(
\"zz800_cyb\", ['zz800', 'cyb']
)\n",
"universe = Universe(
'zz800') + Universe('cyb'
)\n",
"\n",
"def create_scenario(weights_bandwidth=0.02, target_vol=0.01, method='risk_neutral'):\n",
" start_date = '201
0
-01-01'\n",
" start_date = '201
7
-01-01'\n",
" end_date = '2018-04-27'\n",
" freq = '10b'\n",
" neutralized_risk = None\n",
...
...
@@ -69,7 +69,7 @@
" data_source=os.environ['DB_URI'])\n",
"\n",
" industry_names = industry_list('sw', 1)\n",
" constraint_risk = ['SIZE', 'SIZENL', 'BETA']
+ industry_names
\n",
" constraint_risk = ['SIZE', 'SIZENL', 'BETA']\n",
" total_risk_names = constraint_risk + ['benchmark', 'total']\n",
" all_styles = risk_styles + industry_styles + macro_styles\n",
"\n",
...
...
@@ -152,7 +152,7 @@
"source": [
"weight_gaps = [0.005, 0.010, 0.015, 0.020]\n",
"\n",
"with pd.ExcelWriter(f'
{universe.name}
_{benchmark_code}_gap.xlsx', engine='xlsxwriter') as writer:\n",
"with pd.ExcelWriter(f'
zz800_cyb
_{benchmark_code}_gap.xlsx', engine='xlsxwriter') as writer:\n",
" for i, weight_gap in enumerate(weight_gaps):\n",
" ret_df = create_scenario(weight_gap, target_vol=0.01, method='risk_neutral')\n",
" res_df = create_report(ret_df, 25)\n",
...
...
@@ -168,7 +168,7 @@
"source": [
"target_vols = [0.015, 0.030, 0.045, 0.060]\n",
"\n",
"with pd.ExcelWriter(f'
{universe.name}
_{benchmark_code}_tv.xlsx', engine='xlsxwriter') as writer:\n",
"with pd.ExcelWriter(f'
zz800_cyb
_{benchmark_code}_tv.xlsx', engine='xlsxwriter') as writer:\n",
" for i, target_vol in enumerate(target_vols):\n",
" ret_df = create_scenario(0.01, target_vol=target_vol, method='tv')\n",
" res_df = create_report(ret_df, 25)\n",
...
...
notebooks/Example 4 - Single Factor Analysis.ipynb
View file @
d8390b86
...
...
@@ -48,7 +48,7 @@
"benchmark_total_upper = 1.0\n",
"batch = 1\n",
"horizon = map_freq(freq)\n",
"universe = Universe(
\"custom\", ['zz800']
)\n",
"universe = Universe(
'zz800'
)\n",
"data_source = os.environ['DB_URI']\n",
"benchmark_code = 905\n",
"weight_gap = 0.01\n",
...
...
@@ -113,8 +113,7 @@
"Shared Data\n",
"\"\"\"\n",
"\n",
"industry_names = industry_list(industry_name, industry_level)\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA'] + industry_names\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA']\n",
"total_risk_names = constraint_risk + ['benchmark', 'total']\n",
"\n",
"b_type = []\n",
...
...
@@ -262,7 +261,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
5
"
},
"varInspector": {
"cols": {
...
...
notebooks/Example 5 - Style Factor Analysis.ipynb
View file @
d8390b86
...
...
@@ -44,7 +44,7 @@
"category = 'sw'\n",
"level = 1\n",
"freq = '20b'\n",
"universe = Universe('
custom', ['ashare_ex']
)\n",
"universe = Universe('
ashare_ex'
)\n",
"\n",
"horizon = map_freq(freq)\n",
"ref_dates = makeSchedule(start_date, end_date, freq, 'china.sse')"
...
...
@@ -118,6 +118,13 @@
"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,
...
...
@@ -142,7 +149,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
5
"
},
"varInspector": {
"cols": {
...
...
notebooks/Example 6 - Target Volatility Builder.ipynb
View file @
d8390b86
...
...
@@ -42,7 +42,7 @@
"source": [
"ref_date = '2018-01-08'\n",
"engine = SqlEngine(os.environ['DB_URI'])\n",
"universe = Universe('
custom', ['zz800']
)"
"universe = Universe('
zz800'
)"
]
},
{
...
...
@@ -148,7 +148,7 @@
"risk_model = 'short'\n",
"batch = 0\n",
"horizon = map_freq(freq)\n",
"universe = Universe(
\"custom\", ['zz800']
)\n",
"universe = Universe(
'zz800'
)\n",
"data_source = os.environ['DB_URI']\n",
"benchmark_code = 906\n",
"target_vol = 0.05\n",
...
...
@@ -190,7 +190,7 @@
"Constraintes settings\n",
"\"\"\"\n",
"\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA']
+ industry_names
\n",
"constraint_risk = ['SIZE', 'SIZENL', 'BETA']\n",
"total_risk_names = constraint_risk + ['benchmark', 'total']\n",
"\n",
"b_type = []\n",
...
...
@@ -284,7 +284,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
5
"
},
"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