Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,5 @@ TAGS
.ipynb_checkpoints/

.gdb_history

.vscode
19 changes: 14 additions & 5 deletions zipline/utils/run_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def _run(handle_data,
print_algo,
metrics_set,
local_namespace,
environ):
environ,
loaders):
"""Run a backtest for the given algorithm.

This is shared between the cli and :func:`zipline.run_algo`.
Expand Down Expand Up @@ -168,9 +169,12 @@ def _run(handle_data,
def choose_loader(column):
if column in USEquityPricing.columns:
return pipeline_loader
raise ValueError(
"No PipelineLoader registered for column %s." % column
)
elif column in loaders:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will crash in the current implementation if the user doesn't supply any custom loaders (because loaders will be None, so column in loaders will barf).

return loaders[column]
else:
raise ValueError(
"No PipelineLoader registered for column %s." % column
)
else:
env = TradingEnvironment(environ=environ)
choose_loader = None
Expand Down Expand Up @@ -285,7 +289,8 @@ def run_algorithm(start,
default_extension=True,
extensions=(),
strict_extensions=True,
environ=os.environ):
environ=os.environ,
loaders=None):
"""Run a trading algorithm.

Parameters
Expand Down Expand Up @@ -344,6 +349,9 @@ def run_algorithm(start,
environ : mapping[str -> str], optional
The os environment to use. Many extensions use this to get parameters.
This defaults to ``os.environ``.
loaders : iterable{PipelineLoader}, optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docstring and parameter name don't match here.

A dictionary containing custom loaders to include data from external sources
in a pipeline.

Returns
-------
Expand Down Expand Up @@ -396,4 +404,5 @@ def run_algorithm(start,
metrics_set=metrics_set,
local_namespace=False,
environ=environ,
loaders=loaders
)