ricequant / rqalpha

A extendable, replaceable Python algorithmic backtest && trading framework supporting multiple securities
http://rqalpha.io
Other
5.38k stars 1.61k forks source link

通过命令行传递参数执行程序报错:Error: Got unexpected extra arguments #591

Closed hy89 closed 3 years ago

hy89 commented 3 years ago

https://rqalpha.readthedocs.io/zh_CN/latest/intro/optimizing_parameters.html#id3 该文档中代码用来测试时,抛出以上异常 image

代码如下:

import os
import json
import concurrent.futures
import multiprocessing

tasks = []
for short_period in range(3, 10, 2):
    for long_period in range(30, 90, 5):
        extra_vars = {
            "SHORTPERIOD": short_period,
            "LONGPERIOD": long_period,
        }
        vars_params = json.dumps(extra_vars).encode("utf-8").decode("utf-8")

        cmd = ("rqalpha run -fq 1d -f F:/Desktop/my_quant/rqalpha应用/均线策略/sma.py --start-date 2015-01-01 --end-date 2016-01-01 "
               "-o results/out-{short_period}-{long_period}.pkl --account stock 100000 --progress -bm 000001.XSHE --extra-vars '{params}' ").format(
            short_period=short_period,
            long_period=long_period,
            params=vars_params)

        tasks.append(cmd)

def run_bt(cmd):
    print(cmd)
    os.system(cmd)

if __name__ == '__main__':
    with concurrent.futures.ProcessPoolExecutor(max_workers=multiprocessing.cpu_count()) as executor:
        for task in tasks:
            executor.submit(run_bt, task)
mar-heaven commented 3 years ago

请把启动命令展示完整一些