From 7e92df435288e2b1786150848df7c8c2654c5b38 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 6 Apr 2018 15:00:11 -0400 Subject: [PATCH] Move built-in lists to respective module --- piker/cli.py | 26 +++----------------------- piker/watchlists.py | 6 +++++- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/piker/cli.py b/piker/cli.py index 65377937..82fdf138 100644 --- a/piker/cli.py +++ b/piker/cli.py @@ -120,35 +120,15 @@ def watch(loglevel, broker, rate, name): from .ui.watchlist import _async_main log = get_console_log(loglevel) # activate console logging brokermod = get_brokermod(broker) - - watchlists_base = { - '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', - 'WMD.VN', 'HEMP.VN', 'CALI.CN', 'RQB.CN', 'MPX.CN', - 'SEED.TO', 'HMJR.TO', 'CMED.TO', 'PAS.VN', - 'CRON', - ], - 'dad': ['GM', 'TSLA', 'DOL.TO', 'CIM', 'SPY', 'SHOP.TO'], - 'pharma': ['ATE.VN'], - 'indexes': ['SPY', 'DAX', 'QQQ', 'DIA'], - } watchlist_from_file = wl.ensure_watchlists(_watchlists_data_path) - watchlists = wl.merge_watchlist(watchlist_from_file, watchlists_base) - # broker_conf_path = os.path.join( - # click.get_app_dir('piker'), 'watchlists.json') - # from piker.testing import _quote_streamer as brokermod + watchlists = wl.merge_watchlist(watchlist_from_file, wl._builtins) broker_limit = getattr(brokermod, '_rate_limit', float('inf')) + if broker_limit < rate: rate = broker_limit log.warn(f"Limiting {brokermod.__name__} query rate to {rate}/sec") + trio.run(_async_main, name, watchlists[name], brokermod, rate) - # broker_conf_path = os.path.join( - # click.get_app_dir('piker'), 'watchlists.json') - # from piker.testing import _quote_streamer as brokermod @cli.group() diff --git a/piker/watchlists.py b/piker/watchlists.py index ae777904..0f71a49c 100644 --- a/piker/watchlists.py +++ b/piker/watchlists.py @@ -6,12 +6,16 @@ from .log import get_logger log = get_logger(__name__) +_builtins = { + 'indexes': ['SPY', 'DAX', 'QQQ', 'DIA'], +} + def write_sorted_json(watchlist, path): for key in watchlist: watchlist[key] = sorted(list(set(watchlist[key]))) with open(path, 'w') as f: - json.dump(watchlist, f, sort_keys=True) + json.dump(watchlist, f, sort_keys=True, indent=4) def make_config_dir(dir_path):