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
25b0127d
Commit
25b0127d
authored
Mar 05, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug
parent
d3bf7111
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
2 deletions
+27
-2
crosssetctions.py
alphamind/analysis/crosssetctions.py
+27
-2
No files found.
alphamind/analysis/crosssetctions.py
View file @
25b0127d
...
@@ -41,6 +41,7 @@ def cross_section_analysis(ref_date,
...
@@ -41,6 +41,7 @@ def cross_section_analysis(ref_date,
dx_returns
=
engine
.
fetch_dx_return
(
ref_date
,
codes
,
horizon
=
horizon
,
offset
=
1
)
dx_returns
=
engine
.
fetch_dx_return
(
ref_date
,
codes
,
horizon
=
horizon
,
offset
=
1
)
target_pos
=
pd
.
merge
(
target_pos
,
dx_returns
,
on
=
[
'code'
])
target_pos
=
pd
.
merge
(
target_pos
,
dx_returns
,
on
=
[
'code'
])
target_pos
=
pd
.
merge
(
target_pos
,
total_data
[[
'code'
]
+
constraint_risk
],
on
=
[
'code'
])
activate_weight
=
target_pos
.
weight
.
values
activate_weight
=
target_pos
.
weight
.
values
excess_return
=
np
.
exp
(
target_pos
.
dx
.
values
)
-
1.
excess_return
=
np
.
exp
(
target_pos
.
dx
.
values
)
-
1.
port_ret
=
np
.
log
(
activate_weight
@
excess_return
+
1.
)
port_ret
=
np
.
log
(
activate_weight
@
excess_return
+
1.
)
...
@@ -50,5 +51,29 @@ def cross_section_analysis(ref_date,
...
@@ -50,5 +51,29 @@ def cross_section_analysis(ref_date,
t_stats
=
results
.
tvalues
[
1
]
t_stats
=
results
.
tvalues
[
1
]
alpha_logger
.
info
(
f
"{ref_date} is finished with {len(target_pos)} stocks for {factor_name}"
)
alpha_logger
.
info
(
f
"{ref_date} is finished with {len(target_pos)} stocks for {factor_name}"
)
alpha_logger
.
info
(
f
"{ref_date} risk_exposure
{target_pos.weight.values @ total_risk_exp
.values}"
)
alpha_logger
.
info
(
f
"{ref_date} risk_exposure
\n
{target_pos.weight.values @ target_pos[constraint_risk]
.values}"
)
return
port_ret
,
ic
,
t_stats
return
port_ret
,
ic
,
t_stats
if
__name__
==
'__main__'
:
import
numpy
as
np
import
pandas
as
pd
import
statsmodels.api
as
sm
from
alphamind.api
import
*
from
PyFin.api
import
*
factor_name
=
'SIZE'
data_source
=
'postgres+psycopg2://postgres:A12345678!@10.63.6.220/alpha'
engine
=
SqlEngine
(
data_source
)
risk_names
=
list
(
set
(
risk_styles
)
.
difference
({
factor_name
}))
industry_names
=
list
(
set
(
industry_styles
)
.
difference
({
factor_name
}))
constraint_risk
=
risk_names
+
industry_names
universe
=
Universe
(
'custom'
,
[
'ashare_ex'
])
horizon
=
9
cross_section_analysis
(
'2018-02-08'
,
factor_name
,
universe
,
horizon
,
constraint_risk
,
engine
=
engine
)
\ No newline at end of file
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