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
79d150f6
Commit
79d150f6
authored
Nov 27, 2023
by
wenwen.tang
😕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入指数其他四种指标
parent
b884adf3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
robo_index_datas.py
basic/dao/robo_index_datas.py
+5
-0
sync.py
basic/sync.py
+10
-5
benchmark.py
reports/benchmark.py
+1
-1
No files found.
basic/dao/robo_index_datas.py
View file @
79d150f6
...
...
@@ -10,6 +10,11 @@ __COLUMNS__ = {
'rid_pe'
:
'pe'
,
'rid_pb'
:
'pb'
,
'rid_volume'
:
'volume'
,
'rid_frdpe'
:
'frdpe'
,
'rid_frdpes'
:
'frdpes'
,
'rid_erp'
:
'erp'
,
'rid_pc'
:
'pc'
,
}
...
...
basic/sync.py
View file @
79d150f6
...
...
@@ -177,9 +177,10 @@ class IndexSync(JDCDataSync):
return
next_workday
(
last
[
'date'
])
if
last
else
self
.
start_date
def
build_urls
(
self
,
datum
,
start_date
,
page
=
0
)
->
str
:
return
f
'http
s
://jdcprod.thiztech.com/api/datas/index-value?page={page}&size=200&sourceCode={quote(datum["bloombergTicker"])}&sourceType=BLOOMBERG&startDate={format_date(start_date)}'
return
f
'http://jdcprod.thiztech.com/api/datas/index-value?page={page}&size=200&sourceCode={quote(datum["bloombergTicker"])}&sourceType=BLOOMBERG&startDate={format_date(start_date)}'
def
store_date
(
self
,
datumid
,
datas
:
List
[
dict
]):
# add frdpe,frdpes,erp,pc
save_datas
=
[{
'index_id'
:
datumid
,
'date'
:
dt
.
fromtimestamp
(
x
[
'date'
]
/
1000
,
tz
=
pytz
.
timezone
(
'Asia/Shanghai'
))
.
strftime
(
'
%
Y-
%
m-
%
d'
),
...
...
@@ -190,6 +191,10 @@ class IndexSync(JDCDataSync):
'pe'
:
x
[
'peRatio'
]
if
'peRatio'
in
x
else
None
,
'pb'
:
x
[
'pbRatio'
]
if
'pbRatio'
in
x
else
None
,
'volume'
:
x
[
'volume'
]
if
'volume'
in
x
else
None
,
'frdpe'
:
x
[
'forwardPe'
]
if
'forwardPe'
in
x
else
None
,
'frdpes'
:
x
[
'forwardEps'
]
if
'forwardEps'
in
x
else
None
,
'erp'
:
x
[
'erp'
]
if
'erp'
in
x
else
None
,
'pc'
:
x
[
'pcRatio'
]
if
'pcRatio'
in
x
else
None
,
}
for
x
in
datas
if
is_workday
(
dt
.
fromtimestamp
(
x
[
'date'
]
/
1000
,
tz
=
pytz
.
timezone
(
'Asia/Shanghai'
)))
and
'close'
in
x
]
if
save_datas
:
rid
.
batch_insert
(
save_datas
)
...
...
@@ -211,7 +216,7 @@ class EcoSync(JDCDataSync):
return
next_workday
(
last
[
'date'
])
if
last
else
self
.
start_date
def
build_urls
(
self
,
datum
,
start_date
,
page
=
0
)
->
str
:
return
f
'http
s
://jdcprod.thiztech.com/api/datas/eco-value?page={page}&size=200&sourceCode={quote(datum["bloombergTicker"])}&sourceType=BLOOMBERG&startDate={format_date(start_date)}'
return
f
'http://jdcprod.thiztech.com/api/datas/eco-value?page={page}&size=200&sourceCode={quote(datum["bloombergTicker"])}&sourceType=BLOOMBERG&startDate={format_date(start_date)}'
def
store_date
(
self
,
datumid
,
datas
:
List
[
dict
]):
save_datas
=
[{
...
...
@@ -244,7 +249,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
s
://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/asset-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
)
...
...
@@ -254,7 +259,7 @@ 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
s
://jdcprod.thiztech.com/api/subject?busiField=TW&sourceType=TW&subjectType=FUND'
)
response
=
requests
.
get
(
'http://jdcprod.thiztech.com/api/subject?busiField=TW&sourceType=TW&subjectType=FUND'
)
response
=
response
.
json
()
if
not
response
[
'success'
]:
raise
CollectError
(
f
'''find fund subject failed: {response['status']}'''
)
...
...
@@ -298,7 +303,7 @@ class ExrateSync(DataSync):
return
[
x
[
'ticker'
]
for
x
in
navs_config
[
'exrate'
]]
if
'exrate'
in
navs_config
else
[]
def
build_url
(
self
,
ticker
,
start_date
,
page
=
0
):
return
f
'http
s
://jdcprod.thiztech.com/api/datas/exrate-value?page={page}&size=200&sourceCode={quote(ticker)}&sourceType=BLOOMBERG&startDate={format_date(start_date)}'
return
f
'http://jdcprod.thiztech.com/api/datas/exrate-value?page={page}&size=200&sourceCode={quote(ticker)}&sourceType=BLOOMBERG&startDate={format_date(start_date)}'
def
do_sync
(
self
,
max_date
=
dt
.
today
()):
logger
.
info
(
f
'start sync datas for type[EXRATE]'
)
...
...
reports/benchmark.py
View file @
79d150f6
...
...
@@ -44,7 +44,7 @@ class BenchmarkAlligamReportor(RoboReportor):
if
start_date
:
params
[
'startDate'
]
=
format_date
(
start_date
)
while
True
:
response
=
requests
.
get
(
f
'http
s
://jdcprod.thiztech.com/api/datas/asset-value?{urlencode(params)}'
)
.
json
()
response
=
requests
.
get
(
f
'http://jdcprod.thiztech.com/api/datas/asset-value?{urlencode(params)}'
)
.
json
()
if
not
response
[
'success'
]:
raise
Exception
(
f
'''request jdc alligam failed: {response['status']}'''
)
rb
.
batch_insert
([{
...
...
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