v6.5.7
What's Changed
This release focuses on TradingView-parity fixes in the strategy broker emulator and a request.security() correctness fix for helper functions called from multiple sites.
Fixes
-
request.security()per-call-site instantiation — In Pine every call of a user function is a separate instance, so arequest.security()inside a helper called from N sites is N distinct data requests. PyneCore previously allocated a singlesec_idper syntacticrequest.security()call and bound it to the first call site's symbol/timeframe, silently sharing that binding across all call sites. A newSecurityInstantiationTransformernow clones any security-bearing function (directly or transitively) per direct-name call site, so a freshsec_idis allocated per call site. Recursion, decorators, aliases, shadowing and attribute calls fall back to the shared-context behavior. -
Strategy order book — reused price level dropped —
PriceOrderBook.orders_at_pricewas adefaultdict(list), so a stale read duringiter_orderscould resurrect an empty bucket. That orphan key then shadowed the price inadd_order, whose insert guard checked the bucket map instead ofprice_levels, so a later order reusing that exact price never got its level inserted and silently vanished from the intrabar walk. Switched to a plain dict, gated level insertion onprice_levelsitself, and hardenedremove_orderagainst absent buckets. -
Same-bar reversing entry over-margin gate — A same-bar opposite
strategy.entrythat would reverse a position opened earlier in the same bar-open cycle is now margined on both legs at once, matching TradingView: the closing leg's margin is not freed before the opening leg is gated, so the reversing entry is rejected (the first entry is kept) when old + new margin exceeds equity. Prior-bar reversals are unaffected and keep the normal net-margin check. Verified against live TradingView probes onBINANCE:BTCUSDT. -
Sub-1e7 money-tick entry snap grid band — Generalized the sub-1e7 market-entry snap-up in
_judge_money_entryfrom a single hardcoded 0.05 grid to a scale-dependent grid selected per cost band, adding a 0.005 grid on[1.2e7, 1.3e7]cost ticks alongside the existing 0.05 grid on[1e8, 1.16e8]. Outside the mapped bands the plain floor stands, unchanged.
Full Changelog: v6.5.6...v6.5.7