我是python的新手,我正试图从我的Windows命令提示符运行一个开源项目。但是,我收到以下错误:
C:\Users\Joycelin>cd C:\Users\Joycelin\Anaconda2\Lib\site-packages\algofx\script
s
C:\Users\Joycelin\Anaconda2\Lib\site-packages\algofx\scripts>python randomwalk.p
y GBPUSD
1
Traceback (most recent call last):
File "randomwalk.py", line 62, in <module>
pair, d.strftime("%Y%m%d")
File "C:\Users\Joycelin\Anaconda2\lib\ntpath.py", line 65, in join
result_drive, result_path = splitdrive(path)
File "C:\Users\Joycelin\Anaconda2\lib\ntpath.py", line 115, in splitdrive
if len(p) > 1:
TypeError: object of type 'NoneType' has no len()
这是发生错误的脚本(randomwalk.py
)的一部分:
if __name__ == "__main__":
try:
pair = sys.argv[1]
except IndexError:
print("You need to enter a currency pair, e.g. GBPUSD, as a command line parameter.")
else:
np.random.seed(42) # Fix the randomness
S0 = 1.5000
spread = 0.002
mu_dt = 1400 # Milliseconds
sigma_dt = 100 # Millseconds
ask = copy.deepcopy(S0) + spread / 2.0
bid = copy.deepcopy(S0) - spread / 2.0
days = month_weekdays(2016, 2) # January 2014
current_time = datetime.datetime(
days[0].year, days[0].month, days[0].day, 0, 0, 0,
)
# Loop over every day in the month and create a CSV file
# for each day, e.g. "GBPUSD_20150101.csv"
for d in days:
print(d.day)
current_time = current_time.replace(day=d.day)
outfile = open(
os.path.join(
settings.CSV_DATA_DIR,
"%s_%s.csv" % (
pair, d.strftime("%Y%m%d")
)
),
"w")
outfile.write("Time,Ask,Bid,AskVolume,BidVolume\n")
我试图找出&#39;无&#39;引发错误的价值,但仍无法判断它是settings.CSV_DATA_DIR
还是d.strftime("%Y%m%d")
(或者可能是其他内容?)。
这是脚本settings.py
CSV_DATA_DIR = os.environ.get("//Users/Joycelin/csv_data")
OUTPUT_RESULTS_DIR = os.environ.get("//Users/Joycelin/Anaconda2/Lib/site-packages/algofx/output_results")
答案 0 :(得分:0)
Yous settings.py应包含以下内容:
CSV_DATA_DIR = 'C:\\Users\\Joycelin\\csv_data'
OUTPUT_RESULTS_DIR = 'C:\\Users\\Joycelin\\output_results'
我认为您不希望将输出放在Anaconda安装中的一个目录中。