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
92b23c60
Commit
92b23c60
authored
Feb 02, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update examples
parent
9ec057cc
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19747 additions
and
1019 deletions
+19747
-1019
factor_analysis_example.py
alphamind/examples/factor_analysis_example.py
+9
-7
full factor strategy.ipynb
notebooks/full factor strategy.ipynb
+19738
-1012
No files found.
alphamind/examples/factor_analysis_example.py
View file @
92b23c60
...
...
@@ -45,10 +45,9 @@ def factor_analysis(engine, factor_name, universe, benchmark_code, positive=True
Model phase: we need 1 constant linear model and one linear regression model
"""
alpha_name
=
[
factor_name
+
'_'
+
(
'pos'
if
positive
else
'neg'
)]
base1
=
LAST
(
'Alpha60'
)
base2
=
CSRes
(
'roe_q'
,
base1
)
base3
=
CSRes
(
CSRes
(
'ep_q'
,
base1
),
base2
)
simple_expression
=
CSRes
(
CSRes
(
CSRes
(
LAST
(
factor_name
),
base1
),
base2
),
base3
)
base1
=
LAST
(
'roe_q'
)
base2
=
CSRes
(
'ep_q'
,
base1
)
simple_expression
=
CSRes
(
CSRes
(
LAST
(
factor_name
),
base1
),
base2
)
if
not
positive
:
simple_expression
=
-
simple_expression
...
...
@@ -207,7 +206,7 @@ def factor_analysis(engine, factor_name, universe, benchmark_code, positive=True
def
worker_func_positive
(
factor_name
):
from
alphamind.api
import
SqlEngine
,
Universe
engine
=
SqlEngine
()
benchmark_code
=
300
benchmark_code
=
905
universe_name
=
[
'zz800'
]
universe
=
Universe
(
'custom'
,
universe_name
)
return
factor_analysis
(
engine
,
factor_name
,
universe
,
benchmark_code
,
positive
=
True
)
...
...
@@ -216,7 +215,7 @@ def worker_func_positive(factor_name):
def
worker_func_negative
(
factor_name
):
from
alphamind.api
import
SqlEngine
,
Universe
engine
=
SqlEngine
()
benchmark_code
=
300
benchmark_code
=
905
universe_name
=
[
'zz800'
]
universe
=
Universe
(
'custom'
,
universe_name
)
return
factor_analysis
(
engine
,
factor_name
,
universe
,
benchmark_code
,
positive
=
False
)
...
...
@@ -246,7 +245,10 @@ if __name__ == '__main__':
for
f_name
,
df
in
res2
:
factor_df
[
f_name
]
=
df
[
'returns'
]
# factor_name = 'NPFromOperatingTTM'
# f_name, ret_df = worker_func_negative(factor_name)
#
# ret_df[['returns', 'tc_cost']].cumsum().plot(figsize=(12, 6),
# title='Fixed frequency rebalanced: {0} for {1} with benchmark {2}'.format(
# frequency, factor_name,
benchmark_code
),
# frequency, factor_name,
905
),
# secondary_y='tc_cost')
notebooks/full factor strategy.ipynb
View file @
92b23c60
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