barmerge

The barmerge namespace provides constants that control how data requested via request.security() is merged with the current chart’s bar data. Two independent concerns are covered: gap-filling behavior (gaps_off / gaps_on) and bar alignment by open vs. close time (lookahead_off / lookahead_on).

Quick Example

from pynecore.lib import close, high, low, open, bar_index, script, request, barmerge

@script.indicator(title="HTF Close", overlay=True)
def main():
    htf_close: float = request.security(
        "NASDAQ:AAPL",
        "D",
        close,
        gaps=barmerge.gaps_off,
        lookahead=barmerge.lookahead_off
    )

Constants

ConstantDescription
barmerge.gaps_offContinuous merge — gaps are filled with the most recent available value. No na values are introduced.
barmerge.gaps_onMerge with gaps — missing bars are left as na.
barmerge.lookahead_offBars are aligned by close time. The requested value becomes available only after the bar closes.
barmerge.lookahead_onBars are aligned by open time. The requested value is available at the start of the current bar.

Compatibility

  • barmerge.gaps_off and barmerge.gaps_on are fully supported in request.security().
  • barmerge.lookahead_off is the only supported lookahead mode. barmerge.lookahead_on is defined as a constant but not supported at runtime — PyneCore deliberately disables lookahead to prevent future-leak in backtests.