Merge branch 'main' of https://gitea.jayhgq.cn/liurui/PriceForecast
This commit is contained in:
commit
e39d90a503
123
config_jingbo.py
123
config_jingbo.py
@ -86,50 +86,13 @@ ClassifyId = 1214
|
|||||||
|
|
||||||
### 报告上传配置
|
### 报告上传配置
|
||||||
# 变量定义--线上环境
|
# 变量定义--线上环境
|
||||||
# login_pushreport_url = "http://10.200.32.39/jingbo-api/api/server/login"
|
login_pushreport_url = "http://10.200.32.39/jingbo-api/api/server/login"
|
||||||
# upload_url = "http://10.200.32.39/jingbo-api/api/analysis/reportInfo/researchUploadReportSave"
|
upload_url = "http://10.200.32.39/jingbo-api/api/analysis/reportInfo/researchUploadReportSave"
|
||||||
|
|
||||||
# login_data = {
|
|
||||||
# "data": {
|
|
||||||
# "account": "api_dev",
|
|
||||||
# "password": "ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=",
|
|
||||||
# "tenantHashCode": "8a4577dbd919675758d57999a1e891fe",
|
|
||||||
# "terminal": "API"
|
|
||||||
# },
|
|
||||||
# "funcModule": "API",
|
|
||||||
# "funcOperation": "获取token"
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# upload_data = {
|
|
||||||
# "funcModule":'研究报告信息',
|
|
||||||
# "funcOperation":'上传原油价格预测报告',
|
|
||||||
# "data":{
|
|
||||||
# "ownerAccount":'27663', #报告所属用户账号 27663 - 刘小朋
|
|
||||||
# "reportType":'OIL_PRICE_FORECAST', # 报告类型,固定为OIL_PRICE_FORECAST
|
|
||||||
# "fileName": '', #文件名称
|
|
||||||
# "fileBase64": '' ,#文件内容base64
|
|
||||||
# "categoryNo":'yyjgycbg', # 研究报告分类编码
|
|
||||||
# "smartBusinessClassCode":'YCJGYCBG', #分析报告分类编码
|
|
||||||
# "reportEmployeeCode":"E40482" ,# 报告人 E40482 - 管理员 0000027663 - 刘小朋
|
|
||||||
# "reportDeptCode" :"002000621000", # 报告部门 - 002000621000 SH期货研究部
|
|
||||||
# "productGroupCode":"RAW_MATERIAL" # 商品分类
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # 变量定义--测试环境
|
|
||||||
login_pushreport_url = "http://192.168.100.53:8080/jingbo-dev/api/server/login"
|
|
||||||
upload_url = "http://192.168.100.53:8080/jingbo-dev/api/analysis/reportInfo/researchUploadReportSave"
|
|
||||||
# upload_url = "http://192.168.100.109:8080/jingbo/api/analysis/reportInfo/researchUploadReportSave" # zhaoqiwei
|
|
||||||
|
|
||||||
|
|
||||||
login_data = {
|
login_data = {
|
||||||
"data": {
|
"data": {
|
||||||
"account": "api_test",
|
"account": "api_dev",
|
||||||
"password": "MmVmNzNlOWI0MmY0ZDdjZGUwNzE3ZjFiMDJiZDZjZWU=",
|
"password": "ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=",
|
||||||
"tenantHashCode": "8a4577dbd919675758d57999a1e891fe",
|
"tenantHashCode": "8a4577dbd919675758d57999a1e891fe",
|
||||||
"terminal": "API"
|
"terminal": "API"
|
||||||
},
|
},
|
||||||
@ -137,48 +100,85 @@ login_data = {
|
|||||||
"funcOperation": "获取token"
|
"funcOperation": "获取token"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
upload_data = {
|
upload_data = {
|
||||||
"funcModule":'研究报告信息',
|
"funcModule":'研究报告信息',
|
||||||
"funcOperation":'上传原油价格预测报告',
|
"funcOperation":'上传原油价格预测报告',
|
||||||
"data":{
|
"data":{
|
||||||
"ownerAccount":'arui', #报告所属用户账号
|
"ownerAccount":'27663', #报告所属用户账号 27663 - 刘小朋
|
||||||
"reportType":'OIL_PRICE_FORECAST', # 报告类型,固定为OIL_PRICE_FORECAST
|
"reportType":'OIL_PRICE_FORECAST', # 报告类型,固定为OIL_PRICE_FORECAST
|
||||||
"fileName": '2000-40-5-50--100-原油指标数据.xlsx-Brent活跃合约--2024-09-06-15-01-29-预测报告.pdf', #文件名称
|
"fileName": '', #文件名称
|
||||||
"fileBase64": '' ,#文件内容base64
|
"fileBase64": '' ,#文件内容base64
|
||||||
"categoryNo":'yyjgycbg', # 研究报告分类编码
|
"categoryNo":'yyjgycbg', # 研究报告分类编码
|
||||||
"smartBusinessClassCode":'YCJGYCBG', #分析报告分类编码
|
"smartBusinessClassCode":'YCJGYCBG', #分析报告分类编码
|
||||||
"reportEmployeeCode":"E40116", # 报告人
|
"reportEmployeeCode":"E40482" ,# 报告人 E40482 - 管理员 0000027663 - 刘小朋
|
||||||
"reportDeptCode" :"D0044" ,# 报告部门
|
"reportDeptCode" :"002000621000", # 报告部门 - 002000621000 SH期货研究部
|
||||||
"productGroupCode":"RAW_MATERIAL" # 商品分类
|
"productGroupCode":"RAW_MATERIAL" # 商品分类
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### 线上开关
|
|
||||||
# is_train = True # 是否训练
|
|
||||||
# is_debug = False # 是否调试
|
|
||||||
# is_eta = True # 是否使用eta接口
|
|
||||||
# is_timefurture = True # 是否使用时间特征
|
|
||||||
# is_fivemodels = False # 是否使用之前保存的最佳的5个模型
|
|
||||||
# is_edbcode = False # 特征使用edbcoding列表中的
|
|
||||||
# is_edbnamelist = False # 自定义特征,对应上面的edbnamelist
|
|
||||||
# is_update_eta = True # 预测结果上传到eta
|
|
||||||
# is_update_report = True # 是否上传报告
|
|
||||||
|
|
||||||
### 开关
|
# # 变量定义--测试环境
|
||||||
|
# login_pushreport_url = "http://192.168.100.53:8080/jingbo-dev/api/server/login"
|
||||||
|
# upload_url = "http://192.168.100.53:8080/jingbo-dev/api/analysis/reportInfo/researchUploadReportSave"
|
||||||
|
# # upload_url = "http://192.168.100.109:8080/jingbo/api/analysis/reportInfo/researchUploadReportSave" # zhaoqiwei
|
||||||
|
|
||||||
|
|
||||||
|
# login_data = {
|
||||||
|
# "data": {
|
||||||
|
# "account": "api_test",
|
||||||
|
# "password": "MmVmNzNlOWI0MmY0ZDdjZGUwNzE3ZjFiMDJiZDZjZWU=",
|
||||||
|
# "tenantHashCode": "8a4577dbd919675758d57999a1e891fe",
|
||||||
|
# "terminal": "API"
|
||||||
|
# },
|
||||||
|
# "funcModule": "API",
|
||||||
|
# "funcOperation": "获取token"
|
||||||
|
# }
|
||||||
|
|
||||||
|
# upload_data = {
|
||||||
|
# "funcModule":'研究报告信息',
|
||||||
|
# "funcOperation":'上传原油价格预测报告',
|
||||||
|
# "data":{
|
||||||
|
# "ownerAccount":'arui', #报告所属用户账号
|
||||||
|
# "reportType":'OIL_PRICE_FORECAST', # 报告类型,固定为OIL_PRICE_FORECAST
|
||||||
|
# "fileName": '2000-40-5-50--100-原油指标数据.xlsx-Brent活跃合约--2024-09-06-15-01-29-预测报告.pdf', #文件名称
|
||||||
|
# "fileBase64": '' ,#文件内容base64
|
||||||
|
# "categoryNo":'yyjgycbg', # 研究报告分类编码
|
||||||
|
# "smartBusinessClassCode":'YCJGYCBG', #分析报告分类编码
|
||||||
|
# "reportEmployeeCode":"E40116", # 报告人
|
||||||
|
# "reportDeptCode" :"D0044" ,# 报告部门
|
||||||
|
# "productGroupCode":"RAW_MATERIAL" # 商品分类
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
### 线上开关
|
||||||
is_train = True # 是否训练
|
is_train = True # 是否训练
|
||||||
is_debug = False # 是否调试
|
is_debug = False # 是否调试
|
||||||
is_eta = False # 是否使用eta接口
|
is_eta = True # 是否使用eta接口
|
||||||
is_timefurture = True # 是否使用时间特征
|
is_timefurture = True # 是否使用时间特征
|
||||||
is_fivemodels = False # 是否使用之前保存的最佳的5个模型
|
is_fivemodels = False # 是否使用之前保存的最佳的5个模型
|
||||||
is_edbcode = False # 特征使用edbcoding列表中的
|
is_edbcode = False # 特征使用edbcoding列表中的
|
||||||
is_edbnamelist = False # 自定义特征,对应上面的edbnamelist
|
is_edbnamelist = False # 自定义特征,对应上面的edbnamelist
|
||||||
is_update_eta = False # 预测结果上传到eta
|
is_update_eta = True # 预测结果上传到eta
|
||||||
is_update_report = False # 是否上传报告
|
is_update_report = True # 是否上传报告
|
||||||
|
|
||||||
|
### 开关
|
||||||
|
# is_train = True # 是否训练
|
||||||
|
# is_debug = False # 是否调试
|
||||||
|
# is_eta = False # 是否使用eta接口
|
||||||
|
# is_timefurture = True # 是否使用时间特征
|
||||||
|
# is_fivemodels = False # 是否使用之前保存的最佳的5个模型
|
||||||
|
# is_edbcode = False # 特征使用edbcoding列表中的
|
||||||
|
# is_edbnamelist = False # 自定义特征,对应上面的edbnamelist
|
||||||
|
# is_update_eta = False # 预测结果上传到eta
|
||||||
|
# is_update_report = False # 是否上传报告
|
||||||
|
|
||||||
|
|
||||||
# 数据截取日期
|
# 数据截取日期
|
||||||
end_time = '2024-10-29' # 数据截取日期
|
end_time = '' # 数据截取日期
|
||||||
delweekenday = True
|
delweekenday = True
|
||||||
is_corr = False # 特征是否参与滞后领先提升相关系数
|
is_corr = False # 特征是否参与滞后领先提升相关系数
|
||||||
add_kdj = False # 是否添加kdj指标
|
add_kdj = False # 是否添加kdj指标
|
||||||
@ -212,7 +212,8 @@ db_name = os.path.join(dataset,'jbsh_yuanyou.db')
|
|||||||
|
|
||||||
settings = f'{input_size}-{horizon}-{train_steps}--{k}-{data_set}-{y}'
|
settings = f'{input_size}-{horizon}-{train_steps}--{k}-{data_set}-{y}'
|
||||||
# 获取日期时间
|
# 获取日期时间
|
||||||
now = datetime.datetime.now().strftime('%Y%m%d%H%M%S') # 获取当前日期时间
|
# now = datetime.datetime.now().strftime('%Y%m%d%H%M%S') # 获取当前日期时间
|
||||||
|
now = datetime.datetime.now().strftime('%Y-%m-%d') # 获取当前日期时间
|
||||||
reportname = f'Brent原油大模型预测--{now}.pdf' # 报告文件名
|
reportname = f'Brent原油大模型预测--{now}.pdf' # 报告文件名
|
||||||
reportname = reportname.replace(':', '-') # 替换冒号
|
reportname = reportname.replace(':', '-') # 替换冒号
|
||||||
|
|
||||||
|
BIN
jbsh_yuanyou线上数据库10.7备份.db
Normal file
BIN
jbsh_yuanyou线上数据库10.7备份.db
Normal file
Binary file not shown.
49
main.py
49
main.py
@ -1,4 +1,4 @@
|
|||||||
# 读取配置
|
# 读取配置
|
||||||
from config_jingbo import *
|
from config_jingbo import *
|
||||||
# from config_tansuanli import *
|
# from config_tansuanli import *
|
||||||
# from config_juxiting import *
|
# from config_juxiting import *
|
||||||
@ -75,34 +75,29 @@ def predict_main():
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
# 判断当前日期是不是周一
|
# 判断当前日期是不是周一
|
||||||
is_weekday = datetime.datetime.now().weekday() == 4
|
is_weekday = datetime.datetime.now().weekday() == 0
|
||||||
if is_weekday:
|
if is_weekday:
|
||||||
logger.info('今天是周一,更新预测模型')
|
logger.info('今天是周一,更新预测模型')
|
||||||
try:
|
# 计算最近20天预测残差最低的模型名称
|
||||||
# 计算最近20天预测残差最低的模型名称
|
|
||||||
|
|
||||||
model_results = sqlitedb.select_data('trueandpredict',order_by = "ds DESC",limit = "20")
|
model_results = sqlitedb.select_data('trueandpredict',order_by = "ds DESC",limit = "20")
|
||||||
model_results = model_results.dropna()
|
model_results = model_results.dropna()
|
||||||
modelnames = model_results.columns.to_list()[2:]
|
modelnames = model_results.columns.to_list()[2:]
|
||||||
for col in model_results[modelnames].select_dtypes(include=['object']).columns:
|
for col in model_results[modelnames].select_dtypes(include=['object']).columns:
|
||||||
model_results[col] = model_results[col].astype(np.float32)
|
model_results[col] = model_results[col].astype(np.float32)
|
||||||
# 计算每个预测值与真实值之间的偏差率
|
# 计算每个预测值与真实值之间的偏差率
|
||||||
for model in modelnames:
|
for model in modelnames:
|
||||||
model_results[f'{model}_abs_error_rate'] = abs(model_results['y'] - model_results[model]) / model_results['y']
|
model_results[f'{model}_abs_error_rate'] = abs(model_results['y'] - model_results[model]) / model_results['y']
|
||||||
|
|
||||||
# 获取每行对应的最小偏差率值
|
# 获取每行对应的最小偏差率值
|
||||||
min_abs_error_rate_values = model_results.apply(lambda row: row[[f'{model}_abs_error_rate' for model in modelnames]].min(), axis=1)
|
min_abs_error_rate_values = model_results.apply(lambda row: row[[f'{model}_abs_error_rate' for model in modelnames]].min(), axis=1)
|
||||||
# 获取每行对应的最小偏差率值对应的列名
|
# 获取每行对应的最小偏差率值对应的列名
|
||||||
min_abs_error_rate_column_name = model_results.apply(lambda row: row[[f'{model}_abs_error_rate' for model in modelnames]].idxmin(), axis=1)
|
min_abs_error_rate_column_name = model_results.apply(lambda row: row[[f'{model}_abs_error_rate' for model in modelnames]].idxmin(), axis=1)
|
||||||
# 将列名索引转换为列名
|
# 将列名索引转换为列名
|
||||||
min_abs_error_rate_column_name = min_abs_error_rate_column_name.map(lambda x: x.split('_')[0])
|
min_abs_error_rate_column_name = min_abs_error_rate_column_name.map(lambda x: x.split('_')[0])
|
||||||
# 取出现次数最多的模型名称
|
# 取出现次数最多的模型名称
|
||||||
most_common_model = min_abs_error_rate_column_name.value_counts().idxmax()
|
most_common_model = min_abs_error_rate_column_name.value_counts().idxmax()
|
||||||
logger.info(f"最近20天预测残差最低的模型名称:{most_common_model}")
|
logger.info(f"最近20天预测残差最低的模型名称:{most_common_model}")
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"最近20天预测残差最低的模型名称计算失败:{e}")
|
|
||||||
# 取txt中的模型名称
|
|
||||||
most_common_model = pd.read_csv(os.path.join(dataset,'best_modelnames.txt'),header=None).values.flatten().tolist()[0]
|
|
||||||
|
|
||||||
# 保存结果到数据库
|
# 保存结果到数据库
|
||||||
|
|
||||||
@ -148,7 +143,7 @@ def predict_main():
|
|||||||
# # 模型评估
|
# # 模型评估
|
||||||
|
|
||||||
logger.info('训练数据绘图ing')
|
logger.info('训练数据绘图ing')
|
||||||
model_results3 = model_losss_juxiting(sqlitedb)
|
model_results3 = model_losss(sqlitedb)
|
||||||
|
|
||||||
logger.info('训练数据绘图end')
|
logger.info('训练数据绘图end')
|
||||||
# 模型报告
|
# 模型报告
|
||||||
@ -183,7 +178,7 @@ def predict_main():
|
|||||||
file=max(glob.glob(os.path.join(dataset,'*.pdf')), key=os.path.getctime),
|
file=max(glob.glob(os.path.join(dataset,'*.pdf')), key=os.path.getctime),
|
||||||
ssl=ssl,
|
ssl=ssl,
|
||||||
)
|
)
|
||||||
m.send_mail()
|
# m.send_mail()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -11,4 +11,5 @@ while True:
|
|||||||
predict_main()
|
predict_main()
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
except:
|
except:
|
||||||
pass
|
time.sleep(3600)
|
||||||
|
predict_main()
|
Loading…
Reference in New Issue
Block a user