Repository: quantopian/zipline
File: zipline/utils/run_algo.py (Python)

Code before:
                start_session=start,
                end_session=end,
                trading_calendar=trading_calendar,
                capital_base=capital_base,
                data_frequency=data_frequency,
            ),
            metrics_set=metrics_set,
            blotter=blotter,
            benchmark_returns=benchmark_returns,
            benchmark_sid=benchmark_sid,
            **{
                'initialize': initialize,
                'handle_data': handle_data,
                'before_trading_start': before_trading_start,
                'analyze': analyze,
            } if algotext is None else {
                'algo_filename': getattr(algofile, 'name', '<algorithm>'),
                'script': algotext,
            }
        ).run()
    except NoBenchmark:
        raise _RunAlgoError(
            (
                'no ``benchmark_spec`` was provided and'
                ' ``zipline.api.set_benchmark`` was not called in'
                ' ``initialize``'
            ),
            (
                "neither '--benchmark-symbol' nor '--benchmark-sid' was"
                " provided and ``zipline.api.set_benchmark`` was not called"
                " in ``initialize``, did you mean to pass '--no-benchmark'"
            ),
        )

    if output == '-':
        click.echo(str(perf))
    elif output != os.devnull:  # make the zipline magic not write any data
        perf.to_pickle(output)

    return perf


# All of the loaded extensions. We don't want to load an extension twice.
_loaded_extensions = set()


def load_extensions(default, extensions, strict, environ, reload=False):
    """Load all of the given extensions. This should be called by run_algo
    or the cli.

    Parameters

Review comment (suggestion):
```suggestion
                'No ``benchmark_spec`` was provided, and'
                ' ``zipline.api.set_benchmark`` was not called in'
                ' ``initialize``.'
```

Code after:
                start_session=start,
                end_session=end,
                trading_calendar=trading_calendar,
                capital_base=capital_base,
                data_frequency=data_frequency,
            ),
            metrics_set=metrics_set,
            blotter=blotter,
            benchmark_returns=benchmark_returns,
            benchmark_sid=benchmark_sid,
            **{
                'initialize': initialize,
                'handle_data': handle_data,
                'before_trading_start': before_trading_start,
                'analyze': analyze,
            } if algotext is None else {
                'algo_filename': getattr(algofile, 'name', '<algorithm>'),
                'script': algotext,
            }
        ).run()
    except NoBenchmark:
        raise _RunAlgoError(
            (
                'No ``benchmark_spec`` was provided, and'
                ' ``zipline.api.set_benchmark`` was not called in'
                ' ``initialize``.'
            ),
            (
                "Neither '--benchmark-symbol' nor '--benchmark-sid' was"
                " provided, and ``zipline.api.set_benchmark`` was not called"
                " in ``initialize``. Did you mean to pass '--no-benchmark'?"
            ),
        )

    if output == '-':
        click.echo(str(perf))
    elif output != os.devnull:  # make the zipline magic not write any data
        perf.to_pickle(output)

    return perf


# All of the loaded extensions. We don't want to load an extension twice.
_loaded_extensions = set()


def load_extensions(default, extensions, strict, environ, reload=False):
    """Load all of the given extensions. This should be called by run_algo
    or the cli.

    Parameters