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
afe45bce
Commit
afe45bce
authored
Oct 30, 2024
by
吕先亚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ai 通用性改动
parent
95202e88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
EstimateMarketTrendV20.py
ai/EstimateMarketTrendV20.py
+1
-1
reporter.py
ai/reporter.py
+30
-1
No files found.
ai/EstimateMarketTrendV20.py
View file @
afe45bce
...
@@ -16,7 +16,7 @@ from api import DataSync
...
@@ -16,7 +16,7 @@ from api import DataSync
# 截止日期
# 截止日期
max_date
=
None
max_date
=
None
toForecast
=
Tru
e
# False means test, True means forecast
toForecast
=
Fals
e
# False means test, True means forecast
syncData
=
False
# 开启会同步数据库指数及基金数据
syncData
=
False
# 开启会同步数据库指数及基金数据
uploadData
=
False
# 开启会上传预测结果
uploadData
=
False
# 开启会上传预测结果
doReport
=
True
# 开启会生成Excel报告
doReport
=
True
# 开启会生成Excel报告
...
...
ai/reporter.py
View file @
afe45bce
...
@@ -4,7 +4,6 @@ import random
...
@@ -4,7 +4,6 @@ import random
import
pandas
as
pd
import
pandas
as
pd
import
requests
import
requests
from
py_jftech
import
format_date
from
ai.config
import
LABEL_TAG
,
LABEL_RANGE
from
ai.config
import
LABEL_TAG
,
LABEL_RANGE
from
ai.dao
import
robo_predict
from
ai.dao
import
robo_predict
...
@@ -57,9 +56,13 @@ def do_reporter2(records=None, excel_name=None):
...
@@ -57,9 +56,13 @@ def do_reporter2(records=None, excel_name=None):
'result'
:
result
'result'
:
result
}
}
datas
.
append
(
data
)
datas
.
append
(
data
)
RMSE
=
get_RMSE
(
datas
)
RefRMSE
=
get_RefRMSE
(
datas
)
symbol_index_dict
=
{
symbol
:
index
for
index
,
symbol
in
enumerate
(
symbols
)}
symbol_index_dict
=
{
symbol
:
index
for
index
,
symbol
in
enumerate
(
symbols
)}
sorted_data
=
sorted
(
datas
,
key
=
lambda
x
:
symbol_index_dict
[
x
[
'Ticker'
]
.
split
(
' '
)[
0
]])
sorted_data
=
sorted
(
datas
,
key
=
lambda
x
:
symbol_index_dict
[
x
[
'Ticker'
]
.
split
(
' '
)[
0
]])
pf
=
pd
.
DataFrame
(
sorted_data
)
pf
=
pd
.
DataFrame
(
sorted_data
)
pf
[
'RMSE'
]
=
RMSE
pf
[
'RefRMSE'
]
=
RefRMSE
pf
.
to_excel
(
excel_name
if
excel_name
else
"Forcast_Report_chu.xlsx"
,
index
=
False
)
pf
.
to_excel
(
excel_name
if
excel_name
else
"Forcast_Report_chu.xlsx"
,
index
=
False
)
...
@@ -69,6 +72,32 @@ def map_to_label(ret):
...
@@ -69,6 +72,32 @@ def map_to_label(ret):
return
label
return
label
def
get_RMSE
(
datas
):
"""
Root Mean Square Error (RMSE)
@param data: 预测值
@return:
"""
datas
=
[
data
for
data
in
datas
if
data
.
get
(
'real outcome label'
)
is
not
None
]
tags
=
{
v
:
k
for
k
,
v
in
LABEL_TAG
.
items
()}
return
(
sum
(
[(
tags
.
get
(
data
[
'real outcome label'
])
-
tags
.
get
(
data
[
'In 21 business days'
]))
**
2
for
data
in
datas
])
/
len
(
datas
))
**
0.5
def
get_RefRMSE
(
datas
):
"""
Root Mean Square Error (Reference RMSE)
@param data: 预测值
@return:
"""
datas
=
[
data
for
data
in
datas
if
data
.
get
(
'real outcome label'
)
is
not
None
]
tags
=
{
v
:
k
for
k
,
v
in
LABEL_TAG
.
items
()}
return
(
sum
(
[(
tags
.
get
(
data
[
'real outcome label'
])
-
tags
.
get
(
data
[
'random variable label'
]))
**
2
for
data
in
datas
])
/
len
(
datas
))
**
0.5
def
is_right
(
id
,
type
,
start
,
predict
):
def
is_right
(
id
,
type
,
start
,
predict
):
predict_term
=
21
predict_term
=
21
navs
=
[]
navs
=
[]
...
...
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