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
f70bab43
Commit
f70bab43
authored
Jul 21, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made risk style available
parent
7f490ef6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
factoranalysis.py
alphamind/analysis/factoranalysis.py
+10
-2
sqlengine.py
alphamind/data/engines/sqlengine.py
+7
-3
No files found.
alphamind/analysis/factoranalysis.py
View file @
f70bab43
...
...
@@ -172,8 +172,16 @@ def factor_analysis(factors: pd.DataFrame,
if
benchmark
is
not
None
and
risk_exp
is
not
None
and
method
==
'risk_neutral'
:
# using linear programming portfolio builder
benchmark
=
benchmark
.
flatten
()
lbound
=
0.
ubound
=
0.01
+
benchmark
if
'lbound'
in
kwargs
:
lbound
=
kwargs
[
'lbound'
]
else
:
lbound
=
0.
if
'ubound'
in
kwargs
:
ubound
=
kwargs
[
'ubound'
]
else
:
ubound
=
0.01
+
benchmark
if
is_tradable
is
not
None
:
ubound
[
~
is_tradable
]
=
0.
...
...
alphamind/data/engines/sqlengine.py
View file @
f70bab43
...
...
@@ -143,13 +143,17 @@ class SqlEngine(object):
factor_str
=
mapping_factors
(
factors
)
total_risk_factors
=
risk_styles
+
industry_styles
risk_str
=
','
.
join
(
'risk_exposure.'
+
f
for
f
in
total_risk_factors
)
total_risk_factors
=
list
(
set
(
risk_styles
+
industry_styles
)
.
difference
(
factors
))
if
total_risk_factors
:
risk_str
=
','
+
','
.
join
(
'risk_exposure.'
+
f
for
f
in
total_risk_factors
)
else
:
risk_str
=
''
special_risk_table
=
'specific_risk_'
+
risk_model
codes_str
=
','
.
join
(
str
(
c
)
for
c
in
codes
)
sql
=
"select uqer.Code, {factors}
,
{risks}, market.isOpen, {risk_table}.SRISK"
\
sql
=
"select uqer.Code, {factors} {risks}, market.isOpen, {risk_table}.SRISK"
\
" from (uqer INNER JOIN"
\
" risk_exposure on uqer.Date = risk_exposure.Date and uqer.Code = risk_exposure.Code)"
\
" INNER JOIN market on uqer.Date = market.Date and uqer.Code = market.Code"
\
...
...
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