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
eedad6e6
Commit
eedad6e6
authored
Mar 13, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug
parent
721396fa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
update_uqer_data_postgres.py
scripts/update_uqer_data_postgres.py
+17
-6
No files found.
scripts/update_uqer_data_postgres.py
View file @
eedad6e6
...
@@ -563,22 +563,33 @@ def update_uqer_index_components(ds, **kwargs):
...
@@ -563,22 +563,33 @@ def update_uqer_index_components(ds, **kwargs):
endDate
=
ref_date
)
endDate
=
ref_date
)
if
df
.
empty
:
if
df
.
empty
:
ref_previous_date
=
advanceDateByCalendar
(
'china.sse'
,
this_date
,
'-
9m
'
)
ref_previous_date
=
advanceDateByCalendar
(
'china.sse'
,
this_date
,
'-
1b
'
)
query
=
select
([
IndexComponent
])
.
where
(
query
=
select
([
IndexComponent
])
.
where
(
and_
(
and_
(
IndexComponent
.
trade_date
.
between
(
ref_previous_date
,
this_date
)
,
IndexComponent
.
trade_date
==
ref_previous_date
,
IndexComponent
.
indexCode
==
int
(
index
)
IndexComponent
.
indexCode
==
int
(
index
)
)
)
)
)
df
=
pd
.
read_sql
(
query
,
engine
)
df
=
pd
.
read_sql
(
query
,
engine
)
df
=
df
[
df
.
trade_date
==
df
.
trade_date
.
iloc
[
-
1
]]
df
[
'trade_date'
]
=
this_date
df
[
'trade_date'
]
=
this_date
if
df
.
empty
:
if
df
.
empty
:
continue
continue
alpha_logger
.
info
(
'{0} is finished with previous data
'
.
format
(
index
))
alpha_logger
.
info
(
'{0} is finished with previous data
{1}'
.
format
(
index
,
len
(
df
)
))
else
:
else
:
################################
# 2017-10-09, patch for uqer bug
def
filter_out_eqy
(
code
:
str
):
if
code
[
0
]
in
[
'0'
,
'3'
]
and
code
[
-
4
:]
in
[
'XSHE'
]:
return
True
elif
code
[
0
]
in
[
'6'
]
and
code
[
-
4
:]
in
[
'XSHG'
]:
return
True
else
:
return
False
df
=
df
[
df
.
consID
.
apply
(
lambda
x
:
filter_out_eqy
(
x
))]
################################
df
.
rename
(
columns
=
{
'ticker'
:
'indexCode'
,
df
.
rename
(
columns
=
{
'ticker'
:
'indexCode'
,
'secShortName'
:
'indexShortName'
,
'secShortName'
:
'indexShortName'
,
'consTickerSymbol'
:
'code'
,
'consTickerSymbol'
:
'code'
,
...
@@ -589,7 +600,7 @@ def update_uqer_index_components(ds, **kwargs):
...
@@ -589,7 +600,7 @@ def update_uqer_index_components(ds, **kwargs):
df
[
'trade_date'
]
=
this_date
df
[
'trade_date'
]
=
this_date
del
df
[
'secID'
]
del
df
[
'secID'
]
del
df
[
'consID'
]
del
df
[
'consID'
]
alpha_logger
.
info
(
'{0} is finished with new data
'
.
format
(
index
))
alpha_logger
.
info
(
'{0} is finished with new data
{1}'
.
format
(
index
,
len
(
df
)
))
total_data
=
total_data
.
append
(
df
)
total_data
=
total_data
.
append
(
df
)
index_codes
=
total_data
.
indexCode
.
unique
()
index_codes
=
total_data
.
indexCode
.
unique
()
...
...
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