crypto_quant/auto_update_market_data.py

29 lines
937 B
Python
Raw Normal View History

2025-08-20 08:40:33 +00:00
import schedule
import time
import datetime
import core.logger as logging
import subprocess
import os
logger = logging.logger
# 定义要执行的任务
def run_script():
start_time = time.time()
logger.info(f"Executing script at: {datetime.datetime.now()}")
output_file = r'./output/auto_schedule.txt'
with open(output_file, 'a') as f:
f.write(f"Task ran at {datetime.datetime.now()}\n")
python_path = r"D:\miniconda3\envs\okx\python.exe"
script_path = r"D:\python_projects\crypto_quant\huge_volume_main.py"
subprocess.run([python_path, script_path])
end_time = time.time()
logger.info(f"Script execution time: {end_time - start_time} seconds")
# 设置每小时运行一次
interval = 60 * 60
schedule.every(interval).seconds.do(run_script)
# 保持程序运行并检查调度
logger.info("Scheduler started. Press Ctrl+C to stop.")
while True:
schedule.run_pending()
time.sleep(1)