# 这是原油日度,周度,月度的预测,脚本 # 遍历时间,跳过周六日,每日7点开始预测 import datetime import subprocess import time import pandas as pd def run_predictions(target_date): """执行三个预测脚本""" """执行三个预测脚本""" script_commands = [ ["main_yuanyou.py", "--end_time", target_date], ["main_yuanyou_zhoudu.py", "--end_time", target_date], ["main_yuanyou_yuedu.py", "--end_time", target_date] ] # 依次执行每个脚本 for script_parts in script_commands: print(f"开始执行 {script_parts} 的预测任务") # command = [r"C:\Users\EDY\.conda\envs\predict\python", script] # command = [r"C:/Users/Hello/.conda/envs/jaigeyuce/python.exe", script] #yitijipc command = [r"C:/Users/EDY/.conda/envs/priceforecast/python.exe"] + script_parts #168pc # command = [r"C:/Users/Hello/.conda/envs/jaigeyuce/python.exe", script] #yitijipc subprocess.run(command, check=True) def is_weekday(date): """判断是否为工作日(周一到周五)""" return date.weekday() < 5 # 0-4 为周一到周五 if __name__ == "__main__": # start_date = datetime.date(2025, 8, 1) # # 开始时间取当前时间 # # start_date = datetime.date.today() # end_date = datetime.date(2025, 10, 14) # current_date = start_date # while current_date <= end_date: # if is_weekday(current_date): # # 等待到目标日期的7点 # target_time = datetime.datetime.combine( # current_date, datetime.time(13, 15)) # while datetime.datetime.now() < target_time: # time.sleep(60) # 每分钟检查一次 # print(f"等待到 {target_time} 开始执行任务") # print(f"开始执行 {current_date} 的预测任务") # run_predictions(current_date) # current_date += datetime.timedelta(days=1) for i_time in pd.date_range('2025-10-15', '2025-10-15', freq='B'): current_date = i_time.strftime('%Y-%m-%d') print(f"开始执行 {current_date} 的预测任务") run_predictions(current_date) # print(f"开始执行 {current_date} 的预测任务") # run_predictions(current_date)