Profile and Candle Bridge
Composite ATK bridge visuals — candlestick bundles, horizontal_bar profiles, and dual_horizontal_bar_fixed overlays in a single render-only stage.
Profile and Candle Bridge: Composite Visuals Done the Safe Way#
One of the newer examples in the source tree combines three different ATK bridge renderers in a single render-only stage: a compact candle bundle, a horizontal profile, and a dual-profile overlay. This is the pattern to study when one visual idea naturally resolves into a grouped payload instead of one plot or one object.
def build_visuals(frame, params=None, ctx=None):
payload = dict(frame.attrs.get("visual_profile_payload") or {})
tail = frame.tail(int(payload.get("tail_size") or 4)).reset_index(drop=True)
if tail.empty:
return []
last_index = float(tail.iloc[-1]["index"])
y_levels = [float(value) for value in tail["close"].tolist()]
return [
ctx.atk.candlestick(
key="atk_sub_candles",
x=[float(value) for value in tail["index"].tolist()],
open=[float(value) for value in tail["open"].tolist()],
high=[float(value) for value in tail["high"].tolist()],
low=[float(value) for value in tail["low"].tolist()],
close=[float(value) for value in tail["close"].tolist()],
),
ctx.atk.horizontal_bar(
key="atk_horizontal_profile",
x=last_index + 4.0,
y=y_levels,
**dict(payload.get("horizontal_bar") or {}),
),
ctx.atk.dual_horizontal_bar_fixed(
key="atk_dual_profile",
xData=last_index + 8.0,
yData=y_levels,
**dict(payload.get("dual_horizontal_bar_fixed") or {}),
),
]Key patterns in this example#
-
frame.attrscarries the static payload config (tail size, profile options) set inbuild_indicator_frame. -
Coordinates (
last_index,y_levels) are derived from the live frame slice, not from attrs. -
The function returns a list — multiple bridge intents are valid from one
build_visualscall. -
All three renderers share a single render pass with no TA computation.