diff --git a/aisenzhecode/沥青/沥青定性模型每日推送-ytj.ipynb b/aisenzhecode/沥青/沥青定性模型每日推送-ytj.ipynb index f35983e..ef0f62c 100644 --- a/aisenzhecode/沥青/沥青定性模型每日推送-ytj.ipynb +++ b/aisenzhecode/沥青/沥青定性模型每日推送-ytj.ipynb @@ -48,25 +48,58 @@ "two_cols = []\n", "\n", "\n", + "def update_e_value(file_path, column_index, threshold):\n", + " \"\"\"\n", + " 数据修正需求:2025年1月8日\n", + " 如果如果今天的成本即期价跟昨天的成本价差正负1000以上,就按照昨天的成本价计算\n", + "\n", + " 更新Excel文件中指定列的值,如果新值与前一天的值变化大于阈值,则将新值改为前一天的值。\n", + "\n", + " :param file_path: Excel文件路径\n", + " :param column_index: 需要更新的列索引\n", + " :param threshold: 变化阈值\n", + " \"\"\"\n", + " # 读取Excel文件\n", + " try:\n", + " df = pd.read_excel(file_path, engine='openpyxl')\n", + " except:\n", + " df = pd.read_excel(file_path, engine='xlrd')\n", + " print(df.tail())\n", + " # 填充缺失值\n", + " df = df.fillna(method='ffill')\n", + "\n", + " # 获取最后两行数据\n", + " df1 = df.tail(2)\n", + " print(df1)\n", + " # 获取前一天的指定列值\n", + " previous_value = df1.iloc[0, column_index]\n", + " print(previous_value,type(previous_value))\n", + " # 获取当前的指定列值\n", + " current_value = df1.iloc[1, column_index]\n", + " print(current_value,type(current_value))\n", + " # 判断指定列值的变化是否大于阈值\n", + " if abs(current_value - previous_value) > threshold:\n", + " # 如果变化大于阈值,将当前的指定列值改为前一天的值\n", + " df.iloc[-1, column_index] = previous_value\n", + " print('修改了')\n", + " print(df.tail())\n", + " # 将修改后的数据写回Excel文件\n", + " df.to_excel(file_path, index=False,engine='openpyxl')\n", + "\n", "\n", "\n", "def start(date=''):\n", " workbook = xlrd.open_workbook(read_file_path_name)\n", "\n", - "\n", - "\n", " # 选择第一个表格\n", " sheet = workbook.sheet_by_index(0)\n", "\n", " # 获取行数和列数\n", " num_rows = sheet.nrows\n", - "\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", @@ -156,6 +189,7 @@ " new_sheet.write(row, col, data[row][col])\n", "\n", " if i == 0:\n", + " \n", " # 在新的sheet中添加数据\n", " for col in range(col_count):\n", " new_sheet.write(row_count, col, append_rows[col])\n", @@ -163,7 +197,10 @@ " # 保存新的xls文件\n", " new_workbook.save(\"定性模型数据项12-11.xls\")\n", "\n", + " update_e_value('定性模型数据项12-11.xls', 8, 1000)\n", + "\n", " df = pd.read_excel('定性模型数据项12-11.xls')\n", + "\n", " df=df.fillna(df.ffill())\n", " df1 = df[-2:].reset_index()\n", " '''\n", @@ -475,1016 +512,9 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "20210613\n", - "20210614\n", - "20210615\n", - "20210616\n", - "20210617\n", - "20210618\n", - "20210619\n", - "20210620\n", - "20210621\n", - "20210622\n", - "20210623\n", - "20210624\n", - "20210625\n", - "20210626\n", - "20210627\n", - "20210628\n", - "20210629\n", - "20210630\n", - "20210701\n", - "20210702\n", - "20210703\n", - "20210704\n", - "20210705\n", - "20210706\n", - "20210707\n", - "20210708\n", - "20210709\n", - "20210710\n", - "20210711\n", - "20210712\n", - "20210713\n", - "20210714\n", - "20210715\n", - "20210716\n", - "20210717\n", - "20210718\n", - "20210719\n", - "20210720\n", - "20210721\n", - "20210722\n", - "20210723\n", - "20210724\n", - "20210725\n", - "20210726\n", - "20210727\n", - "20210728\n", - "20210729\n", - "20210730\n", - "20210731\n", - "20210801\n", - "20210802\n", - "20210803\n", - "20210804\n", - "20210805\n", - "20210806\n", - "20210807\n", - "20210808\n", - "20210809\n", - "20210810\n", - "20210811\n", - "20210812\n", - "20210813\n", - "20210814\n", - "20210815\n", - "20210816\n", - "20210817\n", - "20210818\n", - "20210819\n", - "20210820\n", - "20210821\n", - "20210822\n", - "20210823\n", - "20210824\n", - "20210825\n", - "20210826\n", - "20210827\n", - "20210828\n", - "20210829\n", - "20210830\n", - "20210831\n", - "20210901\n", - "20210902\n", - "20210903\n", - "20210904\n", - "20210905\n", - "20210906\n", - "20210907\n", - "20210908\n", - "20210909\n", - "20210910\n", - "{'dataDate': '20210910', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210911\n", - "{'dataDate': '20210911', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210912\n", - "{'dataDate': '20210912', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210913\n", - "{'dataDate': '20210913', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210914\n", - "{'dataDate': '20210914', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210915\n", - "{'dataDate': '20210915', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210916\n", - "{'dataDate': '20210916', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210917\n", - "{'dataDate': '20210917', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210918\n", - "{'dataDate': '20210918', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210919\n", - "{'dataDate': '20210919', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210920\n", - "{'dataDate': '20210920', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210921\n", - "{'dataDate': '20210921', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210922\n", - "{'dataDate': '20210922', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210923\n", - "{'dataDate': '20210923', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210924\n", - "{'dataDate': '20210924', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210925\n", - "{'dataDate': '20210925', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210926\n", - "{'dataDate': '20210926', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210927\n", - "{'dataDate': '20210927', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210928\n", - "{'dataDate': '20210928', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210929\n", - "{'dataDate': '20210929', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20210930\n", - "{'dataDate': '20210930', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211001\n", - "{'dataDate': '20211001', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211002\n", - "{'dataDate': '20211002', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211003\n", - "{'dataDate': '20211003', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211004\n", - "{'dataDate': '20211004', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211005\n", - "{'dataDate': '20211005', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211006\n", - "{'dataDate': '20211006', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211007\n", - "{'dataDate': '20211007', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211008\n", - "{'dataDate': '20211008', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211009\n", - "{'dataDate': '20211009', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211010\n", - "{'dataDate': '20211010', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211011\n", - "{'dataDate': '20211011', 'dataItemNo': 'STRIKE|DAY|KGL'}\n", - "20211012\n", - "20211013\n", - "20211014\n", - "20211015\n", - "20211016\n", - "20211017\n", - "20211018\n", - "20211019\n", - "20211020\n", - "20211021\n", - "20211022\n", - "20211023\n", - "20211024\n", - "20211025\n", - "20211026\n", - "20211027\n", - "20211028\n", - "20211029\n", - "20211030\n", - "20211031\n", - "20211101\n", - "20211102\n", - "20211103\n", - "20211104\n", - "20211105\n", - "20211106\n", - "20211107\n", - "20211108\n", - "20211109\n", - "20211110\n", - "20211111\n", - "20211112\n", - "20211113\n", - "20211114\n", - "20211115\n", - "20211116\n", - "20211117\n", - "20211118\n", - "20211119\n", - "20211120\n", - "20211121\n", - "20211122\n", - "20211123\n", - "20211124\n", - "20211125\n", - "20211126\n", - "20211127\n", - "20211128\n", - "20211129\n", - "20211130\n", - "20211201\n", - "20211202\n", - "20211203\n", - "20211204\n", - "20211205\n", - "20211206\n", - "20211207\n", - "20211208\n", - "20211209\n", - "20211210\n", - "20211211\n", - "20211212\n", - "20211213\n", - "20211214\n", - "20211215\n", - "20211216\n", - "20211217\n", - "20211218\n", - "20211219\n", - "20211220\n", - "20211221\n", - "20211222\n", - "20211223\n", - "20211224\n", - "20211225\n", - "20211226\n", - "20211227\n", - "20211228\n", - "20211229\n", - "20211230\n", - "20211231\n", - "20220101\n", - "20220102\n", - "20220103\n", - "20220104\n", - "20220105\n", - "20220106\n", - "20220107\n", - "20220108\n", - "20220109\n", - "20220110\n", - "20220111\n", - "20220112\n", - "20220113\n", - "20220114\n", - "20220115\n", - "20220116\n", - "20220117\n", - "20220118\n", - "20220119\n", - "20220120\n", - "20220121\n", - "20220122\n", - "20220123\n", - "20220124\n", - "20220125\n", - "20220126\n", - "20220127\n", - "20220128\n", - "20220129\n", - "20220130\n", - "20220131\n", - "20220201\n", - "20220202\n", - "20220203\n", - "20220204\n", - "20220205\n", - "20220206\n", - "20220207\n", - "20220208\n", - "20220209\n", - "20220210\n", - "20220211\n", - "20220212\n", - "20220213\n", - "20220214\n", - "20220215\n", - "20220216\n", - "20220217\n", - "20220218\n", - "20220219\n", - "20220220\n", - "20220221\n", - "20220222\n", - "20220223\n", - "20220224\n", - "20220225\n", - "20220226\n", - "20220227\n", - "20220228\n", - "20220301\n", - "20220302\n", - "20220303\n", - "20220304\n", - "20220305\n", - "20220306\n", - "20220307\n", - "20220308\n", - "20220309\n", - "20220310\n", - "20220311\n", - "20220312\n", - "20220313\n", - "20220314\n", - "20220315\n", - "20220316\n", - "20220317\n", - "20220318\n", - "20220319\n", - "20220320\n", - "20220321\n", - "20220322\n", - "20220323\n", - "20220324\n", - "20220325\n", - "20220326\n", - "20220327\n", - "20220328\n", - "20220329\n", - "20220330\n", - "20220331\n", - "20220401\n", - "20220402\n", - "20220403\n", - "20220404\n", - "20220405\n", - "20220406\n", - "20220407\n", - "20220408\n", - "20220409\n", - "20220410\n", - "20220411\n", - "20220412\n", - "20220413\n", - "20220414\n", - "20220415\n", - "20220416\n", - "20220417\n", - "20220418\n", - "20220419\n", - "20220420\n", - "20220421\n", - "20220422\n", - "20220423\n", - "20220424\n", - "20220425\n", - "20220426\n", - "20220427\n", - "20220428\n", - "20220429\n", - "20220430\n", - "20220501\n", - "20220502\n", - "20220503\n", - "20220504\n", - "20220505\n", - "20220506\n", - "20220507\n", - "20220508\n", - "20220509\n", - "20220510\n", - "20220511\n", - "20220512\n", - "20220513\n", - "20220514\n", - "20220515\n", - "20220516\n", - "20220517\n", - "20220518\n", - "20220519\n", - "20220520\n", - "20220521\n", - "20220522\n", - "20220523\n", - "20220524\n", - "20220525\n", - "20220526\n", - "20220527\n", - "20220528\n", - "20220529\n", - "20220530\n", - "20220531\n", - "20220601\n", - "20220602\n", - "20220603\n", - "20220604\n", - "20220605\n", - "20220606\n", - "20220607\n", - "20220608\n", - "20220609\n", - "20220610\n", - "20220611\n", - "20220612\n", - "20220613\n", - "20220614\n", - "20220615\n", - "20220616\n", - "20220617\n", - "20220618\n", - "20220619\n", - "20220620\n", - "20220621\n", - "20220622\n", - "20220623\n", - "20220624\n", - "20220625\n", - "20220626\n", - "20220627\n", - "20220628\n", - "20220629\n", - "20220630\n", - "20220701\n", - "20220702\n", - "20220703\n", - "20220704\n", - "20220705\n", - "20220706\n", - "20220707\n", - "20220708\n", - "20220709\n", - "20220710\n", - "20220711\n", - "20220712\n", - "20220713\n", - "20220714\n", - "20220715\n", - "20220716\n", - "20220717\n", - "20220718\n", - "20220719\n", - "20220720\n", - "20220721\n", - "20220722\n", - "20220723\n", - "20220724\n", - "20220725\n", - "20220726\n", - "20220727\n", - "20220728\n", - "20220729\n", - "20220730\n", - "20220731\n", - "20220801\n", - "20220802\n", - "20220803\n", - "20220804\n", - "20220805\n", - "20220806\n", - "20220807\n", - "20220808\n", - "20220809\n", - "20220810\n", - "20220811\n", - "20220812\n", - "20220813\n", - "20220814\n", - "20220815\n", - "20220816\n", - "20220817\n", - "20220818\n", - "20220819\n", - "20220820\n", - "20220821\n", - "20220822\n", - "20220823\n", - "20220824\n", - "20220825\n", - "20220826\n", - "20220827\n", - "20220828\n", - "20220829\n", - "20220830\n", - "20220831\n", - "20220901\n", - "20220902\n", - "20220903\n", - "20220904\n", - "20220905\n", - "20220906\n", - "20220907\n", - "20220908\n", - "20220909\n", - "20220910\n", - "20220911\n", - "20220912\n", - "20220913\n", - "20220914\n", - "20220915\n", - "20220916\n", - "20220917\n", - "20220918\n", - "20220919\n", - "20220920\n", - "20220921\n", - "20220922\n", - "20220923\n", - "20220924\n", - "20220925\n", - "20220926\n", - "20220927\n", - "20220928\n", - "20220929\n", - "20220930\n", - "20221001\n", - "20221002\n", - "20221003\n", - "20221004\n", - "20221005\n", - "20221006\n", - "20221007\n", - "20221008\n", - "20221009\n", - "20221010\n", - "20221011\n", - "20221012\n", - "20221013\n", - "20221014\n", - "20221015\n", - "20221016\n", - "20221017\n", - "20221018\n", - "20221019\n", - "20221020\n", - "20221021\n", - "20221022\n", - "20221023\n", - "20221024\n", - "20221025\n", - "20221026\n", - "20221027\n", - "20221028\n", - "20221029\n", - "20221030\n", - "20221031\n", - "20221101\n", - "20221102\n", - "20221103\n", - "20221104\n", - "20221105\n", - "20221106\n", - "20221107\n", - "20221108\n", - "20221109\n", - "20221110\n", - "20221111\n", - "20221112\n", - "20221113\n", - "20221114\n", - "20221115\n", - "20221116\n", - "20221117\n", - "20221118\n", - "20221119\n", - "20221120\n", - "20221121\n", - "20221122\n", - "20221123\n", - "20221124\n", - "20221125\n", - "20221126\n", - "20221127\n", - "20221128\n", - "20221129\n", - "20221130\n", - "20221201\n", - "20221202\n", - "20221203\n", - "20221204\n", - "20221205\n", - "20221206\n", - "20221207\n", - "20221208\n", - "20221209\n", - "20221210\n", - "20221211\n", - "20221212\n", - "20221213\n", - "20221214\n", - "20221215\n", - "20221216\n", - "20221217\n", - "20221218\n", - "20221219\n", - "20221220\n", - "20221221\n", - "20221222\n", - "20221223\n", - "20221224\n", - "20221225\n", - "20221226\n", - "20221227\n", - "20221228\n", - "20221229\n", - "20221230\n", - "20221231\n", - "20230101\n", - "20230102\n", - "20230103\n", - "20230104\n", - "20230105\n", - "20230106\n", - "20230107\n", - "20230108\n", - "20230109\n", - "20230110\n", - "20230111\n", - "20230112\n", - "20230113\n", - "20230114\n", - "20230115\n", - "20230116\n", - "20230117\n", - "20230118\n", - "20230119\n", - "20230120\n", - "20230121\n", - "20230122\n", - "20230123\n", - "20230124\n", - "20230125\n", - "20230126\n", - "20230127\n", - "20230128\n", - "20230129\n", - "20230130\n", - "20230131\n", - "20230201\n", - "20230202\n", - "20230203\n", - "20230204\n", - "20230205\n", - "20230206\n", - "20230207\n", - "20230208\n", - "20230209\n", - "20230210\n", - "20230211\n", - "20230212\n", - "20230213\n", - "20230214\n", - "20230215\n", - "20230216\n", - "20230217\n", - "20230218\n", - "20230219\n", - "20230220\n", - "20230221\n", - "20230222\n", - "20230223\n", - "20230224\n", - "20230225\n", - "20230226\n", - "20230227\n", - "20230228\n", - "20230301\n", - "20230302\n", - "20230303\n", - "20230304\n", - "20230305\n", - "20230306\n", - "20230307\n", - "20230308\n", - "20230309\n", - "20230310\n", - "20230311\n", - "20230312\n", - "20230313\n", - "20230314\n", - "20230315\n", - "20230316\n", - "20230317\n", - "20230318\n", - "20230319\n", - "20230320\n", - "20230321\n", - "20230322\n", - "20230323\n", - "20230324\n", - "20230325\n", - "20230326\n", - "20230327\n", - "20230328\n", - "20230329\n", - "20230330\n", - "20230331\n", - "20230401\n", - "20230402\n", - "20230403\n", - "20230404\n", - "20230405\n", - "20230406\n", - "20230407\n", - "20230408\n", - "20230409\n", - "20230410\n", - "20230411\n", - "20230412\n", - "20230413\n", - "20230414\n", - "20230415\n", - "20230416\n", - "20230417\n", - "20230418\n", - "20230419\n", - "20230420\n", - "20230421\n", - "20230422\n", - "20230423\n", - "20230424\n", - "20230425\n", - "20230426\n", - "20230427\n", - "20230428\n", - "20230429\n", - "20230430\n", - "20230501\n", - "20230502\n", - "20230503\n", - "20230504\n", - "20230505\n", - "20230506\n", - "20230507\n", - "20230508\n", - "20230509\n", - "20230510\n", - "20230511\n", - "20230512\n", - "20230513\n", - "20230514\n", - "20230515\n", - "20230516\n", - "20230517\n", - "20230518\n", - "20230519\n", - "20230520\n", - "20230521\n", - "20230522\n", - "20230523\n", - "20230524\n", - "20230525\n", - "20230526\n", - "20230527\n", - "20230528\n", - "20230529\n", - "20230530\n", - "20230531\n", - "20230601\n", - "20230602\n", - "20230603\n", - "20230604\n", - "20230605\n", - "20230606\n", - "20230607\n", - "20230608\n", - "20230609\n", - "20230610\n", - "20230611\n", - "20230612\n", - "20230613\n", - "20230614\n", - "20230615\n", - "20230616\n", - "20230617\n", - "20230618\n", - "20230619\n", - "20230620\n", - "20230621\n", - "20230622\n", - "20230623\n", - "20230624\n", - "20230625\n", - "20230626\n", - "20230627\n", - "20230628\n", - "20230629\n", - "20230630\n", - "20230701\n", - "20230702\n", - "20230703\n", - "20230704\n", - "20230705\n", - "20230706\n", - "20230707\n", - "20230708\n", - "20230709\n", - "20230710\n", - "20230711\n", - "20230712\n", - "20230713\n", - "20230714\n", - "20230715\n", - "20230716\n", - "20230717\n", - "20230718\n", - "20230719\n", - "20230720\n", - "20230721\n", - "20230722\n", - "20230723\n", - "20230724\n", - "20230725\n", - "20230726\n", - "20230727\n", - "20230728\n", - "20230729\n", - "20230730\n", - "20230731\n", - "20230801\n", - "20230802\n", - "20230803\n", - "20230804\n", - "20230805\n", - "20230806\n", - "20230807\n", - "20230808\n", - "20230809\n", - "20230810\n", - "20230811\n", - "20230812\n", - "20230813\n", - "20230814\n", - "20230815\n", - "20230816\n", - "20230817\n", - "20230818\n", - "20230819\n", - "20230820\n", - "20230821\n", - "20230822\n", - "20230823\n", - "20230824\n", - "20230825\n", - "20230826\n", - "20230827\n", - "20230828\n", - "20230829\n", - "20230830\n", - "20230831\n", - "20230901\n", - "20230902\n", - "20230903\n", - "20230904\n", - "20230905\n", - "20230906\n", - "20230907\n", - "20230908\n", - "20230909\n", - "20230910\n", - "20230911\n", - "20230912\n", - "20230913\n", - "20230914\n", - "20230915\n", - "20230916\n", - "20230917\n", - "20230918\n", - "20230919\n", - "20230920\n", - "20230921\n", - "20230922\n", - "20230923\n", - "20230924\n", - "20230925\n", - "20230926\n", - "20230927\n", - "20230928\n", - "20230929\n", - "20230930\n", - "20231001\n", - "20231002\n", - "20231003\n", - "20231004\n", - "20231005\n", - "20231006\n", - "20231007\n", - "20231008\n", - "20231009\n", - "20231010\n", - "20231011\n", - "20231012\n", - "20231013\n", - "20231014\n", - "20231015\n", - "20231016\n", - "20231017\n", - "20231018\n", - "20231019\n", - "20231020\n", - "20231021\n", - "20231022\n", - "20231023\n", - "20231024\n", - "20231025\n", - "20231026\n", - "20231027\n", - "20231028\n", - "20231029\n", - "20231030\n", - "20231031\n", - "20231101\n", - "20231102\n", - "20231103\n", - "20231104\n", - "20231105\n", - "20231106\n", - "20231107\n", - "20231108\n", - "20231109\n", - "20231110\n", - "20231111\n", - "20231112\n", - "20231113\n", - "20231114\n", - "20231115\n", - "20231116\n", - "20231117\n", - "20231118\n", - "20231119\n", - "20231120\n", - "20231121\n", - "20231122\n", - "20231123\n", - "20231124\n", - "20231125\n", - "20231126\n", - "20231127\n", - "20231128\n", - "20231129\n", - "20231130\n", - "20231201\n", - "20231202\n", - "20231203\n", - "20231204\n", - "20231205\n", - "20231206\n", - "20231207\n", - "20231208\n", - "20231209\n", - "20231210\n", - "20231211\n", - "20231212\n", - "20231213\n", - "{'dataDate': '20231213', 'dataItemNo': 'SDHYDDJG'}\n", - "{'dataDate': '20231213', 'dataItemNo': 'SDHYSCQK'}\n", - "{'dataDate': '20231213', 'dataItemNo': 'SDHYZJYS'}\n", - "20231214\n", - "20231215\n", - "20231216\n", - "20231217\n", - "20231218\n", - "20231219\n", - "20231220\n", - "{'dataDate': '20231220', 'dataItemNo': 'SDHYDDJG'}\n", - "{'dataDate': '20231220', 'dataItemNo': 'SDHYSCQK'}\n", - "{'dataDate': '20231220', 'dataItemNo': 'SDHYZJYS'}\n", - "20231221\n", - "20231222\n", - "20231223\n", - "20231224\n", - "20231225\n", - "20231226\n", - "20231227\n", - "{'dataDate': '20231227', 'dataItemNo': 'SDHYDDJG'}\n", - "{'dataDate': '20231227', 'dataItemNo': 'SDHYSCQK'}\n", - "{'dataDate': '20231227', 'dataItemNo': 'SDHYZJYS'}\n", - "20231228\n", - "20231229\n", - "20231230\n", - "20231231\n", - "20240101\n", - "20240102\n", - "20240103\n" - ] - }, - { - "ename": "KeyboardInterrupt", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[4], line 8\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m start_date \u001b[38;5;241m<\u001b[39m end_date:\n\u001b[0;32m 7\u001b[0m \u001b[38;5;28mprint\u001b[39m(start_date\u001b[38;5;241m.\u001b[39mstrftime(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mY\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mm\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m'\u001b[39m))\n\u001b[1;32m----> 8\u001b[0m start(start_date)\n\u001b[0;32m 9\u001b[0m \u001b[38;5;66;03m# start_1(start_date)\u001b[39;00m\n\u001b[0;32m 10\u001b[0m start_date \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m timedelta(days\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m)\n", - "Cell \u001b[1;32mIn[3], line 93\u001b[0m, in \u001b[0;36mstart\u001b[1;34m(date)\u001b[0m\n\u001b[0;32m 84\u001b[0m search_data \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m 85\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m\"\u001b[39m: {\n\u001b[0;32m 86\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdate\u001b[39m\u001b[38;5;124m\"\u001b[39m: cur_time,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 90\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfuncOperation\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m查询\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 91\u001b[0m }\n\u001b[0;32m 92\u001b[0m headers \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAuthorization\u001b[39m\u001b[38;5;124m\"\u001b[39m: token}\n\u001b[1;32m---> 93\u001b[0m search_res \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mpost(url\u001b[38;5;241m=\u001b[39msearch_url, headers\u001b[38;5;241m=\u001b[39mheaders, json\u001b[38;5;241m=\u001b[39msearch_data, timeout\u001b[38;5;241m=\u001b[39m(\u001b[38;5;241m3\u001b[39m, \u001b[38;5;241m5\u001b[39m))\n\u001b[0;32m 94\u001b[0m search_value \u001b[38;5;241m=\u001b[39m json\u001b[38;5;241m.\u001b[39mloads(search_res\u001b[38;5;241m.\u001b[39mtext)[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[0;32m 95\u001b[0m \u001b[38;5;66;03m# datas = search_value\u001b[39;00m\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\requests\\api.py:115\u001b[0m, in \u001b[0;36mpost\u001b[1;34m(url, data, json, **kwargs)\u001b[0m\n\u001b[0;32m 103\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mpost\u001b[39m(url, data\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, json\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m 104\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124;03m\"\"\"Sends a POST request.\u001b[39;00m\n\u001b[0;32m 105\u001b[0m \n\u001b[0;32m 106\u001b[0m \u001b[38;5;124;03m :param url: URL for the new :class:`Request` object.\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 112\u001b[0m \u001b[38;5;124;03m :rtype: requests.Response\u001b[39;00m\n\u001b[0;32m 113\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 115\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m request(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpost\u001b[39m\u001b[38;5;124m\"\u001b[39m, url, data\u001b[38;5;241m=\u001b[39mdata, json\u001b[38;5;241m=\u001b[39mjson, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\requests\\api.py:59\u001b[0m, in \u001b[0;36mrequest\u001b[1;34m(method, url, **kwargs)\u001b[0m\n\u001b[0;32m 55\u001b[0m \u001b[38;5;66;03m# By using the 'with' statement we are sure the session is closed, thus we\u001b[39;00m\n\u001b[0;32m 56\u001b[0m \u001b[38;5;66;03m# avoid leaving sockets open which can trigger a ResourceWarning in some\u001b[39;00m\n\u001b[0;32m 57\u001b[0m \u001b[38;5;66;03m# cases, and look like a memory leak in others.\u001b[39;00m\n\u001b[0;32m 58\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m sessions\u001b[38;5;241m.\u001b[39mSession() \u001b[38;5;28;01mas\u001b[39;00m session:\n\u001b[1;32m---> 59\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m session\u001b[38;5;241m.\u001b[39mrequest(method\u001b[38;5;241m=\u001b[39mmethod, url\u001b[38;5;241m=\u001b[39murl, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\requests\\sessions.py:589\u001b[0m, in \u001b[0;36mSession.request\u001b[1;34m(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)\u001b[0m\n\u001b[0;32m 584\u001b[0m send_kwargs \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m 585\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtimeout\u001b[39m\u001b[38;5;124m\"\u001b[39m: timeout,\n\u001b[0;32m 586\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mallow_redirects\u001b[39m\u001b[38;5;124m\"\u001b[39m: allow_redirects,\n\u001b[0;32m 587\u001b[0m }\n\u001b[0;32m 588\u001b[0m send_kwargs\u001b[38;5;241m.\u001b[39mupdate(settings)\n\u001b[1;32m--> 589\u001b[0m resp \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msend(prep, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39msend_kwargs)\n\u001b[0;32m 591\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m resp\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\requests\\sessions.py:703\u001b[0m, in \u001b[0;36mSession.send\u001b[1;34m(self, request, **kwargs)\u001b[0m\n\u001b[0;32m 700\u001b[0m start \u001b[38;5;241m=\u001b[39m preferred_clock()\n\u001b[0;32m 702\u001b[0m \u001b[38;5;66;03m# Send the request\u001b[39;00m\n\u001b[1;32m--> 703\u001b[0m r \u001b[38;5;241m=\u001b[39m adapter\u001b[38;5;241m.\u001b[39msend(request, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m 705\u001b[0m \u001b[38;5;66;03m# Total elapsed time of the request (approximately)\u001b[39;00m\n\u001b[0;32m 706\u001b[0m elapsed \u001b[38;5;241m=\u001b[39m preferred_clock() \u001b[38;5;241m-\u001b[39m start\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\requests\\adapters.py:486\u001b[0m, in \u001b[0;36mHTTPAdapter.send\u001b[1;34m(self, request, stream, timeout, verify, cert, proxies)\u001b[0m\n\u001b[0;32m 483\u001b[0m timeout \u001b[38;5;241m=\u001b[39m TimeoutSauce(connect\u001b[38;5;241m=\u001b[39mtimeout, read\u001b[38;5;241m=\u001b[39mtimeout)\n\u001b[0;32m 485\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 486\u001b[0m resp \u001b[38;5;241m=\u001b[39m conn\u001b[38;5;241m.\u001b[39murlopen(\n\u001b[0;32m 487\u001b[0m method\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mmethod,\n\u001b[0;32m 488\u001b[0m url\u001b[38;5;241m=\u001b[39murl,\n\u001b[0;32m 489\u001b[0m body\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mbody,\n\u001b[0;32m 490\u001b[0m headers\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mheaders,\n\u001b[0;32m 491\u001b[0m redirect\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 492\u001b[0m assert_same_host\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 493\u001b[0m preload_content\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 494\u001b[0m decode_content\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m 495\u001b[0m retries\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmax_retries,\n\u001b[0;32m 496\u001b[0m timeout\u001b[38;5;241m=\u001b[39mtimeout,\n\u001b[0;32m 497\u001b[0m chunked\u001b[38;5;241m=\u001b[39mchunked,\n\u001b[0;32m 498\u001b[0m )\n\u001b[0;32m 500\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (ProtocolError, \u001b[38;5;167;01mOSError\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[0;32m 501\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mConnectionError\u001b[39;00m(err, request\u001b[38;5;241m=\u001b[39mrequest)\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:791\u001b[0m, in \u001b[0;36mHTTPConnectionPool.urlopen\u001b[1;34m(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)\u001b[0m\n\u001b[0;32m 788\u001b[0m response_conn \u001b[38;5;241m=\u001b[39m conn \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m release_conn \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 790\u001b[0m \u001b[38;5;66;03m# Make the request on the HTTPConnection object\u001b[39;00m\n\u001b[1;32m--> 791\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_make_request(\n\u001b[0;32m 792\u001b[0m conn,\n\u001b[0;32m 793\u001b[0m method,\n\u001b[0;32m 794\u001b[0m url,\n\u001b[0;32m 795\u001b[0m timeout\u001b[38;5;241m=\u001b[39mtimeout_obj,\n\u001b[0;32m 796\u001b[0m body\u001b[38;5;241m=\u001b[39mbody,\n\u001b[0;32m 797\u001b[0m headers\u001b[38;5;241m=\u001b[39mheaders,\n\u001b[0;32m 798\u001b[0m chunked\u001b[38;5;241m=\u001b[39mchunked,\n\u001b[0;32m 799\u001b[0m retries\u001b[38;5;241m=\u001b[39mretries,\n\u001b[0;32m 800\u001b[0m response_conn\u001b[38;5;241m=\u001b[39mresponse_conn,\n\u001b[0;32m 801\u001b[0m preload_content\u001b[38;5;241m=\u001b[39mpreload_content,\n\u001b[0;32m 802\u001b[0m decode_content\u001b[38;5;241m=\u001b[39mdecode_content,\n\u001b[0;32m 803\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mresponse_kw,\n\u001b[0;32m 804\u001b[0m )\n\u001b[0;32m 806\u001b[0m \u001b[38;5;66;03m# Everything went great!\u001b[39;00m\n\u001b[0;32m 807\u001b[0m clean_exit \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\urllib3\\connectionpool.py:537\u001b[0m, in \u001b[0;36mHTTPConnectionPool._make_request\u001b[1;34m(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)\u001b[0m\n\u001b[0;32m 535\u001b[0m \u001b[38;5;66;03m# Receive the response from the server\u001b[39;00m\n\u001b[0;32m 536\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 537\u001b[0m response \u001b[38;5;241m=\u001b[39m conn\u001b[38;5;241m.\u001b[39mgetresponse()\n\u001b[0;32m 538\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (BaseSSLError, \u001b[38;5;167;01mOSError\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 539\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_raise_timeout(err\u001b[38;5;241m=\u001b[39me, url\u001b[38;5;241m=\u001b[39murl, timeout_value\u001b[38;5;241m=\u001b[39mread_timeout)\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\urllib3\\connection.py:461\u001b[0m, in \u001b[0;36mHTTPConnection.getresponse\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 458\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mresponse\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m HTTPResponse\n\u001b[0;32m 460\u001b[0m \u001b[38;5;66;03m# Get the response from http.client.HTTPConnection\u001b[39;00m\n\u001b[1;32m--> 461\u001b[0m httplib_response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39mgetresponse()\n\u001b[0;32m 463\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 464\u001b[0m assert_header_parsing(httplib_response\u001b[38;5;241m.\u001b[39mmsg)\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\http\\client.py:1386\u001b[0m, in \u001b[0;36mHTTPConnection.getresponse\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1384\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1385\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1386\u001b[0m response\u001b[38;5;241m.\u001b[39mbegin()\n\u001b[0;32m 1387\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mConnectionError\u001b[39;00m:\n\u001b[0;32m 1388\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mclose()\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\http\\client.py:325\u001b[0m, in \u001b[0;36mHTTPResponse.begin\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 323\u001b[0m \u001b[38;5;66;03m# read until we get a non-100 response\u001b[39;00m\n\u001b[0;32m 324\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[1;32m--> 325\u001b[0m version, status, reason \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_read_status()\n\u001b[0;32m 326\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m status \u001b[38;5;241m!=\u001b[39m CONTINUE:\n\u001b[0;32m 327\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\http\\client.py:286\u001b[0m, in \u001b[0;36mHTTPResponse._read_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 285\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_read_status\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m--> 286\u001b[0m line \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfp\u001b[38;5;241m.\u001b[39mreadline(_MAXLINE \u001b[38;5;241m+\u001b[39m \u001b[38;5;241m1\u001b[39m), \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124miso-8859-1\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 287\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(line) \u001b[38;5;241m>\u001b[39m _MAXLINE:\n\u001b[0;32m 288\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m LineTooLong(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstatus line\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\socket.py:706\u001b[0m, in \u001b[0;36mSocketIO.readinto\u001b[1;34m(self, b)\u001b[0m\n\u001b[0;32m 704\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[0;32m 705\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 706\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sock\u001b[38;5;241m.\u001b[39mrecv_into(b)\n\u001b[0;32m 707\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m timeout:\n\u001b[0;32m 708\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_timeout_occurred \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n", - "\u001b[1;31mKeyboardInterrupt\u001b[0m: " - ] - } - ], + "outputs": [], "source": [ "from datetime import datetime, timedelta\n", "\n", @@ -1496,16 +526,8 @@ " start(start_date)\n", " # start_1(start_date)\n", " start_date += timedelta(days=1)\n", - " \n", - " " + " \n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/config_jingbo.py b/config_jingbo.py index 3e903b5..28f1f2d 100644 --- a/config_jingbo.py +++ b/config_jingbo.py @@ -176,15 +176,15 @@ table_name = 'v_tbl_crude_oil_warning' ### 开关 is_train = False # 是否训练 is_debug = False # 是否调试 -is_eta = True # 是否使用eta接口 +is_eta = False # 是否使用eta接口 is_market = True # 是否通过市场信息平台获取特征 ,在is_eta 为true 的情况下生效 is_timefurture = True # 是否使用时间特征 is_fivemodels = False # 是否使用之前保存的最佳的5个模型 is_edbcode = False # 特征使用edbcoding列表中的 is_edbnamelist = False # 自定义特征,对应上面的edbnamelist is_update_eta = False # 预测结果上传到eta -is_update_report = True # 是否上传报告 -is_update_warning_data = True # 是否上传预警数据 +is_update_report = False # 是否上传报告 +is_update_warning_data = False # 是否上传预警数据 is_del_corr = 0.6 # 是否删除相关性高的特征,取值为 0-1 ,0 为不删除,0.6 表示删除相关性小于0.6的特征 is_del_tow_month = True # 是否删除两个月不更新的特征 @@ -239,7 +239,7 @@ 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') # 获取当前日期时间 -reportname = f'Brent原油大模型预测--{now}.pdf' # 报告文件名 +reportname = f'Brent原油大模型预测--{end_time}.pdf' # 报告文件名 reportname = reportname.replace(':', '-') # 替换冒号 if end_time == '': end_time = now diff --git a/lib/dataread.py b/lib/dataread.py index 8eb14c0..e2d03f4 100644 --- a/lib/dataread.py +++ b/lib/dataread.py @@ -41,9 +41,9 @@ plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签 plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号 # from config_jingbo_pro import * -# from config_jingbo import * +from config_jingbo import * # from config_yongan import * -from config_juxiting import * +# from config_juxiting import * @@ -722,7 +722,8 @@ def datachuli(df_zhibiaoshuju,df_zhibiaoliebiao,datecol='date',end_time='',y='y' # 按月取样 df = df.resample('M', on='ds').mean().reset_index() # 删除预测列空值的行 - df = df.dropna(subset=['y']) + ''' 工作日缺失,如果删除,会影响预测结果,导致统计准确率出错 ''' + # df = df.dropna(subset=['y']) logger.info(f'删除预测列为空值的行后数据量:{df.shape}') df = df.dropna(axis=1, how='all') logger.info(f'删除全为空值的列后数据量:{df.shape}') diff --git a/main_yuanyou.py b/main_yuanyou.py index 873e362..249ddc5 100644 --- a/main_yuanyou.py +++ b/main_yuanyou.py @@ -284,15 +284,15 @@ def predict_main(): file=max(glob.glob(os.path.join(dataset,'*.pdf')), key=os.path.getctime), ssl=ssl, ) - m.send_mail() + # m.send_mail() if __name__ == '__main__': - # global end_time - # is_on = True - # # 遍历2024-11-25 到 2024-12-3 之间的工作日日期 - # for i_time in pd.date_range('2024-12-27', '2024-12-28', freq='B'): - # end_time = i_time.strftime('%Y-%m-%d') - # predict_main() + global end_time + is_on = True + # 遍历2024-11-25 到 2024-12-3 之间的工作日日期 + for i_time in pd.date_range('2024-10-7', '2024-10-30', freq='B'): + end_time = i_time.strftime('%Y-%m-%d') + predict_main() - predict_main() \ No newline at end of file + # predict_main() \ No newline at end of file diff --git a/models/nerulforcastmodels.py b/models/nerulforcastmodels.py index 3fdb937..8239319 100644 --- a/models/nerulforcastmodels.py +++ b/models/nerulforcastmodels.py @@ -889,7 +889,7 @@ def model_losss(sqlitedb,end_time): # df['ACCURACY'] = df.apply(is_within_range, axis=1) # 计算准确率并保存结果 - def _get_accuracy_rate(df,create_dates,ds_dates,endtime): + def _get_accuracy_rate(df,create_dates,ds_dates): df3 = df.copy() df3 = df3[df3['CREAT_DATE'].isin(create_dates)] df3 = df3[df3['ds'].isin(ds_dates)] @@ -901,7 +901,7 @@ def model_losss(sqlitedb,end_time): df4.loc[len(df4)] = {'开始日期':ds_dates[0],'结束日期':ds_dates[-1],'准确率':accuracy_rote} df4.to_sql("accuracy_rote", con=sqlitedb.connection, if_exists='append', index=False) create_dates,ds_dates = get_week_date(end_time) - _get_accuracy_rate(df,create_dates,ds_dates,end_time) + _get_accuracy_rate(df,create_dates,ds_dates) def _add_abs_error_rate(): # 计算每个预测值与真实值之间的偏差率 @@ -941,6 +941,9 @@ def model_losss(sqlitedb,end_time): df = df[-lens:] # 取180个数据点画图 # 历史价格 plt.figure(figsize=(20, 10)) + # 时间格式更改 + df['ds'] = pd.to_datetime(df['ds']) + plt.plot(df['ds'], df['y'], label='真实值') # 颜色填充 plt.fill_between(df['ds'], df['max_within_quantile'], df['min_within_quantile'], alpha=0.2) @@ -962,6 +965,11 @@ def model_losss(sqlitedb,end_time): plt.axvline(x=df['ds'].iloc[-horizon], color='r', linestyle='--') plt.legend() plt.xlabel('日期') + # 设置横轴日期格式为年-月-日 + plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d')) + # 自动设置横轴日期显示 + plt.gca().xaxis.set_major_locator(mdates.AutoDateLocator()) + plt.xticks(rotation=45) # 日期标签旋转45度,防止重叠 plt.ylabel('价格') plt.savefig(os.path.join(dataset,'历史价格-预测值.png'), bbox_inches='tight') @@ -969,6 +977,7 @@ def model_losss(sqlitedb,end_time): def _plt_modeltopten_predict_ture(df): + df['ds'] = pd.to_datetime(df['ds']) df['max_cutoff'] = df.groupby('ds')['CREAT_DATE'].transform('max') df = df[df['CREAT_DATE'] == df['max_cutoff']] df['mean'] = df['mean'].astype(float) @@ -996,6 +1005,10 @@ def model_losss(sqlitedb,end_time): plt.axvline(x=df['ds'].iloc[-horizon], color='r', linestyle='--') plt.legend() plt.xlabel('日期') + # 自动设置横轴日期显示 + plt.gca().xaxis.set_major_locator(mdates.AutoDateLocator()) + plt.xticks(rotation=45) # 日期标签旋转45度,防止重叠 + plt.ylabel('价格') plt.savefig(os.path.join(dataset,'历史价格-预测值1.png'), bbox_inches='tight') @@ -1367,7 +1380,7 @@ def brent_export_pdf(num_indicators=475,num_models=21, num_dayindicator=202,inpu ### 添加标题 - content.append(Graphs.draw_title(f'{y}{end_time}预测报告')) + content.append(Graphs.draw_title(f'{y}{time}预测报告')) ### 预测结果 content.append(Graphs.draw_little_title('一、预测结果:'))