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')