From 37a4d2e5f89b22b1c2996f39df96cb1be75484fb Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 9 Feb 2018 03:29:10 -0500 Subject: [PATCH] Expose watchlist app via `piker watch` for now --- piker/cli.py | 27 +++++++++++++++++++++++++++ piker/ui/watchlist.py | 35 ++++------------------------------- setup.py | 3 +-- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/piker/cli.py b/piker/cli.py index ed864eba..9cfc015b 100644 --- a/piker/cli.py +++ b/piker/cli.py @@ -102,3 +102,30 @@ def stream(broker, loglevel, tickers, keys): ]), loglevel ) + + +@cli.command() +@click.option('--broker', default='questrade', help='Broker backend to use') +@click.option('--loglevel', '-l', default='warning', help='Logging level') +@click.argument('watchlist-name', nargs=1, required=True) +def watch(loglevel, broker, watchlist_name): + """Spawn a watchlist. + """ + from .ui.watchlist import _async_main + get_console_log(loglevel) # activate console logging + brokermod = import_module('.' + broker, 'piker.brokers') + + watchlists = { + 'cannabis': [ + 'EMH.VN', 'LEAF.TO', 'HVT.VN', 'HMMJ.TO', 'APH.TO', + 'CBW.VN', 'TRST.CN', 'VFF.TO', 'ACB.TO', 'ABCN.VN', + 'APH.TO', 'MARI.CN', 'WMD.VN', 'LEAF.TO', 'THCX.VN', + 'WEED.TO', 'NINE.VN', 'RTI.VN', 'SNN.CN', 'ACB.TO', + 'OGI.VN', 'IMH.VN', 'FIRE.VN', 'EAT.CN', 'NUU.VN', + 'WMD.VN', 'HEMP.VN', 'CALI.CN', 'RBQ.CN', + ], + } + # broker_conf_path = os.path.join( + # click.get_app_dir('piker'), 'watchlists.json') + # from piker.testing import _quote_streamer as brokermod + trio.run(_async_main, watchlists[watchlist_name], brokermod) diff --git a/piker/ui/watchlist.py b/piker/ui/watchlist.py index 9724029b..98dcca58 100644 --- a/piker/ui/watchlist.py +++ b/piker/ui/watchlist.py @@ -1,5 +1,7 @@ """ -A real-time, sorted watchlist +A real-time, sorted watchlist. + +Launch with ``piker watch ``. """ from importlib import import_module @@ -15,6 +17,7 @@ from kivy import utils from kivy.app import async_runTouchApp +from ..cli import cli from ..log import get_logger, get_console_log log = get_logger('watchlist') @@ -330,33 +333,3 @@ async def _async_main(tickers, brokermod): nursery.start_soon(run_kivy, widgets['root'], nursery) nursery.start_soon(update_quotes, widgets, queue, sd, first_quotes) - - -@click.group() -def cli(): - pass - - -@cli.command() -@click.option('--broker', default='questrade', help='Broker backend to use') -@click.option('--loglevel', '-l', default='warning', help='Logging level') -def run(loglevel, broker): - """Spawn a watchlist. - """ - get_console_log(loglevel) # activate console logging - brokermod = import_module('.' + broker, 'piker.brokers') - - watchlists = { - 'cannabis': [ - 'EMH.VN', 'LEAF.TO', 'HVT.VN', 'HMMJ.TO', 'APH.TO', - 'CBW.VN', 'TRST.CN', 'VFF.TO', 'ACB.TO', 'ABCN.VN', - 'APH.TO', 'MARI.CN', 'WMD.VN', 'LEAF.TO', 'THCX.VN', - 'WEED.TO', 'NINE.VN', 'RTI.VN', 'SNN.CN', 'ACB.TO', - 'OGI.VN', 'IMH.VN', 'FIRE.VN', 'EAT.CN', 'NUU.VN', - 'WMD.VN', 'HEMP.VN', 'CALI.CN', 'RBQ.CN', - ], - } - # broker_conf_path = os.path.join( - # click.get_app_dir('piker'), 'watchlists.json') - # from piker.testing import _quote_streamer as brokermod - trio.run(_async_main, watchlists['cannabis'], brokermod) diff --git a/setup.py b/setup.py index 4a729053..71b5ed49 100755 --- a/setup.py +++ b/setup.py @@ -30,8 +30,7 @@ setup( ], entry_points={ 'console_scripts': [ - 'piker = piker.brokers.cli:cli', - 'watchlist = piker.ui.watchlist:cli', + 'piker = piker.cli:cli', ] }, install_requires=[