opencode-pine2pyne 0.2.1__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. opencode_pine2pyne-0.2.3/PKG-INFO +343 -0
  2. opencode_pine2pyne-0.2.3/README.md +323 -0
  3. opencode_pine2pyne-0.2.3/opencode_pine2pyne.egg-info/PKG-INFO +343 -0
  4. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/opencode_pine2pyne.egg-info/SOURCES.txt +12 -1
  5. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/__init__.py +5 -1
  6. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/block_value_lowering.py +11 -0
  7. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/codegen.py +17 -3
  8. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/emitted_names.py +8 -2
  9. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/import_resolver.py +51 -1
  10. opencode_pine2pyne-0.2.3/pine2pyne/legacy_function_names.py +66 -0
  11. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/lexer.py +26 -0
  12. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/parser.py +50 -10
  13. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/pine_builtins.py +8 -0
  14. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/pine_semantics.py +18 -2
  15. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/scope_renamer.py +51 -9
  16. opencode_pine2pyne-0.2.3/pine2pyne/strategy_when_lowering.py +101 -0
  17. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/transformer.py +31 -14
  18. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_assignment_to_a_call_result_field.py +1 -1
  19. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_block_tail_value_runtime.py +10 -9
  20. opencode_pine2pyne-0.2.3/tests/test_collect_bool_annotations.py +77 -0
  21. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_compare_ground_truth_completeness.py +139 -6
  22. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_corpus_regression.py +16 -64
  23. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_error_demo_claims.py +1 -2
  24. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_error_demo_runtime.py +1 -1
  25. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_errors.py +6 -0
  26. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ground_truth_digests.py +5 -4
  27. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ground_truth_manifest_order.py +35 -0
  28. opencode_pine2pyne-0.2.3/tests/test_ground_truth_nondeterministic_marks.py +221 -0
  29. opencode_pine2pyne-0.2.3/tests/test_ground_truth_pynecore_commit.py +177 -0
  30. opencode_pine2pyne-0.2.3/tests/test_legacy_unprefixed_functions_card116.py +117 -0
  31. opencode_pine2pyne-0.2.3/tests/test_library_boundary_runtime.py +313 -0
  32. opencode_pine2pyne-0.2.3/tests/test_local_named_like_a_function_card118.py +59 -0
  33. opencode_pine2pyne-0.2.3/tests/test_loop_counter_history_refusal.py +88 -0
  34. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_script_declaration_binding.py +3 -3
  35. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_shadowing_runtime.py +6 -4
  36. opencode_pine2pyne-0.2.3/tests/test_strategy_when_argument_card117.py +160 -0
  37. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_transformer.py +5 -14
  38. opencode_pine2pyne-0.2.3/tests/test_tuple_target_refusal.py +58 -0
  39. opencode_pine2pyne-0.2.3/tests/test_type_as_identifier_card115.py +193 -0
  40. opencode_pine2pyne-0.2.3/tests/test_v5_bool_cast_runtime.py +236 -0
  41. opencode_pine2pyne-0.2.1/PKG-INFO +0 -301
  42. opencode_pine2pyne-0.2.1/README.md +0 -281
  43. opencode_pine2pyne-0.2.1/opencode_pine2pyne.egg-info/PKG-INFO +0 -301
  44. opencode_pine2pyne-0.2.1/tests/test_screener_regression.py +0 -492
  45. opencode_pine2pyne-0.2.1/tests/test_v5_bool_cast_runtime.py +0 -100
  46. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/LICENSE +0 -0
  47. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/opencode_pine2pyne.egg-info/dependency_links.txt +0 -0
  48. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/opencode_pine2pyne.egg-info/entry_points.txt +0 -0
  49. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/opencode_pine2pyne.egg-info/requires.txt +0 -0
  50. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/opencode_pine2pyne.egg-info/top_level.txt +0 -0
  51. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/README.md +0 -0
  52. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/TRANSPILER_BEST_PRACTICES.md +0 -0
  53. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/TRANSPILER_USAGE.md +0 -0
  54. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/__main__.py +0 -0
  55. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/ast_nodes.py +0 -0
  56. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/ast_walk.py +0 -0
  57. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/bool_builtins.py +0 -0
  58. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/bool_value_typing.py +0 -0
  59. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/cli.py +0 -0
  60. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/conditional_history_calls.py +0 -0
  61. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/errors.py +0 -0
  62. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/for_loop_end_bound.py +0 -0
  63. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/grouped_history_lowering.py +0 -0
  64. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/library_collision.py +0 -0
  65. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/namespace_members.py +0 -0
  66. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/once_lowering.py +0 -0
  67. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/overload_resolution.py +0 -0
  68. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/parse_repair.py +0 -0
  69. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/strict_boolean.py +0 -0
  70. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/symbol_table.py +0 -0
  71. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/tokens.py +0 -0
  72. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/type_inference.py +0 -0
  73. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pine2pyne/udt_field_defaults.py +0 -0
  74. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/pyproject.toml +0 -0
  75. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/setup.cfg +0 -0
  76. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_block_value_runtime.py +0 -0
  77. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_builtin_named_function_and_enum_input.py +0 -0
  78. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_cli.py +0 -0
  79. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_codegen.py +0 -0
  80. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_codegen_operator_grouping.py +0 -0
  81. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_codegen_refusal.py +0 -0
  82. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_collect_namespace_members.py +0 -0
  83. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_conditional_history_call_warning.py +0 -0
  84. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_dotted_udt_default_runtime.py +0 -0
  85. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_drawing_receiver_runtime.py +0 -0
  86. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_emitted_name_collision_runtime.py +0 -0
  87. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_emitted_name_plan.py +0 -0
  88. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_for_in_pairs_runtime.py +0 -0
  89. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_for_loop_dynamic_end_runtime.py +0 -0
  90. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_function_tail_runtime.py +0 -0
  91. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_generated_tables.py +0 -0
  92. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ground_truth_check_no_output.py +0 -0
  93. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ground_truth_check_own_directory.py +0 -0
  94. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ground_truth_no_output.py +0 -0
  95. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ground_truth_run_dir_isolation.py +0 -0
  96. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ground_truth_settings.py +0 -0
  97. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ground_truth_wrapper_retired.py +0 -0
  98. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_grouped_history_lowering.py +0 -0
  99. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_grouped_history_runtime.py +0 -0
  100. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_import_resolver.py +0 -0
  101. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_input_constant_and_enum_order_runtime.py +0 -0
  102. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_input_history_read_runtime.py +0 -0
  103. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_input_numeric_positional_binding.py +0 -0
  104. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_lexer.py +0 -0
  105. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_library_name_collision.py +0 -0
  106. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_library_name_collision_runtime.py +0 -0
  107. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_loop_and_array_edge_cases.py +0 -0
  108. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_method_namespaces.py +0 -0
  109. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_method_receiver_shape_runtime.py +0 -0
  110. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_method_routing_runtime.py +0 -0
  111. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_once_structure_parser.py +0 -0
  112. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_once_structure_runtime.py +0 -0
  113. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_overload_dispatch_runtime.py +0 -0
  114. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_overload_resolution.py +0 -0
  115. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_parse_repair_card55.py +0 -0
  116. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_parser.py +0 -0
  117. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_parser_positions.py +0 -0
  118. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_pine_builtins.py +0 -0
  119. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_pine_semantics.py +0 -0
  120. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_release_artifact_grouping.py +0 -0
  121. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_runtime_floor.py +0 -0
  122. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_scope_model_drift.py +0 -0
  123. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_scope_renamer.py +0 -0
  124. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_strict_and_or_runtime.py +0 -0
  125. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_suite_harness_exit_verdict.py +0 -0
  126. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_suite_report_compare.py +0 -0
  127. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_switch_subject_runtime.py +0 -0
  128. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_symbol_table.py +0 -0
  129. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_ta_conditional_runtime.py +0 -0
  130. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_transformer_receiver_typing.py +0 -0
  131. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_transformer_single_use.py +0 -0
  132. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_udt_array_new_runtime.py +0 -0
  133. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_udt_bool_field_default_by_version_runtime.py +0 -0
  134. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_udt_field_defaults_runtime.py +0 -0
  135. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_udt_field_history_runtime.py +0 -0
  136. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_udt_type_proof.py +0 -0
  137. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_untyped_na_runtime.py +0 -0
  138. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_user_declaration_shadows_builtin_runtime.py +0 -0
  139. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_var_history_runtime.py +0 -0
  140. {opencode_pine2pyne-0.2.1 → opencode_pine2pyne-0.2.3}/tests/test_variable_function_runtime.py +0 -0
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: opencode-pine2pyne
3
+ Version: 0.2.3
4
+ Summary: Pine Script v6 to PyneCore Python transpiler
5
+ Author: rubycell
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/rubycell/pine2pyne
8
+ Project-URL: Repository, https://github.com/rubycell/pine2pyne
9
+ Keywords: pinescript,tradingview,transpiler,pynecore,backtesting
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Topic :: Office/Business :: Financial :: Investment
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Provides-Extra: runtime
18
+ Requires-Dist: opencode-pyneruntime[cli]>=6.9.1; extra == "runtime"
19
+ Dynamic: license-file
20
+
21
+ # pine2pyne - Pine Script to PyneCore transpiler
22
+
23
+ Snapshot written 2026-10-19 at origin/main `dd8b5d3` (branch `card-118-local-named-like-method`, clean apart from this README.md).
24
+ The old README is kept at `/home/mike/workspace/github/pine2pyne/backup/README.before-2026-10-19.md` (git-ignored).
25
+ Each fact below names its source file. A fact marked UNVERIFIED was not checked in this snapshot.
26
+
27
+ Backlog and known bugs: [Projects board #10](https://github.com/users/rubycell/projects/10)
28
+ (Backlog = open, P0/P1/P2; Done = shipped). The board page itself was not opened in this snapshot: UNVERIFIED.
29
+
30
+ ## 1. What this repo is
31
+
32
+ - A transpiler. It reads a TradingView Pine Script file (`.pine`) and writes a PyneCore Python file (`.py`).
33
+ Source: `pine2pyne/__init__.py` (`transpile()`), `pyproject.toml` (description "Pine Script v6 to PyneCore Python transpiler").
34
+ - Users: the strategy developers of this workspace. They transpile a strategy, then run or optimize it with the `pyne` CLI
35
+ of the PyneCore runtime (repo `/home/mike/workspace/github/pynecore`).
36
+ - Where it runs: a command-line tool and a Python library. It has no service, no port and no host of its own.
37
+ Development happens on mike-PC. Full test suites run on Minh_pc (see section 7).
38
+ - Package: `opencode-pine2pyne` on PyPI, version `0.2.3` in `pine2pyne/__init__.py` and `CHANGELOG.md`.
39
+ Live PyPI state is UNVERIFIED: 0.2.3 is prepared (commit and local tag `v0.2.3`), not uploaded.
40
+ `CHANGELOG.md` lists #115 to #118 under 0.2.3; the tag `v0.2.2` is the release before them.
41
+ - The transpiler imports only the standard library (`pyproject.toml`: `dependencies = []`).
42
+ The generated script needs the runtime `opencode-pyneruntime` (`runtime` extra, `>=6.9.1`).
43
+ - License: Apache-2.0 (`pyproject.toml`, `LICENSE`).
44
+
45
+ ## 2. Architecture
46
+
47
+ The pipeline is in `transpile()` in `/home/mike/workspace/github/pine2pyne/pine2pyne/__init__.py`:
48
+
49
+ ```mermaid
50
+ flowchart LR
51
+ A[.pine source] --> B[parse_source<br/>lexer + parser + parse_repair]
52
+ B --> C[qualify_legacy_function_names<br/>v1-v4 names to v5 names]
53
+ C --> D[enforce_pine_semantics<br/>refuse what TradingView refuses]
54
+ D --> E[Transformer<br/>Pine AST to PyneCore AST]
55
+ E --> F[CodeGenerator]
56
+ F --> G[.py script]
57
+ G --> H[pyne run / pyne optimize<br/>PyneCore runtime]
58
+ ```
59
+
60
+ - Lowering passes run in the parser and in the transformer. They rewrite a Pine construct into plain
61
+ statements. Examples: `once`, `when=` of a strategy call (v1-v5), grouped history `(a + b)[1]`,
62
+ block values of `if`/`switch`, strict `and`/`or` for Pine v5 and earlier.
63
+ Sources: imports in `pine2pyne/parser.py` and `pine2pyne/transformer.py`.
64
+ - Two tables are generated from an installed runtime: `pine2pyne/namespace_members.py` and `pine2pyne/bool_builtins.py`
65
+ (both say "GENERATED ... from opencode-pyneruntime 6.9.4; do not edit by hand").
66
+ Regenerate them after a runtime upgrade with `tools/collect_namespace_members.py` and `tools/collect_bool_builtins.py`.
67
+ - The transpiler refuses a script when TradingView refuses it (`SemanticError`, card #28) and warns with
68
+ `SemanticWarning` when it only advises. `pyproject.toml` turns an unexpected `SemanticWarning` into a test failure.
69
+ - Runtime code placement rule: group a new runtime member beside its kin. Source: `CLAUDE.md`, "Runtime Code Placement".
70
+ - Three separate test systems check it (section 7). A green run of one says nothing about the others.
71
+ Source: `CLAUDE.md`.
72
+
73
+ ## 3. Modules
74
+
75
+ All in `/home/mike/workspace/github/pine2pyne/pine2pyne/` (33 `.py` files, 13,176 lines in total by `wc -l`).
76
+
77
+ Core pipeline:
78
+ - `lexer.py`, `tokens.py` - tokens, with indentation tracking.
79
+ - `parser.py`, `ast_nodes.py`, `ast_walk.py` - recursive descent parser, AST node classes, shared child walk.
80
+ - `parse_repair.py` - repairs a rejected known spelling of valid Pine (card #55).
81
+ - `legacy_function_names.py` - Pine v1-v4 call names to v5 names (card #116).
82
+ - `pine_semantics.py` - checks TradingView's compiler makes that the grammar does not (card #28).
83
+ - `transformer.py` - Pine AST to PyneCore AST. The largest file.
84
+ - `codegen.py` - emits Python source.
85
+ - `cli.py`, `__main__.py` - command line (`pine2pyne` command and `python -m pine2pyne`).
86
+ - `errors.py` - error types with source locations.
87
+
88
+ Support tables and typing:
89
+ - `pine_builtins.py` - maps Pine built-ins to PyneCore.
90
+ - `namespace_members.py`, `bool_builtins.py` - generated runtime tables.
91
+ - `symbol_table.py`, `type_inference.py`, `bool_value_typing.py` - scopes, Series or Persistent typing, bool typing.
92
+ - `import_resolver.py`, `emitted_names.py` - import lines; emitted names that must not collide.
93
+
94
+ Lowering and refusal passes:
95
+ - `scope_renamer.py` - gives a shadowing local, or a binding named like a runtime name, a name of its own.
96
+ - `library_collision.py` - a user binding named like a `pynecore.lib` name.
97
+ - `overload_resolution.py` - same-name functions and methods.
98
+ - `once_lowering.py`, `strategy_when_lowering.py`, `block_value_lowering.py`, `grouped_history_lowering.py`.
99
+ - `for_loop_end_bound.py`, `strict_boolean.py`, `udt_field_defaults.py`, `conditional_history_calls.py`.
100
+
101
+ Other top-level folders:
102
+ - `tests/` - 86 `test_*.py` files, fixtures in `tests/fixtures/`, old strategy outputs in `tests/ground_truth/`.
103
+ - `tools/` - corpus harnesses, ground-truth tools, table generators (section 7).
104
+ - `sample/pinescript/` (413 `.pine` files) and `sample_pds/` (331 `.pine` files) - the corpus. Counts by `ls | wc -l`.
105
+ - `sandbox/` - Docker image (section 6).
106
+ - `docs/` - `test_plan.md`, `instructions/` (optimizer guides), `misc/`, `code_review/`.
107
+ - `ground_truth/` - tracked baseline: `digests.json` and `manifest.json` only.
108
+ - `other_transpiler/`, `runs/`, `scripts/`, `strategy/`, `upstream-run/`, `agents/`, `.claude/agentandskill/` - strategy
109
+ experiments and agent prompts. Their use today is UNVERIFIED.
110
+ - `workdir/` - git-ignored scratch folder for runs (`.gitignore`). `backup/` and `dist/` are git-ignored too.
111
+ - `pine2pyne/README.md` is the package's own README (set as package data in `pyproject.toml`).
112
+ It may be stale (it says "transformer.py (1626 lines)"): UNVERIFIED.
113
+
114
+ ## 4. Services
115
+
116
+ None. The repo starts no long-running process: no systemd unit, no cron job, no listening port.
117
+ Source: no unit, crontab installer or server entry point found in the repo; `pyproject.toml` has one console script,
118
+ `pine2pyne = "pine2pyne.cli:main"`. Distributed optimizer runs start remote `pyne optimize` processes over SSH
119
+ from tools that live in another repo (section 7).
120
+
121
+ ## 5. Dashboard and its features
122
+
123
+ None. This repo has no web UI. Source: no web framework or HTML page in the repo.
124
+
125
+ ## 6. Docker
126
+
127
+ - One Dockerfile: `/home/mike/workspace/github/pine2pyne/sandbox/Dockerfile`. Base image `python:3.13-slim`.
128
+ Build arg `SOURCE=pypi` (default) installs `opencode-pine2pyne` and `opencode-pyneruntime[cli]>=6.9.1` from PyPI.
129
+ `SOURCE=local` installs the wheels in `sandbox/wheels/`.
130
+ The user is `pyne`, the work folder is `/work`, and the default command prints `pine2pyne --version`, then opens a shell.
131
+ - Suggested image name in `sandbox/README.md`: `pyne-sandbox`. Run with `-v "$PWD/workdir:/work"`.
132
+ `sandbox/smoke.sh <data.ohlcv>` transpiles a small strategy and runs `pyne run` on it.
133
+ - `sandbox/wheels/` is stale: it holds `opencode_pine2pyne-0.1.0` and `opencode_pyneruntime-6.6.4` (file names, dated 2026-07-31).
134
+ `git ls-files sandbox/wheels` lists nothing: the wheels are not tracked.
135
+ - No compose file, no ports, no volumes other than the `/work` mount in `sandbox/README.md`.
136
+ - Live state, read only, 2026-10-19. `ssh -o BatchMode=yes minh@minhpc 'docker ps -a; docker images'` and
137
+ `docker ps -a; docker images` on mike-PC show no `pyne-sandbox` image and no pine2pyne container.
138
+ The containers seen there belong to other projects (`vnstock-openclaw-trial-*`, `botrehearsal-trial-*`, `svb-sandbox:*` images).
139
+ Result: the sandbox image is not built on either host.
140
+
141
+ ## 7. Commands
142
+
143
+ Run all commands from the repo root with the venv active. Paths and options come from `tools/*.py` and `pine2pyne/cli.py`.
144
+
145
+ Set up:
146
+ ```bash
147
+ bash /home/mike/.claude/skills/opencode-pine2pyne-setup/setup.sh # skill script: builds .venv, seeds demo data, smoke test
148
+ # or by hand:
149
+ python3 -m venv .venv
150
+ .venv/bin/pip install -e .
151
+ .venv/bin/pip install 'opencode-pyneruntime[cli]>=6.9.1' # same floor as pyproject.toml [runtime]
152
+ .venv/bin/pip install optuna numpy # optimizer deps, not pulled in by the runtime
153
+ source .venv/bin/activate # Linux and macOS; on Windows: .venv\Scripts\activate
154
+ .venv/bin/python -c "import pynecore, pine2pyne, optuna, numpy; print('all ok')"
155
+ ```
156
+ The setup script ends with the lines `smoke test : PASS` and `READY`. A failure prints `READY : NO` and exits 1
157
+ (`setup.sh` lines 22, 31 and 111-112). It writes `.sandbox-env.sh` with `PINE_CPU_COUNT` and `PINE_MAX_WORKERS`
158
+ (source: `/home/mike/.claude/skills/opencode-pine2pyne-setup/setup.sh`; the file is git-ignored).
159
+ The `runtime` extra also works: `pip install "opencode-pine2pyne[runtime]"` (`pyproject.toml`).
160
+ Test tools (pytest, hypothesis) are in no manifest: a venv built from this README cannot run the unit suite
161
+ (project memory "Test deps undeclared"; not re-checked, UNVERIFIED).
162
+
163
+ Transpile (`pine2pyne/cli.py`, options `-o`, `--validate`, `-v`, `--version`):
164
+ ```bash
165
+ python -m pine2pyne input.pine # to stdout
166
+ python -m pine2pyne input.pine -o output.py
167
+ python -m pine2pyne "sample/pinescript/*.pine" -o workdir/scripts/ # batch into a folder
168
+ python -m pine2pyne strategy.pine --validate # parse and check only
169
+ ```
170
+
171
+ Run and optimize (the `pyne` CLI of the runtime; from `workdir/`):
172
+ ```bash
173
+ pyne run strategy.py data/data.ohlcv
174
+ pyne optimize strategy.py data/data.ohlcv optimize.json -n 20
175
+ ```
176
+ Optimizer guides: `docs/instructions/Optimizer.md` (the root `Optimizer.md` was deleted in commit `cde04c9`;
177
+ old links to it are dead).
178
+
179
+ Test. Where each run goes: `/home/mike/.claude/where-tests-run.md`. Every full suite runs on Minh_pc through the
180
+ `qa-remote-suite` skill. A batch that checks this tool across many strategies is a test, so it runs on Minh_pc too.
181
+ On mike-PC only a targeted run is allowed, through `mike-pc-test-run`.
182
+
183
+ There are three test systems. A green run of one says nothing about the others.
184
+
185
+ 1. Unit tests, pytest, `tests/` (`pyproject.toml`: `testpaths = ["tests"]`):
186
+ ```bash
187
+ .venv/bin/python -m pytest tests/ -q
188
+ .venv/bin/python -m pytest tests/ --cov=pine2pyne --cov-report=term-missing
189
+ .venv/bin/python -m pytest tests/ -m 'not corpus_runtime' -q # skip tests that run the runtime
190
+ .venv/bin/python -m pytest tests/ -m 'not release_artifact' -q # skip the wheel build test (needs uv)
191
+ ```
192
+ - No `--ignore` is needed (`CLAUDE.md`; the screener test was retired in card #106).
193
+ - Last measured numbers: 6,870 tests, 6,848 passed, 1 skipped, 21 xfailed, 93% line and 86% branch coverage,
194
+ at `a16621b` (old README). Not re-run in this snapshot: UNVERIFIED. `docs/test_plan.md` holds older numbers
195
+ (2062 passed, 93.3% line, 86.6% branch) and the mutation results.
196
+ - Strict xfail marks a pinned, unfixed bug. Do not delete the marker to get green. When the bug is fixed the
197
+ test XPASSes, strict turns that into a failure, and you then convert the test to a regression assertion.
198
+ Source: `CLAUDE.md` ("6 sites (21 test cases)" there; not re-counted, UNVERIFIED).
199
+ - Guard for the operator-grouping bug (card #6): `tests/test_codegen_operator_grouping.py`.
200
+
201
+ 2. Sample suites, end-to-end transpile and `pyne run` over the corpus (`tools/test_all_samples.py`,
202
+ `tools/test_all_sample_pds.py`, shared code in `tools/_suite_common.py`):
203
+ ```bash
204
+ python tools/test_all_samples.py # sample/pinescript
205
+ python tools/test_all_sample_pds.py # sample_pds
206
+ python tools/test_all_samples.py "ex_001*" # filter by pattern
207
+ python tools/test_all_samples.py --timeout 30 --verbose -j 0
208
+ python tools/test_all_samples.py --run-dir /tmp/run1 # private scripts/, output/ and reports (card #70)
209
+ ```
210
+ - Defaults: data `workdir/data/demo.ohlcv`, timeout 15 s, `-j` 24 (`tools/test_all_samples.py`).
211
+ Reports go to `test_results{,_pds}.{json,txt}` at the repo root (git-ignored), or into `--run-dir`.
212
+ - Latest local reports, 2026-10-02 08:45 (`test_results.json`, `test_results_pds.json`; local files, not tracked):
213
+ - `sample/pinescript`: 411 run, 2 skipped, 411 transpiled, 393 passed, 18 failed
214
+ (11 `pynecore_api`, 5 `missing_security_data`, 2 `type_error`).
215
+ - `sample_pds`: 328 run, 3 skipped, 319 transpiled, 322 passed, 6 failed (all `missing_security_data`).
216
+ Of the 322 passes, 304 ran clean and 18 are expected-error samples (`expect_error` in
217
+ `tools/sample_expectations.toml`): 9 `pine_refusal` (transpile refused, so not in the 319),
218
+ 5 `index_error` and 4 `value_error`. The report's `runtime_failed` is 15 = 6 failures + 5 + 4 expected-error passes.
219
+ (As of 2026-10-20 `expds_160` is no longer declared: TradingView does not halt on it, measured. The declared
220
+ `index_error` samples are 4 now; the report above was made before that.)
221
+ Counted from the `results` list of `test_results_pds.json` (passed, transpile, runtime, error_type per sample).
222
+ - `CLAUDE.md` holds the same numbers (table "Converting Pine Script to PyneCore Python"). Its old 2026-08-17
223
+ figures (391/411, 304/328) were replaced on 2026-10-19.
224
+ - Per-sample rules are in `tools/sample_expectations.toml` (25 sections). Keys: `expect_error` (must fail with that
225
+ category; running clean is a FAIL), `requires_feeds` (extra feeds, passed as `--security TF=name`), `runs_clean`,
226
+ `card`, `refusal`, `why`. Pytest validates the file (`tests/test_error_demo_claims.py`).
227
+ - A feed for `requires_feeds` is made with `cd workdir && pyne data aggregate data/demo.ohlcv -tf 2D`.
228
+
229
+ 3. Ground truth, numeric regression (`tools/generate_ground_truth.py`, `tools/compare_ground_truth.py`,
230
+ `tools/ground_truth_check.py`, shared code in `tools/_ground_truth_common.py`):
231
+ ```bash
232
+ python tools/generate_ground_truth.py # (re)build the baseline; only when the new output is confirmed correct
233
+ python tools/compare_ground_truth.py # compare current output with the baseline
234
+ python tools/compare_ground_truth.py --suite sample_pds -j 12
235
+ python tools/ground_truth_check.py capture # then: compare. Local check, writes only ground_truth_check/ (git-ignored)
236
+ ```
237
+ - `capture --force` moves the old `ground_truth_check/` to `backup/deleteable/ground_truth_check_<time>/`;
238
+ it deletes nothing (`tools/ground_truth_check.py` lines 27-28, 201-206).
239
+ - Baseline: `ground_truth/digests.json` (sha256 and line count per output file, plus the data sha256) and
240
+ `ground_truth/manifest.json`. The output CSVs (about 920 MB) are git-ignored (`.gitignore`, card #62).
241
+ - Current baseline (`manifest.json`, generated 2026-10-20 on pynecore `ae6f03172d6127e88c6ae4f2ced61f0c93a6a331`):
242
+ 562 tested, 551 passed, 9 transpile failures, 2 runtime failures, 0 timeouts, 1,637 output files.
243
+ `digests.json` has 551 samples. The 2026-10-03 baseline (550 passed, 1,634 files) matched no current runtime;
244
+ it was made on a pynecore side branch (`88741ade6092`, checked on `ex_001` only).
245
+ - `pynecore_commit` (in `digests.json` and `manifest.json`): the full sha of the pynecore checkout that the `pyne`
246
+ in use imports, written by `generate_ground_truth.py`. `-dirty` is added when a tracked file under that
247
+ checkout's `src/` differs; the value is `null` when the runtime is not a pynecore checkout (`src/pynecore` of a
248
+ git work tree). `compare_ground_truth.py` prints the baseline and the runtime commit and WARNS when they differ,
249
+ or when either is `-dirty` or unknown; it never refuses for this reason.
250
+ - Data: `workdir/data/VN30F1M_15m.ohlcv`, data sha256 `e9ef984b09eaa6d2...` (`digests.json`).
251
+ Capital 10,000,000,000 and timeout 120 s per sample (`tools/_ground_truth_common.py`).
252
+ Why this capital: at 1,000,000 one VN30F1M contract costs more than the equity, so nearly every strategy
253
+ records zero trades (card #57; `tools/_ground_truth_common.py` lines 14-18).
254
+ - Exit codes of compare: 0 = every recorded sample verified (skipped nondeterministic files are listed, not judged);
255
+ 1 = digests missing or empty, a regression, a new failure, an unverified recorded sample or a stale mark;
256
+ 2 = `DATA CHANGED` (the data file is not the one of the baseline).
257
+ - A `REGRESSION` line names the sample and the file (`tools/compare_ground_truth.py` line 271). To see what changed,
258
+ diff that sample's CSV in the run root against the baseline copy in `ground_truth/<suite>/<sample>/`.
259
+ - `--suite sample` or `--suite sample_pds` rebuilds one suite and keeps the other suite's digests. It refuses
260
+ (exit 1) unless a baseline made on the same data AND the same known `pynecore_commit` exists
261
+ (`tools/generate_ground_truth.py` lines 250-258): one commit must describe the whole file.
262
+ - Before a new baseline is written, the old CSV folder moves to `backup/deleteable/ground_truth_csv_<time>/`;
263
+ nothing is deleted (`tools/generate_ground_truth.py` lines 260-267).
264
+ - Each sample runs in its own folder under `backup/deleteable/ground_truth_runs/<tool>-<time>/` (about 0.9 GB each).
265
+ No tool deletes them. Move old ones to the backup disk by hand, never `rm` (card #70, old README).
266
+ - Nondeterministic plot files: 11 `sample_pds` samples call an unseeded `math.random()` in a plot, so the digest of
267
+ their plot csv `<name>.csv` changes on every run (expds_022, 037, 039, 043, 045, 081, 091, 092, 104, 114, 115).
268
+ `manifest.json` marks exactly those files with `nondeterministic_files` on the sample entry. The list of the 11
269
+ samples is one tuple, `NONDETERMINISTIC_PLOT_SAMPLES` in `tools/_ground_truth_common.py`, and
270
+ `generate_ground_truth.py` writes the marks (a full run, or `--mark-nondeterministic-only`, which changes
271
+ only the manifest and runs no sample). Do not edit the marks by hand. `compare_ground_truth.py` skips only the
272
+ marked files, prints each one under `SKIPPED NONDETERMINISTIC FILES (N)`, and still checks every other file of
273
+ those samples (`_strat.csv`, `_trade.csv`, `_plot_meta.json`). A mark that no longer holds (the file matches
274
+ its digest, or the baseline records no such file) is listed under `STALE NONDETERMINISTIC MARKS` and fails the
275
+ run: regenerate the marks. A new sample with an unseeded `math.random()` needs its key in the tuple.
276
+ Checked 2026-10-20 on pynecore `ae6f03172`: two compares in a row each exited 0 (551 OK, 0 REGRESSION, 11 files skipped).
277
+ - The old shell wrapper was retired in card #66. `tools/ground_truth_check.py capture` then `compare` replace it.
278
+
279
+ Other tools in `tools/`: `corpus_transpile_ab.py --base <git ref>` (A/B of the transpiled corpus against another revision),
280
+ `_run_layout.py`, `_suite_report_compare.py`, `probes/`.
281
+
282
+ Test data. `workdir/` is git-ignored, so a fresh clone has no data. Both data files were checked on 2026-10-19:
283
+ ```bash
284
+ mkdir -p workdir/data
285
+ git show 227f3d2^:workdir/data/demo.ohlcv > workdir/data/demo.ohlcv # sha256 starts 67e827cc1a5f71ed
286
+ cp tests/fixtures/data/demo.toml workdir/data/demo.toml
287
+ (cd workdir && pyne data aggregate data/demo.ohlcv -tf 2D && pyne data aggregate data/demo.ohlcv -tf 5D)
288
+ git show 5d63d21:workdir/data/VN30F1M_15m.ohlcv > workdir/data/VN30F1M_15m.ohlcv # sha256 starts e9ef984b09eaa6d2
289
+ cp tests/fixtures/data/VN30F1M_15m.toml workdir/data/VN30F1M_15m.toml
290
+ ```
291
+ Take the `.toml` files from `tests/fixtures/data/`, not from the old commits: the old ones number weekdays 1..7,
292
+ and pynecore rejects day 7 (0 = Monday ... 6 = Sunday). Source: old README, project memory "pyne runtime gotchas".
293
+ The `/opencode-pine2pyne-setup` skill seeds a small synthetic fixture instead. That is fine for a smoke test, but the
294
+ results do not match the recorded numbers.
295
+
296
+ Lint: no linter config found in `pyproject.toml`. UNVERIFIED for any other file.
297
+
298
+ Deploy (release to PyPI): use the skill `/home/mike/.claude/skills/pypi-publish/SKILL.md`. The repo has no CI file
299
+ and no Makefile. `CHANGELOG.md` is the release log; add the entry for #115 to #118 at the next release.
300
+
301
+ Distributed optimization. `CLAUDE.md` and the old README name `tools/pyne-dynamic.sh`, `tools/pyne-parallel.sh` and
302
+ `tools/machines.txt`. **These files are not in this repo.** They moved out in commit `227f3d2`
303
+ ("move workdir/ and tools/ out to the pinescript workbench"). They exist at
304
+ `/home/mike/workspace/github/pinescript/tools/pyne-dynamic.sh`, `.../pyne-parallel.sh` and `.../machines.txt`.
305
+ Use those paths. That they run unchanged against this repo is UNVERIFIED. The tool options are in `CLAUDE.md`
306
+ ("Distributed Optimization") and `docs/misc/DynamicJobQueue.md`. `CLAUDE.md` also holds the cluster setup, the
307
+ machine file format and the troubleshooting table (headings "Shared: Machines file format", "Adding a new node",
308
+ "Troubleshooting").
309
+
310
+ ## 8. Data and keys
311
+
312
+ - Corpus: `sample/pinescript/` and `sample_pds/` (tracked `.pine` files).
313
+ - Test data: `workdir/data/` (git-ignored; restore with the commands in section 7).
314
+ - Baseline: `ground_truth/digests.json`, `ground_truth/manifest.json` (tracked).
315
+ - Run output: `workdir/scripts/`, `workdir/output/`, `test_results*.json|txt` (git-ignored).
316
+ - Disposable output: `backup/deleteable/` (git-ignored). Disk rule: `~/.claude/CLAUDE.md`, "Never Delete on the root disk".
317
+ - Key names only. `/home/mike/workspace/github/pine2pyne/.env` holds `PYPI_TOKEN`. `.gitignore` excludes it
318
+ (`.env`, `.env.*`, `*.pem`, `*.key`, `.pypirc`, `.netrc`). `git ls-files .env` shows it is not tracked.
319
+ - Environment names: `PINE_CPU_COUNT` and `PINE_MAX_WORKERS` (written by the setup skill into `.sandbox-env.sh`).
320
+ `PYNE_OPTIMIZE_MODE=1` is set by the optimizer in
321
+ `/home/mike/workspace/github/pynecore/plugins/pyne_optimize_and_stats_tools/pynecore_optimize_and_stats_tools/optimize.py`
322
+ (lines 312, 832 and 887).
323
+ - No other key or secret file was found in the repo files that were read.
324
+
325
+ ## 9. Related repos and skills
326
+
327
+ Calls this repo:
328
+ - `/home/mike/workspace/github/pinescript` (the strategy workbench). Its `CLAUDE.md` says the transpiler and runtime
329
+ moved out to `pine2pyne` and `pynecore`, and lists two ways to get the toolchain (editable installs, or PyPI).
330
+ The workbench holds `workdir/` and the cluster scripts of section 7.
331
+ - The skills below call `pine2pyne`. They are listed in the session skill list; their code was not read here.
332
+ `opencode-pyne-run`, `opencode-pine-test-run`, `sandbox-e2e`, `opencode-strategy-optimize`.
333
+
334
+ This repo calls:
335
+ - `/home/mike/workspace/github/pynecore` (runtime `opencode-pyneruntime`, the `pyne` CLI). The `.venv` of this repo
336
+ imports it from `/home/mike/workspace/github/pynecore/src/pynecore/` (checked with `import pynecore`).
337
+ The runtime is a fork of PyneSys/pynecore. Never change original pynecore files (see that repo's rules).
338
+ - Skills it uses: `opencode-pine2pyne-setup`, `pypi-publish`, `qa-remote-suite`, `mike-pc-test-run`.
339
+ Skills live in `/home/mike/.claude/skills/`.
340
+
341
+ Rules for every repo are in `/home/mike/.claude/CLAUDE.md`. This README does not copy them. Repo-specific
342
+ instructions (runtime code placement, pinned xfail bugs, pipeline notes) are in
343
+ `/home/mike/workspace/github/pine2pyne/CLAUDE.md`.