Make watchlist app retrieve quotes from the broker daemon
parent
73ef95f42a
commit
4898459bcd
|
@ -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 = [
|
||||
|
|
Loading…
Reference in New Issue