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
5703c859
Commit
5703c859
authored
Feb 25, 2026
by
wenwen.tang
😕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配新数据源
parent
fca62352
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
28 deletions
+29
-28
benchmark.py
reports/benchmark.py
+29
-28
No files found.
reports/benchmark.py
View file @
5703c859
...
@@ -8,6 +8,7 @@ import requests
...
@@ -8,6 +8,7 @@ import requests
from
py_jftech
import
component
,
filter_weekend
,
next_workday
,
get_config
,
format_date
from
py_jftech
import
component
,
filter_weekend
,
next_workday
,
get_config
,
format_date
from
api
import
RoboReportor
from
api
import
RoboReportor
from
basic.sync
import
ths_token
from
reports.dao
import
robo_benckmark
as
rb
from
reports.dao
import
robo_benckmark
as
rb
config
=
get_config
(
__name__
)
config
=
get_config
(
__name__
)
...
@@ -18,7 +19,7 @@ class BenchmarkAlligamReportor(RoboReportor):
...
@@ -18,7 +19,7 @@ class BenchmarkAlligamReportor(RoboReportor):
@
property
@
property
def
report_name
(
self
)
->
str
:
def
report_name
(
self
)
->
str
:
return
'BENCHMARK_
ALLIGAM
'
return
'BENCHMARK_
SPX
'
@
property
@
property
def
module_name
(
self
)
->
str
:
def
module_name
(
self
)
->
str
:
...
@@ -26,42 +27,42 @@ class BenchmarkAlligamReportor(RoboReportor):
...
@@ -26,42 +27,42 @@ class BenchmarkAlligamReportor(RoboReportor):
@
property
@
property
def
risk
(
self
):
def
risk
(
self
):
return
'
alligam
'
return
'
SPX
'
@
property
@
property
def
base_params
(
self
):
def
base_params
(
self
):
return
{
return
{
'subjectKeys'
:
879
,
'code'
:
"SPX.GI"
,
'size'
:
200
,
'sourceType'
:
'BLOOMBERG'
}
}
def
sync_benchmark
(
self
,
start_date
=
None
):
def
sync_benchmark
(
self
,
start_date
=
None
):
url
=
"https://quantapi.51ifind.com/api/v1/cmd_history_quotation"
headers
=
{
"Content-Type"
:
"application/json"
,
"access_token"
:
ths_token
(),
"ifindlang"
:
"cn"
}
params
=
{
params
=
{
**
self
.
base_params
,
'codes'
:
self
.
base_params
[
'code'
],
'page'
:
0
'indicators'
:
'close'
,
'startdate'
:
format_date
(
start_date
)
if
start_date
else
"2012-01-01"
,
'enddate'
:
format_date
(
dt
.
today
())
}
}
if
start_date
:
response
=
requests
.
post
(
url
,
json
=
params
,
headers
=
headers
)
params
[
'startDate'
]
=
format_date
(
start_date
)
response
=
response
.
json
()[
'tables'
]
while
True
:
if
len
(
response
)
==
0
or
response
[
0
]
.
get
(
'time'
)
is
None
or
len
(
response
[
0
][
'time'
])
==
0
:
response
=
requests
.
get
(
f
'http://jdcprod.thiztech.com/api/datas/asset-value?{urlencode(params)}'
)
.
json
()
return
if
not
response
[
'success'
]:
rb
.
batch_insert
([{
raise
Exception
(
f
'''request jdc alligam failed: {response['status']}'''
)
'date'
:
time
,
if
response
[
'body'
][
'content'
]:
'module'
:
self
.
module_name
,
rb
.
batch_insert
([{
'risk'
:
self
.
risk
,
'date'
:
dt
.
fromtimestamp
(
x
[
'date'
]
/
1000
),
'nav'
:
close
,
'module'
:
self
.
module_name
,
'remarks'
:
json
.
dumps
({
'risk'
:
self
.
risk
,
'av'
:
close
,
'nav'
:
x
[
'calibrateValue'
],
'div'
:
0
'remarks'
:
json
.
dumps
({
},
ensure_ascii
=
False
)
'av'
:
x
[
'originValue'
],
}
for
time
,
close
in
zip
(
response
[
0
][
'time'
],
response
[
0
][
'table'
][
'close'
])])
'div'
:
x
[
'dividend'
]
if
'dividend'
in
x
else
0
},
ensure_ascii
=
False
)
}
for
x
in
response
[
'body'
][
'content'
]])
if
response
[
'body'
][
'last'
]:
break
else
:
params
=
{
**
params
,
'page'
:
params
[
'page'
]
+
1
}
def
load_report
(
self
,
max_date
=
dt
.
today
(),
min_date
=
None
)
->
List
[
dict
]:
def
load_report
(
self
,
max_date
=
dt
.
today
(),
min_date
=
None
)
->
List
[
dict
]:
max_date
=
filter_weekend
(
max_date
)
max_date
=
filter_weekend
(
max_date
)
...
...
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