Add optional mxmn HL tracer support to m4 sampler

big_data_lines
Tyler Goodlet 2022-03-23 17:29:28 -04:00
parent 1abe513ecb
commit 88a7314bd0
1 changed files with 19 additions and 10 deletions

View File

@ -185,14 +185,19 @@ def ohlc_to_m4_line(
ohlc: np.ndarray,
px_width: int,
downsample: bool = False,
uppx: Optional[float] = None,
pretrace: bool = False,
) -> tuple[np.ndarray, np.ndarray]:
'''
Convert an OHLC struct-array to a m4 downsampled 1-d array.
'''
xpts, flat = ohlc_flatten(ohlc)
xpts, flat = ohlc_flatten(
ohlc,
use_mxmn=pretrace,
)
if uppx:
# optionally log-scale down the "supposed pxs on screen"
@ -208,6 +213,7 @@ def ohlc_to_m4_line(
)
px_width *= scaler
if downsample:
bins, x, y = ds_m4(
xpts,
flat,
@ -216,7 +222,10 @@ def ohlc_to_m4_line(
x = np.broadcast_to(x[:, None], y.shape)
x = (x + np.array([-0.43, 0, 0, 0.43])).flatten()
y = y.flatten()
return x, y
else:
return xpts, flat
def ds_m4(