Port all to use new cursor and ohlc refs
parent
b6eeed1ae0
commit
8b966cd7e4
|
@ -133,7 +133,7 @@ class DynamicDateAxis(Axis):
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
chart = self.linkedsplits.chart
|
chart = self.linkedsplits.chart
|
||||||
bars = chart._ohlc
|
bars = chart._arrays['ohlc']
|
||||||
shm = self.linkedsplits.chart._shm
|
shm = self.linkedsplits.chart._shm
|
||||||
first = shm._first.value
|
first = shm._first.value
|
||||||
|
|
||||||
|
@ -232,7 +232,6 @@ class AxisLabel(pg.GraphicsObject):
|
||||||
p.setPen(self.fg_color)
|
p.setPen(self.fg_color)
|
||||||
p.drawText(self.rect, self.text_flags, self.label_str)
|
p.drawText(self.rect, self.text_flags, self.label_str)
|
||||||
|
|
||||||
|
|
||||||
def draw(
|
def draw(
|
||||||
self,
|
self,
|
||||||
p: QtGui.QPainter,
|
p: QtGui.QPainter,
|
||||||
|
@ -250,9 +249,9 @@ class AxisLabel(pg.GraphicsObject):
|
||||||
# reason; ok by us
|
# reason; ok by us
|
||||||
p.setOpacity(self.opacity)
|
p.setOpacity(self.opacity)
|
||||||
|
|
||||||
# this cause the L1 labels to glitch out if used
|
# this cause the L1 labels to glitch out if used in the subtype
|
||||||
# in the subtype and it will leave a small black strip
|
# and it will leave a small black strip with the arrow path if
|
||||||
# with the arrow path if done before the above
|
# done before the above
|
||||||
p.fillRect(self.rect, self.bg_color)
|
p.fillRect(self.rect, self.bg_color)
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,8 +294,8 @@ class AxisLabel(pg.GraphicsObject):
|
||||||
|
|
||||||
self.rect = QtCore.QRectF(
|
self.rect = QtCore.QRectF(
|
||||||
0, 0,
|
0, 0,
|
||||||
(w or txt_w) + self._x_margin /2,
|
(w or txt_w) + self._x_margin / 2,
|
||||||
(h or txt_h) + self._y_margin /2,
|
(h or txt_h) + self._y_margin / 2,
|
||||||
)
|
)
|
||||||
# print(self.rect)
|
# print(self.rect)
|
||||||
# hb = self.path.controlPointRect()
|
# hb = self.path.controlPointRect()
|
||||||
|
|
|
@ -111,12 +111,12 @@ class LineEditor:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# chart.setCursor(QtCore.Qt.PointingHandCursor)
|
# chart.setCursor(QtCore.Qt.PointingHandCursor)
|
||||||
if not self.chart._cursor:
|
cursor = self.chart.linked.cursor
|
||||||
|
if not cursor:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
chart = self.chart._cursor.active_plot
|
chart = cursor.active_plot
|
||||||
cursor = chart._cursor
|
y = cursor._datum_xy[1]
|
||||||
y = chart._cursor._datum_xy[1]
|
|
||||||
|
|
||||||
symbol = chart._lc.symbol
|
symbol = chart._lc.symbol
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ class LineEditor:
|
||||||
"""
|
"""
|
||||||
# chart = self.chart._cursor.active_plot
|
# chart = self.chart._cursor.active_plot
|
||||||
# # chart.setCursor(QtCore.Qt.ArrowCursor)
|
# # chart.setCursor(QtCore.Qt.ArrowCursor)
|
||||||
cursor = self.chart._cursor
|
cursor = self.chart.linked.cursor
|
||||||
|
|
||||||
# delete "staged" cursor tracking line from view
|
# delete "staged" cursor tracking line from view
|
||||||
line = self._active_staged_line
|
line = self._active_staged_line
|
||||||
|
@ -251,7 +251,7 @@ class LineEditor:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Delete any hoverable under the cursor
|
# Delete any hoverable under the cursor
|
||||||
return self.chart._cursor._hovered
|
return self.chart.linked.cursor._hovered
|
||||||
|
|
||||||
def all_lines(self) -> tuple[LevelLine]:
|
def all_lines(self) -> tuple[LevelLine]:
|
||||||
return tuple(self._order_lines.values())
|
return tuple(self._order_lines.values())
|
||||||
|
@ -275,13 +275,14 @@ class LineEditor:
|
||||||
if line:
|
if line:
|
||||||
|
|
||||||
# if hovered remove from cursor set
|
# if hovered remove from cursor set
|
||||||
hovered = self.chart._cursor._hovered
|
cursor = self.chart.linked.cursor
|
||||||
|
hovered = cursor._hovered
|
||||||
if line in hovered:
|
if line in hovered:
|
||||||
hovered.remove(line)
|
hovered.remove(line)
|
||||||
|
|
||||||
# make sure the xhair doesn't get left off
|
# make sure the xhair doesn't get left off
|
||||||
# just because we never got a un-hover event
|
# just because we never got a un-hover event
|
||||||
self.chart._cursor.show_xhair()
|
cursor.show_xhair()
|
||||||
|
|
||||||
line.delete()
|
line.delete()
|
||||||
return line
|
return line
|
||||||
|
@ -411,7 +412,7 @@ class SelectRect(QtGui.QGraphicsRectItem):
|
||||||
ixmn, ixmx = round(xmn), round(xmx)
|
ixmn, ixmx = round(xmn), round(xmx)
|
||||||
nbars = ixmx - ixmn + 1
|
nbars = ixmx - ixmn + 1
|
||||||
|
|
||||||
data = self._chart._ohlc[ixmn:ixmx]
|
data = self._chart._arrays['ohlc'][ixmn:ixmx]
|
||||||
|
|
||||||
if len(data):
|
if len(data):
|
||||||
std = data['close'].std()
|
std = data['close'].std()
|
||||||
|
|
|
@ -259,10 +259,10 @@ class LevelLine(pg.InfiniteLine):
|
||||||
detailed control and start end signalling.
|
detailed control and start end signalling.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
chart = self._chart
|
cursor = self._chart.linked.cursor
|
||||||
|
|
||||||
# hide y-crosshair
|
# hide y-crosshair
|
||||||
chart._cursor.hide_xhair()
|
cursor.hide_xhair()
|
||||||
|
|
||||||
# highlight
|
# highlight
|
||||||
self.currentPen = self.hoverPen
|
self.currentPen = self.hoverPen
|
||||||
|
@ -308,7 +308,7 @@ class LevelLine(pg.InfiniteLine):
|
||||||
# This is the final position in the drag
|
# This is the final position in the drag
|
||||||
if ev.isFinish():
|
if ev.isFinish():
|
||||||
# show y-crosshair again
|
# show y-crosshair again
|
||||||
chart._cursor.show_xhair()
|
cursor.show_xhair()
|
||||||
|
|
||||||
def delete(self) -> None:
|
def delete(self) -> None:
|
||||||
"""Remove this line from containing chart/view/scene.
|
"""Remove this line from containing chart/view/scene.
|
||||||
|
@ -326,7 +326,7 @@ class LevelLine(pg.InfiniteLine):
|
||||||
|
|
||||||
# remove from chart/cursor states
|
# remove from chart/cursor states
|
||||||
chart = self._chart
|
chart = self._chart
|
||||||
cur = chart._cursor
|
cur = chart.linked.cursor
|
||||||
|
|
||||||
if self in cur._hovered:
|
if self in cur._hovered:
|
||||||
cur._hovered.remove(self)
|
cur._hovered.remove(self)
|
||||||
|
@ -457,8 +457,7 @@ class LevelLine(pg.InfiniteLine):
|
||||||
"""Mouse hover callback.
|
"""Mouse hover callback.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
chart = self._chart
|
cur = self._chart.linked.cursor
|
||||||
cur = chart._cursor
|
|
||||||
|
|
||||||
# hovered
|
# hovered
|
||||||
if (not ev.isExit()) and ev.acceptDrags(QtCore.Qt.LeftButton):
|
if (not ev.isExit()) and ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||||
|
@ -648,7 +647,10 @@ def order_line(
|
||||||
# use ``QPathGraphicsItem``s to draw markers in scene coords
|
# use ``QPathGraphicsItem``s to draw markers in scene coords
|
||||||
# instead of the old way that was doing the same but by
|
# instead of the old way that was doing the same but by
|
||||||
# resetting the graphics item transform intermittently
|
# resetting the graphics item transform intermittently
|
||||||
|
|
||||||
|
# XXX: this is our new approach but seems slower?
|
||||||
# line.add_marker(mk_marker(marker_style, marker_size))
|
# line.add_marker(mk_marker(marker_style, marker_size))
|
||||||
|
|
||||||
assert not line.markers
|
assert not line.markers
|
||||||
|
|
||||||
# the old way which is still somehow faster?
|
# the old way which is still somehow faster?
|
||||||
|
@ -659,7 +661,10 @@ def order_line(
|
||||||
marker_size,
|
marker_size,
|
||||||
use_qgpath=False,
|
use_qgpath=False,
|
||||||
)
|
)
|
||||||
# manually append for later ``.pain()`` drawing
|
# manually append for later ``InfiniteLine.paint()`` drawing
|
||||||
|
# XXX: this was manually tested as faster then using the
|
||||||
|
# QGraphicsItem around a painter path.. probably needs further
|
||||||
|
# testing to figure out why tf that's true.
|
||||||
line.markers.append((path, 0, marker_size))
|
line.markers.append((path, 0, marker_size))
|
||||||
|
|
||||||
orient_v = 'top' if action == 'sell' else 'bottom'
|
orient_v = 'top' if action == 'sell' else 'bottom'
|
||||||
|
@ -754,9 +759,29 @@ def position_line(
|
||||||
ymn, ymx = vr[1]
|
ymn, ymx = vr[1]
|
||||||
level = line.value()
|
level = line.value()
|
||||||
|
|
||||||
if level > ymx or level < ymn:
|
if gt := level > ymx or (lt := level < ymn):
|
||||||
line._marker.hide()
|
|
||||||
|
if chartview.mode.name == 'order':
|
||||||
|
|
||||||
|
# provide "nav hub" like indicator for where
|
||||||
|
# the position is on the y-dimension
|
||||||
|
if gt:
|
||||||
|
# pin to top of view since position is above current
|
||||||
|
# y-range
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif lt:
|
||||||
|
# pin to bottom of view since position is above
|
||||||
|
# below y-range
|
||||||
|
pass
|
||||||
|
|
||||||
|
else:
|
||||||
|
# order mode is not active
|
||||||
|
# so hide the pp market
|
||||||
|
line._marker.hide()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
# pp line is viewable so show marker
|
||||||
line._marker.show()
|
line._marker.show()
|
||||||
|
|
||||||
vb.sigYRangeChanged.connect(update_pp_nav)
|
vb.sigYRangeChanged.connect(update_pp_nav)
|
||||||
|
@ -787,6 +812,7 @@ def position_line(
|
||||||
style = '>|'
|
style = '>|'
|
||||||
|
|
||||||
arrow_path = mk_marker(style, size=arrow_size)
|
arrow_path = mk_marker(style, size=arrow_size)
|
||||||
|
# XXX: uses new marker drawing approach
|
||||||
line.add_marker(arrow_path)
|
line.add_marker(arrow_path)
|
||||||
line.set_level(level)
|
line.set_level(level)
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ async def handle_viewmode_inputs(
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
mode = view.mode
|
mode = view.mode
|
||||||
status_bar = main_window().status_bar
|
|
||||||
|
|
||||||
# track edge triggered keys
|
# track edge triggered keys
|
||||||
# (https://en.wikipedia.org/wiki/Interrupt#Triggering_methods)
|
# (https://en.wikipedia.org/wiki/Interrupt#Triggering_methods)
|
||||||
|
@ -148,6 +147,14 @@ async def handle_viewmode_inputs(
|
||||||
if key in pressed:
|
if key in pressed:
|
||||||
pressed.remove(key)
|
pressed.remove(key)
|
||||||
|
|
||||||
|
# QUERY MODE #
|
||||||
|
if {Qt.Key_Q}.intersection(pressed):
|
||||||
|
|
||||||
|
view.linkedsplits.cursor.in_query_mode = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
view.linkedsplits.cursor.in_query_mode = False
|
||||||
|
|
||||||
# SELECTION MODE #
|
# SELECTION MODE #
|
||||||
|
|
||||||
if shift:
|
if shift:
|
||||||
|
@ -297,7 +304,7 @@ class ChartView(ViewBox):
|
||||||
log.debug("Max zoom bruh...")
|
log.debug("Max zoom bruh...")
|
||||||
return
|
return
|
||||||
|
|
||||||
if ev.delta() < 0 and vl >= len(chart._ohlc) + 666:
|
if ev.delta() < 0 and vl >= len(chart._arrays['ohlc']) + 666:
|
||||||
log.debug("Min zoom bruh...")
|
log.debug("Min zoom bruh...")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ class OrderMode:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# not initialized yet
|
# not initialized yet
|
||||||
if not self.chart._cursor:
|
if not self.chart.linked.cursor:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._action = action
|
self._action = action
|
||||||
|
@ -210,7 +210,7 @@ class OrderMode:
|
||||||
|
|
||||||
if msg is not None:
|
if msg is not None:
|
||||||
self.lines.remove_line(uuid=uuid)
|
self.lines.remove_line(uuid=uuid)
|
||||||
self.chart._cursor.show_xhair()
|
self.chart.linked.cursor.show_xhair()
|
||||||
|
|
||||||
pending = self._pending_submissions.pop(uuid, None)
|
pending = self._pending_submissions.pop(uuid, None)
|
||||||
if pending:
|
if pending:
|
||||||
|
@ -238,8 +238,9 @@ class OrderMode:
|
||||||
|
|
||||||
size = size or self._size
|
size = size or self._size
|
||||||
|
|
||||||
chart = self.chart._cursor.active_plot
|
cursor = self.chart.linked.cursor
|
||||||
y = chart._cursor._datum_xy[1]
|
chart = cursor.active_plot
|
||||||
|
y = cursor._datum_xy[1]
|
||||||
|
|
||||||
symbol = self.chart._lc._symbol
|
symbol = self.chart._lc._symbol
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue