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
01c9058f
Commit
01c9058f
authored
May 01, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update notebook
parent
2f997476
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
54 deletions
+8
-54
factor analysis.ipynb
notebooks/factor analysis.ipynb
+8
-54
No files found.
notebooks/factor analysis.ipynb
View file @
01c9058f
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
"factor = 'ROEAfterNonRecurring' # 'DROEAfterNonRecurring'\n",
"factor = 'ROEAfterNonRecurring' # 'DROEAfterNonRecurring'\n",
"\n",
"\n",
"conn = sqlalchemy.create_engine('mysql+mysqldb://root:we083826@localhost:3306/multifactor?charset=utf8')\n",
"conn = sqlalchemy.create_engine('mysql+mysqldb://root:we083826@localhost:3306/multifactor?charset=utf8')\n",
"df = pd.read_sql('select factor_data.{0}, trade_data.Return as dailyReturn, {1}.* '\n",
"df = pd.read_sql('select factor_data.{0}, trade_data.Return as dailyReturn, {1}.*
, 1 as Market
'\n",
" 'from factor_data, trade_data, {1} '\n",
" 'from factor_data, trade_data, {1} '\n",
" 'where factor_data.Date = {1}.Date and factor_data.Code = {1}.Code '\n",
" 'where factor_data.Date = {1}.Date and factor_data.Code = {1}.Code '\n",
" 'and factor_data.Date = trade_data.Date and factor_data.Code = trade_data.Code;'.format(factor, \n",
" 'and factor_data.Date = trade_data.Date and factor_data.Code = trade_data.Code;'.format(factor, \n",
...
@@ -137,7 +137,9 @@
...
@@ -137,7 +137,9 @@
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"outputs": [],
"source": [
"source": [
"total_data = df.copy()"
"total_data = df.copy()"
...
@@ -424,7 +426,7 @@
...
@@ -424,7 +426,7 @@
"outputs": [],
"outputs": [],
"source": [
"source": [
"top_sources = aggregated_bars.sum().abs().sort_values(ascending=False).index[:10]\n",
"top_sources = aggregated_bars.sum().abs().sort_values(ascending=False).index[:10]\n",
"aggregated_bars.sum().
abs().
sort_values(ascending=False).plot(kind='bar', figsize=(16, 8))"
"aggregated_bars.sum().sort_values(ascending=False).plot(kind='bar', figsize=(16, 8))"
]
]
},
},
{
{
...
@@ -455,7 +457,7 @@
...
@@ -455,7 +457,7 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"exposure_table[top_sources
[1:]
].plot(figsize=(14,7))\n",
"exposure_table[top_sources
.difference(['idiosyncratic'])
].plot(figsize=(14,7))\n",
"plt.legend(loc='upper center', ncol=len(top_sources[1:]) // 3)"
"plt.legend(loc='upper center', ncol=len(top_sources[1:]) // 3)"
]
]
},
},
...
@@ -479,62 +481,14 @@
...
@@ -479,62 +481,14 @@
"del total_data"
"del total_data"
]
]
},
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"total_factors = [factor] + risk_facto_cols.tolist()"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"total_factors"
"import gc\n",
]
"gc.collect()"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"aggregated_bars.sum().abs().sort_values(ascending=False)[:10].plot?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"aggregated_bars.sum().abs().sort_values(ascending=False)[:10].plot"
]
]
},
},
{
{
...
...
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