diff --git a/piker/brokers/api.py b/piker/_cacheables.py similarity index 95% rename from piker/brokers/api.py rename to piker/_cacheables.py index c1e11a01..c1113431 100644 --- a/piker/brokers/api.py +++ b/piker/_cacheables.py @@ -15,7 +15,7 @@ # along with this program. If not, see . """ -Actor-aware broker agnostic interface. +Cacheing apis and toolz. """ from typing import Dict @@ -23,8 +23,8 @@ from contextlib import asynccontextmanager, AsyncExitStack import trio -from . import get_brokermod -from ..log import get_logger +from .brokers import get_brokermod +from .log import get_logger log = get_logger(__name__) diff --git a/piker/brokers/binance.py b/piker/brokers/binance.py index e8309cdb..59fb3ea4 100644 --- a/piker/brokers/binance.py +++ b/piker/brokers/binance.py @@ -33,7 +33,7 @@ from pydantic.dataclasses import dataclass from pydantic import BaseModel import wsproto -from .api import open_cached_client +from .._cacheables import open_cached_client from ._util import resproc, SymbolNotFound from ..log import get_logger, get_console_log from ..data import ShmArray diff --git a/piker/brokers/core.py b/piker/brokers/core.py index 59621b63..b16f46fe 100644 --- a/piker/brokers/core.py +++ b/piker/brokers/core.py @@ -29,7 +29,7 @@ import trio from ..log import get_logger from . import get_brokermod from .._daemon import maybe_spawn_brokerd -from .api import open_cached_client +from .._cacheables import open_cached_client log = get_logger(__name__) diff --git a/piker/brokers/ib.py b/piker/brokers/ib.py index f604fc93..45b93416 100644 --- a/piker/brokers/ib.py +++ b/piker/brokers/ib.py @@ -1358,6 +1358,9 @@ async def trades_dialogue( # start order request handler **before** local trades event loop n.start_soon(handle_order_requests, ems_stream) + # TODO: for some reason we can receive a ``None`` here when the + # ib-gw goes down? Not sure exactly how that's happening looking + # at the eventkit code above but we should probably handle it... async for event_name, item in ib_trade_events_stream: # XXX: begin normalization of nonsense ib_insync internal @@ -1469,9 +1472,8 @@ async def trades_dialogue( @tractor.context async def open_symbol_search( ctx: tractor.Context, -) -> None: - # async with open_cached_client('ib') as client: +) -> None: # load all symbols locally for fast search await ctx.started({}) diff --git a/piker/brokers/kraken.py b/piker/brokers/kraken.py index 6d41ab10..cfce2d5a 100644 --- a/piker/brokers/kraken.py +++ b/piker/brokers/kraken.py @@ -34,7 +34,7 @@ from pydantic.dataclasses import dataclass from pydantic import BaseModel import wsproto -from .api import open_cached_client +from .._cacheables import open_cached_client from ._util import resproc, SymbolNotFound, BrokerError from ..log import get_logger, get_console_log from ..data import ShmArray diff --git a/piker/brokers/questrade.py b/piker/brokers/questrade.py index 3f09587c..7109f15e 100644 --- a/piker/brokers/questrade.py +++ b/piker/brokers/questrade.py @@ -42,6 +42,7 @@ import wrapt import asks from ..calc import humanize, percent_change +from .._cacheables import open_cached_client from . import config from ._util import resproc, BrokerError, SymbolNotFound from ..log import get_logger, colorize_json, get_console_log @@ -1197,7 +1198,7 @@ async def stream_quotes( # XXX: required to propagate ``tractor`` loglevel to piker logging get_console_log(loglevel) - async with api.open_cached_client('questrade') as client: + async with open_cached_client('questrade') as client: if feed_type == 'stock': formatter = format_stock_quote get_quotes = await stock_quoter(client, symbols)