Skip to content

## [0.9.6] - 2026-03-14 - Runtime Error Handling, Loop Guard, Array Fixes, Nested UDTs, New Market Data Providers#165

Merged
alaa-eddine merged 11 commits intomainfrom
dev
Mar 14, 2026
Merged

## [0.9.6] - 2026-03-14 - Runtime Error Handling, Loop Guard, Array Fixes, Nested UDTs, New Market Data Providers#165
alaa-eddine merged 11 commits intomainfrom
dev

Conversation

@alaa-eddine
Copy link
Collaborator

Added

  • FMPProvider (beta) (Financial Modeling Prep): New provider for US equities, ETFs, crypto and forex via the FMP REST API. Supports daily (EOD) and intraday timeframes (1m–4h, paid plans). Configures with Provider.FMP.configure({ apiKey: '...' }).
  • AlpacaProvider (beta): New provider for US equities and ETFs via Alpaca Markets. Supports minute through monthly timeframes with cursor-based pagination (up to 10 000 bars/page). Configures with Provider.Alpaca.configure({ apiKey: '...', secretKey: '...' }).
  • BaseProvider Abstract Class: New shared base class for all providers. Handles closeTime normalization, fail-early API key validation, and automatic candle aggregation — when a requested timeframe is not natively supported, BaseProvider selects the best available sub-timeframe, fetches sub-candles, and aggregates them transparently. BinanceProvider and MockProvider have been refactored to extend it.
  • Candle Aggregation Engine (src/marketData/aggregation.ts): New module with selectSubTimeframe(), aggregateCandles(), and getAggregationRatio(). Supports fixed-ratio aggregation for intraday timeframes and calendar-based grouping for weekly/monthly bars.
  • PineRuntimeError: New exported error class with a method?: string property. Thrown on Pine Script runtime violations (out-of-bounds access, loop limit exceeded). Distinguishable from general JS errors via instanceof.
  • PineTS.setMaxLoops(n): Configures the maximum iterations allowed per loop (default 500 000, matching TradingView's limit). Exceeding it throws a PineRuntimeError.
  • Loop Guard Injection: The transpiler injects a counter + guard at the top of every for/while body, preventing runaway loops from hanging the runtime.
  • Negative Array Indices (Pine Script v6): array.get, array.set, array.insert, array.remove, matrix.get, matrix.set now accept negative indices (-1 = last element).

Fixed

  • Stored Numbers Precision: $.set() now applies context.precision() when writing a number into a Series, preventing floating-point drift from accumulating across bars.
  • User Functions Returning Tuples with Complex Expressions: transformReturnStatement was not walking into binary, unary, call, logical, or conditional expression nodes inside tuple arrays. Expressions like _mid + _dev * mult or -_val were left with bare identifiers, producing wrong values at runtime.
  • Array/Matrix Out-of-Bounds Reporting: array.get/set/insert/remove and matrix.get/set/row/col now throw a PineRuntimeError when an index (after negative normalization) is still out of bounds, replacing the previous silent NaN/undefined.
  • Weak integer check fixed previously using ((valus | 0) == value) now using Number.isInteger(value)

@alaa-eddine alaa-eddine merged commit def1118 into main Mar 14, 2026
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant