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
dfc2079f
Commit
dfc2079f
authored
Mar 21, 2024
by
wenwen.tang
😕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加导出Excel逻辑
parent
7db266e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
11 deletions
+56
-11
EstimateMarketTrendV20.py
ai/EstimateMarketTrendV20.py
+22
-10
robo_datas.py
ai/dao/robo_datas.py
+1
-1
reporter.py
ai/reporter.py
+33
-0
No files found.
ai/EstimateMarketTrendV20.py
View file @
dfc2079f
...
...
@@ -6,21 +6,28 @@ from py_jftech import autowired, parse_date, prev_workday, format_date
from
ai.dao.robo_datas
import
get_base_info
,
get_index_list
,
get_fund_list
from
ai.data_access
import
DataAccess
from
ai.model_trainer
import
ModelTrainer
from
ai.noticer
import
send
from
ai.training_data_builder
import
TrainingDataBuilder
from
api
import
DataSync
# 截止日期
# max_date = None
max_date
=
'2024-0
2-23
'
max_date
=
'2024-0
3-01
'
# max_date = '2024-01-11'
toForecast
=
True
# False means test, True means forecast
syncData
=
False
# 开启会同步数据库指数及基金数据
uploadData
=
False
# 开启会上传预测结果
doReport
=
True
# 开启会生成Excel报告
# 待预测指数
# PREDICT_LIST = [67, 121, 122, 123]
PREDICT_LIST
=
[
67
,
121
,
122
,
123
,
155
,
15
7
,
158
,
159
,
160
,
161
,
162
,
163
,
164
,
165
,
166
,
167
,
168
,
169
,
170
,
171
,
174
,
175
,
177
,
178
]
PREDICT_LIST
=
[
67
,
121
,
122
,
123
,
155
,
15
6
,
157
,
158
,
159
,
160
,
161
,
162
,
163
,
164
,
165
,
166
,
167
,
168
,
169
,
170
,
171
,
17
4
,
17
5
,
177
,
178
]
eco
=
[
65
,
66
,
74
,
134
]
index
=
[
67
,
68
,
69
,
70
,
71
,
72
,
73
,
75
,
76
,
77
,
105
,
106
,
116
,
117
,
138
,
139
,
142
,
143
,
140
,
141
,
144
,
145
,
146
]
fund
=
[
121
,
122
,
123
,
155
,
157
,
158
,
159
,
160
,
161
,
162
,
163
,
164
,
165
,
166
,
167
,
168
,
169
,
170
,
171
,
174
,
175
,
177
,
fund
=
[
121
,
122
,
123
,
155
,
156
,
157
,
158
,
159
,
160
,
161
,
162
,
163
,
164
,
165
,
166
,
167
,
168
,
169
,
170
,
171
,
174
,
175
,
177
,
178
]
...
...
@@ -39,10 +46,15 @@ def predictionFromMoel(the_model, scaledX_forecast, predict_item, indexDict: dic
content
=
f
"""
\n
On day {forecastDay.strftime("
%
m/
%
d/
%
Y")}, the model predicts {predict_item} to be {predictionStr} in {str(numForecastDays)} business days.
\n
"""
print
(
content
)
# 上传预测结果
# key = [k for k, v in indexDict.items() if v == predict_item]
# index_info = get_base_info(key)[0]
# upload_predict(index_info['ticker'], forecastDay, predictionStr)
# send(content)
key
=
[
k
for
k
,
v
in
indexDict
.
items
()
if
v
==
predict_item
]
index_info
=
get_base_info
(
key
)[
0
]
if
uploadData
:
from
ai.noticer
import
upload_predict
upload_predict
(
index_info
[
'ticker'
],
forecastDay
,
predictionStr
)
if
doReport
:
from
ai.reporter
import
do_reporter
do_reporter
()
send
(
content
)
return
prediction
...
...
@@ -78,8 +90,8 @@ def judgement(id, type, predict):
########################################
if
__name__
==
'__main__'
:
sync
()
toForecast
=
True
# False means test, True means forecast
if
syncData
:
sync
()
# define some parameters
win1W
=
5
# 1 week
win1M
=
21
# 1 Month
...
...
ai/dao/robo_datas.py
View file @
dfc2079f
...
...
@@ -44,6 +44,6 @@ def get_fund_list(fund_ids=None, min_date=None, max_date=None, limit=None):
def
get_base_info
(
ids
=
None
):
sqls
=
[]
return
f
"""
SELECT rbd_id id,v_rbd_bloomberg_ticker ticker,v_rbd_type type FROM `robo_base_datum`
SELECT rbd_id id,v_rbd_bloomberg_ticker ticker,v_rbd_type type
, rbd_datas datas
FROM `robo_base_datum`
{where(*sqls,rbd_id=to_tuple(ids))}
"""
\ No newline at end of file
ai/reporter.py
0 → 100644
View file @
dfc2079f
import
datetime
import
json
import
pandas
as
pd
import
requests
symbols
=
[
'ACWI'
,
'EWJ'
,
'MCHI'
,
'EEM'
,
'BKF'
,
'INDA'
,
'AAXJ'
,
'VGK'
,
'QQQ'
,
'SPY'
,
'SPX'
,
'IWN'
,
'IUSG'
,
'IWD'
,
'DON'
,
'GDX'
,
'TOLZ'
,
'XLU'
,
'XBI'
,
'ESGD'
,
'IGE'
,
'EMLC'
,
'IGAA'
,
'LQD'
,
'HYG'
,
'SHY'
,
'IEI'
,
'IEF'
,
'GLD'
,
'IYR'
,
'UUP'
,
'CEW'
,
'TLT'
]
def
do_reporter
(
start
=
'2023-10-01'
,
end
=
datetime
.
date
.
today
()):
url
=
f
"https://jrp.jfquant.com/api/v1.0/ai/predict?startTime={start}&endTime={end.strftime('
%
Y-
%
m-
%
d')}"
resp
=
requests
.
get
(
url
)
datas
=
[]
symbol_index_dict
=
{
symbol
:
index
for
index
,
symbol
in
enumerate
(
symbols
)}
for
value
in
resp
.
json
()[
'body'
]
.
values
():
for
item
in
value
:
data
=
{
'Forcast On Date'
:
item
[
'aiPredict'
][
'predictDate'
],
'Ticker'
:
item
[
'bloombergTicker'
]
.
replace
(
' Index'
,
''
)
.
replace
(
' Equity'
,
''
),
'In 21 business days'
:
'UP'
if
item
[
'aiPredict'
][
'predict'
]
==
1
else
'DOWN'
,
'Ticker Name'
:
item
[
'indexName'
],
}
datas
.
append
(
data
)
sorted_data
=
sorted
(
datas
,
key
=
lambda
x
:
symbol_index_dict
[
x
[
'Ticker'
]
.
split
(
' '
)[
0
]])
print
(
json
.
dumps
(
sorted_data
,
ensure_ascii
=
False
))
pf
=
pd
.
DataFrame
(
sorted_data
)
pf
.
to_excel
(
"Forcast_Report.xlsx"
,
index
=
False
)
if
__name__
==
'__main__'
:
do_reporter
()
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