From 1a1e7681262159e35ab39084605bf15f03f4c305 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 15 Jul 2020 08:28:13 -0400 Subject: [PATCH] Port to new data apis --- piker/brokers/core.py | 4 ++-- piker/cli/__init__.py | 1 + piker/data/marketstore.py | 4 +++- piker/ui/cli.py | 6 +++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/piker/brokers/core.py b/piker/brokers/core.py index 2e672c61..67255a41 100644 --- a/piker/brokers/core.py +++ b/piker/brokers/core.py @@ -112,11 +112,11 @@ async def symbol_info( async def symbol_search( brokermod: ModuleType, - symbol: str, + pattern: str, **kwargs, ) -> Dict[str, Dict[str, Dict[str, Any]]]: """Return symbol info from broker. """ async with brokermod.get_client() as client: # TODO: support multiple asset type concurrent searches. - return await client.search_stocks(symbol, **kwargs) + return await client.search_stocks(pattern=pattern, **kwargs) diff --git a/piker/cli/__init__.py b/piker/cli/__init__.py index ea72b6b6..097f9ad5 100644 --- a/piker/cli/__init__.py +++ b/piker/cli/__init__.py @@ -9,6 +9,7 @@ import tractor from ..log import get_console_log, get_logger from ..brokers import get_brokermod, config + log = get_logger('cli') DEFAULT_BROKER = 'questrade' diff --git a/piker/data/marketstore.py b/piker/data/marketstore.py index 84e62ecb..0c68adf7 100644 --- a/piker/data/marketstore.py +++ b/piker/data/marketstore.py @@ -16,6 +16,7 @@ import msgpack import numpy as np import pandas as pd import pymarketstore as pymkts +import tractor from trio_websocket import open_websocket_url from ..log import get_logger, get_console_log @@ -320,7 +321,8 @@ async def stream_quotes( # update cache _cache[symbol].update(quote) else: - quotes = {symbol: [{key.lower(): val for key, val in quote.items()}]} + quotes = { + symbol: [{key.lower(): val for key, val in quote.items()}]} if quotes: yield quotes diff --git a/piker/ui/cli.py b/piker/ui/cli.py index 78c749df..2be6d436 100644 --- a/piker/ui/cli.py +++ b/piker/ui/cli.py @@ -117,4 +117,8 @@ def chart(config, symbol, date, tl, rate, test): """ from ._chart import main - main(symbol) + # global opts + loglevel = config['loglevel'] + brokername = config['broker'] + + main(sym=symbol, brokername=brokername, loglevel=loglevel)