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
881d14a2
Commit
881d14a2
authored
May 29, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commited missing part
parent
058b7552
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
sqlengine.py
alphamind/data/engines/sqlengine.py
+11
-11
No files found.
alphamind/data/engines/sqlengine.py
View file @
881d14a2
...
@@ -562,12 +562,12 @@ class SqlEngine(object):
...
@@ -562,12 +562,12 @@ class SqlEngine(object):
return
risk_cov
,
risk_exp
return
risk_cov
,
risk_exp
elif
model_type
==
'factor'
:
elif
model_type
==
'factor'
:
factor_names
=
risk_cov
.
Factor
.
tolist
()
factor_names
=
risk_cov
.
Factor
.
tolist
()
risk_cov
.
set_index
(
'Factor'
,
inplace
=
True
)
new_risk_cov
.
set_index
(
'Factor'
)
factor_cov
=
risk_cov
.
loc
[
factor_names
,
factor_names
]
/
10000.
factor_cov
=
new_
risk_cov
.
loc
[
factor_names
,
factor_names
]
/
10000.
risk_exp
.
set_index
(
'code'
,
inplace
=
True
)
new_risk_exp
=
risk_exp
.
set_index
(
'code'
)
factor_loading
=
risk_exp
.
loc
[:,
factor_names
]
factor_loading
=
new_
risk_exp
.
loc
[:,
factor_names
]
idsync
=
risk_exp
[
'srisk'
]
*
risk_exp
[
'srisk'
]
/
10000
idsync
=
new_risk_exp
[
'srisk'
]
*
new_
risk_exp
[
'srisk'
]
/
10000
return
FactorRiskModel
(
factor_cov
,
factor_loading
,
idsync
)
return
FactorRiskModel
(
factor_cov
,
factor_loading
,
idsync
)
,
risk_cov
,
risk_exp
def
fetch_risk_model_range
(
self
,
def
fetch_risk_model_range
(
self
,
universe
:
Universe
,
universe
:
Universe
,
...
@@ -621,11 +621,11 @@ class SqlEngine(object):
...
@@ -621,11 +621,11 @@ class SqlEngine(object):
if
not
model_type
:
if
not
model_type
:
return
risk_cov
,
risk_exp
return
risk_cov
,
risk_exp
elif
model_type
==
'factor'
:
elif
model_type
==
'factor'
:
risk_cov
.
set_index
(
'Factor'
,
inplace
=
True
)
new_risk_cov
=
risk_cov
.
set_index
(
'Factor'
)
risk_exp
.
set_index
(
'code'
,
inplace
=
True
)
new_risk_exp
=
risk_exp
.
set_index
(
'code'
)
risk_cov_groups
=
risk_cov
.
groupby
(
'trade_date'
)
risk_cov_groups
=
new_
risk_cov
.
groupby
(
'trade_date'
)
risk_exp_groups
=
risk_exp
.
groupby
(
'trade_date'
)
risk_exp_groups
=
new_
risk_exp
.
groupby
(
'trade_date'
)
models
=
dict
()
models
=
dict
()
for
ref_date
,
cov_g
in
risk_cov_groups
:
for
ref_date
,
cov_g
in
risk_cov_groups
:
...
@@ -635,7 +635,7 @@ class SqlEngine(object):
...
@@ -635,7 +635,7 @@ class SqlEngine(object):
factor_loading
=
exp_g
.
loc
[:,
factor_names
]
factor_loading
=
exp_g
.
loc
[:,
factor_names
]
idsync
=
exp_g
[
'srisk'
]
*
exp_g
[
'srisk'
]
/
10000
idsync
=
exp_g
[
'srisk'
]
*
exp_g
[
'srisk'
]
/
10000
models
[
ref_date
]
=
FactorRiskModel
(
factor_cov
,
factor_loading
,
idsync
)
models
[
ref_date
]
=
FactorRiskModel
(
factor_cov
,
factor_loading
,
idsync
)
return
pd
.
Series
(
models
)
return
pd
.
Series
(
models
)
,
risk_cov
,
risk_exp
def
fetch_industry
(
self
,
def
fetch_industry
(
self
,
ref_date
:
str
,
ref_date
:
str
,
...
...
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