Drop all `ChartPlotWidget._lc` remap to `.linked

ordermodepps_backup
Tyler Goodlet 2021-07-22 11:42:12 -04:00
parent ca2729d2c0
commit 5eada47cbf
5 changed files with 10 additions and 15 deletions

View File

@ -1,5 +1,5 @@
# piker: trading gear for hackers # piker: trading gear for hackers
# Copyright (C) 2018-present Tyler Goodlet (in stewardship of piker0) # Copyright (C) 2018-present Tyler Goodlet (in stewardship for piker0)
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -287,7 +287,6 @@ class LinkedSplits(QtWidgets.QWidget):
self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.splitter) self.layout.addWidget(self.splitter)
# state tracker?
self._symbol: Symbol = None self._symbol: Symbol = None
@property @property
@ -491,7 +490,6 @@ class ChartPlotWidget(pg.PlotWidget):
**kwargs **kwargs
) )
self.name = name self.name = name
self._lc = linkedsplits
self.linked = linkedsplits self.linked = linkedsplits
# scene-local placeholder for book graphics # scene-local placeholder for book graphics
@ -737,7 +735,7 @@ class ChartPlotWidget(pg.PlotWidget):
# if the sticky is for our symbol # if the sticky is for our symbol
# use the tick size precision for display # use the tick size precision for display
sym = self._lc.symbol sym = self.linked.symbol
if name == sym.key: if name == sym.key:
digits = sym.digits() digits = sym.digits()
else: else:
@ -987,7 +985,7 @@ async def chart_from_quotes(
last, volume = ohlcv.array[-1][['close', 'volume']] last, volume = ohlcv.array[-1][['close', 'volume']]
symbol = chart._lc.symbol symbol = chart.linked.symbol
l1 = L1Labels( l1 = L1Labels(
chart, chart,
@ -1005,7 +1003,7 @@ async def chart_from_quotes(
# levels this might be dark volume we need to # levels this might be dark volume we need to
# present differently? # present differently?
tick_size = chart._lc.symbol.tick_size tick_size = chart.linked.symbol.tick_size
tick_margin = 2 * tick_size tick_margin = 2 * tick_size
last_ask = last_bid = last_clear = time.time() last_ask = last_bid = last_clear = time.time()
@ -1014,7 +1012,7 @@ async def chart_from_quotes(
async for quotes in stream: async for quotes in stream:
# chart isn't actively shown so just skip render cycle # chart isn't actively shown so just skip render cycle
if chart._lc.isHidden(): if chart.linked.isHidden():
continue continue
for sym, quote in quotes.items(): for sym, quote in quotes.items():
@ -1304,7 +1302,7 @@ async def run_fsp(
value = array[fsp_func_name][-1] value = array[fsp_func_name][-1]
last_val_sticky.update_from_data(-1, value) last_val_sticky.update_from_data(-1, value)
chart._lc.focus() chart.linked.focus()
# works also for overlays in which case data is looked up from # works also for overlays in which case data is looked up from
# internal chart array set.... # internal chart array set....
@ -1339,7 +1337,7 @@ async def run_fsp(
async for value in stream: async for value in stream:
# chart isn't actively shown so just skip render cycle # chart isn't actively shown so just skip render cycle
if chart._lc.isHidden(): if chart.linked.isHidden():
continue continue
now = time.time() now = time.time()

View File

@ -119,7 +119,7 @@ class LineEditor:
chart = cursor.active_plot chart = cursor.active_plot
y = cursor._datum_xy[1] y = cursor._datum_xy[1]
symbol = chart._lc.symbol symbol = chart.linked.symbol
# add a "staged" cursor-tracking line to view # add a "staged" cursor-tracking line to view
# and cash it in a a var # and cash it in a a var
@ -199,7 +199,7 @@ class LineEditor:
if not line: if not line:
raise RuntimeError("No line is currently staged!?") raise RuntimeError("No line is currently staged!?")
sym = chart._lc.symbol sym = chart.linked.symbol
line = order_line( line = order_line(
chart, chart,

View File

@ -175,9 +175,6 @@ class Label:
assert s_xy == self.txt.pos() assert s_xy == self.txt.pos()
# def orient_on(self, h: str, v: str) -> None:
# pass
@property @property
def fmt_str(self) -> str: def fmt_str(self) -> str:
return self._fmt_str return self._fmt_str

View File

@ -119,7 +119,7 @@ class LevelLine(pg.InfiniteLine):
self._on_drag_start = lambda l: None self._on_drag_start = lambda l: None
self._on_drag_end = lambda l: None self._on_drag_end = lambda l: None
self._y_incr_mult = 1 / chart._lc._symbol.tick_size self._y_incr_mult = 1 / chart.linked.symbol.tick_size
self._right_end_sc: float = 0 self._right_end_sc: float = 0
def txt_offsets(self) -> Tuple[int, int]: def txt_offsets(self) -> Tuple[int, int]: