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
9ae414ab
Commit
9ae414ab
authored
Jul 01, 2019
by
Dr.李
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/alpha-miner/alpha-mind
parents
e686a434
b6923004
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
784 additions
and
11 deletions
+784
-11
sqlengine.py
alphamind/data/engines/sqlengine.py
+7
-7
utilities.py
alphamind/data/engines/utilities.py
+6
-4
Quick Start 9 - Back Testing Stock Screening.ipynb
notebooks/Quick Start 9 - Back Testing Stock Screening.ipynb
+771
-0
No files found.
alphamind/data/engines/sqlengine.py
View file @
9ae414ab
...
...
@@ -843,13 +843,13 @@ class SqlEngine(object):
if
__name__
==
'__main__'
:
from
PyFin.api
import
*
from
alphamind.api
import
*
from
PyFin.api
import
bizDatesList
engine
=
SqlEngine
()
ref_date
=
'2017-05-03'
freq
=
"1m"
universe
=
Universe
(
'zz800'
)
dates
=
bizDatesList
(
'china.sse'
,
'2018-05-01'
,
'2018-05-10
'
)
codes
=
engine
.
fetch_codes
(
ref_date
,
universe
)
engine
=
SqlEngine
(
'postgresql+psycopg2://alpha:alpha@180.166.26.82:8889
'
)
rebalance_dates
=
makeSchedule
(
'2015-01-31'
,
'2019-05-30'
,
freq
,
'china.sse'
,
BizDayConventions
.
Preceding
)
res
=
engine
.
fetch_dx_return_range
(
universe
,
dates
=
dates
,
horizon
=
4
,
benchmark
=
300
)
print
(
res
)
\ No newline at end of file
formula
=
CSTopN
(
LAST
(
'EP'
),
5
,
groups
=
'sw1'
)
factors
=
engine
.
fetch_factor_range
(
universe
,
{
'alpha'
:
formula
},
dates
=
rebalance_dates
)
\ No newline at end of file
alphamind/data/engines/utilities.py
View file @
9ae414ab
...
...
@@ -36,15 +36,17 @@ def _map_risk_model_table(risk_model: str) -> tuple:
def
_map_factors
(
factors
:
Iterable
[
str
],
used_factor_tables
)
->
Dict
:
factor_cols
=
{}
excluded
=
{
'trade_date'
,
'code'
,
'isOpen'
}
factors
=
set
(
factors
)
.
difference
({
'trade_date'
,
'code'
,
'isOpen'
})
to_keep
=
factors
.
copy
()
for
f
in
factors
:
for
t
in
used_factor_tables
:
if
f
not
in
excluded
and
f
in
t
.
__table__
.
columns
:
if
f
in
t
.
__table__
.
columns
:
factor_cols
[
t
.
__table__
.
columns
[
f
]]
=
t
to_keep
.
remove
(
f
)
break
if
not
factor_cols
:
raise
ValueError
(
"
some factors in <{0}> can't be find"
.
format
(
factors
))
if
to_keep
:
raise
ValueError
(
"
factors in <{0}> can't be find"
.
format
(
to_keep
))
return
factor_cols
...
...
notebooks/Quick Start 9 - Back Testing Stock Screening.ipynb
0 → 100644
View file @
9ae414ab
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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