Skip to content

PyneCore v6.5.6

Choose a tag to compare

@wallneradam wallneradam released this 08 Jul 15:58

This release focuses on TradingView parity: strategy margin-call and exit-leg sizing, session/date-string handling, request.* graceful degradation, cross-symbol request.security() correctness, and several series-history and rolling-ta.* fixes.

Strategy / broker emulator

  • Sub-lot margin calls now trim exactly one whole contract capped by the current position size (min(1.0, quantity)), both at the bar open and intrabar, matching TradingView (the Gaussian Channel corpus shows 43 such single-contract trims on 8+ contract positions).
  • strategy.exit qty/qty_percent legs bound to one entry are capped at the unreserved entry remainder (min(requested, init_size - sibling_reservations)), and create no order when that remainder is <= 0, matching TradingView's first-come-first-served leg reservation.
  • strategy.close/strategy.close_all(immediately=true) fills are deferred to after the script body: the position settles at the bar close but stays script-visible until the next bar, so position_size-gated plots/expressions after the close call no longer read the flat position one bar early. Exit price, P&L and cumulative stats are bit-identical; only the timing moves.
  • Below 1e7 order money, a market entry snaps up to the next lot when the raw money-tick count reaches the 0.05-tick floor cell (measured [1e8, 1.16e8] cost band); the snapped size still faces the ordinary creation-time margin check at the placement close.

request.security() / cross-symbol

  • Gap-compact a same-TF cross-symbol security child (e.g. TVC:US10Y@30 on a 24/7 BINANCE:BTCUSDT@30 chart): stateful indicators (ta.ema, ta.atr) inside the child no longer run over synthetic weekend/overnight fill bars, so indicator state freezes between real bars and forward-fills (gaps_off) / emits na (gaps_on) like TradingView.

Builtins / lib parity

  • label.set_textcolor keyword parameter renamed color -> textcolor (Pine v6 name); previously raised TypeError on the named call.
  • str.tostring second parameter renamed fmt -> format (Pine v6 name); previously named-argument calls (str.tostring(x, format=format.percent)) raised TypeError.
  • request.seed() returns na instead of raising (seed data lives in TradingView-hosted community repositories PyneCore cannot access), mirroring request.footprint().
  • request.financial() gains explicit named parameters and returns na when ignore_invalid_symbol is set, mirroring request.earnings().
  • string.format / str.tostring propagate na when the format pattern is na.
  • math.sum periodically resyncs its sliding window from the buffer so residual Kahan rounding no longer breaks TradingView-preserved identities (flat windows now sum exactly to n*v).
  • array.covariance uses the Welford online co-moment to match TradingView bit-for-bit on the unbiased path.

Sessions / date parsing

  • session.islastbar_regular/islastbar now fire on 24/7 markets: a session end at midnight (00:00 = 24:00) is rolled forward one day so the closing-bar window matches; strategies gating on it (e.g. a Friday-close hard exit) no longer strand positions.
  • A "0000-0000" session (start equals end, the input.session default) spans the full 24 hours: every bar on an allowed weekday now qualifies instead of being reported out of session (which previously placed zero trades).
  • parse_datestring accepts ISO datetimes without seconds ("2021-01-01 00:00", both space and T separators) and space-separated numeric dates ("05 12 2000" is May 12, month-first; day-first "31 1 2000" stays rejected), verified live on TradingView.

Series / transformers

  • Tuple-unpacked series variables (a, b = f()) now record per-bar history: previously the slot buffer never advanced and a[1] was permanently na.
  • A parent-scope series indexed only from inside a nested function is no longer pruned to a scalar (which crashed with 'float' object is not subscriptable); index usage propagates up the scope chain.
  • Rolling ta.* (sma, wma, cog, stdev, variance, bb, bbw, kc, correlation, change, roc) no longer collapse to na for length > 500: the indexed buffer grows with max_bars_back(series, length); length > 5000 now raises, matching Pine's own ceiling.
  • DynamicDefaultTransformer evaluates lib.*-referencing parameter defaults (e.g. source = hl2) per call rather than at def time, so anchored library call sites no longer freeze the first bar's value.