Warn about missing symbols at CLI level

kivy_mainline_and_py3.8
Tyler Goodlet 2018-12-01 16:11:38 -05:00
parent 61294c6c44
commit 2915e83324
2 changed files with 8 additions and 6 deletions

View File

@ -46,12 +46,7 @@ async def stocks_quote(
"""Return quotes dict for ``tickers``. """Return quotes dict for ``tickers``.
""" """
async with brokermod.get_client() as client: async with brokermod.get_client() as client:
results = await client.quote(tickers) return await client.quote(tickers)
for val in results:
if val is None:
brokermod.log.warn(f"Could not find symbol {key}?")
return results
# TODO: these need tests # TODO: these need tests

View File

@ -5,6 +5,7 @@ from functools import partial
import json import json
import os import os
from operator import attrgetter from operator import attrgetter
from operator import itemgetter
import click import click
import pandas as pd 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}?") log.error(f"No quotes could be found for {tickers}?")
return 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: if df_output:
cols = next(filter(bool, quotes.values())).copy() cols = next(filter(bool, quotes.values())).copy()
cols.pop('symbol') cols.pop('symbol')