Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
R
robo-dividend
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
wenwen.tang
robo-dividend
Commits
bbbf3b86
Commit
bbbf3b86
authored
Mar 17, 2025
by
吕先亚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
etf
parent
05c3b6dc
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
273 additions
and
8 deletions
+273
-8
sync.py
basic/sync.py
+8
-8
config-etf.yml
config-etf.yml
+265
-0
No files found.
basic/sync.py
View file @
bbbf3b86
...
...
@@ -251,7 +251,7 @@ class FundNavSync(JDCDataSync):
return
None
querys
=
self
.
_jdc_querys
[
datum
[
'id'
]]
query_str
=
'&'
.
join
([
f
'{x[0]}={quote(str(x[1]).encode())}'
for
x
in
querys
.
items
()])
return
f
'http://jdcprod.thiztech.com/api/datas/
asset
-value?page={page}&size=200&startDate={format_date(start_date)}&{query_str}'
return
f
'http://jdcprod.thiztech.com/api/datas/
index
-value?page={page}&size=200&startDate={format_date(start_date)}&{query_str}'
def
find_jdc_querys
(
self
):
funds
=
self
.
_datum
.
get_datums
(
type
=
DatumType
.
FUND
,
exclude
=
False
)
...
...
@@ -261,28 +261,28 @@ class FundNavSync(JDCDataSync):
}
for
x
in
funds
if
'ftTicker'
not
in
x
and
'bloombergTicker'
in
x
}
ft_tickers
=
{
x
[
'ftTicker'
]:
x
for
x
in
funds
if
'ftTicker'
in
x
}
response
=
requests
.
get
(
'http://jdcprod.thiztech.com/api/subject?
busiField=TW&sourceType=TW&subjectType=FUND
'
)
response
=
requests
.
get
(
'http://jdcprod.thiztech.com/api/subject?
sourceType=THS&subjectType=INDEX
'
)
response
=
response
.
json
()
if
not
response
[
'success'
]:
raise
CollectError
(
f
'''find fund subject failed: {response['status']}'''
)
return
{
**
urls
,
**
{
ft_tickers
[
x
[
'
fundId
'
]][
'id'
]:
{
ft_tickers
[
x
[
'
collectCode
'
]][
'id'
]:
{
'subjectKeys'
:
x
[
'key'
],
'sourceType'
:
'T
W
'
}
for
x
in
response
[
'body'
][
'content'
]
if
x
[
'
fundId
'
]
in
ft_tickers
'sourceType'
:
'T
HS
'
}
for
x
in
response
[
'body'
][
'content'
]
if
x
[
'
collectCode
'
]
in
ft_tickers
}}
def
store_date
(
self
,
datumid
,
datas
:
List
[
dict
]):
save_navs
=
[{
'fund_id'
:
datumid
,
'nav_date'
:
dt
.
fromtimestamp
(
x
[
'date'
]
/
1000
,
tz
=
pytz
.
timezone
(
'Asia/Shanghai'
)),
'av'
:
x
[
'
originValu
e'
],
'av'
:
x
[
'
clos
e'
],
'div'
:
x
[
'dividend'
]
if
'dividend'
in
x
else
0
,
'split'
:
x
[
'split'
]
if
'split'
in
x
else
1
,
'accrue_split'
:
x
[
'totalSplit'
]
if
'totalSplit'
in
x
else
1
,
'av_p'
:
x
[
'
postValu
e'
],
'av_p'
:
x
[
'
clos
e'
],
'div_p'
:
x
[
'postDividend'
]
if
'postDividend'
in
x
else
0
,
'nav_cal'
:
x
[
'c
alibrateValu
e'
]
'nav_cal'
:
x
[
'c
los
e'
]
}
for
x
in
datas
if
is_workday
(
dt
.
fromtimestamp
(
x
[
'date'
]
/
1000
,
tz
=
pytz
.
timezone
(
'Asia/Shanghai'
)))]
if
save_navs
:
rfn
.
batch_insert
(
save_navs
)
...
...
config-etf.yml
0 → 100644
View file @
bbbf3b86
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