Use common `.brokers` logger in most backends

rekt_pps
Tyler Goodlet 2023-03-22 12:32:21 -04:00
parent 2ae9576cd8
commit ea42f66b54
7 changed files with 31 additions and 28 deletions

View File

@ -28,7 +28,13 @@ import tractor
from ..cli import cli
from .. import watchlists as wl
from ..log import get_console_log, colorize_json, get_logger
from ..log import (
colorize_json,
)
from ._util import (
log,
get_console_log,
)
from ..service import (
maybe_spawn_brokerd,
maybe_open_pikerd,
@ -38,9 +44,7 @@ from ..brokers import (
get_brokermod,
data,
)
log = get_logger('cli')
DEFAULT_BROKER = 'questrade'
DEFAULT_BROKER = 'binance'
_config_dir = click.get_app_dir('piker')
_watchlists_data_path = os.path.join(_config_dir, 'watchlists.json')

View File

@ -26,15 +26,12 @@ from typing import List, Dict, Any, Optional
import trio
from ..log import get_logger
from ._util import log
from . import get_brokermod
from ..service import maybe_spawn_brokerd
from .._cacheables import open_cached_client
log = get_logger(__name__)
async def api(brokername: str, methname: str, **kwargs) -> dict:
"""Make (proxy through) a broker API call by name and return its result.
"""

View File

@ -41,13 +41,13 @@ import tractor
from tractor.experimental import msgpub
from async_generator import asynccontextmanager
from ..log import get_logger, get_console_log
from ._util import (
log,
get_console_log,
)
from . import get_brokermod
log = get_logger(__name__)
async def wait_for_network(
net_func: Callable,
sleep: int = 1

View File

@ -24,9 +24,7 @@ import subprocess
import tractor
from piker.log import get_logger
log = get_logger(__name__)
from .._util import log
_reset_tech: Literal[

View File

@ -68,12 +68,10 @@ import numpy as np
from piker import config
from piker.log import get_logger
from piker.brokers._util import log
from piker.data._source import base_ohlc_dtype
log = get_logger(__name__)
_time_units = {
's': ' sec',
'm': ' mins',

View File

@ -43,10 +43,13 @@ from ..calc import humanize, percent_change
from .._cacheables import open_cached_client, async_lifo_cache
from .. import config
from ._util import resproc, BrokerError, SymbolNotFound
from ..log import get_logger, colorize_json, get_console_log
log = get_logger(__name__)
from ..log import (
colorize_json,
)
from .util import (
log,
get_console_log,
)
_use_practice_account = False
_refresh_token_ep = 'https://{}login.questrade.com/oauth2/'

View File

@ -27,12 +27,13 @@ from typing import List
from async_generator import asynccontextmanager
import asks
from ..log import get_logger
from ._util import resproc, BrokerError
from ._util import (
resproc,
BrokerError,
log,
)
from ..calc import percent_change
log = get_logger(__name__)
_service_ep = 'https://api.robinhood.com'
@ -65,8 +66,10 @@ class Client:
self.api = _API(self._sess)
def _zip_in_order(self, symbols: [str], quotes: List[dict]):
return {quote.get('symbol', sym) if quote else sym: quote
for sym, quote in zip(symbols, results_dict)}
return {
quote.get('symbol', sym) if quote else sym: quote
for sym, quote in zip(symbols, quotes)
}
async def quote(self, symbols: [str]):
"""Retrieve quotes for a list of ``symbols``.