Skip to content

feature/go-runner-extras#2

Open
bvasilenko wants to merge 187 commits intomasterfrom
feature/go-runner-extras
Open

feature/go-runner-extras#2
bvasilenko wants to merge 187 commits intomasterfrom
feature/go-runner-extras

Conversation

@bvasilenko
Copy link
Collaborator

@bvasilenko bvasilenko commented Jan 14, 2026

Go Runner PoC

Performance

  • Total: <50ms (excl. data fetch)
  • Go parser: 5-10ms
  • Go runtime: <10ms

License Safety

  • Go stdlib (BSD-3-Clause)
  • participle/v2 (MIT)
  • Pure Go TA
# Blocker Scope Strategies Evidence
1 Codegen expression emission correctness ✅ FIXED — Unary negation now routes through generateConditionExpression (clean inline). If-block variables promoted via NestedVariableScanner.ScanIfBlock in first pass moon, aostoch generator.go, nested_variable_scanner.go, variable_declaration_registrar.go
2 UDF/arrow body scope lacks built-in access ~~✅ RESOLVED — All built-in vars and functions accessible in arrow/UDF scope. Arrow codegen resolves 26 identifiers: close/open/high/low/volume/hl2/hlc3/ohlc4/hlcc4/tr/bar_index/time/time_close/time_tradingday/last_bar_time/timenow/dayofweek/dayofmonth/hour/minute/month/second/year/weekofyear/last_bar_index/na. Official Pine has ~60+ built-in variables across namespaces. Resolved built-in vars (15): time, time_close, time_tradingday, last_bar_time, timenow, dayofweek, dayofmonth, hour, minute, month, second, year, weekofyear, last_bar_index, na. Resolved namespaces (9): barstate.*, timeframe.*, syminfo.*, dayofweek.*, session.*, chart.*, dividends.*, earnings.*, math.*. Resolved functions: timeframe.change/from_seconds/in_seconds, timestamp(), year()/month()/dayofweek()/dayofmonth()/hour()/minute()/second()/weekofyear(), time(). All blocker items resolved.~~ ann, ultima, ut+, moon builtin_identifier_registry.go, builtin_namespace_resolver.go, builtin_identifier_handler.go, builtin_access_scope.go, arrow_builtin_access_generator.go, builtin_usage_detector.go, time_series_lifecycle.go, session_series_lifecycle.go, generator.go, runtime/context/timeframe.go, calendar_handler.go, call_handler_calendar.go, call_handler_timeframe_func.go, inline_timeframe_change_handler.go, timeframe_change_codegen.go, runtime/calendar/calendar.go, runtime/calendar/timestamp.go, runtime/context/timeframe_boundary.go, runtime/context/timeframe_converter.go, time_handler.go, value_handler.go
3 Expression-position function dispatch gap ✅ FIXED — generator.go:generateVariableFromCall() now routes through CallExpressionRouter before TODO fallback (lines 2555-2562). All registered handlers (str.*, ticker.*, math.*, value.*, calendar.*, timeframe.*, color.*, strategy.*) now work in variable assignment expressions. ExpressionPositionDispatcher fallback routes expression-position calls through CallExpressionRouter. HoistableCallClassifier gates TAFunctionRegistry handlers for hoisting. RuntimeDynamic-period TA calls now hoisted via SupportsDynamicPeriod() dispatch (sma, ema, stdev, highest, lowest confirmed end-to-end; rsi/atr hoisted but rejected at handler level: handler_rsi_handler.go:27, handler_atr_handler.go:27). Per-statement interleaved calc emission prevents NaN ordering in hoisted calcs. security()/request.security() in expression position now hoisted through full evaluator via 2-gate classification (IsHoistable + requiresTempVar). IsSecurityFunction shared predicate consolidates 7 callsites. Still affects: unregistered ta.* (#5), array.* (#12), map.* (#13), request.* (non-security functions, #16). Remaining gaps: ta.rsi/ta.atr reject IsRuntimeDynamic() at handler level; multiple dynamic-period TA calls in same scope generate duplicate period := declarations alpha (#5), zigzag (#10) expression_position_dispatcher.go, hoistable_call_classifier.go, variable_init_call_filter.go, security_function_classifier.go, dynamic_period_support.go, dynamic_period_ta_generator.go, dynamic_period_emitters.go, handler_rsi_handler.go, handler_atr_handler.go, generator.go, call_expression_router_position_test.go
4 Computed period expressions unsupported ✅ FIXED — ComputedPeriod renders arbitrary expressions via exprGen.Generate(). Arithmetic (length/2), function calls (math.round(math.sqrt(length))), and compound expressions now supported hull period_expression.go, arrow_function_ta_call_generator.go, arrow_inline_ta_call_generator.go, inline_ta_registry.go
5 Incomplete ta.* function coverage 26 of 58 official ta.* members implemented (22 single-output + 4 tuple). Missing functions (32): alma, bbw, cci, cmo, cog, correlation, cross, falling, highestbars, hma, kc, kcw, lowestbars, max, median, min, mode, mom, percentile_linear_interpolation, percentile_nearest_rank, percentrank, pivot_point_levels, range, rising, roc, sar, supertrend, swma, tr (function overload), tsi, variance, vwma, wpr. Missing tuple returns (2): kc (3-tuple), supertrend (2-tuple). Missing variables (8): ta.accdist, ta.iii, ta.nvi, ta.obv, ta.pvi, ta.pvt, ta.wad, ta.wvad. Implemented: sma, ema, stdev, wma, dev, atr, rma, rsi, change, pivothigh, pivotlow, crossover, crossunder, fixnan, sum, valuewhen, highest, lowest, linreg, macd, bb, stoch, dmi, barssince, mfi, cum alpha, aostoch ta_function_handler.go:33, tuple_indicator_registry.go, ta_signatures*.go
6 Color literal and function gaps ✅ FIXED — HexColor regex supports 8-digit RGBA. All 7 color.* functions implemented: color.new, color.rgb, color.from_gradient, color.r/g/b/t. ColorHandler + ColorFunctionRegistry + ColorCallHandler in router. Runtime in visual/color.go max color_handler.go, color_function_registry.go, call_handler_color.go, runtime/visual/color.go, grammar.go
7 strategy.* API surface incomplete 10 of 48+ official strategy.* functions implemented. Implemented (10): entry, close, close_all, exit, initial_capital, grossprofit, grossloss, wintrades, losstrades, eventrades. Missing order functions (3): strategy.order, strategy.cancel, strategy.cancel_all. Missing risk management (6): strategy.risk.allow_entry_in, strategy.risk.max_cons_loss_days, strategy.risk.max_drawdown, strategy.risk.max_intraday_filled_orders, strategy.risk.max_intraday_loss, strategy.risk.max_position_size. Missing trade introspection (31): strategy.closedtrades.* (18 functions: commission, entry_bar_index, entry_comment, entry_id, entry_price, entry_time, exit_bar_index, exit_comment, exit_id, exit_price, exit_time, max_drawdown, max_drawdown_percent, max_runup, max_runup_percent, profit, profit_percent, size), strategy.opentrades.* (13 functions: same set minus exit_*). Missing utility (3): convert_to_account, convert_to_symbol, default_entry_qty. Missing variables (28): equity, netprofit, position_size, position_avg_price, position_entry_name, opentrades, closedtrades, max_drawdown, max_runup, openprofit, account_currency, avg_trade, avg_winning_trade, avg_losing_trade, margin_liquidation_price, etc. Missing constants (14): strategy.cash, strategy.fixed, strategy.percent_of_equity, strategy.oca.cancel/none/reduce, strategy.commission.*, strategy.direction.* hull, ultima call_handler_strategy.go, runtime/strategy/strategy.go, runtime/strategy/aggregators.go, codegen/builtin_identifier_handler.go
8 input.* missing type handlers ✅ CLOSED — 13/13 implementable input.* handlers complete. input.enum requires enum keyword (language-level feature → #23) max, ultima input_handler.go, input_constant_extractor.go, input_type_resolver.go, input_declaration_resolver.go, color_constant_resolver.go
9 String functions (str.*) ✅ FIXED — 18/18 official str.* functions implemented via StringNamespaceHandler with full CallExpressionRouter integration. Implemented: str.tostring, str.tonumber, str.length, str.format, str.format_time, str.contains, str.pos, str.substring, str.lower, str.upper, str.trim, str.replace, str.replace_all, str.split, str.startswith, str.endswith, str.repeat, str.match. Strategy pattern with 8 code generators: SimpleStringGenerator, TwoArgStringGenerator, SubstringGenerator, ReplaceGenerator, RepeatGenerator, ToStringGenerator, FormatGenerator, FormatTimeGenerator. DRY architecture: StringArgumentParser for argument extraction, StringFunctionRegistry for signature validation, StringFunctionSignature for argument count enforcement. 147 test cases in call_handler_string_test.go validate all functions, argument variations, nested expressions, and router integration ultima call_handler_string.go, call_handler_string_test.go, string_argument_parser.go, string_code_generators.go, string_function_registry.go, string_function_signature.go, call_handler.go, call_handler_test.go
10 ticker.* namespace gaps ✅ CLOSED — 9/9 official ticker.* functions have handlers with full argument support: heikinashi, renko, kagi, linebreak, pointfigure, standard, new, modify, inherit. Session/adjustment/backadjustment/settlement_as_close modifiers encoded in ticker ID via runtime TickerID struct. Codegen resolves Pine modifier constants (session.regular/extended, adjustment.none/splits/dividends, backadjustment.inherit/on/off, settlement_as_close.inherit/on/off). Non-HA chart type transformers return identity → #11 call_handler_ticker.go, ticker_modifier_resolver.go, runtime/ticker/session.go, runtime/ticker/ticker_id.go, runtime/ticker/constructor.go
11 Non-HA chart type transformers return identity Official Pine supports 6 chart types via ticker.* constructors: heikinashi, renko, kagi, linebreak, pointfigure, range. Only HeikinAshi has real transform. Renko, Kagi, LineBreak, PointFigure, Range → IdentityTransformer (passthrough) bar_transformer.go:52
12 Array data structure (array.*) 0 of 55 official array.* functions implemented. No runtime array type. Full list: new<type>/new_float/new_int/new_bool/new_string/new_color/new_label/new_line/new_box/new_table/new_linefill, from, get, set, push, pop, shift, unshift, insert, remove, clear, size, includes, indexof, lastindexof, first, last, slice, copy, concat, sort, sort_indices, reverse, fill, join, avg, sum, min, max, median, mode, stdev, variance, range, percentile_linear_interpolation, percentile_nearest_rank, percentrank, abs, standardize, covariance, binary_search, binary_search_leftmost, binary_search_rightmost, every, some 0 hits in codegen
13 Map data structure (map.*) 0 of 11 official map.* functions implemented. Doubly blocked with #19 (generic syntax). Full list: map.new<K,V>, map.put, map.get, map.contains, map.remove, map.clear, map.keys, map.values, map.size, map.copy, map.put_all 0 hits in codegen
14 alert()/alertcondition() 0 of 2 official alert functions implemented. No runtime alert model ultima 0 hits in codegen
15 Drawing objects and plot output family 0 of ~93 official drawing functions implemented. label.* (20): new, delete, copy, get_text, get_x, get_y, set_color, set_point, set_size, set_style, set_text, set_text_font_family, set_textalign, set_textcolor, set_tooltip, set_x, set_xloc, set_xy, set_y, set_yloc. line.* (18): new, delete, copy, get_price, get_x1/x2/y1/y2, set_color, set_extend, set_first_point, set_second_point, set_style, set_width, set_x1/x2/xloc/xy1/xy2/y1/y2. box.* (25): new, delete, copy, get/set for all edges, bgcolor, border_color/style/width, text/text_color/size/halign/valign/wrap/font_family, extend, top_left_point, bottom_right_point. table.* (18): new, delete, cell, clear, merge_cells, set_bgcolor/border_color/border_width/frame_color/frame_width/position, cell_set_*. linefill.* (5), polyline.* (2), chart.point.* (5). Missing plot siblings (9): only plot() implemented — missing bgcolor, barcolor, fill, hline, plotarrow, plotbar, plotcandle, plotchar, plotshape max 0 drawing hits in codegen, call_handler_plot.go handles plot() only
16 request.* namespace gaps 1 of 10 official request.* functions implemented (request.security). request.security correctness: derived price field resolution (ohlc4/hlc3/hl2/hlcc4), input defval extraction for resolution-type, Pine v1/v2 lookahead default, cross-timeframe time-range extension. Missing (9): request.security_lower_tf, request.currency_rate, request.dividends, request.earnings, request.economic, request.financial, request.quandl, request.seed, request.splits ann security_inject.go, security_field_resolver.go, input_defval_resolver.go, security_argument_extractor.go, security_bar_mapper.go, bar_evaluator.go
17 matrix.* data structure 0 of ~40 official matrix.* functions implemented. No runtime matrix type. Includes: new<type>, get, set, rows, columns, add_row, add_col, remove_row, remove_col, fill, copy, concat, sum, diff, mult, det, inv, pinv, transpose, rank, trace, eigenvalues, eigenvectors, kron, pow, reshape, reverse, sort, submatrix, swap_columns, swap_rows, avg, max, min, median, mode, elements_count, is_square/identity/diagonal/symmetric/antisymmetric/triangular/stochastic/binary/antidiagonal/zero 0 hits in codegen
18 log.* / runtime.* / misc functions 0 of 5 functions. Missing: log.error, log.info, log.warning, runtime.error, max_bars_back 0 hits in codegen
19 Library import/export No grammar, AST, or codegen for Pine library system. Official Pine supports import user/library/version as alias and export keyword for function/UDT publishing 0 hits
20 User-defined types (type) No grammar, AST, or codegen for Pine v5 type declarations / UDTs. Official Pine supports type keyword with field declarations, .new() constructors, field access via dot notation 0 hits
21 Methods (method) No grammar, AST, or codegen for Pine v5 method declarations. Official Pine supports method keyword for user-defined methods on built-in and user-defined types with dot-call syntax 0 hits
22 map.new<K,V>() generics </> lexed as comparison operators, no generic type syntax in grammar. Blocks map.new<>, array.new<>, matrix.new<> and generic UDT fields Parse error: unexpected token "," on map.new<string, float>()
23 enum keyword + input.enum() No grammar, AST, or codegen for Pine v5 enum declarations. Blocks input.enum(), enum field dot access, str.tostring(enum), enum in collection type templates. 0 hits in lexer/parser/AST. Functionally equivalent dropdown already supported via input.string(..., options=[...]) + switch 0 hits in lexer/parser/AST

@bvasilenko bvasilenko self-assigned this Jan 14, 2026
@github-actions
Copy link

⏱️ Time Estimation

Scope: Branch commits only (28beb5b..c12cc18)

Based on commit timestamp analysis (0.5h session threshold)

  • Boris Vasilenko: 1.8h (5 commits)

Total: 1.8h across 5 commits

…nstants, allow_entry_in with runtime, codegen, and integration tests
…omplete hasStrategyRuntimeInExpression detection with runtime, codegen, and integration tests
…al lookback storage, unit and integration tests
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⏱️ Time Estimation

Scope: Branch commits only (28beb5b..038d682)

Based on commit timestamp analysis (0.5h session threshold)

  • Boris Vasilenko: 97.5h (168 commits)

Total: 97.5h across 168 commits

…c-driven codegen, security evaluator state, and regression tests
…ers, IIFE generators, security evaluator state, and integration tests
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⏱️ Time Estimation

Scope: Branch commits only (28beb5b..fc148d4)

Based on commit timestamp analysis (0.5h session threshold)

  • Boris Vasilenko: 98.8h (172 commits)

Total: 98.8h across 172 commits

…ared Keltner builder extraction, and golden tests
…arrow scopes with shared initializer, dead code removal, and regression tests
…cessor, array.get/size codegen, and regression tests
…empVarEmissionTracker, ConditionalExpression boolean wrapping, and regression tests
…torage with direct Series in state managers, and add security TA integration tests
…rsSince state manager with ForwardSeriesBuffer, and end-to-end regression tests
…riesOffsetShifter extraction, IIFE bounds-checked OHLCV pattern support, and end-to-end integration tests
…Expression with BarEvaluator interface, expressionKey cache isolation, and end-to-end regression tests
…float) with open registry dispatch, ta.* alias routing, and end-to-end regression tests
…er resolver, v3 alias registry, loop counter float64 cast, and end-to-end regression tests
…ring parameter detection via equality comparison codegen, dual call-site capture registry, and end-to-end regression tests
…support, strategy.close/close_all safe snapshot multi-trade closing, and end-to-end integration tests
…eak/pointfigure qualification with heikenashi typo tolerance, and end-to-end regression tests
@github-actions
Copy link

⏱️ Time Estimation

Scope: Branch commits only (28beb5b..240dce6)

Based on commit timestamp analysis (0.5h session threshold)

  • Boris Vasilenko: 107.9h (187 commits)

Total: 107.9h across 187 commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant