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
7f602e97
Commit
7f602e97
authored
Aug 30, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified sql script for fetching data
parent
65c88236
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
70 deletions
+77
-70
models.py
alphamind/data/dbmodel/models.py
+3
-0
sqlengine.py
alphamind/data/engines/sqlengine.py
+54
-52
universe.py
alphamind/data/engines/universe.py
+20
-18
No files found.
alphamind/data/dbmodel/models.py
View file @
7f602e97
...
@@ -1677,6 +1677,9 @@ class FullFactorView(Base):
...
@@ -1677,6 +1677,9 @@ class FullFactorView(Base):
AERODEF
=
Column
(
BigInteger
)
AERODEF
=
Column
(
BigInteger
)
Conglomerates
=
Column
(
BigInteger
)
Conglomerates
=
Column
(
BigInteger
)
COUNTRY
=
Column
(
BigInteger
)
COUNTRY
=
Column
(
BigInteger
)
d_srisk
=
Column
(
Float
(
53
))
s_srisk
=
Column
(
Float
(
53
))
l_srisk
=
Column
(
Float
(
53
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
alphamind/data/engines/sqlengine.py
View file @
7f602e97
This diff is collapsed.
Click to expand it.
alphamind/data/engines/universe.py
View file @
7f602e97
...
@@ -56,35 +56,37 @@ class Universe(object):
...
@@ -56,35 +56,37 @@ class Universe(object):
return
all_and_conditions
,
all_or_conditions
return
all_and_conditions
,
all_or_conditions
def
query
(
self
,
ref_date
):
def
query
(
self
,
ref_date
):
query
=
select
([
UniverseTable
.
trade_date
,
UniverseTable
.
code
])
.
distinct
()
all_and_conditions
,
all_or_conditions
=
self
.
_create_condition
()
all_and_conditions
,
all_or_conditions
=
self
.
_create_condition
()
query
=
query
.
where
(
if
all_or_conditions
:
and_
(
query
=
and_
(
UniverseTable
.
trade_date
==
ref_date
,
UniverseTable
.
trade_date
==
ref_date
,
or_
(
or_
(
and_
(
*
all_and_conditions
),
and_
(
*
all_and_conditions
),
*
all_or_conditions
*
all_or_conditions
)
)
)
else
:
query
=
and_
(
UniverseTable
.
trade_date
==
ref_date
,
*
all_and_conditions
)
)
)
return
query
return
query
def
query_range
(
self
,
start_date
=
None
,
end_date
=
None
,
dates
=
None
):
def
query_range
(
self
,
start_date
=
None
,
end_date
=
None
,
dates
=
None
):
query
=
select
([
UniverseTable
.
trade_date
,
UniverseTable
.
code
])
.
distinct
()
all_and_conditions
,
all_or_conditions
=
self
.
_create_condition
()
all_and_conditions
,
all_or_conditions
=
self
.
_create_condition
()
dates_cond
=
UniverseTable
.
trade_date
.
in_
(
dates
)
if
dates
else
UniverseTable
.
trade_date
.
between
(
start_date
,
end_date
)
dates_cond
=
UniverseTable
.
trade_date
.
in_
(
dates
)
if
dates
else
UniverseTable
.
trade_date
.
between
(
start_date
,
end_date
)
query
=
query
.
where
(
if
all_or_conditions
:
and_
(
query
=
and_
(
dates_cond
,
dates_cond
,
or_
(
or_
(
and_
(
*
all_and_conditions
),
and_
(
*
all_and_conditions
),
*
all_or_conditions
*
all_or_conditions
)
)
)
)
else
:
)
query
=
and_
(
dates_cond
,
*
all_and_conditions
)
return
query
return
query
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