From 543c11f377bbda8fad878216de30d80fd8cd42c3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 1 Oct 2023 19:14:08 -0400 Subject: [PATCH] ib: only normalize and log first quote if it arrives --- piker/brokers/ib/api.py | 4 +++- piker/brokers/ib/feed.py | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/piker/brokers/ib/api.py b/piker/brokers/ib/api.py index cc0ad051..6ff44e6d 100644 --- a/piker/brokers/ib/api.py +++ b/piker/brokers/ib/api.py @@ -1000,7 +1000,9 @@ _scan_ignore: set[tuple[str, int]] = set() def get_config() -> dict[str, Any]: - conf, path = config.load('brokers') + conf, path = config.load( + conf_name='brokers', + ) section = conf.get('ib') accounts = section.get('accounts') diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index 44e3af2a..6ef6e915 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -25,6 +25,7 @@ from contextlib import ( from dataclasses import asdict from datetime import datetime from functools import partial +from pprint import pformat from math import isnan import time from typing import ( @@ -836,9 +837,12 @@ async def stream_quotes( con: Contract = details.contract first_ticker: Ticker = await proxy.get_quote(contract=con) - first_quote: dict = normalize(first_ticker) - - log.warning(f'FIRST QUOTE: {first_quote}') + if first_ticker: + first_quote: dict = normalize(first_ticker) + log.info( + 'Rxed init quote:\n' + f'{pformat(first_quote)}' + ) # TODO: we should instead spawn a task that waits on a feed to start # and let it wait indefinitely..instead of this hard coded stuff. @@ -858,7 +862,10 @@ async def stream_quotes( 'crypto', } ): - task_status.started((init_msgs, first_quote)) + task_status.started(( + init_msgs, + first_quote, + )) # it's not really live but this will unblock # the brokerd feed task to tell the ui to update? @@ -889,7 +896,10 @@ async def stream_quotes( # only on first entry at feed boot up if startup: startup = False - task_status.started((init_msgs, first_quote)) + task_status.started(( + init_msgs, + first_quote, + )) # start a stream restarter task which monitors the # data feed event.