Use step size to determine bar gaps
parent
02ce03c191
commit
5648210710
|
@ -98,6 +98,16 @@ class IncrementalFormatter(msgspec.Struct):
|
||||||
_last_vr: tuple[float, float] | None = None
|
_last_vr: tuple[float, float] | None = None
|
||||||
_last_ivdr: tuple[float, float] | None = None
|
_last_ivdr: tuple[float, float] | None = None
|
||||||
|
|
||||||
|
_index_step_size: float = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def index_step_size(self) -> float:
|
||||||
|
'''
|
||||||
|
Readonly value computed on first ``.diff()`` call.
|
||||||
|
|
||||||
|
'''
|
||||||
|
return self._index_step_size
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
msg = (
|
msg = (
|
||||||
f'{type(self)}: ->\n\n'
|
f'{type(self)}: ->\n\n'
|
||||||
|
@ -171,6 +181,9 @@ class IncrementalFormatter(msgspec.Struct):
|
||||||
# set us in a zero-to-append state
|
# set us in a zero-to-append state
|
||||||
nd_stop = self.xy_nd_stop = src_stop
|
nd_stop = self.xy_nd_stop = src_stop
|
||||||
|
|
||||||
|
align_index = array[self.index_field]
|
||||||
|
self._index_step_size = align_index[-1] - align_index[-2]
|
||||||
|
|
||||||
# compute the length diffs between the first/last index entry in
|
# compute the length diffs between the first/last index entry in
|
||||||
# the input data and the last indexes we have on record from the
|
# the input data and the last indexes we have on record from the
|
||||||
# last time we updated the curve index.
|
# last time we updated the curve index.
|
||||||
|
@ -556,8 +569,7 @@ class OHLCBarsFmtr(IncrementalFormatter):
|
||||||
x, y, c = path_arrays_from_ohlc(
|
x, y, c = path_arrays_from_ohlc(
|
||||||
array,
|
array,
|
||||||
start,
|
start,
|
||||||
# self.index_field,
|
bar_gap=w * self.index_step_size,
|
||||||
bar_gap=w,
|
|
||||||
)
|
)
|
||||||
return x, y, c
|
return x, y, c
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue