diff --git a/zipline/data/bundles/quandl.py b/zipline/data/bundles/quandl.py index 4250d115..d60bef2f 100644 --- a/zipline/data/bundles/quandl.py +++ b/zipline/data/bundles/quandl.py @@ -333,6 +333,7 @@ def download_with_progress(url, chunk_size, **progress_kwargs): data.write(chunk) pbar.update(len(chunk)) + data.seek(0) return data diff --git a/zipline/utils/paths.py b/zipline/utils/paths.py index 103c116b..0e87d94d 100644 --- a/zipline/utils/paths.py +++ b/zipline/utils/paths.py @@ -45,6 +45,20 @@ def ensure_directory_containing(path): ensure_directory(os.path.dirname(path)) +def ensure_file(path): + """ + Ensure that a file exists. This will create any parent directories needed + and create an empty file if it does not exists. + + Parameters + ---------- + path : str + The file path to ensure exists. + """ + ensure_directory_containing(path) + open(path, 'a+').close() # touch the file + + def last_modified_time(path): """ Get the last modified time of path as a Timestamp. diff --git a/zipline/utils/run_algo.py b/zipline/utils/run_algo.py index 288307ba..fbe64597 100644 --- a/zipline/utils/run_algo.py +++ b/zipline/utils/run_algo.py @@ -187,7 +187,7 @@ def load_extensions(default, extensions, strict, environ, reload=False): """ if default: default_extension_path = pth.default_extension(environ=environ) - open(default_extension_path, 'a+').close() # touch the file + pth.ensure_file(default_extension_path) # put the default extension first so other extensions can depend on # the order they are loaded extensions = concatv([default_extension_path], extensions)