Skip to content

v6.5.7

Choose a tag to compare

@wallneradam wallneradam released this 10 Jul 17:19
· 442 commits to main since this release

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 a request.security() inside a helper called from N sites is N distinct data requests. PyneCore previously allocated a single sec_id per syntactic request.security() call and bound it to the first call site's symbol/timeframe, silently sharing that binding across all call sites. A new SecurityInstantiationTransformer now clones any security-bearing function (directly or transitively) per direct-name call site, so a fresh sec_id is allocated per call site. Recursion, decorators, aliases, shadowing and attribute calls fall back to the shared-context behavior.

  • Strategy order book — reused price level droppedPriceOrderBook.orders_at_price was a defaultdict(list), so a stale read during iter_orders could resurrect an empty bucket. That orphan key then shadowed the price in add_order, whose insert guard checked the bucket map instead of price_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 on price_levels itself, and hardened remove_order against absent buckets.

  • Same-bar reversing entry over-margin gate — A same-bar opposite strategy.entry that 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 on BINANCE:BTCUSDT.

  • Sub-1e7 money-tick entry snap grid band — Generalized the sub-1e7 market-entry snap-up in _judge_money_entry from 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