设置原油配置,判断周一的时候发送预警信息

This commit is contained in:
workpc 2024-11-18 16:55:14 +08:00
parent 9b7f64535f
commit 280bbab349
6 changed files with 199 additions and 8 deletions

185
Untitled.ipynb Normal file
View File

@ -0,0 +1,185 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"id": "9048d286-415f-4a33-be3a-9d7099aa85de",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from config_jingbo import *"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "07e338e7-1dd1-417f-b4e2-65d0efc983d6",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(os.path.join(dataset,'last_update_times.csv'))\n",
"df = df.sort_values(by=['warning_date'], ascending=[False])"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "659eec10-f0b8-4d65-b70e-6f07f45291bc",
"metadata": {},
"outputs": [],
"source": [
"y_last_update_time = df[df['feature']=='y']['warning_date'].values[0]\n"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "31035e6f-36e8-4b17-a14b-f7dd79ae085a",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>last_update_time</th>\n",
" <th>feature</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>500</th>\n",
" <td>2024-11-14</td>\n",
" <td>lmcads03 lme comdty</td>\n",
" </tr>\n",
" <tr>\n",
" <th>251</th>\n",
" <td>2024-11-14</td>\n",
" <td>美国MEH轻原油现货价格美湾</td>\n",
" </tr>\n",
" <tr>\n",
" <th>231</th>\n",
" <td>2024-11-14</td>\n",
" <td>WTI原油Cushing-C1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>264</th>\n",
" <td>2024-11-14</td>\n",
" <td>LLS原油现货价格</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>2024-11-14</td>\n",
" <td>OMAN原油中质远期现货DES价山东</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>2023-01-03</td>\n",
" <td>PVM Dubai EFS/Swap vs ICE First Month Brent</td>\n",
" </tr>\n",
" <tr>\n",
" <th>91</th>\n",
" <td>2022-11-16</td>\n",
" <td>Brent/迪拜原油升贴水</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
" <td>2022-01-31</td>\n",
" <td>W-B活跃合约价差</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>2022-01-31</td>\n",
" <td>B-W活跃合约价差</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>2018-10-24</td>\n",
" <td>西北欧即期Brent 211利润</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>73 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" last_update_time feature\n",
"500 2024-11-14 lmcads03 lme comdty\n",
"251 2024-11-14 美国MEH轻原油现货价格美湾\n",
"231 2024-11-14 WTI原油Cushing-C1\n",
"264 2024-11-14 LLS原油现货价格\n",
"82 2024-11-14 OMAN原油中质远期现货DES价山东\n",
".. ... ...\n",
"83 2023-01-03 PVM Dubai EFS/Swap vs ICE First Month Brent\n",
"91 2022-11-16 Brent/迪拜原油升贴水\n",
"94 2022-01-31 W-B活跃合约价差\n",
"95 2022-01-31 B-W活跃合约价差\n",
"31 2018-10-24 西北欧即期Brent 211利润\n",
"\n",
"[73 rows x 2 columns]"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[df['warning_date']<y_last_update_time][['last_update_time','feature']]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "937a9adb-1652-4d6b-a5c7-828d7c17769d",
"metadata": {},
"outputs": [],
"source": [
"df2 = pd.read_csv(os.path.join(dataset,''))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -175,7 +175,7 @@ warning_data = {
# is_edbnamelist = False # 自定义特征对应上面的edbnamelist
# is_update_eta = True # 预测结果上传到eta
# is_update_report = True # 是否上传报告
# is_update_warning_data = False # 是否上传预警数据
# is_update_warning_data = True if datetime.datetime.now().weekday() == 1 else False # 是否上传预警数据
### 开关
@ -188,7 +188,7 @@ is_edbcode = False # 特征使用edbcoding列表中的
is_edbnamelist = False # 自定义特征对应上面的edbnamelist
is_update_eta = False # 预测结果上传到eta
is_update_report = False # 是否上传报告
is_update_warning_data = True # 是否上传预警数据
is_update_warning_data = False # 是否上传预警数据
# 数据截取日期
end_time = '' # 数据截取日期

Binary file not shown.

Binary file not shown.

View File

@ -504,21 +504,27 @@ def datachuli(df_zhibiaoshuju,df_zhibiaoliebiao,datecol='date',end_time='',y='y'
logger.info('特征停更信息保存到文件last_update_times.csv')
logger.info(f'删除预警的特征前数据量:{df.shape}')
y_last_update_time = last_update_times['y']
y_last_update_time = last_update_times_df[last_update_times_df['feature']=='y']['warning_date'].values[0]
columns_to_drop = last_update_times_df[last_update_times_df['warning_date'] < y_last_update_time ]['feature'].values.tolist()
df = df.drop(columns = columns_to_drop)
logger.info(f'删除预警的特征后数据量:{df.shape}')
if is_update_warning_data:
logger.info(f'上传预警信息')
try:
warning_data_df = last_update_times_df[last_update_times_df['feature'].isin(columns_to_drop)][['last_update_time','feature']]
warning_data_df.sort_values(by='last_update_time',ascending=False,inplace=True)
warning_data_df = last_update_times_df[last_update_times_df['warning_date']<y_last_update_time][['last_update_time','feature']]
if len(warning_data_df) > 0:
content = '原油特征指标预警信息:\n\n'
warning_data_df = warning_data_df.sort_values(by='last_update_time',ascending=False)
for ds, df in warning_data_df.groupby('last_update_time'):
content += f'{ds} \n {df["feature"].to_string(index=False).replace(" ", "")}\n\n'
else:
logger.info(f'没有需要上传的预警信息')
content = '没有需要维护的特征指标'
warning_data['data']['WARNING_DATE'] = y_last_update_time
warning_data['data']['WARNING_CONTENT'] = warning_data_df.to_string(index=False)
warning_data['data']['WARNING_CONTENT'] = content
token = get_head_auth_report()
upload_warning_data(token, warning_data)
logger.info(f'上传预警信息成功')