Return xy data from `Curve.draw_last_datum()` methods
parent
a66934a49d
commit
e5f96391e3
|
@ -383,17 +383,16 @@ class Curve(pg.GraphicsObject):
|
||||||
x = render_data['index']
|
x = render_data['index']
|
||||||
y = render_data[array_key]
|
y = render_data[array_key]
|
||||||
|
|
||||||
x_last = x[-1]
|
|
||||||
y_last = y[-1]
|
|
||||||
|
|
||||||
# draw the "current" step graphic segment so it
|
# draw the "current" step graphic segment so it
|
||||||
# lines up with the "middle" of the current
|
# lines up with the "middle" of the current
|
||||||
# (OHLC) sample.
|
# (OHLC) sample.
|
||||||
self._last_line = QLineF(
|
self._last_line = QLineF(
|
||||||
x[-2], y[-2],
|
x[-2], y[-2],
|
||||||
x_last, y_last
|
x[-1], y[-1],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return x, y
|
||||||
|
|
||||||
|
|
||||||
# TODO: this should probably be a "downsampled" curve type
|
# TODO: this should probably be a "downsampled" curve type
|
||||||
# that draws a bar-style (but for the px column) last graphics
|
# that draws a bar-style (but for the px column) last graphics
|
||||||
|
@ -421,6 +420,7 @@ class FlattenedOHLC(Curve):
|
||||||
x[-2], y[-2],
|
x[-2], y[-2],
|
||||||
x[-1], y[-1]
|
x[-1], y[-1]
|
||||||
)
|
)
|
||||||
|
return x, y
|
||||||
|
|
||||||
|
|
||||||
class StepCurve(Curve):
|
class StepCurve(Curve):
|
||||||
|
@ -461,6 +461,7 @@ class StepCurve(Curve):
|
||||||
x_last - w, 0,
|
x_last - w, 0,
|
||||||
x_last + w, y_last,
|
x_last + w, y_last,
|
||||||
)
|
)
|
||||||
|
return x, y
|
||||||
|
|
||||||
def sub_paint(
|
def sub_paint(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -200,16 +200,26 @@ class BarItems(pg.GraphicsObject):
|
||||||
reset: bool,
|
reset: bool,
|
||||||
array_key: str,
|
array_key: str,
|
||||||
|
|
||||||
|
fields: list[str] = [
|
||||||
|
'index',
|
||||||
|
'open',
|
||||||
|
'high',
|
||||||
|
'low',
|
||||||
|
'close',
|
||||||
|
],
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
last = src_data[-1]
|
|
||||||
|
# relevant fields
|
||||||
|
ohlc = src_data[fields]
|
||||||
|
last_row = ohlc[-1:]
|
||||||
|
|
||||||
|
# individual values
|
||||||
|
last_row = i, o, h, l, last = ohlc[-1]
|
||||||
|
|
||||||
# generate new lines objects for updatable "current bar"
|
# generate new lines objects for updatable "current bar"
|
||||||
self._last_bar_lines = bar_from_ohlc_row(last)
|
self._last_bar_lines = bar_from_ohlc_row(last_row)
|
||||||
|
|
||||||
# last bar update
|
|
||||||
i, o, h, l, last, v = last[
|
|
||||||
['index', 'open', 'high', 'low', 'close', 'volume']
|
|
||||||
]
|
|
||||||
# assert i == graphics.start_index - 1
|
# assert i == graphics.start_index - 1
|
||||||
# assert i == last_index
|
# assert i == last_index
|
||||||
body, larm, rarm = self._last_bar_lines
|
body, larm, rarm = self._last_bar_lines
|
||||||
|
@ -236,3 +246,5 @@ class BarItems(pg.GraphicsObject):
|
||||||
# removal of the body for a bar index that is now out of
|
# removal of the body for a bar index that is now out of
|
||||||
# date / from some previous sample. It's weird though
|
# date / from some previous sample. It's weird though
|
||||||
# because i've seen it do this to bars i - 3 back?
|
# because i've seen it do this to bars i - 3 back?
|
||||||
|
|
||||||
|
return ohlc['index'], ohlc['close']
|
||||||
|
|
Loading…
Reference in New Issue