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
bbfc8f37
Commit
bbfc8f37
authored
May 29, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made fetch industry workable with null codes
parent
f5cbde24
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
sqlengine.py
alphamind/data/engines/sqlengine.py
+11
-6
No files found.
alphamind/data/engines/sqlengine.py
View file @
bbfc8f37
...
...
@@ -615,7 +615,7 @@ class SqlEngine(object):
def
fetch_industry
(
self
,
ref_date
:
str
,
codes
:
Iterable
[
int
],
codes
:
Iterable
[
int
]
=
None
,
category
:
str
=
'sw'
,
level
:
int
=
1
):
...
...
@@ -623,21 +623,26 @@ class SqlEngine(object):
code_name
=
'industryID'
+
str
(
level
)
category_name
=
'industryName'
+
str
(
level
)
query
=
select
([
Industry
.
code
,
getattr
(
Industry
,
code_name
)
.
label
(
'industry_code'
),
getattr
(
Industry
,
category_name
)
.
label
(
'industry'
)])
.
where
(
and_
(
cond
=
and_
(
Industry
.
trade_date
==
ref_date
,
Industry
.
code
.
in_
(
codes
),
Industry
.
industry
==
industry_category_name
)
if
codes
else
and_
(
Industry
.
trade_date
==
ref_date
,
Industry
.
industry
==
industry_category_name
)
query
=
select
([
Industry
.
code
,
getattr
(
Industry
,
code_name
)
.
label
(
'industry_code'
),
getattr
(
Industry
,
category_name
)
.
label
(
'industry'
)])
.
where
(
cond
)
.
distinct
()
return
pd
.
read_sql
(
query
,
self
.
engine
)
.
dropna
()
.
drop_duplicates
([
'code'
])
def
fetch_industry_matrix
(
self
,
ref_date
:
str
,
codes
:
Iterable
[
int
],
codes
:
Iterable
[
int
]
=
None
,
category
:
str
=
'sw'
,
level
:
int
=
1
):
df
=
self
.
fetch_industry
(
ref_date
,
codes
,
category
,
level
)
...
...
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