From 341a8f698964a63564db3eecf31da543e52d5458 Mon Sep 17 00:00:00 2001 From: Scapogo Date: Tue, 3 Oct 2017 09:33:54 -0700 Subject: [PATCH 1/4] Created broker list option --- zipline/__main__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/zipline/__main__.py b/zipline/__main__.py index 1280d78a2e..cb737999a0 100644 --- a/zipline/__main__.py +++ b/zipline/__main__.py @@ -204,6 +204,11 @@ def _(*args, **kwargs): metavar='FILENAME', help='Filename where the state will be stored' ) +@click.option( + '--broker-list', + is_flag=True, + help='Get list of available brokers' +) @click.pass_context def run(ctx, algofile, @@ -220,9 +225,15 @@ def run(ctx, local_namespace, broker, broker_uri, - state_file): + state_file, + broker_list): """Run a backtest for the given algorithm. """ + + if broker_list: + click.echo("Supported brokers: Interactive Brokers [ib]") + return + # check that the start and end dates are passed correctly if not broker and start is None and end is None: # check both at the same time to avoid the case where a user From a0415de39a019e8cfd2e33a083b268c2e2bbbab7 Mon Sep 17 00:00:00 2001 From: Scapogo Date: Sun, 8 Oct 2017 11:39:30 -0700 Subject: [PATCH 2/4] fixed conflict --- zipline/__main__.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/zipline/__main__.py b/zipline/__main__.py index cb737999a0..f8370b1b82 100644 --- a/zipline/__main__.py +++ b/zipline/__main__.py @@ -9,9 +9,12 @@ import pandas as pd from six import text_type +import pkgutil + from zipline.data import bundles as bundles_module from zipline.utils.cli import Date, Timestamp from zipline.utils.run_algo import _run, load_extensions +from zipline.gens import brokers try: __IPYTHON__ @@ -209,6 +212,13 @@ def _(*args, **kwargs): is_flag=True, help='Get list of available brokers' ) +@click.option( + '--realtime-bar-target', + default=None, + metavar='DIRNAME', + help='Directory where the realtime collected minutely bars are saved' +) + @click.pass_context def run(ctx, algofile, @@ -226,12 +236,16 @@ def run(ctx, broker, broker_uri, state_file, - broker_list): + broker_list, + realtime_bar_target): """Run a backtest for the given algorithm. """ if broker_list: - click.echo("Supported brokers: Interactive Brokers [ib]") + click.echo("Supported brokers:") + for module_loader, name, ispkg in pkgutil.iter_modules(brokers.__path__): + if name != 'broker': + print name return # check that the start and end dates are passed correctly @@ -297,6 +311,7 @@ def run(ctx, environ=os.environ, broker=brokerobj, state_filename=state_file, + realtime_bar_target=realtime_bar_target ) if output == '-': From f402442440c5fb7919d260d8ff72e01c100f124c Mon Sep 17 00:00:00 2001 From: Scapogo Date: Sun, 8 Oct 2017 11:42:18 -0700 Subject: [PATCH 3/4] fixed conflict --- zipline/__main__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zipline/__main__.py b/zipline/__main__.py index f8370b1b82..72d2ea318a 100644 --- a/zipline/__main__.py +++ b/zipline/__main__.py @@ -207,17 +207,17 @@ def _(*args, **kwargs): metavar='FILENAME', help='Filename where the state will be stored' ) -@click.option( - '--broker-list', - is_flag=True, - help='Get list of available brokers' -) @click.option( '--realtime-bar-target', default=None, metavar='DIRNAME', help='Directory where the realtime collected minutely bars are saved' ) +@click.option( + '--broker-list', + is_flag=True, + help='Get list of available brokers' +) @click.pass_context def run(ctx, From bc2dfaeabd6f0dc9c5a9ae585bb0da2ff19f7b9f Mon Sep 17 00:00:00 2001 From: Scapogo Date: Tue, 10 Oct 2017 09:14:35 -0700 Subject: [PATCH 4/4] requested changes implemented --- zipline/__main__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zipline/__main__.py b/zipline/__main__.py index 72d2ea318a..328162e9f3 100644 --- a/zipline/__main__.py +++ b/zipline/__main__.py @@ -214,7 +214,7 @@ def _(*args, **kwargs): help='Directory where the realtime collected minutely bars are saved' ) @click.option( - '--broker-list', + '--list-brokers', is_flag=True, help='Get list of available brokers' ) @@ -236,16 +236,16 @@ def run(ctx, broker, broker_uri, state_file, - broker_list, - realtime_bar_target): + realtime_bar_target, + list_brokers): """Run a backtest for the given algorithm. """ - if broker_list: + if list_brokers: click.echo("Supported brokers:") - for module_loader, name, ispkg in pkgutil.iter_modules(brokers.__path__): + for _, name, _ in pkgutil.iter_modules(brokers.__path__): if name != 'broker': - print name + click.echo(name) return # check that the start and end dates are passed correctly