Skip to content

v6.5.5 — TradingView parity: strategy sizing, request.security multi-context, builtin compatibility

Choose a tag to compare

@wallneradam wallneradam released this 06 Jul 13:15
· 439 commits to main since this release

This release focuses on TradingView parity — closing strategy-sizing and request.security() multi-context edge cases — alongside several builtin/lib compatibility fixes and two robustness fixes that stop runaway CPU/memory.

Strategy / broker emulation

  • Same-direction market entries that clear their own placement-time 100%-equity check but over-margin at bar open only because an earlier same-bar entry already grew the position are now filled (both legs pass their own bar-start check, and the bar-open margin call trims the aggregate), matching TradingView. The sub-1e7 fill-margin tolerance was tightened from 7.5e-10 to 1e-11 so real overages are rejected while float noise still fills.
  • A default-sized (percent_of_equity / cash) price-based entry that re-resolves to a larger quantity at the fill price now has its no-qty bracket exit grow with it, so one exit closes the whole fill instead of stranding a sliver that surfaced as a spurious extra trade.

request.security() / multi-context correctness

  • timeframe.main_period now reports the chart's main-series timeframe inside a request.security() child. Previously it fell back to the child's own period, so a timeframe.change(timeframe.main_period) reset key (the canonical up/down-volume accumulator) reset every intrabar instead of once per chart bar.
  • Fixed three bugs blocking nested request.security() scripts: timeframe.main_period used as a security timeframe argument at module-exec time no longer crashes; string.match now translates Pine's \z regex escape to Python's \Z; and the security protocol is now injected into imported library modules, so a library that itself calls request.security() no longer raises NameError.
  • --security path resolution no longer mangles symbols containing a dot (e.g. a perpetual BINANCE:BTCUSDT.P); the dotted stem previously resolved to a non-existent .ohlcv file and aborted the run with "Security data not found".
  • last_bar_time is now anchored to the chart's final historical bar (Pine's whole-history-known semantics), with live runs still tracking the realtime bar. chart.left_visible_bar_time / right_visible_bar_time are rebased on it so right-edge viewport comparisons fire correctly.

Builtins / lib compatibility

  • array.max(id, nth) and array.min(id, nth) now accept Pine v6's optional 0-based nth rank (na elements ignored); array.max(id, 0) no longer raises a TypeError.
  • lib_math.sum (and through it ta.sma / ta.rsi / ta.mfi) now supports a varying series length (e.g. ta.sma(src, ta.barssince(cond))); a per-bar-changing window previously produced garbage. The constant-length O(1) fast path is unchanged.
  • Bare ta.vwap now works as the Pine built-in variable form (session-anchored VWAP of hlc3), not only the ta.vwap(source) function form.
  • request.footprint() now returns na (with a working not na(fp) guard and a new Footprint.total_volume() accessor) instead of raising, so footprint scripts that guard their reads keep running on data without tick-level order flow.

Robustness

  • Iterating an NA or a Series through the sequence protocol (str.join(na), list(na), tuple unpacking) no longer spins forever at 100% CPU: NA.__iter__ now raises loudly, SeriesImpl iterates newest-to-oldest and terminates, and string.repeat / string.replace guard na inputs.
  • An orphaned request.security() child process now self-terminates within ~2s when its parent is hard-killed (SIGKILL or a subprocess timeout). On macOS such an orphan previously spun at 100% CPU and pinned its OHLCV + interpreter memory, enough to exhaust RAM and freeze the host.
  • Volume is restored to feed precision on read via _round_volume, removing the ~1e-7 float32 dust that accumulated in every volume sum.