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=[