更改埃森哲代码

This commit is contained in:
workpc 2025-01-23 15:07:59 +08:00
parent d1c77ea39c
commit 76fb3c8b51
12 changed files with 944 additions and 375 deletions

Binary file not shown.

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 25,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -34,7 +34,7 @@
"}\n", "}\n",
"\n", "\n",
"\n", "\n",
"read_file_path_name = \"定性模型数据项12-11.xls\"\n", "read_file_path_name = \"定性模型数据项12-11.xlsx\"\n",
"one_cols = []\n", "one_cols = []\n",
"two_cols = []\n", "two_cols = []\n",
"\n", "\n",
@ -51,32 +51,34 @@
" :param threshold: 变化阈值\n", " :param threshold: 变化阈值\n",
" \"\"\"\n", " \"\"\"\n",
" # 读取Excel文件\n", " # 读取Excel文件\n",
" try:\n", " # try:\n",
" df = pd.read_excel(file_path, engine='openpyxl')\n", " # df = pd.read_excel(file_path, engine='openpyxl')\n",
" except:\n", " # except:\n",
" df = pd.read_excel(file_path, engine='xlrd')\n", " # df = pd.read_excel(file_path, engine='xlrd')\n",
" \n",
" df = pd.read_excel(file_path)\n",
" # 所有列列统一数据格式为float\n", " # 所有列列统一数据格式为float\n",
" df = df.applymap(lambda x: float(x) if isinstance(x, (int, float)) else x)\n", " df = df.applymap(lambda x: float(x) if isinstance(x, (int, float)) else x)\n",
" \n", " \n",
" print(df.tail())\n", " # print(df.tail())\n",
" # 填充缺失值\n", " # 填充缺失值\n",
" df = df.fillna(method='ffill')\n", " df = df.fillna(method='ffill')\n",
"\n", "\n",
" # 获取最后两行数据\n", " # 获取最后两行数据\n",
" df1 = df.tail(2)\n", " df1 = df.tail(2)\n",
" print(df1)\n", " # print(df1)\n",
" # 获取前一天的指定列值\n", " # 获取前一天的指定列值\n",
" previous_value = df1.iloc[0, column_index]\n", " previous_value = df1.iloc[0, column_index]\n",
" print(previous_value,type(previous_value))\n", " print('前一天的',previous_value,type(previous_value))\n",
" # 获取当前的指定列值\n", " # 获取当前的指定列值\n",
" current_value = df1.iloc[1, column_index]\n", " current_value = df1.iloc[1, column_index]\n",
" print(current_value,type(current_value))\n", " print('现在的',current_value,type(current_value))\n",
" # 判断指定列值的变化是否大于阈值\n", " # 判断指定列值的变化是否大于阈值\n",
" if abs(current_value - previous_value) > threshold:\n", " if abs(current_value - previous_value) > threshold:\n",
" # 如果变化大于阈值,将当前的指定列值改为前一天的值\n", " # 如果变化大于阈值,将当前的指定列值改为前一天的值\n",
" df.iloc[-1, column_index] = previous_value\n", " df.iloc[-1, column_index] = previous_value\n",
" print('修改了')\n", " print('修改了')\n",
" print(df.tail())\n", " # print(df.tail())\n",
" # 将修改后的数据写回Excel文件\n", " # 将修改后的数据写回Excel文件\n",
" df.to_excel(file_path, index=False,engine='openpyxl')\n", " df.to_excel(file_path, index=False,engine='openpyxl')\n",
"\n", "\n",
@ -90,7 +92,7 @@
" token = None\n", " token = None\n",
" return token\n", " return token\n",
"\n", "\n",
"def updateExcelData(date='',token=None):\n", "def updateExcelDatabak(date='',token=None):\n",
" workbook = xlrd.open_workbook(read_file_path_name)\n", " workbook = xlrd.open_workbook(read_file_path_name)\n",
"\n", "\n",
" # 选择第一个表格\n", " # 选择第一个表格\n",
@ -134,7 +136,7 @@
" else:\n", " else:\n",
" append_rows.append(\"\")\n", " append_rows.append(\"\")\n",
"\n", "\n",
" workbook = xlrd.open_workbook('定性模型数据项12-11.xls')\n", " workbook = xlrd.open_workbook('定性模型数据项12-11.xlsx')\n",
"\n", "\n",
" # 获取所有sheet的个数\n", " # 获取所有sheet的个数\n",
" sheet_count = len(workbook.sheet_names())\n", " sheet_count = len(workbook.sheet_names())\n",
@ -173,10 +175,125 @@
" new_sheet.write(row_count, col, append_rows[col])\n", " new_sheet.write(row_count, col, append_rows[col])\n",
"\n", "\n",
" # 保存新的xls文件\n", " # 保存新的xls文件\n",
" new_workbook.save(\"定性模型数据项12-11.xls\")\n", " new_workbook.save(\"定性模型数据项12-11.xlsx\")\n",
"\n",
"def updateYesterdayExcelData(date='', token=None):\n",
" # 使用pandas读取Excel文件\n",
" df = pd.read_excel(read_file_path_name, engine='openpyxl')\n",
"\n",
" # 获取第二行的数据作为列名\n",
" one_cols = df.iloc[0,:].tolist()\n",
"\n",
" # 获取当前日期的前一天\n",
" if date == '':\n",
" previous_date = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')\n",
" else:\n",
" # 字符串转日期\n",
" previous_date = (datetime.strptime(date, \"%Y-%m-%d\")-timedelta(days=1)).strftime('%Y-%m-%d')\n",
" \n",
"\n",
" cur_time, cur_time2 = getNow(previous_date)\n",
" search_data = {\n",
" \"data\": {\n",
" \"date\": cur_time,\n",
" \"dataItemNoList\": one_cols[1:]\n",
" },\n",
" \"funcModule\": \"数据项\",\n",
" \"funcOperation\": \"查询\"\n",
" }\n",
" headers = {\"Authorization\": token}\n",
" search_res = requests.post(url=search_url, headers=headers, json=search_data, timeout=(3, 5))\n",
" search_value = json.loads(search_res.text)[\"data\"]\n",
" if search_value:\n",
" datas = search_value\n",
" else:\n",
" datas = None\n",
"\n",
" append_rows = [cur_time2]\n",
" dataItemNo_dataValue = {}\n",
" for data_value in datas:\n",
" if \"dataValue\" not in data_value:\n",
" print(data_value)\n",
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
" else:\n",
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
" for value in one_cols[1:]:\n",
" if value in dataItemNo_dataValue:\n",
" append_rows.append(dataItemNo_dataValue[value])\n",
" else:\n",
" append_rows.append(\"\")\n",
"\n",
" print('更新数据前')\n",
" print(df.tail(1))\n",
" # 检查日期是否已存在于数据中\n",
" if previous_date not in df['日期'].values:\n",
" # 将新的数据添加到DataFrame中\n",
" new_row = pd.DataFrame([append_rows], columns=df.columns.tolist())\n",
" df = pd.concat([df, new_row], ignore_index=True)\n",
" else:\n",
" # 更新现有数据\n",
" print('日期存在,即将更新')\n",
" print('新数据',append_rows[1:])\n",
" df.loc[df['日期'] == previous_date, df.columns.tolist()[1:]] = append_rows[1:]\n",
"\n",
" print('更新数据后')\n",
" print(df.tail(1))\n",
" # 使用pandas保存Excel文件\n",
" df.to_excel(\"定性模型数据项12-11.xlsx\", index=False, engine='openpyxl')\n",
"\n",
"\n",
"def updateExcelData(date='', token=None):\n",
" # 使用pandas读取Excel文件\n",
" df = pd.read_excel(read_file_path_name, engine='openpyxl')\n",
"\n",
" # 获取第一行的数据作为列名\n",
" # one_cols = df.columns.tolist()\n",
" \n",
" # 获取第二行的数据作为列名\n",
" one_cols = df.iloc[0,:].tolist()\n",
"\n",
" cur_time, cur_time2 = getNow(date)\n",
" search_data = {\n",
" \"data\": {\n",
" \"date\": cur_time,\n",
" \"dataItemNoList\": one_cols[1:]\n",
" },\n",
" \"funcModule\": \"数据项\",\n",
" \"funcOperation\": \"查询\"\n",
" }\n",
" headers = {\"Authorization\": token}\n",
" search_res = requests.post(url=search_url, headers=headers, json=search_data, timeout=(3, 5))\n",
" search_value = json.loads(search_res.text)[\"data\"]\n",
" if search_value:\n",
" datas = search_value\n",
" else:\n",
" datas = None\n",
"\n",
" append_rows = [cur_time2]\n",
" dataItemNo_dataValue = {}\n",
" for data_value in datas:\n",
" if \"dataValue\" not in data_value:\n",
" print(data_value)\n",
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
" else:\n",
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
" for value in one_cols[1:]:\n",
" if value in dataItemNo_dataValue:\n",
" append_rows.append(dataItemNo_dataValue[value])\n",
" else:\n",
" append_rows.append(\"\")\n",
"\n",
" # 将新的数据添加到DataFrame中\n",
" new_row = pd.DataFrame([append_rows], columns=df.columns.tolist())\n",
" df = pd.concat([df, new_row], ignore_index=True)\n",
" # df = df.append(pd.Series(append_rows), ignore_index=True)\n",
"\n",
" # 使用pandas保存Excel文件\n",
" df.to_excel(\"定性模型数据项12-11.xlsx\", index=False, engine='openpyxl')\n",
"\n",
"\n", "\n",
"def qualitativeModel():\n", "def qualitativeModel():\n",
" df = pd.read_excel('定性模型数据项12-11.xls')\n", " df = pd.read_excel('定性模型数据项12-11.xlsx')\n",
"\n", "\n",
" df=df.fillna(df.ffill())\n", " df=df.fillna(df.ffill())\n",
" df1 = df[-2:].reset_index()\n", " df1 = df[-2:].reset_index()\n",
@ -185,21 +302,31 @@
" 2025年1月8日 修改:\n", " 2025年1月8日 修改:\n",
" 复盘分析后发现2024-7月开始开工率数据从0.28 变为了28 ,改为下面的判断规则\n", " 复盘分析后发现2024-7月开始开工率数据从0.28 变为了28 ,改为下面的判断规则\n",
" '''\n", " '''\n",
" if df1.loc[1,'70号沥青开工率'] > 30:\n", " if df1.loc[1,'70号沥青开工率'] / 100 > 0.3:\n",
" a = (df1.loc[1,'70号沥青开工率']-0.2)*5/0.1\n", " a = (df1.loc[1,'70号沥青开工率'] / 100 -0.2)*5/0.1\n",
" else :\n", " else :\n",
" a = 0\n", " a = 0\n",
" b = df1.loc[1,'资金因素']\n", " b = df1.loc[1,'资金因素']\n",
" \n",
" print('昨日计划提货偏差改之前',df1.loc[1,'昨日计划提货偏差'])\n",
" # 昨日计划提货偏差 = 京博产量 - 计划产量\n",
" df1.loc[1,'昨日计划提货偏差'] = df1.loc[1,'京博产量'] - df1.loc[1,'计划产量']\n",
" \n",
" print('昨日计划提货偏差改之后',df1.loc[1,'昨日计划提货偏差'])\n",
" if df1.loc[1,'昨日计划提货偏差']>0:\n", " if df1.loc[1,'昨日计划提货偏差']>0:\n",
" c = df1.loc[1,'昨日计划提货偏差']*10/2000\n", " c = df1.loc[1,'昨日计划提货偏差']*10/2000\n",
" else :\n", " else :\n",
" c = df1.loc[1,'昨日计划提货偏差']*10/3000\n", " c = df1.loc[1,'昨日计划提货偏差']*10/3000\n",
" d = df1.loc[1,'生产情况']\n", " \n",
" # 生产情况 = (京博产量 - 计划产量)/500*5\n",
" d = (df1.loc[1,'京博产量'] - df1.loc[1,'计划产量']) / 500 * 5\n",
" \n",
" if df1.loc[1,'基质沥青库存']/265007 >0.8:\n", " if df1.loc[1,'基质沥青库存']/265007 >0.8:\n",
" e = (df1.loc[1,'基质沥青库存'] - df1.loc[0,'基质沥青库存'])*10/-5000\n", " e = (df1.loc[1,'基质沥青库存'] - df1.loc[0,'基质沥青库存'])*10/-5000\n",
" else : \n", " else : \n",
" e = 0\n", " e = 0\n",
" f = df1.loc[1,'下游客户价格预期']\n", "# f = df1.loc[1,'下游客户价格预期']\n",
" f = 1 # 2025年1月23日修改价格预期都按1计算\n",
" if abs(df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])>=100:\n", " if abs(df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])>=100:\n",
" g = (df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])*50/100\n", " g = (df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])*50/100\n",
" else :\n", " else :\n",
@ -213,7 +340,10 @@
" if date == '':\n", " if date == '':\n",
" now = datetime.now() - timedelta(days=offset)\n", " now = datetime.now() - timedelta(days=offset)\n",
" else:\n", " else:\n",
" date = datetime.strptime(date, \"%Y-%m-%d\")\n", " try:\n",
" date = datetime.strptime(date, \"%Y-%m-%d\")\n",
" except:\n",
" date = datetime.strptime(date, \"%Y%m%d\")\n",
" now = date\n", " now = date\n",
"\n", "\n",
" year = now.year\n", " year = now.year\n",
@ -293,7 +423,7 @@
" else:\n", " else:\n",
" append_rows.append(\"\")\n", " append_rows.append(\"\")\n",
"\n", "\n",
" workbook = xlrd.open_workbook('定性模型数据项12-11.xls')\n", " workbook = xlrd.open_workbook('定性模型数据项12-11.xlsx')\n",
"\n", "\n",
" # 获取所有sheet的个数\n", " # 获取所有sheet的个数\n",
" sheet_count = len(workbook.sheet_names())\n", " sheet_count = len(workbook.sheet_names())\n",
@ -332,11 +462,11 @@
" new_sheet.write(row_count, col, append_rows[col])\n", " new_sheet.write(row_count, col, append_rows[col])\n",
"\n", "\n",
" # 保存新的xls文件\n", " # 保存新的xls文件\n",
" new_workbook.save(\"定性模型数据项12-11.xls\")\n", " new_workbook.save(\"定性模型数据项12-11.xlsx\")\n",
"\n", "\n",
" update_e_value('定性模型数据项12-11.xls', 8, 1000)\n", " update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
"\n", "\n",
" df = pd.read_excel('定性模型数据项12-11.xls')\n", " df = pd.read_excel('定性模型数据项12-11.xlsx')\n",
"\n", "\n",
" df=df.fillna(df.ffill())\n", " df=df.fillna(df.ffill())\n",
" df1 = df[-2:].reset_index()\n", " df1 = df[-2:].reset_index()\n",
@ -359,7 +489,8 @@
" e = (df1.loc[1,'基质沥青库存'] - df1.loc[0,'基质沥青库存'])*10/-5000\n", " e = (df1.loc[1,'基质沥青库存'] - df1.loc[0,'基质沥青库存'])*10/-5000\n",
" else : \n", " else : \n",
" e = 0\n", " e = 0\n",
" f = df1.loc[1,'下游客户价格预期']\n", "# f = df1.loc[1,'下游客户价格预期']\n",
" f = 1 # 2025年1月23日修改价格预期都按1计算\n",
" if abs(df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])>=100:\n", " if abs(df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])>=100:\n",
" g = (df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])*50/100\n", " g = (df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])*50/100\n",
" else :\n", " else :\n",
@ -459,7 +590,7 @@
" else:\n", " else:\n",
" append_rows.append(\"\")\n", " append_rows.append(\"\")\n",
"\n", "\n",
" workbook = xlrd.open_workbook('定性模型数据项12-11.xls')\n", " workbook = xlrd.open_workbook('定性模型数据项12-11.xlsx')\n",
"\n", "\n",
" # 获取所有sheet的个数\n", " # 获取所有sheet的个数\n",
" sheet_count = len(workbook.sheet_names())\n", " sheet_count = len(workbook.sheet_names())\n",
@ -497,11 +628,11 @@
" new_sheet.write(row_count, col, append_rows[col])\n", " new_sheet.write(row_count, col, append_rows[col])\n",
"\n", "\n",
" # 保存新的xls文件\n", " # 保存新的xls文件\n",
" new_workbook.save(\"定性模型数据项12-11.xls\")\n", " new_workbook.save(\"定性模型数据项12-11.xlsx\")\n",
" \n", " \n",
" update_e_value('定性模型数据项12-11.xls', 8, 1000)\n", " update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
"\n", "\n",
" df = pd.read_excel('定性模型数据项12-11.xls')\n", " df = pd.read_excel('定性模型数据项12-11.xlsx')\n",
" df=df.fillna(df.ffill())\n", " df=df.fillna(df.ffill())\n",
" df1 = df[-2:].reset_index()\n", " df1 = df[-2:].reset_index()\n",
" # if df1.loc[1,'70号沥青开工率'] > 0.3: -- 2025年1月9日 发版更改\n", " # if df1.loc[1,'70号沥青开工率'] > 0.3: -- 2025年1月9日 发版更改\n",
@ -519,38 +650,204 @@
" e = (df1.loc[1,'基质沥青库存'] - df1.loc[0,'基质沥青库存'])*10/-5000\n", " e = (df1.loc[1,'基质沥青库存'] - df1.loc[0,'基质沥青库存'])*10/-5000\n",
" else : \n", " else : \n",
" e = 0\n", " e = 0\n",
" f = df1.loc[1,'下游客户价格预期']\n", "# f = df1.loc[1,'下游客户价格预期']\n",
" f = 1 # 2025年1月23日修改价格预期都按1计算\n",
" if abs(df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])>=100:\n", " if abs(df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])>=100:\n",
" g = (df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])*50/100\n", " g = (df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])*50/100\n",
" else :\n", " else :\n",
" g = 0\n", " g = 0\n",
" h = df1.loc[1,'订单结构']\n", " h = df1.loc[1,'订单结构']\n",
" x = round(0.08*a+0*b+0.15*c+0.08*d +0.03*e +0.08*f +0.4*g+0.18*h+df1.loc[0,'京博指导价'],2)\n", " x = round(0.08*a+0*b+0.15*c+0.08*d +0.03*e +0.08*f +0.4*g+0.18*h+df1.loc[0,'京博指导价'],2)\n",
" \n",
"\n",
" # login_res1 = requests.post(url=login_url, json=login_data, timeout=(3, 30))\n",
" # text1 = json.loads(login_res1.text)\n",
" # token_push = text1[\"data\"][\"accessToken\"]\n",
"\n", "\n",
"\n", "\n",
" login_res1 = requests.post(url=login_url, json=login_data, timeout=(3, 30))\n", " # data1 = {\n",
" text1 = json.loads(login_res1.text)\n", " # \"funcModule\": \"数据表信息列表\",\n",
" token_push = text1[\"data\"][\"accessToken\"]\n", " # \"funcOperation\": \"新增\",\n",
" # \"data\": [\n",
" # {\"dataItemNo\": \"C01100036|Forecast_Price|DX|ACN\",\n",
" # \"dataDate\": cur_time,\n",
" # \"dataStatus\": \"add\",\n",
" # \"dataValue\": x\n",
" # }\n",
"\n",
" # ]\n",
" # }\n",
" # headers1 = {\"Authorization\": token_push}\n",
" # res = requests.post(url=upload_url, headers=headers1, json=data1, timeout=(3, 5))\n",
" \n",
" \n",
"\n", "\n",
"\n", "\n",
" data1 = {\n", "def start_test():\n",
" \"funcModule\": \"数据表信息列表\",\n", " workbook = xlrd.open_workbook(read_file_path_name)\n",
" \"funcOperation\": \"新增\",\n",
" \"data\": [\n",
" {\"dataItemNo\": \"C01100036|Forecast_Price|DX|ACN\",\n",
" \"dataDate\": cur_time,\n",
" \"dataStatus\": \"add\",\n",
" \"dataValue\": x\n",
" }\n",
"\n", "\n",
" ]\n", "\n",
"\n",
" # 选择第一个表格\n",
" sheet = workbook.sheet_by_index(0)\n",
"\n",
" # 获取行数和列数\n",
" num_rows = sheet.nrows\n",
"\n",
"\n",
"\n",
" row_data = sheet.row_values(1)\n",
" one_cols = row_data\n",
"\n",
"\n",
" login_res = requests.post(url=login_url, json=login_data, timeout=(3, 5))\n",
" text = json.loads(login_res.text)\n",
" if text[\"status\"]:\n",
" token = text[\"data\"][\"accessToken\"]\n",
" else:\n",
" print(\"获取认证失败\")\n",
" token = None\n",
"\n",
"\n",
" now = datetime.now()\n",
" year = now.year\n",
" month = now.month\n",
" day = now.day\n",
"\n",
" if month < 10:\n",
" month = \"0\" + str(month)\n",
" if day < 10:\n",
" day = \"0\" + str(day)\n",
" cur_time = str(year) + str(month) + str(day)\n",
" cur_time2 = str(year) + \"-\" + str(month) + \"-\" + str(day)\n",
" search_data = {\n",
" \"data\": {\n",
" \"date\": cur_time,\n",
" \"dataItemNoList\": one_cols[1:]\n",
" },\n",
" \"funcModule\": \"数据项\",\n",
" \"funcOperation\": \"查询\"\n",
" }\n", " }\n",
" headers1 = {\"Authorization\": token_push}\n", " headers = {\"Authorization\": token}\n",
" res = requests.post(url=upload_url, headers=headers1, json=data1, timeout=(3, 5))\n", " search_res = requests.post(url=search_url, headers=headers, json=search_data, timeout=(3, 5))\n",
" search_value = json.loads(search_res.text)[\"data\"]\n",
"# datas = search_value\n",
" if search_value:\n",
" datas = search_value\n",
" else :\n",
" datas = None\n",
" \n",
"\n",
" append_rows = [cur_time2]\n",
" dataItemNo_dataValue = {}\n",
"# for data_value in datas:\n",
"# dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
" for data_value in datas:\n",
" if \"dataValue\" not in data_value:\n",
" print(data_value)\n",
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
" else:\n",
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
" for value in one_cols[1:]:\n",
" if value in dataItemNo_dataValue:\n",
" append_rows.append(dataItemNo_dataValue[value])\n",
" else:\n",
" append_rows.append(\"\")\n",
"\n",
" workbook = xlrd.open_workbook('定性模型数据项12-11.xlsx')\n",
"\n",
" # 获取所有sheet的个数\n",
" sheet_count = len(workbook.sheet_names())\n",
"\n",
" # 获取所有sheet的名称\n",
" sheet_names = workbook.sheet_names()\n",
"\n",
" new_workbook = xlwt.Workbook()\n",
" for i in range(sheet_count):\n",
" # 获取当前sheet\n",
" sheet = workbook.sheet_by_index(i)\n",
"\n",
" # 获取sheet的行数和列数\n",
" row_count = sheet.nrows\n",
" col_count = sheet.ncols\n",
" # 获取原有数据\n",
" data = []\n",
" for row in range(row_count):\n",
" row_data = []\n",
" for col in range(col_count):\n",
" row_data.append(sheet.cell_value(row, col))\n",
" data.append(row_data)\n",
" # 创建xlwt的Workbook对象\n",
" # 创建sheet\n",
" new_sheet = new_workbook.add_sheet(sheet_names[i])\n",
"\n",
" # 将原有的数据写入新的sheet\n",
" for row in range(row_count):\n",
" for col in range(col_count):\n",
" new_sheet.write(row, col, data[row][col])\n",
"\n",
" if i == 0:\n",
" # 在新的sheet中添加数据\n",
" for col in range(col_count):\n",
" new_sheet.write(row_count, col, append_rows[col])\n",
"\n",
" # 保存新的xls文件\n",
" new_workbook.save(\"定性模型数据项12-11.xlsx\")\n",
" \n",
" update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
"\n",
" df = pd.read_excel('定性模型数据项12-11.xlsx')\n",
" df=df.fillna(df.ffill())\n",
" df1 = df[-2:].reset_index()\n",
" # if df1.loc[1,'70号沥青开工率'] > 0.3: -- 2025年1月9日 发版更改\n",
" if df1.loc[1,'70号沥青开工率'] / 100 > 0.3:\n",
" a = (df1.loc[1,'70号沥青开工率'] / 100 -0.2)*5/0.1\n",
" else :\n",
" a = 0\n",
" b = df1.loc[1,'资金因素']\n",
" if df1.loc[1,'昨日计划提货偏差']>0:\n",
" c = df1.loc[1,'昨日计划提货偏差']*10/2000\n",
" else :\n",
" c = df1.loc[1,'昨日计划提货偏差']*10/3000\n",
" d = df1.loc[1,'生产情况']\n",
" if df1.loc[1,'基质沥青库存']/265007 >0.8:\n",
" e = (df1.loc[1,'基质沥青库存'] - df1.loc[0,'基质沥青库存'])*10/-5000\n",
" else : \n",
" e = 0\n",
"# f = df1.loc[1,'下游客户价格预期']\n",
" f = 1 # 2025年1月23日修改价格预期都按1计算\n",
" if abs(df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])>=100:\n",
" g = (df1.loc[1,'即期成本'] - df1.loc[0,'即期成本'])*50/100\n",
" else :\n",
" g = 0\n",
" h = df1.loc[1,'订单结构']\n",
" x = round(0.08*a+0*b+0.15*c+0.08*d +0.03*e +0.08*f +0.4*g+0.18*h+df1.loc[0,'京博指导价'],2)\n",
" \n",
"\n",
" # login_res1 = requests.post(url=login_url, json=login_data, timeout=(3, 30))\n",
" # text1 = json.loads(login_res1.text)\n",
" # token_push = text1[\"data\"][\"accessToken\"]\n",
"\n",
"\n",
" # data1 = {\n",
" # \"funcModule\": \"数据表信息列表\",\n",
" # \"funcOperation\": \"新增\",\n",
" # \"data\": [\n",
" # {\"dataItemNo\": \"C01100036|Forecast_Price|DX|ACN\",\n",
" # \"dataDate\": cur_time,\n",
" # \"dataStatus\": \"add\",\n",
" # \"dataValue\": x\n",
" # }\n",
"\n",
" # ]\n",
" # }\n",
" # headers1 = {\"Authorization\": token_push}\n",
" # res = requests.post(url=upload_url, headers=headers1, json=data1, timeout=(3, 5))\n",
" \n", " \n",
" \n", " \n",
"\n", "\n",
"\n", "\n",
"\n",
"def start_1():\n", "def start_1():\n",
" workbook = xlrd.open_workbook(read_file_path_name)\n", " workbook = xlrd.open_workbook(read_file_path_name)\n",
"\n", "\n",
@ -623,7 +920,7 @@
" else:\n", " else:\n",
" append_rows.append(\"\")\n", " append_rows.append(\"\")\n",
"\n", "\n",
" workbook = xlrd.open_workbook('定性模型数据项12-11.xls')\n", " workbook = xlrd.open_workbook('定性模型数据项12-11.xlsx')\n",
"\n", "\n",
" # 获取所有sheet的个数\n", " # 获取所有sheet的个数\n",
" sheet_count = len(workbook.sheet_names())\n", " sheet_count = len(workbook.sheet_names())\n",
@ -661,7 +958,7 @@
" new_sheet.write(row_count, col, append_rows[col])\n", " new_sheet.write(row_count, col, append_rows[col])\n",
"\n", "\n",
" # 保存新的xls文件\n", " # 保存新的xls文件\n",
" new_workbook.save(\"定性模型数据项12-11.xls\")\n", " new_workbook.save(\"定性模型数据项12-11.xlsx\")\n",
"\n", "\n",
"\n", "\n",
"\n", "\n",
@ -670,10 +967,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 26,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"### 原始代码备份\n",
"\n",
"# if __name__ == \"__main__\":\n", "# if __name__ == \"__main__\":\n",
"\n", "\n",
" # 需要单独运行放开\n", " # 需要单独运行放开\n",
@ -701,32 +1000,142 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 27,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# 重新上传定性数据\n", "# if __name__ == \"__main__\":\n",
"# def main():\n",
"# # 获取当前日期\n",
"# date = datetime.now().date()\n",
"# date = date.strftime('%Y%m%d')\n",
"# # 获取登录token\n",
"# token = getLogToken()\n",
"# updateExcelData(date,token)\n",
"# update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
"# x = qualitativeModel()\n",
"# print('预测结果:',x)\n",
"# cur_time,cur_time2 = getNow(date)\n",
"# pushData(cur_time,x,token)\n",
"\n", "\n",
"from datetime import datetime, timedelta\n", "# print(\"运行中...\")\n",
"# # 每天定时12点运行\n",
"# while True:\n",
"# # 获取当前时间\n",
"# current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
"# try:\n",
"# # 判断当前时间是否为执行任务的时间点\n",
"# if current_time == \"12:00:00\":\n",
"# try:\n",
"# main()\n",
"# except Exception as e:\n",
"# print(f\"12点执行失败: {e}\")\n",
"# # 等待到12点30分再次执行\n",
"# while current_time != \"12:30:00\":\n",
"# current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
"# time.sleep(1)\n",
"# try:\n",
"# main()\n",
"# except Exception as e:\n",
"# print(f\"12点30分也执行失败: {e}\")\n",
"# elif current_time == \"20:00:00\":\n",
"# print(\"更新前一天数据\")\n",
"# token = getLogToken()\n",
"# updateYesterdayExcelData(token=token)\n",
" \n",
"# time.sleep(1)\n",
"# except Exception as e:\n",
"# print(f\"执行失败: {e}\")"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"# # 重新上传定性数据\n",
"\n", "\n",
"def main(date='',token=None):\n", "# def main(date='',token=None):\n",
" updateExcelData(date,token)\n", "# updateExcelData(date,token)\n",
" update_e_value('定性模型数据项12-11.xls', 8, 1000)\n", "# update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
" x = qualitativeModel()\n", "# x = qualitativeModel()\n",
" cur_time,cur_time2 = getNow(date)\n", "# print('**************************************************预测结果:',x)\n",
" pushData(cur_time,x,token)\n", "# cur_time,cur_time2 = getNow(date)\n",
"# pushData(cur_time,x,token)\n",
"\n", "\n",
"\n", "\n",
"start_date = datetime(2024, 7, 1)\n", "# start_date = datetime(2025, 1, 15)\n",
"end_date = datetime(2025, 1, 1)\n", "# end_date = datetime(2025, 1, 24)\n",
"token = getLogToken()\n", "# token = getLogToken()\n",
"while start_date < end_date:\n", "# while start_date < end_date:\n",
" print(start_date.strftime('%Y%m%d'))\n", "# print(start_date.strftime('%Y%m%d'))\n",
" main(start_date.strftime('%Y%m%d'),token)\n", "# main(start_date.strftime('%Y%m%d'),token)\n",
" start_date += timedelta(days=1)\n", "# start_date += timedelta(days=1)\n",
" time.sleep(1)\n", "# time.sleep(5)\n",
" \n" " \n"
] ]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"更新数据前\n",
" 日期 京博指导价 70号沥青开工率 资金因素 昨日计划提货偏差 生产情况 基质沥青库存 下游客户价格预期 即期成本 \\\n",
"1326 2025-01-23 3650 6 6 NaN NaN NaN 3650 3846.3643 \n",
"\n",
" 订单结构 计划产量 京博产量 \n",
"1326 1 4505.365 NaN \n",
"日期存在,即将更新\n",
"新数据 [3650.0, '', '', '', '', '', 3650.0, 3846.3643, 1.0, 4505.365, '']\n",
"更新数据后\n",
" 日期 京博指导价 70号沥青开工率 资金因素 昨日计划提货偏差 生产情况 基质沥青库存 下游客户价格预期 \\\n",
"1326 2025-01-23 3650.0 3650.0 \n",
"\n",
" 即期成本 订单结构 计划产量 京博产量 \n",
"1326 3846.3643 1.0 4505.365 \n",
"更新完了\n"
]
}
],
"source": [
"# 调试更新数据\n",
"date = '2025-01-24'\n",
"token = getLogToken()\n",
"updateYesterdayExcelData(date=date,token=token)\n",
"print('更新完了')"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"# # 快速调试线上\n",
"# def main():\n",
"# # 获取当前日期\n",
"# date = datetime.now().date()\n",
"# date = date.strftime('%Y%m%d')\n",
"# # 获取登录token\n",
"# token = getLogToken()\n",
"# updateExcelData(date,token)\n",
"# update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
"# x = qualitativeModel()\n",
"# print('预测结果:',x)\n",
"# cur_time,cur_time2 = getNow(date)\n",
"# pushData(cur_time,x,token)\n",
"\n",
"# current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
"# main()\n",
"# token = getLogToken()\n",
"# updateYesterdayExcelData(token=token)"
]
} }
], ],
"metadata": { "metadata": {

View File

@ -2,20 +2,30 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\statsmodels\\compat\\pandas.py:49: FutureWarning:\n",
"\n",
"The Panel class is removed from pandas. Accessing it from the top-level namespace will also be removed in the next version\n",
"\n"
]
},
{ {
"data": { "data": {
"text/html": [ "text/html": [
" <script type=\"text/javascript\">\n", " <script type=\"text/javascript\">\n",
" window.PlotlyConfig = {MathJaxConfig: 'local'};\n", " window.PlotlyConfig = {MathJaxConfig: 'local'};\n",
" if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}\n", " if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}\n",
" if (typeof require !== 'undefined') {\n", " if (typeof require !== 'undefined') {\n",
" require.undef(\"plotly\");\n", " require.undef(\"plotly\");\n",
" requirejs.config({\n", " requirejs.config({\n",
" paths: {\n", " paths: {\n",
" 'plotly': ['https://cdn.plot.ly/plotly-2.12.1.min']\n", " 'plotly': ['https://cdn.plot.ly/plotly-2.2.0.min']\n",
" }\n", " }\n",
" });\n", " });\n",
" require(['plotly'], function(Plotly) {\n", " require(['plotly'], function(Plotly) {\n",
@ -35,7 +45,7 @@
"import json\n", "import json\n",
"import xlrd\n", "import xlrd\n",
"import xlwt\n", "import xlwt\n",
"from datetime import datetime\n", "from datetime import datetime,timedelta\n",
"import time\n", "import time\n",
"# 变量定义\n", "# 变量定义\n",
"login_url = \"http://10.200.32.39/jingbo-api/api/server/login\"\n", "login_url = \"http://10.200.32.39/jingbo-api/api/server/login\"\n",
@ -95,7 +105,6 @@
"from sklearn.linear_model import Lasso\n", "from sklearn.linear_model import Lasso\n",
"from xgboost import XGBRegressor\n", "from xgboost import XGBRegressor\n",
"\n", "\n",
"import datetime\n",
"import statsmodels.api as sm\n", "import statsmodels.api as sm\n",
"try:\n", "try:\n",
" from keras.preprocessing.sequence import TimeseriesGenerator\n", " from keras.preprocessing.sequence import TimeseriesGenerator\n",
@ -150,7 +159,7 @@
"def get_data_value(token, dataItemNoList,date):\n", "def get_data_value(token, dataItemNoList,date):\n",
" search_data = {\n", " search_data = {\n",
" \"data\": {\n", " \"data\": {\n",
" \"date\": get_cur_time(date)[0],\n", " \"date\": date,\n",
" \"dataItemNoList\": dataItemNoList\n", " \"dataItemNoList\": dataItemNoList\n",
" },\n", " },\n",
" \"funcModule\": \"数据项\",\n", " \"funcModule\": \"数据项\",\n",
@ -158,8 +167,11 @@
" }\n", " }\n",
" headers = {\"Authorization\": token}\n", " headers = {\"Authorization\": token}\n",
" search_res = requests.post(url=search_url, headers=headers, json=search_data, timeout=(3, 5))\n", " search_res = requests.post(url=search_url, headers=headers, json=search_data, timeout=(3, 5))\n",
" print(search_data)\n",
" \n",
" try:\n", " try:\n",
" search_value = json.loads(search_res.text)[\"data\"]\n", " search_value = json.loads(search_res.text)[\"data\"]\n",
" print(search_value)\n",
" except json.JSONDecodeError as e:\n", " except json.JSONDecodeError as e:\n",
" print(f\"Error decoding JSON: {e}\")\n", " print(f\"Error decoding JSON: {e}\")\n",
" print(\"Response content:\", search_res.text)\n", " print(\"Response content:\", search_res.text)\n",
@ -196,8 +208,7 @@
"\n", "\n",
"def get_cur_time(date = ''):\n", "def get_cur_time(date = ''):\n",
" if date == '':\n", " if date == '':\n",
" import datetime\n", " now = datetime.now()\n",
" now = datetime.datetime.now()\n",
" else:\n", " else:\n",
" now = date\n", " now = date\n",
" year = now.year\n", " year = now.year\n",
@ -234,7 +245,7 @@
" \"funcOperation\": \"新增\",\n", " \"funcOperation\": \"新增\",\n",
" \"data\": [\n", " \"data\": [\n",
" {\"dataItemNo\": \"250855713|Forecast_Price|ACN\",\n", " {\"dataItemNo\": \"250855713|Forecast_Price|ACN\",\n",
" \"dataDate\": get_cur_time(date)[0],\n", " \"dataDate\": date,\n",
" \"dataStatus\": \"add\",\n", " \"dataStatus\": \"add\",\n",
" \"dataValue\": forecast_price()\n", " \"dataValue\": forecast_price()\n",
" }\n", " }\n",
@ -243,7 +254,7 @@
" }\n", " }\n",
" headers = {\"Authorization\": token_push}\n", " headers = {\"Authorization\": token_push}\n",
" res = requests.post(url=upload_url, headers=headers, json=data, timeout=(3, 5))\n", " res = requests.post(url=upload_url, headers=headers, json=data, timeout=(3, 5))\n",
" print(res.text)\n", " # print(res.text)\n",
"\n", "\n",
" \n", " \n",
"# def upload_data_to_system(token):\n", "# def upload_data_to_system(token):\n",
@ -263,7 +274,7 @@
"# res = requests.post(url=upload_url, headers=headers, json=data, timeout=(3, 5))\n", "# res = requests.post(url=upload_url, headers=headers, json=data, timeout=(3, 5))\n",
"# print(res.text)\n", "# print(res.text)\n",
"\n", "\n",
" \n", "price_list = []\n",
" \n", " \n",
"def forecast_price():\n", "def forecast_price():\n",
" # df_test = pd.read_csv('定价模型数据收集0212.csv')\n", " # df_test = pd.read_csv('定价模型数据收集0212.csv')\n",
@ -307,6 +318,7 @@
" a = a[0]\n", " a = a[0]\n",
" a = float(a)\n", " a = float(a)\n",
" a = round(a,2)\n", " a = round(a,2)\n",
" price_list.append(a)\n",
" return a\n", " return a\n",
"def optimize_Model():\n", "def optimize_Model():\n",
" from sklearn.model_selection import train_test_split\n", " from sklearn.model_selection import train_test_split\n",
@ -348,7 +360,6 @@
" from sklearn.linear_model import Lasso\n", " from sklearn.linear_model import Lasso\n",
" from xgboost import XGBRegressor\n", " from xgboost import XGBRegressor\n",
"\n", "\n",
" from datetime import datetime\n",
" import statsmodels.api as sm\n", " import statsmodels.api as sm\n",
" try:\n", " try:\n",
" from keras.preprocessing.sequence import TimeseriesGenerator\n", " from keras.preprocessing.sequence import TimeseriesGenerator\n",
@ -516,9 +527,7 @@
"\n", "\n",
"\n", "\n",
"\n", "\n",
"\n", "def start(date=''):\n",
"\n",
"def start(date):\n",
" read_xls_data()\n", " read_xls_data()\n",
"\n", "\n",
" token = get_head_auth()\n", " token = get_head_auth()\n",
@ -527,13 +536,13 @@
" token_push = get_head_push_auth()\n", " token_push = get_head_push_auth()\n",
" if not token_push:\n", " if not token_push:\n",
" return\n", " return\n",
"\n", " cur_time,cur_time2 = getNow(date)\n",
" datas = get_data_value(token, one_cols[1:],date)\n", " datas = get_data_value(token, one_cols[1:],cur_time)\n",
"# if not datas:\n", "# if not datas:\n",
"# return\n", "# return\n",
"\n", "\n",
" # data_list = [two_cols, one_cols]\n", " # data_list = [two_cols, one_cols]\n",
" append_rows = [get_cur_time(date)[1]]\n", " append_rows = [cur_time2]\n",
" dataItemNo_dataValue = {}\n", " dataItemNo_dataValue = {}\n",
" for data_value in datas:\n", " for data_value in datas:\n",
" if \"dataValue\" not in data_value:\n", " if \"dataValue\" not in data_value:\n",
@ -549,28 +558,50 @@
" append_rows.append(\"\")\n", " append_rows.append(\"\")\n",
" save_xls(append_rows)\n", " save_xls(append_rows)\n",
" optimize_Model()\n", " optimize_Model()\n",
" upload_data_to_system(token_push,date)\n", " upload_data_to_system(token_push,cur_time)\n",
" \n", " \n",
" \n", " \n",
" \n", " \n",
" # data_list.append(three_cols)\n", " # data_list.append(three_cols)\n",
" # write_xls(data_list)\n", " # write_xls(data_list)\n",
"\n", "\n",
"def getNow(date='',offset=0):\n",
" if date == '':\n",
" from datetime import datetime\n",
" now = datetime.now() - timedelta(days=offset)\n",
" else:\n",
" try:\n",
" date = datetime.strptime(date, \"%Y-%m-%d\")\n",
" except:\n",
" date = datetime.strptime(date, \"%Y%m%d\")\n",
" now = date\n",
"\n", "\n",
"def start_1():\n", " year = now.year\n",
" month = now.month\n",
" day = now.day\n",
"\n",
" if month < 10:\n",
" month = \"0\" + str(month)\n",
" if day < 10:\n",
" day = \"0\" + str(day)\n",
" cur_time = str(year) + str(month) + str(day)\n",
" cur_time2 = str(year) + \"-\" + str(month) + \"-\" + str(day)\n",
" return cur_time,cur_time2\n",
" \n",
"def start_1(date=''):\n",
" read_xls_data()\n", " read_xls_data()\n",
"\n", "\n",
" token = get_head_auth()\n", " token = get_head_auth()\n",
" if not token:\n", " if not token:\n",
" return\n", " return\n",
" \n", " \n",
"\n", " cur_time,cur_time2 = getNow(date)\n",
" datas = get_data_value(token, one_cols[1:])\n", " datas = get_data_value(token, one_cols[1:],date=cur_time)\n",
"# if not datas:\n", "# if not datas:\n",
"# return\n", "# return\n",
"\n", "\n",
" # data_list = [two_cols, one_cols]\n", " # data_list = [two_cols, one_cols]\n",
" append_rows = [get_cur_time()[1]]\n", " append_rows = [cur_time2]\n",
" dataItemNo_dataValue = {}\n", " dataItemNo_dataValue = {}\n",
" for data_value in datas:\n", " for data_value in datas:\n",
" if \"dataValue\" not in data_value:\n", " if \"dataValue\" not in data_value:\n",
@ -688,71 +719,89 @@
"\n", "\n",
" # 保存新的xls文件\n", " # 保存新的xls文件\n",
" new_workbook.save(\"液化气数据.xls\")\n", " new_workbook.save(\"液化气数据.xls\")\n",
"\n", "\n"
"\n",
"if __name__ == \"__main__\":\n",
" pass\n",
" # 需要单独运行放开\n",
"# start()\n",
"\n",
" # 每天定时12点运行\n",
" # while True:\n",
" # # 获取当前时间\n",
" # current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
" # current_time_1 = time.strftime(\"%H:%M:%S\", time.localtime())\n",
"\n",
" # # 判断当前时间是否为执行任务的时间点\n",
" # if current_time == \"09:15:00\":\n",
" # print(\"执行定时任务\")\n",
" # start()\n",
"\n",
" # # 休眠1秒钟避免过多占用CPU资源\n",
" # time.sleep(1)\n",
" \n",
" # elif current_time_1 == \"20:00:00\":\n",
" # print(\"更新数据\")\n",
" # start_1()\n",
" # time.sleep(1)\n",
"\n",
"\n",
"# # 检测数据准确性, 需要检测放开\n",
"# # check_data(\"100028098|LISTING_PRICE\")\n",
"# # check_data(\"9137070016544622XB|DAY_Yield\")\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"metadata": {}, "metadata": {
"scrolled": true
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"20241213\n", "运行中\n",
"{'dataDate': '20241213', 'dataItemNo': '91110000710932515R|C01100008|SUPPLY_MERE'}\n" "13:38:57\n",
] "13:38:58\n",
}, "13:38:59\n",
{ "13:39:00\n",
"name": "stderr", "13:39:01\n",
"output_type": "stream", "13:39:02\n",
"text": [ "13:39:03\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:291: UserWarning:\n", "13:39:04\n",
"\n", "13:39:05\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n", "13:39:06\n",
"\n", "13:39:07\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:293: UserWarning:\n", "13:39:08\n",
"\n", "13:39:09\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n", "13:39:10\n",
"\n" "13:39:11\n",
] "13:39:12\n",
}, "13:39:13\n",
{ "13:39:14\n",
"name": "stdout", "13:39:15\n",
"output_type": "stream", "13:39:16\n",
"text": [ "13:39:17\n",
"Using matplotlib backend: <object object at 0x0000016FC45DB050>\n", "13:39:18\n",
"%pylab is deprecated, use %matplotlib inline and import the required libraries.\n", "13:39:19\n",
"13:39:20\n",
"13:39:21\n",
"13:39:22\n",
"13:39:23\n",
"13:39:24\n",
"13:39:25\n",
"13:39:26\n",
"13:39:27\n",
"13:39:28\n",
"13:39:29\n",
"13:39:30\n",
"13:39:31\n",
"13:39:32\n",
"13:39:33\n",
"13:39:34\n",
"13:39:35\n",
"13:39:36\n",
"13:39:37\n",
"13:39:38\n",
"13:39:39\n",
"13:39:40\n",
"13:39:41\n",
"13:39:42\n",
"13:39:43\n",
"13:39:44\n",
"13:39:45\n",
"13:39:46\n",
"13:39:47\n",
"13:39:48\n",
"13:39:49\n",
"13:39:50\n",
"13:39:51\n",
"13:39:52\n",
"13:39:53\n",
"13:39:54\n",
"13:39:55\n",
"13:39:56\n",
"13:39:57\n",
"13:39:58\n",
"13:39:59\n",
"13:40:00\n",
"执行定时任务\n",
"{'data': {'date': '20250123', 'dataItemNoList': ['251926669|STRIKE_PRICE', 'C01100008|CORTED_VALUE', 'C01100008|AUCTION_MAX_PRICE', 'C01100008|YEDAY_AMOUNT', 'ICE_CL0_LAST_YEDAY_PRICE\\n', '100028046|LISTING_PRICE', 'C01100008|PLAN_SALE', '91370200163576944B|C01100008|STRIKE_PRICE', '9137078672073757X8|C01100008|STRIKE_PRICE', '91370500674526498A|C01100008|STRIKE_PRICE', '91370305773165341A|C01100008|STRIKE_PRICE', '91370521164880008P|C01100008|STRIKE_PRICE', '91370321164425136B|C01100008|STRIKE_PRICE', 'SD|GC|ZDW|LIST_PRICE', '370500|ISOBUTANE|LIST_PRICE', 'SD|YT|SG|LIST_PRICE', '91110000710926094P|C01100008|SUPPLY_MERE', '91110000710932515R|C01100008|SUPPLY_MERE', '91370500674526498A|C01100008|SUPPLY_MERE', '91370321164425136B|C01100008|SUPPLY_MERE', 'C01100008|OTHER|SUPPLY_MERE', 'SD|WJH|DEMANDS', 'C01100008|SUY_DED_DAP', 'C01100008|EFFECTIVE_STOCK', '912102117169477344|C01100008|STRIKE_PRICE', '91110304102767480H|C01100008|STRIKE_PRICE', '91130193670310403L|C01100008|STRIKE_PRICE', 'HD|LPG|IMPORT_PRICE', 'SD|WJH|SALES_PRICE']}, 'funcModule': '数据项', 'funcOperation': '查询'}\n",
"[{'dataDate': '20250123', 'dataItemNo': '251926669|STRIKE_PRICE', 'dataValue': 5400.0}, {'dataDate': '20250123', 'dataItemNo': '91370305773165341A|C01100008|STRIKE_PRICE', 'dataValue': 5500.0}, {'dataDate': '20250123', 'dataItemNo': '91370321164425136B|C01100008|STRIKE_PRICE', 'dataValue': 5430.0}, {'dataDate': '20250123', 'dataItemNo': '91370521164880008P|C01100008|STRIKE_PRICE', 'dataValue': 5535.0}]\n",
"Using matplotlib backend: Qt5Agg\n",
"Populating the interactive namespace from numpy and matplotlib\n", "Populating the interactive namespace from numpy and matplotlib\n",
"Fitting 3 folds for each of 180 candidates, totalling 540 fits\n" "Fitting 3 folds for each of 180 candidates, totalling 540 fits\n"
] ]
@ -761,18 +810,10 @@
"name": "stderr", "name": "stderr",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"d:\\ProgramData\\anaconda3\\Lib\\site-packages\\IPython\\core\\magics\\pylab.py:162: UserWarning:\n", "C:\\Users\\Administrator\\Anaconda3\\lib\\site-packages\\IPython\\core\\magics\\pylab.py:160: UserWarning:\n",
"\n", "\n",
"pylab import has clobbered these variables: ['plot', 'datetime', 'random', '__version__']\n", "pylab import has clobbered these variables: ['datetime', 'random', 'plot', '__version__']\n",
"`%matplotlib` prevents importing * from pylab and numpy\n", "`%matplotlib` prevents importing * from pylab and numpy\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:240: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:242: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n" "\n"
] ]
}, },
@ -781,232 +822,344 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Date\n", "Date\n",
"2024-12-13 5284.853516\n", "2025-01-23 5399.734863\n",
"Name: 日度预测价格, dtype: float32\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:274: FutureWarning:\n",
"\n",
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"confirmFlg\":false,\"status\":true}\n",
"20241214\n",
"{'dataDate': '20241214', 'dataItemNo': '91110000710932515R|C01100008|SUPPLY_MERE'}\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:291: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:293: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using matplotlib backend: QtAgg\n",
"%pylab is deprecated, use %matplotlib inline and import the required libraries.\n",
"Populating the interactive namespace from numpy and matplotlib\n",
"Fitting 3 folds for each of 180 candidates, totalling 540 fits\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:240: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:242: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Date\n",
"2024-12-14 5230.033691\n",
"Name: 日度预测价格, dtype: float32\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:274: FutureWarning:\n",
"\n",
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"confirmFlg\":false,\"status\":true}\n",
"20241215\n",
"{'dataDate': '20241215', 'dataItemNo': '91110000710932515R|C01100008|SUPPLY_MERE'}\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:291: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:293: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using matplotlib backend: QtAgg\n",
"%pylab is deprecated, use %matplotlib inline and import the required libraries.\n",
"Populating the interactive namespace from numpy and matplotlib\n",
"Fitting 3 folds for each of 180 candidates, totalling 540 fits\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:240: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:242: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Date\n",
"2024-12-15 5229.949707\n",
"Name: 日度预测价格, dtype: float32\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:274: FutureWarning:\n",
"\n",
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"confirmFlg\":false,\"status\":true}\n",
"20241216\n",
"{'dataDate': '20241216', 'dataItemNo': '91110000710932515R|C01100008|SUPPLY_MERE'}\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:291: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:293: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using matplotlib backend: QtAgg\n",
"%pylab is deprecated, use %matplotlib inline and import the required libraries.\n",
"Populating the interactive namespace from numpy and matplotlib\n",
"Fitting 3 folds for each of 180 candidates, totalling 540 fits\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:240: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:242: UserWarning:\n",
"\n",
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
"\n",
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_20960\\2946673419.py:274: FutureWarning:\n",
"\n",
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Date\n",
"2024-12-16 5240.49707\n",
"Name: 日度预测价格, dtype: float32\n", "Name: 日度预测价格, dtype: float32\n",
"{\"confirmFlg\":false,\"status\":true}\n" "13:40:46\n",
"13:40:47\n",
"13:40:48\n",
"13:40:49\n",
"13:40:50\n",
"13:40:51\n",
"13:40:52\n",
"13:40:53\n",
"13:40:54\n",
"13:40:55\n",
"13:40:56\n",
"13:40:57\n",
"13:40:58\n",
"13:40:59\n",
"13:41:00\n",
"13:41:01\n",
"13:41:02\n",
"13:41:03\n",
"13:41:04\n",
"13:41:05\n",
"13:41:06\n",
"13:41:07\n",
"13:41:08\n",
"13:41:09\n",
"13:41:10\n",
"13:41:11\n",
"13:41:12\n",
"13:41:13\n",
"13:41:14\n",
"13:41:15\n",
"13:41:16\n",
"13:41:17\n",
"13:41:18\n",
"13:41:19\n",
"13:41:20\n",
"13:41:21\n",
"13:41:22\n",
"13:41:23\n",
"13:41:24\n",
"13:41:25\n",
"13:41:26\n",
"13:41:27\n",
"13:41:28\n",
"13:41:29\n",
"13:41:30\n",
"13:41:31\n",
"13:41:32\n",
"13:41:33\n",
"13:41:34\n",
"13:41:35\n",
"13:41:36\n",
"13:41:37\n",
"13:41:38\n",
"13:41:39\n",
"13:41:40\n",
"13:41:41\n",
"13:41:42\n",
"13:41:43\n",
"13:41:44\n",
"13:41:45\n",
"13:41:46\n",
"13:41:47\n",
"13:41:48\n",
"13:41:49\n",
"13:41:50\n",
"13:41:51\n",
"13:41:52\n",
"13:41:53\n",
"13:41:54\n",
"13:41:55\n",
"13:41:56\n",
"13:41:57\n",
"13:41:58\n",
"13:41:59\n",
"13:42:00\n",
"13:42:01\n",
"13:42:02\n",
"13:42:03\n",
"13:42:04\n",
"13:42:05\n",
"13:42:06\n",
"13:42:07\n",
"13:42:08\n",
"13:42:09\n",
"13:42:10\n",
"13:42:11\n",
"13:42:12\n",
"13:42:13\n",
"13:42:14\n",
"13:42:15\n",
"13:42:16\n",
"13:42:17\n",
"13:42:18\n",
"13:42:19\n",
"13:42:20\n",
"13:42:21\n",
"13:42:22\n",
"13:42:23\n",
"13:42:24\n",
"13:42:25\n",
"13:42:26\n",
"13:42:27\n",
"13:42:28\n",
"13:42:29\n",
"13:42:30\n",
"13:42:31\n",
"13:42:32\n",
"13:42:33\n",
"13:42:34\n",
"13:42:35\n",
"13:42:36\n",
"13:42:37\n",
"13:42:38\n",
"13:42:39\n",
"13:42:40\n",
"13:42:41\n",
"13:42:42\n",
"13:42:43\n",
"13:42:45\n",
"13:42:46\n",
"13:42:47\n",
"13:42:48\n",
"13:42:49\n",
"13:42:50\n",
"13:42:51\n",
"13:42:52\n",
"13:42:53\n",
"13:42:54\n",
"13:42:55\n",
"13:42:56\n",
"13:42:57\n",
"13:42:58\n",
"13:42:59\n",
"13:43:00\n",
"13:43:01\n",
"13:43:02\n",
"13:43:03\n",
"13:43:04\n",
"13:43:05\n",
"13:43:06\n",
"13:43:07\n",
"13:43:08\n",
"13:43:09\n",
"13:43:10\n",
"13:43:11\n",
"13:43:12\n",
"13:43:13\n",
"13:43:14\n",
"13:43:15\n",
"13:43:16\n",
"13:43:17\n",
"13:43:18\n",
"13:43:19\n",
"13:43:20\n",
"13:43:21\n",
"13:43:22\n",
"13:43:23\n",
"13:43:24\n",
"13:43:25\n",
"13:43:26\n",
"13:43:27\n",
"13:43:28\n",
"13:43:29\n",
"13:43:30\n",
"13:43:31\n",
"13:43:32\n",
"13:43:33\n",
"13:43:34\n",
"13:43:35\n",
"13:43:36\n",
"13:43:37\n",
"13:43:38\n",
"13:43:39\n",
"13:43:40\n",
"13:43:41\n",
"13:43:42\n",
"13:43:43\n",
"13:43:44\n",
"13:43:45\n",
"13:43:46\n",
"13:43:47\n",
"13:43:48\n",
"13:43:49\n",
"13:43:50\n",
"13:43:51\n",
"13:43:52\n",
"13:43:53\n",
"13:43:54\n",
"13:43:55\n",
"13:43:56\n",
"13:43:57\n",
"13:43:58\n",
"13:43:59\n",
"13:44:00\n",
"13:44:01\n",
"13:44:02\n",
"13:44:03\n",
"13:44:04\n",
"13:44:05\n",
"13:44:06\n",
"13:44:07\n",
"13:44:08\n",
"13:44:09\n",
"13:44:10\n",
"13:44:11\n",
"13:44:12\n",
"13:44:13\n",
"13:44:14\n",
"13:44:15\n",
"13:44:16\n",
"13:44:17\n",
"13:44:18\n",
"13:44:19\n",
"13:44:20\n",
"13:44:21\n",
"13:44:22\n",
"13:44:23\n",
"13:44:24\n",
"13:44:25\n",
"13:44:26\n",
"13:44:27\n",
"13:44:28\n",
"13:44:29\n",
"13:44:30\n",
"13:44:31\n",
"13:44:32\n",
"13:44:33\n",
"13:44:34\n",
"13:44:35\n",
"13:44:36\n",
"13:44:37\n",
"13:44:38\n",
"13:44:39\n",
"13:44:40\n",
"13:44:41\n",
"13:44:42\n",
"13:44:43\n",
"13:44:44\n",
"13:44:45\n",
"13:44:46\n",
"13:44:47\n",
"13:44:48\n",
"13:44:49\n",
"13:44:50\n",
"13:44:51\n",
"13:44:52\n",
"13:44:53\n",
"13:44:54\n",
"13:44:55\n",
"13:44:56\n",
"13:44:57\n",
"13:44:58\n",
"13:44:59\n",
"13:45:00\n",
"更新数据\n",
"{'data': {'date': '20250123', 'dataItemNoList': ['251926669|STRIKE_PRICE', 'C01100008|CORTED_VALUE', 'C01100008|AUCTION_MAX_PRICE', 'C01100008|YEDAY_AMOUNT', 'ICE_CL0_LAST_YEDAY_PRICE\\n', '100028046|LISTING_PRICE', 'C01100008|PLAN_SALE', '91370200163576944B|C01100008|STRIKE_PRICE', '9137078672073757X8|C01100008|STRIKE_PRICE', '91370500674526498A|C01100008|STRIKE_PRICE', '91370305773165341A|C01100008|STRIKE_PRICE', '91370521164880008P|C01100008|STRIKE_PRICE', '91370321164425136B|C01100008|STRIKE_PRICE', 'SD|GC|ZDW|LIST_PRICE', '370500|ISOBUTANE|LIST_PRICE', 'SD|YT|SG|LIST_PRICE', '91110000710926094P|C01100008|SUPPLY_MERE', '91110000710932515R|C01100008|SUPPLY_MERE', '91370500674526498A|C01100008|SUPPLY_MERE', '91370321164425136B|C01100008|SUPPLY_MERE', 'C01100008|OTHER|SUPPLY_MERE', 'SD|WJH|DEMANDS', 'C01100008|SUY_DED_DAP', 'C01100008|EFFECTIVE_STOCK', '912102117169477344|C01100008|STRIKE_PRICE', '91110304102767480H|C01100008|STRIKE_PRICE', '91130193670310403L|C01100008|STRIKE_PRICE', 'HD|LPG|IMPORT_PRICE', 'SD|WJH|SALES_PRICE']}, 'funcModule': '数据项', 'funcOperation': '查询'}\n",
"[{'dataDate': '20250123', 'dataItemNo': '251926669|STRIKE_PRICE', 'dataValue': 5400.0}, {'dataDate': '20250123', 'dataItemNo': '91370305773165341A|C01100008|STRIKE_PRICE', 'dataValue': 5500.0}, {'dataDate': '20250123', 'dataItemNo': '91370321164425136B|C01100008|STRIKE_PRICE', 'dataValue': 5430.0}, {'dataDate': '20250123', 'dataItemNo': '91370521164880008P|C01100008|STRIKE_PRICE', 'dataValue': 5535.0}]\n",
"13:45:04\n",
"13:45:05\n",
"13:45:06\n",
"13:45:07\n",
"13:45:08\n",
"13:45:09\n",
"13:45:10\n",
"13:45:11\n",
"13:45:12\n",
"13:45:13\n",
"13:45:14\n"
] ]
} }
], ],
"source": [ "source": [
"from datetime import datetime, timedelta\n",
"\n", "\n",
"start_date = datetime(2024, 12, 13)\n", "if __name__ == \"__main__\":\n",
"end_date = datetime(2024, 12, 17)\n", " print('运行中')\n",
" # 需要单独运行放开\n",
"# start()\n",
"# start_1(date='2025-01-22')\n",
"# start_1()\n",
"\n", "\n",
"while start_date < end_date:\n", " # 每天定时12点运行\n",
" print(start_date.strftime('%Y%m%d'))\n", " while True:\n",
" start(start_date)\n", " try:\n",
" # time.sleep(1)\n", " # 获取当前时间\n",
" # start_2(start_date)\n", " current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
" start_date += timedelta(days=1)" " current_time_1 = time.strftime(\"%H:%M:%S\", time.localtime())\n",
"# print(current_time_1)\n",
"\n",
" # 判断当前时间是否为执行任务的时间点\n",
" if current_time == \"09:15:00\":\n",
" print(\"执行定时任务\")\n",
" start()\n",
"\n",
" # 休眠1秒钟避免过多占用CPU资源\n",
" time.sleep(1)\n",
"\n",
" elif current_time_1 == \"20:00:00\":\n",
" print(\"更新数据\")\n",
" start_1()\n",
" time.sleep(1)\n",
" except:\n",
" print('执行错误')\n",
" time.sleep(1)\n",
"\n",
"\n",
" # 检测数据准确性, 需要检测放开\n",
" # check_data(\"100028098|LISTING_PRICE\")\n",
" # check_data(\"9137070016544622XB|DAY_Yield\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# from datetime import datetime, timedelta\n",
"\n",
"# start_date = datetime(2025, 1, 21)\n",
"# end_date = datetime(2025, 1, 23)\n",
"\n",
"# while start_date < end_date:\n",
"# print(start_date.strftime('%Y%m%d'))\n",
"# start(start_date)\n",
"# # time.sleep(1)\n",
"# # start_2(start_date)\n",
"# start_date += timedelta(days=1)\n",
"# time.sleep(5)\n",
"\n",
"# print(price_list)"
] ]
} }
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "base", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -1020,7 +1173,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.7" "version": "3.7.0"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -1,15 +1,22 @@
# 定时执行cmd命令 # 定时执行cmd命令
import os
import time
from main import predict_main
import time
import os
while True: while True:
try: try:
print(time.strftime('%H:%M')) print(time.strftime('%H:%M'))
# 判断是不是工作日且 是1700 700 才执行 # 判断是不是工作日且 是1700 700 才执行
if time.strftime('%A') not in ['Saturday', 'Sunday'] and time.strftime('%H:%M') in [ '18:00']: if time.strftime('%A') not in ['Saturday', 'Sunday'] and time.strftime('%H:%M') in ['07:50']:
predict_main() # 要执行的命令
command = r"d:\yuanyouyuce\envs\predict\python main_yuanyou.py"
# 调用系统命令
os.system(command)
time.sleep(60) time.sleep(60)
except: except:
time.sleep(3600) time.sleep(3600)
predict_main() # 要执行的命令
command = r"d:\yuanyouyuce\envs\predict\python main_yuanyou.py"
# 调用系统命令
os.system(command)