Skip to content

AST transformer rewrites barstate.isconfirmed as a call, but historical-mode subprocess assigns it as a literal True → TypeError: 'bool' object is not callable #53

@Zombajo

Description

@Zombajo

Summary

Filing as a follow-up to #49 (which you closed as not-a-bug because the request.security subprocess is historical-only by design). Agreed on that design intent — but the AST transformer rewrites every barstate.isconfirmed reference into a property call, and the historical-mode subprocess assigns the literal True to that name. The two are incompatible: any compiled strategy that references barstate.isconfirmed inside a code path reachable from the subprocess crashes with:

TypeError: 'bool' object is not callable

This is internal PyneCore behavior (AST transformer ↔ historical-mode subprocess) rather than a TV-divergence issue, which is why it deserves its own report.

Reproduction

Any compiled strategy that uses barstate.isconfirmed and also calls request.security will crash on the first subprocess iteration. Minimal Pine source:

//@version=6
strategy("isconfirmed_subprocess_crash")
htf_close = request.security(syminfo.tickerid, "60", close)
if barstate.isconfirmed
    strategy.entry("L", strategy.long)

Compile with PyneSys, run on any data. Expected: strategy evaluates barstate.isconfirmed correctly inside the subprocess. Observed: TypeError: 'bool' object is not callable on the first subprocess bar.

Suspected cause

The AST transformer (likely in the compile pipeline that PyneSys produces) rewrites barstate.isconfirmed into a property / method call site. The historical-mode subprocess module (around core/security_process.py:150-160 in our v6.4.5 install) assigns the literal True to that name in the subprocess namespace. Literal True isn't callable, so the rewritten call crashes.

Proposed fix direction

Either:

  • The historical-mode subprocess assigns a callable wrapper (e.g., a lambda: True or a property descriptor) instead of the literal, OR
  • The AST transformer detects historical-mode subprocess context and doesn't rewrite barstate.isconfirmed into a call there.

We've been running with a local patch at security_process.py:150-160 that swaps the literal for a callable _isconfirmed_true marker. With the patch removed (per your #49 verdict), our test pipeline crashes immediately on the first subprocess bar regardless of strategy logic.

Environment

  • PyneCore version: pynesys-pynecore 6.4.5
  • Python: 3.13.7
  • OS: Windows 11

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions