From eda8c8ce11f202602b88e33e04622194aaf6a1c0 Mon Sep 17 00:00:00 2001 From: fredfortier Date: Sat, 26 Aug 2017 13:41:27 -0400 Subject: [PATCH] Fixes after rebasing to develop --- catalyst/__main__.py | 15 +++++++++++++-- catalyst/utils/run_algo.py | 11 +++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/catalyst/__main__.py b/catalyst/__main__.py index 154db69d..c6db635c 100644 --- a/catalyst/__main__.py +++ b/catalyst/__main__.py @@ -210,6 +210,12 @@ def ipython_only(option): '--algo-name', help='A label assigned to the algorithm for tracking purposes.', ) +@click.option( + '-c', + '--reference-currency', + help='The reference currency used to calculate statistics ' + '(e.g. usd, btc, eth).', +) @click.pass_context def run(ctx, algofile, @@ -226,7 +232,8 @@ def run(ctx, local_namespace, live, exchange_name, - algo_namespace): + algo_namespace, + base_currency): """Run a backtest for the given algorithm. """ @@ -237,6 +244,9 @@ def run(ctx, if algo_namespace is None: ctx.fail("must specify an algorithm name '-n' in live execution " "mode '--live'") + if base_currency is None: + ctx.fail("must specify a reference currency '-c' in live " + "execution mode '--live'") else: # check that the start and end dates are passed correctly if start is None and end is None: @@ -278,7 +288,8 @@ def run(ctx, environ=os.environ, live=live, exchange=exchange_name, - algo_namespace=algo_namespace + algo_namespace=algo_namespace, + base_currency=base_currency ) if output == '-': diff --git a/catalyst/utils/run_algo.py b/catalyst/utils/run_algo.py index 7edc7dcb..1c8c7655 100644 --- a/catalyst/utils/run_algo.py +++ b/catalyst/utils/run_algo.py @@ -90,8 +90,10 @@ def _run(handle_data, print_algo, local_namespace, environ, + live, exchange, - algo_namespace): + algo_namespace, + base_currency): """Run a backtest for the given algorithm. This is shared between the cli and :func:`catalyst.run_algo`. @@ -238,7 +240,7 @@ def _run(handle_data, ) else: - if exchange is not None: + if live and exchange is not None: env = TradingEnvironment( environ=environ, exchange_tz="UTC", @@ -290,7 +292,7 @@ def _run(handle_data, TradingAlgorithmClass = ( partial(ExchangeTradingAlgorithm, exchange=exchange, algo_namespace=algo_namespace) - if exchange else TradingAlgorithm) + if live and exchange else TradingAlgorithm) perf = TradingAlgorithmClass( namespace=namespace, @@ -529,5 +531,6 @@ def run_algorithm(initialize, environ=environ, live=live, exchange=exchange, - algo_namespace=algo_namespace + algo_namespace=algo_namespace, + base_currency=base_currency )