From 82a5daf91bef8ddc0f9eaef5d56f35267b9abc35 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 17 Jun 2020 14:51:29 -0400 Subject: [PATCH] Move all kivy ui components to subpackage --- piker/brokers/questrade.py | 8 +++++++- piker/ui/{ => kivy}/monitor.py | 4 ++-- piker/ui/kivy/mouse_over.py | 4 ++-- piker/ui/{ => kivy}/option_chain.py | 7 +++---- piker/ui/{ => kivy}/pager.py | 4 ++-- piker/ui/{ => kivy}/tabular.py | 4 ++-- 6 files changed, 18 insertions(+), 13 deletions(-) rename piker/ui/{ => kivy}/monitor.py (99%) rename piker/ui/{ => kivy}/option_chain.py (99%) rename piker/ui/{ => kivy}/pager.py (99%) rename piker/ui/{ => kivy}/tabular.py (99%) diff --git a/piker/brokers/questrade.py b/piker/brokers/questrade.py index 58b31fcf..f3708d3f 100644 --- a/piker/brokers/questrade.py +++ b/piker/brokers/questrade.py @@ -989,13 +989,19 @@ def format_option_quote( # change = percent_change(previous, last) computed = { # why QT do you have to be an asshole shipping null values!!! - '$ vol': round((quote['VWAP'] or 0) * (quote['volume'] or 0), 3), + # '$ vol': round((quote['VWAP'] or 0) * (quote['volume'] or 0), 3), # '%': round(change, 3), # 'close': previous, } new = {} displayable = {} + vwap = quote.get('VWAP') + volume = quote.get('volume') + if volume is not None: # could be 0 + # why questrade do you have to be an asshole shipping null values!!! + computed['$ vol'] = round((vwap or 0) * (volume or 0), 3) + # structuring and normalization for key, new_key in keymap.items(): display_value = value = computed.get(key) or quote.get(key) diff --git a/piker/ui/monitor.py b/piker/ui/kivy/monitor.py similarity index 99% rename from piker/ui/monitor.py rename to piker/ui/kivy/monitor.py index cd73c3fa..932b581e 100644 --- a/piker/ui/monitor.py +++ b/piker/ui/kivy/monitor.py @@ -15,11 +15,11 @@ from kivy.lang import Builder from kivy.app import async_runTouchApp from kivy.core.window import Window -from ..brokers.data import DataFeed +from ...brokers.data import DataFeed from .tabular import ( Row, TickerTable, _kv, _black_rgba, colorcode, ) -from ..log import get_logger +from ...log import get_logger from .pager import PagerView diff --git a/piker/ui/kivy/mouse_over.py b/piker/ui/kivy/mouse_over.py index c9ad149b..766371cd 100644 --- a/piker/ui/kivy/mouse_over.py +++ b/piker/ui/kivy/mouse_over.py @@ -11,7 +11,6 @@ from kivy.properties import BooleanProperty, ObjectProperty from kivy.core.window import Window from kivy.clock import Clock - from ...log import get_logger @@ -100,7 +99,8 @@ class MouseOverBehavior(object): # throttle at 10ms latency @triggered(timeout=0.01, interval=False) def _on_mouse_pos(cls, *args): - log.debug(f"{cls} time since last call: {time.time() - cls._last_time}") + log.debug( + f"{cls} time since last call: {time.time() - cls._last_time}") cls._last_time = time.time() # XXX: how to still do this at the class level? # don't proceed if I'm not displayed <=> If have no parent diff --git a/piker/ui/option_chain.py b/piker/ui/kivy/option_chain.py similarity index 99% rename from piker/ui/option_chain.py rename to piker/ui/kivy/option_chain.py index e2421103..cfa0e665 100644 --- a/piker/ui/option_chain.py +++ b/piker/ui/kivy/option_chain.py @@ -15,11 +15,10 @@ from kivy.app import async_runTouchApp from kivy.core.window import Window from kivy.uix.label import Label -from ..log import get_logger, get_console_log -from ..brokers.data import DataFeed -from ..brokers import get_brokermod +from ...log import get_logger, get_console_log +from ...brokers.data import DataFeed +from ...brokers import get_brokermod from .pager import PagerView - from .tabular import Row, HeaderCell, Cell, TickerTable from .monitor import update_quotes diff --git a/piker/ui/pager.py b/piker/ui/kivy/pager.py similarity index 99% rename from piker/ui/pager.py rename to piker/ui/kivy/pager.py index ca17935b..20a8baef 100644 --- a/piker/ui/pager.py +++ b/piker/ui/kivy/pager.py @@ -9,8 +9,8 @@ from kivy.uix.widget import Widget from kivy.uix.textinput import TextInput from kivy.uix.scrollview import ScrollView -from ..log import get_logger -from .kivy.utils_async import async_bind +from ...log import get_logger +from .utils_async import async_bind log = get_logger('keyboard') diff --git a/piker/ui/tabular.py b/piker/ui/kivy/tabular.py similarity index 99% rename from piker/ui/tabular.py rename to piker/ui/kivy/tabular.py index 27c1e091..5a5a6b3a 100644 --- a/piker/ui/tabular.py +++ b/piker/ui/kivy/tabular.py @@ -12,8 +12,8 @@ from kivy.uix.button import Button from kivy import utils from kivy.properties import BooleanProperty -from ..log import get_logger -from .kivy.mouse_over import new_mouse_over_group +from ...log import get_logger +from .mouse_over import new_mouse_over_group HoverBehavior = new_mouse_over_group()