From 2915e83324c156c64f0198269a8b82bb39c792c9 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 1 Dec 2018 16:11:38 -0500 Subject: [PATCH] Warn about missing symbols at CLI level --- piker/brokers/core.py | 7 +------ piker/cli.py | 7 +++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/piker/brokers/core.py b/piker/brokers/core.py index e6fed8a1..b493a9e7 100644 --- a/piker/brokers/core.py +++ b/piker/brokers/core.py @@ -46,12 +46,7 @@ async def stocks_quote( """Return quotes dict for ``tickers``. """ async with brokermod.get_client() as client: - results = await client.quote(tickers) - for val in results: - if val is None: - brokermod.log.warn(f"Could not find symbol {key}?") - - return results + return await client.quote(tickers) # TODO: these need tests diff --git a/piker/cli.py b/piker/cli.py index d0ab22fc..6dd3b327 100644 --- a/piker/cli.py +++ b/piker/cli.py @@ -5,6 +5,7 @@ from functools import partial import json import os from operator import attrgetter +from operator import itemgetter import click import pandas as pd @@ -101,6 +102,12 @@ def quote(loglevel, broker, tickers, df_output): log.error(f"No quotes could be found for {tickers}?") return + if len(quotes) < len(tickers): + syms = tuple(map(itemgetter('symbol'), quotes)) + for ticker in tickers: + if ticker not in syms: + brokermod.log.warn(f"Could not find symbol {ticker}?") + if df_output: cols = next(filter(bool, quotes.values())).copy() cols.pop('symbol')