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
e25eb965
Commit
e25eb965
authored
Jan 17, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added update special tables
parent
efbb432e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7560 additions
and
3050 deletions
+7560
-3050
turnoveranalysis.py
alphamind/analysis/turnoveranalysis.py
+30
-0
factor_res_analysis.py
alphamind/examples/factor_res_analysis.py
+5
-5
formula_expression.py
alphamind/examples/formula_expression.py
+6
-5
full factor strategy.ipynb
notebooks/full factor strategy.ipynb
+7519
-3040
No files found.
alphamind/analysis/turnoveranalysis.py
0 → 100644
View file @
e25eb965
# -*- coding: utf-8 -*-
"""
Created on 2018-1-15
@author: cheng.li
"""
import
numpy
as
np
from
alphamind.data.standardize
import
standardize
def
factor_turn_over
(
factor_values
:
np
.
ndarray
,
trade_dates
:
np
.
ndarray
,
codes
:
np
.
ndarray
,
use_standize
:
bool
=
True
):
if
use_standize
:
factor_values
=
standardize
(
factor_values
,
trade_dates
)
if
__name__
==
'__main__'
:
from
alphamind.api
import
*
engine
=
SqlEngine
()
factor
=
'ep_q'
freq
=
'5b'
start_date
=
'2017-06-01'
end_date
=
'2017-08-01'
universe
=
Universe
(
'custom'
,
[
'zz500'
])
alphamind/examples/factor_res_analysis.py
View file @
e25eb965
...
@@ -70,23 +70,23 @@ def factor_residue_analysis(start_date,
...
@@ -70,23 +70,23 @@ def factor_residue_analysis(start_date,
start_date
=
advanceDateByCalendar
(
'china.sse'
,
dates
[
0
],
'-1d'
)
start_date
=
advanceDateByCalendar
(
'china.sse'
,
dates
[
0
],
'-1d'
)
df
.
loc
[
start_date
]
=
0.
df
.
loc
[
start_date
]
=
0.
df
.
sort_index
(
inplace
=
True
)
df
.
sort_index
(
inplace
=
True
)
df
[
'$top1 -
top5$'
]
=
df
[
0
]
-
df
[
4
]
df
[
'$top1 -
bottom1$'
]
=
df
[
4
]
-
df
[
0
]
return
df
return
df
engine
=
SqlEngine
()
engine
=
SqlEngine
()
df
=
engine
.
fetch_factor_coverage
()
.
groupby
(
'factor'
)
.
mean
()
#
df = engine.fetch_factor_coverage().groupby('factor').mean()
df
=
df
[
df
.
coverage
>=
0.98
]
#
df = df[df.coverage >= 0.98]
universe
=
Universe
(
'custom'
,
[
'zz800'
])
universe
=
Universe
(
'custom'
,
[
'zz800'
])
factor_df
=
pd
.
DataFrame
()
factor_df
=
pd
.
DataFrame
()
for
i
,
factor
in
enumerate
(
df
.
index
):
for
i
,
factor
in
enumerate
(
[
'EGRO'
]
):
res
=
factor_residue_analysis
(
'2012-01-01'
,
res
=
factor_residue_analysis
(
'2012-01-01'
,
'2018-01-05'
,
'2018-01-05'
,
factor
,
factor
,
'5b'
,
'5b'
,
universe
,
universe
,
engine
)
engine
)
factor_df
[
factor
]
=
res
[
'$top1 -
top5
$'
]
factor_df
[
factor
]
=
res
[
'$top1 -
bottom1
$'
]
alpha_logger
.
info
(
'{0}: {1} is done'
.
format
(
i
+
1
,
factor
))
alpha_logger
.
info
(
'{0}: {1} is done'
.
format
(
i
+
1
,
factor
))
alphamind/examples/formula_expression.py
View file @
e25eb965
...
@@ -19,9 +19,12 @@ start = dt.datetime.now()
...
@@ -19,9 +19,12 @@ start = dt.datetime.now()
universe
=
Universe
(
'custom'
,
[
'zz800'
])
universe
=
Universe
(
'custom'
,
[
'zz800'
])
simple_expression
=
CSRes
(
LAST
(
'OperCashInToAsset'
),
'roe_q'
)
factor_name
=
'Beta20'
base1
=
LAST
(
'roe_q'
)
base2
=
CSRes
(
LAST
(
'ep_q'
),
'roe_q'
)
simple_expression
=
CSRes
(
CSRes
(
LAST
(
factor_name
),
base1
),
base2
)
alpha_factor_name
=
'alpha_factor
'
alpha_factor_name
=
factor_name
+
'_res
'
alpha_factor
=
{
alpha_factor_name
:
simple_expression
}
alpha_factor
=
{
alpha_factor_name
:
simple_expression
}
# end of formula definition
# end of formula definition
...
@@ -29,7 +32,7 @@ alpha_factor = {alpha_factor_name: simple_expression}
...
@@ -29,7 +32,7 @@ alpha_factor = {alpha_factor_name: simple_expression}
engine
=
SqlEngine
(
'postgresql+psycopg2://postgres:A12345678!@10.63.6.220/alpha'
)
engine
=
SqlEngine
(
'postgresql+psycopg2://postgres:A12345678!@10.63.6.220/alpha'
)
neutralize_risk
=
[
'SIZE'
,
'LEVERAGE'
]
+
industry_styles
neutralize_risk
=
[
'SIZE'
,
'LEVERAGE'
]
+
industry_styles
freq
=
'
10
b'
freq
=
'
5
b'
n_bins
=
5
n_bins
=
5
horizon
=
map_freq
(
freq
)
horizon
=
map_freq
(
freq
)
...
@@ -91,8 +94,6 @@ df = df.cumsum().plot(ax=axes[0], title='Quantile Analysis for {0}'.format(alpha
...
@@ -91,8 +94,6 @@ df = df.cumsum().plot(ax=axes[0], title='Quantile Analysis for {0}'.format(alpha
# =================================================================== #
# =================================================================== #
factor_name
=
'PE'
alpha_factor_name
=
alpha_factor_name
+
'_1w_diff'
alpha_factor_name
=
alpha_factor_name
+
'_1w_diff'
alpha_factor
=
{
alpha_factor_name
:
DIFF
(
simple_expression
)}
alpha_factor
=
{
alpha_factor_name
:
DIFF
(
simple_expression
)}
...
...
notebooks/full factor strategy.ipynb
View file @
e25eb965
This diff is collapsed.
Click to expand it.
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