We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
def run_with_args(run_fun, *args): if len(sys.argv) == 3: # 区间作业 python xxx.py 2023-03-01 2023-03-21 tmp_year, tmp_month, tmp_day = sys.argv[1].split("-") start_date = datetime.datetime(int(tmp_year), int(tmp_month), int(tmp_day)).date() tmp_year, tmp_month, tmp_day = sys.argv[2].split("-") end_date = datetime.datetime(int(tmp_year), int(tmp_month), int(tmp_day)).date() run_date = start_date try: with concurrent.futures.ThreadPoolExecutor() as executor: while run_date <= end_date: if trd.is_trade_date(run_date): executor.submit(run_fun, run_date, *args) time.sleep(2) run_date += datetime.timedelta(days=1) except Exception as e: logging.error(f"run_template.run_with_args处理异常:{run_fun}{sys.argv}{e}")
执行: def main(): runt.run_with_args(save_nph_stock_spot_data) runt.run_with_args(save_nph_etf_spot_data) 参数:2010-01-01 2025-02-25
那么程序将空转至2025-02-25,非常耗时间
The text was updated successfully, but these errors were encountered:
No branches or pull requests
def run_with_args(run_fun, *args):
if len(sys.argv) == 3:
# 区间作业 python xxx.py 2023-03-01 2023-03-21
tmp_year, tmp_month, tmp_day = sys.argv[1].split("-")
start_date = datetime.datetime(int(tmp_year), int(tmp_month), int(tmp_day)).date()
tmp_year, tmp_month, tmp_day = sys.argv[2].split("-")
end_date = datetime.datetime(int(tmp_year), int(tmp_month), int(tmp_day)).date()
run_date = start_date
try:
with concurrent.futures.ThreadPoolExecutor() as executor:
while run_date <= end_date:
if trd.is_trade_date(run_date):
executor.submit(run_fun, run_date, *args)
time.sleep(2)
run_date += datetime.timedelta(days=1)
except Exception as e:
logging.error(f"run_template.run_with_args处理异常:{run_fun}{sys.argv}{e}")
执行:
def main():
runt.run_with_args(save_nph_stock_spot_data)
runt.run_with_args(save_nph_etf_spot_data)
参数:2010-01-01 2025-02-25
那么程序将空转至2025-02-25,非常耗时间
The text was updated successfully, but these errors were encountered: