Make watchlist app retrieve quotes from the broker daemon

kivy_mainline_and_py3.8
Tyler Goodlet 2018-04-16 02:16:26 -04:00
parent 73ef95f42a
commit 4898459bcd
1 changed files with 65 additions and 67 deletions

View File

@ -7,7 +7,6 @@ Launch with ``piker watch <watchlist name>``.
"""
from itertools import chain
from types import ModuleType
from functools import partial
import trio
from kivy.uix.boxlayout import BoxLayout
@ -21,7 +20,6 @@ from kivy.core.window import Window
from ..log import get_logger
from .pager import PagerView
from ..brokers.core import poll_tickers
log = get_logger('watchlist')
@ -49,7 +47,7 @@ _kv = (f'''
#:kivy 1.10.0
<Cell>
font_size: 18
font_size: 20
# text_size: self.size
size: self.texture_size
color: {colorcode('gray')}
@ -386,17 +384,17 @@ async def _async_main(name, tickers, brokermod, rate):
This is started with cli command `piker watch`.
'''
queue = trio.Queue(1000)
# setup ticker stream
from ..brokers.core import StreamQueue
queue = StreamQueue(await trio.open_tcp_stream('127.0.0.1', 1616))
await queue.put(tickers) # initial request for symbols price streams
# get initial symbol data
async with brokermod.get_client() as client:
async with trio.open_nursery() as nursery:
# get long term data including last days close price
sd = await client.symbol_data(tickers)
nursery.start_soon(
partial(poll_tickers, client, brokermod.quoter, tickers, queue,
rate=rate)
)
async with trio.open_nursery() as nursery:
# get first quotes response
quotes = await queue.get()
first_quotes = [