pineforge-codegen 1.6.3__tar.gz → 1.8.0__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.
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/CHANGELOG.md +355 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/CONTRIBUTING.md +30 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/PKG-INFO +10 -5
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/README.md +9 -4
- pineforge_codegen-1.8.0/VERSION +1 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/docs/PUBLIC_CONTRACT.md +96 -9
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/__init__.py +6 -1
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/base.py +561 -5
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/capabilities.py +8 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/checked_settings.py +13 -1
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/collection_history.py +95 -9
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/emit_top.py +141 -14
- pineforge_codegen-1.8.0/pineforge_codegen/codegen/graph_journal.py +540 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/helpers.py +22 -8
- pineforge_codegen-1.8.0/pineforge_codegen/codegen/history_sharing.py +222 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/host_members.py +1 -0
- pineforge_codegen-1.8.0/pineforge_codegen/codegen/id_sites.py +260 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/input.py +70 -7
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/security.py +706 -56
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/tables.py +160 -33
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/types.py +13 -1
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/visit_call.py +35 -32
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/visit_expr.py +26 -1
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/visit_stmt.py +15 -11
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/collection_history.py +1 -1
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/cpp_allowlist.py +3 -3
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/diagnostics_catalog.json +11 -2
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/lexer.py +62 -2
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/parser.py +76 -14
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/pragmas.py +3 -2
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/signatures.py +18 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/support_checker.py +14 -10
- pineforge_codegen-1.6.3/VERSION +0 -1
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/.gitignore +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/LEGAL.md +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/LICENSE +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/docs/codegen-coverage-gaps.md +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/docs/pine-cap-activation.md +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/analyzer/__init__.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/analyzer/base.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/analyzer/call_handlers.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/analyzer/contracts.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/analyzer/diagnostics.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/analyzer/tables.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/analyzer/types.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/ast_nodes.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/block_locals.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/builtin_keywords.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/__init__.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/constant_fold.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/drawing.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/helpers_syminfo.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/order_shapes.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/run_stops.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/session_market.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/ta.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/codegen/tv_number_format.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/diagnostic_codes.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/errors.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/external_requests.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/finite_ta_length.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/library_inline.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/library_modules.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/library_v5.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/limits.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/matrix_overloads.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/method_binding.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/pine_libraries.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/pine_spelling.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/request_discovery.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/request_feed_inventory.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/security_contexts.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/session_reads.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/symbols.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/timeframe_token_cli.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/tokens.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pineforge_codegen/tv_input_choices.py +0 -0
- {pineforge_codegen-1.6.3 → pineforge_codegen-1.8.0}/pyproject.toml +0 -0
|
@@ -20,6 +20,361 @@ supported as exact pairs; on the 0.x line they are independent. See the
|
|
|
20
20
|
the release commit. A prerelease note describes changes since the preceding
|
|
21
21
|
prerelease or stable tag; the final stable note consolidates the series.
|
|
22
22
|
|
|
23
|
+
## Unreleased
|
|
24
|
+
|
|
25
|
+
Planned as 1.8.0, a minor release of the exact engine/codegen pair, paired with
|
|
26
|
+
engine `v1.8.0`. This entry records what changed in this repository since
|
|
27
|
+
1.7.0 and nothing else: the behaviour changes, the CHANGELOG-only change and
|
|
28
|
+
the fixes that ship in the same release. The behaviour changes alter the
|
|
29
|
+
published input manifest, the emitted C++ for scripts that read
|
|
30
|
+
`strategy.account_currency`, have a persistent declaration whose initializer
|
|
31
|
+
depends on earlier statements, have a helper-local `var color` or a
|
|
32
|
+
`request.security` rollback hook, use a pivot-levels helper or an array or
|
|
33
|
+
matrix history read, bind `fclose`, have a calendar timestamp lambda whose body
|
|
34
|
+
identifiers collide with requested-context bindings, or use
|
|
35
|
+
`calc_on_order_fills` with growing primitive arrays, maps or matrices, and the
|
|
36
|
+
accepted input (line endings, one-line field assignments, an unevaluated
|
|
37
|
+
`request.currency_rate`).
|
|
38
|
+
|
|
39
|
+
### Compatibility and migration
|
|
40
|
+
|
|
41
|
+
- Pairs with engine `v1.8.0` exactly. Regenerate strategy C++ with this release
|
|
42
|
+
and relink every strategy library against the engine `v1.8.0` headers and
|
|
43
|
+
`libpineforge.a`, even when the C ABI number is unchanged (README
|
|
44
|
+
[Engine pairing](README.md#engine-pairing)).
|
|
45
|
+
- **Hosts must recognize the new input type `color`.** The input manifest
|
|
46
|
+
(`transpile_full()` and the Pyodide/glue manifest) now reports every
|
|
47
|
+
`input.color` entry as `"type": "color"` with an unsigned packed
|
|
48
|
+
`0xAARRGGBB` integer `default` (`color.red` is `4294063685`, `0xFFF23645`;
|
|
49
|
+
transparency is included), where 1.7.0 and earlier reported `"type": "string"`
|
|
50
|
+
with a Pine-spelling default such as `"color.red"`. A host with a closed list
|
|
51
|
+
of manifest types needs a `color` arm. Treat the default as a number in
|
|
52
|
+
`0..4294967295`: do not parse it as a signed 32-bit integer, and send its
|
|
53
|
+
decimal text to the native setter (`get_input_int64`). A default that cannot
|
|
54
|
+
be folded to a constant keeps its previous (null) metadata. `supported`, the
|
|
55
|
+
emitted C++, the native setters and receipts, and the C ABI are unchanged.
|
|
56
|
+
`pineforge-hpo` accepts color inputs from its 1.8.0 release (a packed integer
|
|
57
|
+
in `0..4294967295`, booleans refused).
|
|
58
|
+
- Every generated strategy library gains the two id-sites receipt exports (see
|
|
59
|
+
the entry below); trading code is unchanged. Apart from that, the emitted C++
|
|
60
|
+
is intended to change only for the scripts the entries below name: those that
|
|
61
|
+
read `strategy.account_currency`, whose persistent declarations depend on
|
|
62
|
+
earlier statements, with a helper-local `var color`, with a helper that reads
|
|
63
|
+
the history of a derived argument, with a pivot-levels helper or an array or
|
|
64
|
+
matrix history read, that bind `fclose`, with a calendar timestamp lambda
|
|
65
|
+
whose body identifiers collide with requested-context bindings, or with a
|
|
66
|
+
`request.security` (for the late-restore change alone, only the
|
|
67
|
+
generated `restore_script_state()` changes, in 72 of the 555 corpus and
|
|
68
|
+
fixture scripts; the other entries change the scripts they name). This is
|
|
69
|
+
the design intent of the pull requests and their tests, not a byte
|
|
70
|
+
comparison of generated C++ against 1.7.0. Nine diagnostic codes are added
|
|
71
|
+
(`PF-E3093`, the refusal for a helper-local `var` of an unsupported type, and
|
|
72
|
+
`PF-E3094` through `PF-E3101`, the refusals of a derived helper-argument
|
|
73
|
+
history) and
|
|
74
|
+
the user-facing text of `PF-E1088` and `PF-W1088` is reworded; the catalog
|
|
75
|
+
schema is not changed.
|
|
76
|
+
- Engine behavior changes are described in the paired engine's own release
|
|
77
|
+
notes; this entry does not summarize them.
|
|
78
|
+
|
|
79
|
+
### Changes since 1.7.0
|
|
80
|
+
|
|
81
|
+
- Preserve the calendar timestamp lambda's fixed body when a request
|
|
82
|
+
expression also reads a mutable global, helper local, loop counter or tuple
|
|
83
|
+
element whose name matches a body identifier, including history reads.
|
|
84
|
+
Calendar argument expressions still read their requested-context bindings.
|
|
85
|
+
- Avoid libc name collisions in generated C++: pivot-level helpers use
|
|
86
|
+
`open_price`, array and matrix history helpers use `open_slot`, and authored
|
|
87
|
+
`fclose` names are escaped. Scripts using either helper change only that
|
|
88
|
+
renamed identifier; scripts binding `fclose` change its escaped spelling.
|
|
89
|
+
- Avoid copying growing primitive arrays at each order-fill checkpoint when
|
|
90
|
+
their writes can be tracked completely. Rollback records individual edits;
|
|
91
|
+
bulk operations retain full preimages, and other arrays keep their existing
|
|
92
|
+
snapshots. The generated strategy class of a script that uses this is not
|
|
93
|
+
copyable or movable.
|
|
94
|
+
- Avoid checkpoint copies for isolated primitive maps and matrices with fully
|
|
95
|
+
tracked writes. Sparse writes use individual undo records; bulk mutations
|
|
96
|
+
save at most one full preimage per root between checkpoint or restore
|
|
97
|
+
boundaries. Dense writes switch to that preimage after exhausting the
|
|
98
|
+
element-count budget, preserving key order, matrix shape and handle identity.
|
|
99
|
+
- Reuse unchanged primitive-array history snapshots when every write can be
|
|
100
|
+
tracked, while preserving detached historical values and order-fill rollback.
|
|
101
|
+
The generated strategy class of a script that uses this is not copyable or
|
|
102
|
+
movable.
|
|
103
|
+
- Fix a silent wrong value under `calc_on_order_fills`: a fill recalculation
|
|
104
|
+
that ran after a deferred `request.security` evaluation (for example a late
|
|
105
|
+
margin-call liquidation) restored the strategy checkpoint taken before that
|
|
106
|
+
evaluation and rolled the requested context's own state back (helper-local
|
|
107
|
+
`var` series, requested TA objects, OHLC and expression histories, mutable
|
|
108
|
+
copies and bar-index clocks), while the engine's requested aggregators had
|
|
109
|
+
already advanced. The generated `restore_script_state()` now leaves that
|
|
110
|
+
requested progression alone and still restores the chart's state and the
|
|
111
|
+
merged request results; payloads that keep user calls on the chart's bar
|
|
112
|
+
(the chart-fallback warning) keep their old rollback, and so do the shared
|
|
113
|
+
helper-local `var` series of a script that has such a payload, so the
|
|
114
|
+
late-restore loss is fixed for every script without that warning and not
|
|
115
|
+
for the helper-local state of a script that has it. The emitted C++ changes
|
|
116
|
+
only in that one function; no engine change or ABI change is involved.
|
|
117
|
+
- Initialize a persistent (`var`) UDT, array, map or matrix once at its
|
|
118
|
+
declaration, in statement order, when its initializer reads a value computed
|
|
119
|
+
earlier in the statement walk: an earlier declaration, reassignment, field
|
|
120
|
+
write, collection method or global read by a user helper
|
|
121
|
+
([#226](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/226)).
|
|
122
|
+
The first-bar preamble previously read the zero default. Emitted C++ changes
|
|
123
|
+
only for scripts with such a dependency; independent constructors and
|
|
124
|
+
callable-local declarations keep their routes. A `varip` declaration with the
|
|
125
|
+
same dependency takes the same route, with its storage and once flag left out
|
|
126
|
+
of the `calc_on_order_fills` rollback checkpoint
|
|
127
|
+
([#258](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/258)).
|
|
128
|
+
- Raise currency-conversion errors only when `request.currency_rate` is
|
|
129
|
+
evaluated, not when the call merely appears in a branch that never runs
|
|
130
|
+
([#228](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/228)).
|
|
131
|
+
No currency-rate data feed is added: an evaluated call stops the run with a
|
|
132
|
+
no-data error. Only the diagnostic text of scripts that previously failed to
|
|
133
|
+
translate changes, and the wording of one warning; a call that names its second argument `to = ...` still
|
|
134
|
+
does not parse, as before.
|
|
135
|
+
- Support explicit and inferred helper-local `var color` state in
|
|
136
|
+
`request.security`, preserving persistence, transparency and `na`
|
|
137
|
+
([#229](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/229)).
|
|
138
|
+
The epoch-width integer and the collection, object and drawing refusals are
|
|
139
|
+
unchanged; the refusal for any other unsupported helper-local `var` type has
|
|
140
|
+
the new code `PF-E3093`.
|
|
141
|
+
- Sample the history of a derived helper argument on the requested context's
|
|
142
|
+
own bars in `request.security`: a helper such as `f(x) => x[1]` called as
|
|
143
|
+
`f(close - open)` now reads the previous value of the argument on the
|
|
144
|
+
requested bars, not the chart's bars
|
|
145
|
+
([#229](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/229)).
|
|
146
|
+
The argument is sampled through one ring per call site, which the
|
|
147
|
+
late-restore rule above leaves alone with the rest of the requested state.
|
|
148
|
+
Shapes that cannot be sampled are refused with located errors, `PF-E3094`
|
|
149
|
+
through `PF-E3101`: a derived history offset that is not a non-negative
|
|
150
|
+
constant integer, a ring capacity that is not representable, a call that is
|
|
151
|
+
not unconditional, a helper that depends on other helpers' state, history
|
|
152
|
+
composed with helper-result history, a mutable global that cannot be
|
|
153
|
+
replayed, and a parameter whose type or width has no lossless history.
|
|
154
|
+
Direct OHLC and time bindings, builtin forms and method envelopes keep their
|
|
155
|
+
existing lowering.
|
|
156
|
+
- Accept a UDT field assignment (`:=`, `+=`, ...) as the body of a one-line
|
|
157
|
+
function or method, `set(State s) => s.value := 1`, translating like the same
|
|
158
|
+
body on its own indented line
|
|
159
|
+
([#230](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/230)).
|
|
160
|
+
A plain-name or subscript target in a one-line body keeps its parser error.
|
|
161
|
+
- Fix `input.color` metadata so its default round-trips through the native
|
|
162
|
+
input setter ([#231](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/231),
|
|
163
|
+
[#251](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/251)).
|
|
164
|
+
Python `transpile_full()` and the Pyodide/glue manifest now report
|
|
165
|
+
`type: "color"` and an unsigned packed `0xAARRGGBB` integer default for named
|
|
166
|
+
Pine v6 colors, hex literals and literal `color.new` / `color.rgb`
|
|
167
|
+
expressions, including transparency. Unfoldable defaults retain their previous
|
|
168
|
+
metadata; accepted expressions are unchanged. See the migration note above.
|
|
169
|
+
- Fix `strategy.account_currency` to return the declared constant currency,
|
|
170
|
+
falling back to the symbol currency when omitted or `currency.NONE`, and
|
|
171
|
+
support currency-constant comparisons and string concatenation
|
|
172
|
+
([#227](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/227),
|
|
173
|
+
[#250](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/250)).
|
|
174
|
+
No currency conversion is added; only the value the script reads changes, so a
|
|
175
|
+
script that branches on `strategy.account_currency` can now take a different
|
|
176
|
+
branch than under 1.7.0.
|
|
177
|
+
- Accept CRLF and lone CR code line endings like LF across the Python and JSON
|
|
178
|
+
translation entry points, preserving generated C++, diagnostics and literal
|
|
179
|
+
string contents
|
|
180
|
+
([#230](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/230),
|
|
181
|
+
[#252](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/252)).
|
|
182
|
+
This is the line-ending part of #230; a lone `\r` inside a string literal
|
|
183
|
+
stays data. Output for LF sources is unchanged.
|
|
184
|
+
- Report how many order sites create a computed id in one execution of the
|
|
185
|
+
script (not per bar: `calc_on_order_fills` runs the script again after each
|
|
186
|
+
fill). Every generated
|
|
187
|
+
strategy library also defines `strategy_id_sites_api_version()`, which returns
|
|
188
|
+
1, and `strategy_id_sites_receipt(s, json, capacity, required, error,
|
|
189
|
+
error_capacity)`, beside the order-shapes receipt and with the same buffer
|
|
190
|
+
protocol. Its canonical JSON, `{"strategy":{"ids":{"freshPerBar":K}},"version":1}`,
|
|
191
|
+
counts the lowered `strategy.entry`, `strategy.order` and `strategy.exit` sites
|
|
192
|
+
whose `id` is not a literal, once per static call of the function that holds
|
|
193
|
+
them and once per iteration of a `for` loop with known bounds; a loop without a
|
|
194
|
+
static bound or a recursion around a computed id gives
|
|
195
|
+
`{"strategy":{"ids":{"freshPerBarStatus":"unbounded"}},"version":1}`. The
|
|
196
|
+
emitted C++ of every strategy gains the two exports; trading code is unchanged.
|
|
197
|
+
- Backfill release notes for earlier codegen releases, including the Security
|
|
198
|
+
entry for GHSA-5www-2x9c-mgr6
|
|
199
|
+
([#248](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/248)).
|
|
200
|
+
|
|
201
|
+
## 1.7.0 — 2026-10-25
|
|
202
|
+
|
|
203
|
+
A minor release of the exact engine/codegen pair, paired with engine `v1.7.0`
|
|
204
|
+
and dated 2026-10-25. This entry records what changed in this repository since
|
|
205
|
+
1.6.3, and nothing else: three pull requests merged after `v1.6.3`, one of which
|
|
206
|
+
changes the emitted C++ and the other two only the repository's own CI.
|
|
207
|
+
|
|
208
|
+
### Compatibility and migration
|
|
209
|
+
|
|
210
|
+
- Pairs with engine `v1.7.0` exactly. Regenerate strategy C++ with this release
|
|
211
|
+
and relink every strategy library against the engine `v1.7.0` headers and
|
|
212
|
+
`libpineforge.a`; this applies even when the C ABI number is unchanged
|
|
213
|
+
(README [Engine pairing](README.md#engine-pairing)). Replacing the archive
|
|
214
|
+
alone does not update a statically linked strategy library.
|
|
215
|
+
- The emitted C++ changes, as described below: every generated library gains a
|
|
216
|
+
new exported function, the generated constructor gains a guarded statement
|
|
217
|
+
for scripts that do not read closed-trade rows, and the set of reserved names
|
|
218
|
+
grows. The Python API, the diagnostic codes and severities, and the catalog
|
|
219
|
+
schema are not changed; the order-shapes receipt's `host_reads` list gains
|
|
220
|
+
`set_trade_history_streamable` for scripts that do not read closed-trade rows.
|
|
221
|
+
- Engine behavior changes are described in the paired engine's own release
|
|
222
|
+
notes; this entry does not summarize them.
|
|
223
|
+
|
|
224
|
+
### Changes since 1.6.3
|
|
225
|
+
|
|
226
|
+
- Declare whether the emitted code reads closed-trade rows, and let scripts that
|
|
227
|
+
do not read them opt into streamed trade history
|
|
228
|
+
([#213](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/213)).
|
|
229
|
+
Generated libraries now export `int strategy_reads_trade_history(void)`: `1`
|
|
230
|
+
when the emitted code reads a `strategy.closedtrades.*` accessor, `0` when it
|
|
231
|
+
does not. The closed-trade count (`strategy.closedtrades` alone) and the
|
|
232
|
+
open-trade accessors (`strategy.opentrades.*`) do not count as reads. For a
|
|
233
|
+
script that does not read closed-trade rows, the generated constructor calls
|
|
234
|
+
`this->set_trade_history_streamable(true)`, guarded by
|
|
235
|
+
`#if defined(PINEFORGE_HAS_TRADE_HISTORY_POLICY_V1)` so that it compiles
|
|
236
|
+
against engine headers that lack the setter; a script that reads closed-trade
|
|
237
|
+
rows emits no such call, and the order-shapes receipt's `host_reads` names the
|
|
238
|
+
setter for non-readers only. The constructor's host calls are now qualified
|
|
239
|
+
(`this->configure_pine_strategy(cfg)`). A library generated by an earlier
|
|
240
|
+
release has no such export, and its absence does not establish that the
|
|
241
|
+
script is a non-reader. What the engine does with the streaming setting is
|
|
242
|
+
described in the engine `v1.7.0` release notes.
|
|
243
|
+
- Reserve more names in generated C++ and escape them as `pf_safe_<name>` when a
|
|
244
|
+
Pine identifier uses one (same pull request, documented in the new
|
|
245
|
+
"Identifiers in generated C++" section of
|
|
246
|
+
[docs/PUBLIC_CONTRACT.md](docs/PUBLIC_CONTRACT.md)): the engine namespaces and
|
|
247
|
+
types that `using namespace pineforge;` brings into scope (`report`,
|
|
248
|
+
`report_sink`, `report_sequence`, `source`, `native_calendar`, `pine_color`,
|
|
249
|
+
`RunFailureCode`, `RunFailureInfo`, `QtyType`, `CommissionType`, `XLoc`,
|
|
250
|
+
`YLoc`, `normalize_timezone_for_posix`), the generated C exports
|
|
251
|
+
(`strategy_create`, `strategy_create_checked`, `run_backtest`,
|
|
252
|
+
`run_backtest_full`, `run_backtest_full_checked`, `strategy_free`,
|
|
253
|
+
`report_free`, `strategy_set_input`, `strategy_set_input_checked`,
|
|
254
|
+
`strategy_set_override`, `strategy_set_override_checked`,
|
|
255
|
+
`strategy_set_magnifier_volume_weighted` and the new
|
|
256
|
+
`strategy_reads_trade_history`), the feature macros
|
|
257
|
+
`PINEFORGE_HAS_TRADE_HISTORY_POLICY_V1` and
|
|
258
|
+
`PINEFORGE_HAS_SYMBOL_SECURITY_EVAL_V1`, and the host member
|
|
259
|
+
`set_trade_history_streamable`. A Pine `type report`, for example, now becomes
|
|
260
|
+
`struct pf_safe_report`; before, such a script could fail to compile against the
|
|
261
|
+
1.7.0 engine headers with an ambiguous reference. User-defined type handles
|
|
262
|
+
and `request.security` evaluators use the escaped spelling too. An identifier
|
|
263
|
+
that does not collide keeps its spelling. The existing `CPP_RESERVED` export lists the new
|
|
264
|
+
names; no new reserved-name API is introduced.
|
|
265
|
+
- Repository and CI only, no effect on emitted C++ or on the Python and JSON
|
|
266
|
+
contract: the `promote-baseline` workflow refuses untrusted heads and actors
|
|
267
|
+
(SEC846,
|
|
268
|
+
[#242](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/242)),
|
|
269
|
+
and `test.yml` adopts the organization's CI canon (CR-241,
|
|
270
|
+
[#243](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/243)).
|
|
271
|
+
|
|
272
|
+
## 1.6.3 — 2026-10-23
|
|
273
|
+
|
|
274
|
+
A patch release of the exact engine/codegen pair, paired with engine `v1.6.3`
|
|
275
|
+
and dated 2026-10-23. This entry records what changed in this repository since
|
|
276
|
+
1.6.2 and nothing else: one security fix to the emitted C++, merged from a
|
|
277
|
+
private fork (commit `041889818e2206fdf7261574128064fb0b4142ad`), and four pull
|
|
278
|
+
requests that change only the repository's own CI, publishing and documentation.
|
|
279
|
+
|
|
280
|
+
### Security
|
|
281
|
+
|
|
282
|
+
- Published advisory
|
|
283
|
+
[GHSA-5www-2x9c-mgr6](https://github.com/pineforge-4pass/pineforge-codegen-oss/security/advisories/GHSA-5www-2x9c-mgr6),
|
|
284
|
+
"Codegen can emit C++ calls and type names taken from the input script"
|
|
285
|
+
(severity high, CWE-94). Fixed in 1.6.3 of both packages. The affected
|
|
286
|
+
versions are `pineforge-codegen` from 0.6.4 up to but not including 1.6.3 and
|
|
287
|
+
`@pineforge/codegen-pyodide` from 0.7.0 up to but not including 1.6.3, which
|
|
288
|
+
ships the same Python sources. Images of
|
|
289
|
+
`ghcr.io/pineforge-4pass/pineforge-release` before 1.6.3 contain an affected
|
|
290
|
+
codegen; the 1.6.3 image contains the fixed one. Upgrade to 1.6.3 or later; the
|
|
291
|
+
advisory states the mitigation and the upgrade steps and, like this entry,
|
|
292
|
+
contains no reproduction recipe.
|
|
293
|
+
|
|
294
|
+
### Compatibility and migration
|
|
295
|
+
|
|
296
|
+
- Scripts that reached the two affected paths are now refused instead of
|
|
297
|
+
transpiled. A call or member that the codegen has no lowering for ends with
|
|
298
|
+
`<name>(...) is not implemented in PineForge runtime.` where it used to be
|
|
299
|
+
written into the emitted C++; a token that is not a type, in a type position
|
|
300
|
+
or inside `<...>`, ends with a located parse error; and `array.new` or
|
|
301
|
+
`array.from` with an undeclared element type is refused with the same
|
|
302
|
+
"not implemented" message. A script that compiled under 1.6.2 can therefore
|
|
303
|
+
fail with a compile or parse error under 1.6.3, and this is the intended
|
|
304
|
+
effect of the fix. For scripts that stay accepted the emitted C++ is unchanged
|
|
305
|
+
except that the default of an enum-typed element is `na<double>()` (a type
|
|
306
|
+
name that is not a declared user type falls back to its slot's default) and
|
|
307
|
+
`format`, `currency` and `order` values are typed `std::string`. A pair change
|
|
308
|
+
requires regenerated C++ and relinked strategy libraries against the paired
|
|
309
|
+
engine release's headers and `libpineforge.a` (README
|
|
310
|
+
[Engine pairing](README.md#engine-pairing)); regenerate any C++ that an
|
|
311
|
+
affected release produced from a script you do not trust.
|
|
312
|
+
|
|
313
|
+
### Changes since 1.6.2
|
|
314
|
+
|
|
315
|
+
- Run every codegen job on GitHub-hosted runners
|
|
316
|
+
([#237](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/237)).
|
|
317
|
+
- Publish to npm only by operator dispatch, in the main-only `npm-publish`
|
|
318
|
+
environment
|
|
319
|
+
([#238](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/238)),
|
|
320
|
+
and state the npm publishing bound as it now exists: both npm jobs run in that
|
|
321
|
+
environment
|
|
322
|
+
([#240](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/240)).
|
|
323
|
+
- Stop naming a retired private campaign repository in five lines of the
|
|
324
|
+
documentation
|
|
325
|
+
([#239](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/239)).
|
|
326
|
+
|
|
327
|
+
## 1.6.2 — 2026-10-21
|
|
328
|
+
|
|
329
|
+
A patch release of the exact engine/codegen pair, paired with engine `v1.6.2`
|
|
330
|
+
and dated 2026-10-21; the prerelease `1.6.2-rc.1` (2026-10-19) pairs with engine
|
|
331
|
+
`v1.6.2-rc.1`. This entry records what changed in this repository since 1.6.1
|
|
332
|
+
and nothing else: a checker for generated C++ and a reserved-name change in the
|
|
333
|
+
emitter, a change of the licensor's written entity, and CI changes.
|
|
334
|
+
|
|
335
|
+
### Compatibility and migration
|
|
336
|
+
|
|
337
|
+
- New command `pf-cpp-allowlist` (`pineforge_codegen.cpp_allowlist:main`,
|
|
338
|
+
installed with the package), a checker for a generated C++ translation unit
|
|
339
|
+
that flags dangerous primitives
|
|
340
|
+
([#210](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/210),
|
|
341
|
+
CR-164 S1). It is a denylist with known false positives, a mitigation and not
|
|
342
|
+
proof that a unit is safe (the wording of the 1.6.3 security advisory).
|
|
343
|
+
- A script identifier equal to a symbol that the checker refuses when it appears
|
|
344
|
+
bare (`system`, `free`, `socket`, `open` and the rest of the list in
|
|
345
|
+
`pineforge_codegen/codegen/helpers.py`, `LIBC_RESERVED_NAMES`) is now emitted
|
|
346
|
+
as `pf_safe_<name>` instead of the bare libc name, so the emitted C++ for
|
|
347
|
+
scripts that declare such a name changes.
|
|
348
|
+
- A pair change requires regenerated C++ and relinked strategy libraries against
|
|
349
|
+
the paired engine release's headers and `libpineforge.a` (README
|
|
350
|
+
[Engine pairing](README.md#engine-pairing)).
|
|
351
|
+
|
|
352
|
+
### Changes since 1.6.1
|
|
353
|
+
|
|
354
|
+
- The licensor entity is written exactly as `PINEFORGE LLC` in `LICENSE`,
|
|
355
|
+
`LEGAL.md` and `CONTRIBUTING.md`
|
|
356
|
+
([#234](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/234)).
|
|
357
|
+
- CI: Linux x64 jobs on the pf-ci-spot pool
|
|
358
|
+
([#212](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/212),
|
|
359
|
+
tracked at fragment b240f6d7 in
|
|
360
|
+
[#215](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/215)),
|
|
361
|
+
credentialed release and deploy jobs kept on hosted runners
|
|
362
|
+
([#214](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/214)), a
|
|
363
|
+
guarded job and a token-free OIDC job to claim the PyPI `tunaxis-codegen` and
|
|
364
|
+
npm `@tunaxis/codegen-pyodide` names with a 0.0.1 placeholder
|
|
365
|
+
([#216](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/216),
|
|
366
|
+
[#217](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/217)), the
|
|
367
|
+
App-token owner following the repository owner
|
|
368
|
+
([#221](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/221)),
|
|
369
|
+
the open Dependabot bumps folded and pinned by SHA with the exact release
|
|
370
|
+
([#223](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/223)),
|
|
371
|
+
superseded pull-request runs of the gate and test workflows cancelled
|
|
372
|
+
([#225](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/225)),
|
|
373
|
+
`timeout-minutes` dropped from `gate.yml` and `test.yml`
|
|
374
|
+
([#233](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/233)),
|
|
375
|
+
and the pull-request suite skipped on draft pull requests
|
|
376
|
+
([#236](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/236)).
|
|
377
|
+
|
|
23
378
|
## 1.6.1 — 2026-10-18
|
|
24
379
|
|
|
25
380
|
A patch release of the exact engine/codegen pair, paired with engine `v1.6.1`
|
|
@@ -109,6 +109,36 @@ the Python `build` frontend, run `python -m build`, assemble the npm payload,
|
|
|
109
109
|
then run `npm pack --dry-run` from `npm/`. These commands build local artifacts;
|
|
110
110
|
publishing is a separate release operation.
|
|
111
111
|
|
|
112
|
+
`promote-baseline.yml` runs from the base repository on `pull_request_target`
|
|
113
|
+
closes and `workflow_dispatch`, and its credential job depends on
|
|
114
|
+
`promote-guard`. The guard has empty job permissions, holds no secrets, and
|
|
115
|
+
checks out no code. Every pull request close first requires a head in this
|
|
116
|
+
repository with `fork == false`, even when unmerged. An author outside
|
|
117
|
+
`OWNER`/`MEMBER`/`COLLABORATOR` and the
|
|
118
|
+
`dependabot[bot]`/`pineforge-app[bot]` allowlist must have
|
|
119
|
+
`admin`/`maintain`/`write` permission returned by GitHub, including a
|
|
120
|
+
`CONTRIBUTOR` whose organization membership is private. A failed author
|
|
121
|
+
lookup, an empty permission, or a non-write permission refuses the close
|
|
122
|
+
before any unmerged exit or merger check.
|
|
123
|
+
A merged pull request also requires an allowlisted merger or a successful
|
|
124
|
+
`admin`/`maintain`/`write` permission lookup for the merger. An empty merger,
|
|
125
|
+
a failed merger lookup, or an empty or non-write merger permission refuses
|
|
126
|
+
promotion.
|
|
127
|
+
An unmerged close of our own allowed pull request passes the guard with
|
|
128
|
+
promotion skipped. Manual dispatch requires repository write access, and
|
|
129
|
+
every other event is refused.
|
|
130
|
+
|
|
131
|
+
App-token minting jobs use two main-only GitHub environments: human-dispatched
|
|
132
|
+
release jobs use `release`, with the owner as required reviewer; automatic
|
|
133
|
+
baseline promotion (including its manual re-fire) uses `release-bot`, without
|
|
134
|
+
a reviewer. The `workflow-lint` preflight checks every workflow and requires a
|
|
135
|
+
literal, non-empty job environment for App-token actions or private-key secret
|
|
136
|
+
use, and flags recognizable scripted minting for human review. Keep this change
|
|
137
|
+
in draft until the owner confirms both environments and their same-name secret
|
|
138
|
+
copies exist. For rollback, remove the added `environment:` lines and revert
|
|
139
|
+
their policy pins together; repository-level secret copies remain available
|
|
140
|
+
until the owner deletes them after the dry runs.
|
|
141
|
+
|
|
112
142
|
## npm publication (operators)
|
|
113
143
|
|
|
114
144
|
The release and npm publication workflows run on GitHub-hosted runners.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pineforge-codegen
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
4
4
|
Summary: PineScript v6 to C++ transpiler that targets the pineforge-engine runtime.
|
|
5
5
|
Project-URL: Homepage, https://github.com/pineforge-4pass/pineforge-codegen-oss
|
|
6
6
|
Project-URL: Issues, https://github.com/pineforge-4pass/pineforge-codegen-oss/issues
|
|
@@ -368,8 +368,9 @@ Give each input a unique title; different `group=` labels do not separate
|
|
|
368
368
|
override keys. The paired checked path refuses a shared key and returns a null
|
|
369
369
|
fingerprint for a completed run of such a script even without an override.
|
|
370
370
|
The [1.4.0 migration notes](CHANGELOG.md#140--2026-10-08) cover this change,
|
|
371
|
-
new refusals of some previously accepted settings, and
|
|
372
|
-
|
|
371
|
+
new refusals of some previously accepted settings, and that release's color
|
|
372
|
+
metadata mismatch. Current color manifests use `type: "color"` with a packed
|
|
373
|
+
integer default; check stored presets before submitting them.
|
|
373
374
|
Users of `pineforge-hpo` 0.11.0 must preserve the manifest's number type for
|
|
374
375
|
each option at its input boundary; see the [known issue](CHANGELOG.md#known-issues-with-consumers).
|
|
375
376
|
|
|
@@ -528,8 +529,12 @@ not a lossless-string promise. Literal Unicode and escaped backslashes are
|
|
|
528
529
|
retained. Run-time arithmetic, `not true` and calendar-part `timestamp` values
|
|
529
530
|
still have no published default or unfoldable bounds; a folded
|
|
530
531
|
`timestamp("...")` is a literal. The whole numeric `options` field is omitted
|
|
531
|
-
if any choice is unfoldable.
|
|
532
|
-
|
|
532
|
+
if any choice is unfoldable. An `input.color` has manifest `type: "color"` and
|
|
533
|
+
a literal-foldable `default` encoded as an unsigned `0xAARRGGBB` integer:
|
|
534
|
+
`color.red` is `4294063685` (`0xFFF23645`), and `color.new` / `color.rgb` include
|
|
535
|
+
their literal transparency. Preserve that integer and pass its decimal text to
|
|
536
|
+
the native input setter. Releases through 1.7.0 published a `string` type and
|
|
537
|
+
Pine spelling for colors; the generated C++ and other input types are unchanged.
|
|
533
538
|
The [contract](docs/PUBLIC_CONTRACT.md#input-manifest-and-override-keys) lists
|
|
534
539
|
these retained limits. The PyPI and Pyodide manifests carry the same fields; no key is
|
|
535
540
|
renamed or removed, and the changelog lists the values that changed.
|
|
@@ -83,8 +83,9 @@ Give each input a unique title; different `group=` labels do not separate
|
|
|
83
83
|
override keys. The paired checked path refuses a shared key and returns a null
|
|
84
84
|
fingerprint for a completed run of such a script even without an override.
|
|
85
85
|
The [1.4.0 migration notes](CHANGELOG.md#140--2026-10-08) cover this change,
|
|
86
|
-
new refusals of some previously accepted settings, and
|
|
87
|
-
|
|
86
|
+
new refusals of some previously accepted settings, and that release's color
|
|
87
|
+
metadata mismatch. Current color manifests use `type: "color"` with a packed
|
|
88
|
+
integer default; check stored presets before submitting them.
|
|
88
89
|
Users of `pineforge-hpo` 0.11.0 must preserve the manifest's number type for
|
|
89
90
|
each option at its input boundary; see the [known issue](CHANGELOG.md#known-issues-with-consumers).
|
|
90
91
|
|
|
@@ -243,8 +244,12 @@ not a lossless-string promise. Literal Unicode and escaped backslashes are
|
|
|
243
244
|
retained. Run-time arithmetic, `not true` and calendar-part `timestamp` values
|
|
244
245
|
still have no published default or unfoldable bounds; a folded
|
|
245
246
|
`timestamp("...")` is a literal. The whole numeric `options` field is omitted
|
|
246
|
-
if any choice is unfoldable.
|
|
247
|
-
|
|
247
|
+
if any choice is unfoldable. An `input.color` has manifest `type: "color"` and
|
|
248
|
+
a literal-foldable `default` encoded as an unsigned `0xAARRGGBB` integer:
|
|
249
|
+
`color.red` is `4294063685` (`0xFFF23645`), and `color.new` / `color.rgb` include
|
|
250
|
+
their literal transparency. Preserve that integer and pass its decimal text to
|
|
251
|
+
the native input setter. Releases through 1.7.0 published a `string` type and
|
|
252
|
+
Pine spelling for colors; the generated C++ and other input types are unchanged.
|
|
248
253
|
The [contract](docs/PUBLIC_CONTRACT.md#input-manifest-and-override-keys) lists
|
|
249
254
|
these retained limits. The PyPI and Pyodide manifests carry the same fields; no key is
|
|
250
255
|
renamed or removed, and the changelog lists the values that changed.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.8.0
|
|
@@ -7,6 +7,50 @@ Text marked **since 1.5.0** describes diagnostic additions that 1.4.0 and
|
|
|
7
7
|
earlier releases do not have: the `note` severity, the `user_message` template
|
|
8
8
|
and the eleven codes that became notes.
|
|
9
9
|
|
|
10
|
+
## Identifiers in generated C++
|
|
11
|
+
|
|
12
|
+
Legal Pine identifiers that collide with C++ keywords, engine names or emitter
|
|
13
|
+
temporaries are escaped in generated C++; they remain valid Pine names. The
|
|
14
|
+
existing `pineforge_codegen.codegen.CPP_RESERVED` export contains the explicit
|
|
15
|
+
reserved names. `_safe_name` also escapes emitter temporary patterns and
|
|
16
|
+
allocates a distinct name when the script already uses the preferred escape.
|
|
17
|
+
An identifier that does not collide keeps its spelling.
|
|
18
|
+
|
|
19
|
+
The imported engine names `report`, `report_sink`, `report_sequence`, `source`,
|
|
20
|
+
`native_calendar`, `pine_color`, `RunFailureCode`, `RunFailureInfo`, `QtyType`,
|
|
21
|
+
`CommissionType`, `XLoc`, `YLoc` and `normalize_timezone_for_posix` are reserved
|
|
22
|
+
because `using namespace pineforge;` brings them into unqualified lookup. A Pine
|
|
23
|
+
`type report`, for example, becomes `struct pf_safe_report` and its references
|
|
24
|
+
use that name. These names live in `codegen/helpers.py`'s
|
|
25
|
+
`CPP_EMITTER_NAMES`, which also reserves the generated C export
|
|
26
|
+
`strategy_reads_trade_history`. A Pine type or function of that name uses
|
|
27
|
+
`pf_safe_strategy_reads_trade_history`; the export keeps its public spelling.
|
|
28
|
+
The same set explicitly reserves the exports `strategy_create`,
|
|
29
|
+
`strategy_create_checked`, `run_backtest`, `run_backtest_full`, `strategy_free`,
|
|
30
|
+
`report_free`, `strategy_set_input`, `strategy_set_override`,
|
|
31
|
+
`strategy_set_magnifier_volume_weighted`, `strategy_set_input_checked`,
|
|
32
|
+
`strategy_set_override_checked` and `run_backtest_full_checked`. Pine identifiers
|
|
33
|
+
use `pf_safe_<name>`; these exports keep their public spellings.
|
|
34
|
+
`CPP_STANDARD_MACROS` reserves `PINEFORGE_HAS_TRADE_HISTORY_POLICY_V1`, so a Pine
|
|
35
|
+
variable of that name uses `pf_safe_PINEFORGE_HAS_TRADE_HISTORY_POLICY_V1`
|
|
36
|
+
instead of expanding the engine's feature macro in a declaration. It also
|
|
37
|
+
explicitly reserves `PINEFORGE_HAS_SYMBOL_SECURITY_EVAL_V1`, using the same
|
|
38
|
+
`pf_safe_` escape for a Pine identifier.
|
|
39
|
+
`codegen/host_members.py`'s `HOST_MEMBER_NAMES` separately reserves the public or
|
|
40
|
+
protected host members the emitter spells, including
|
|
41
|
+
`set_trade_history_streamable`, inherited from `BacktestEngine`. All three sets
|
|
42
|
+
feed the existing `CPP_RESERVED` export; no new reserved-name API is introduced.
|
|
43
|
+
|
|
44
|
+
Since the 1.7.0 trade-history policy addition, generated libraries export
|
|
45
|
+
`int strategy_reads_trade_history(void)`: `1` means the emitted code reads
|
|
46
|
+
closed-trade rows, and `0` means no such read was emitted. A closed-trade count
|
|
47
|
+
alone does not require those rows. For a non-reader, the constructor calls
|
|
48
|
+
`set_trade_history_streamable(true)` under
|
|
49
|
+
`PINEFORGE_HAS_TRADE_HISTORY_POLICY_V1`; a reader emits no policy call.
|
|
50
|
+
The order-shapes receipt's `host_reads` therefore includes the setter only for
|
|
51
|
+
non-readers. Older generated libraries can lack the export; its absence does
|
|
52
|
+
not establish that the script is a non-reader.
|
|
53
|
+
|
|
10
54
|
## Optional compiled execution capabilities
|
|
11
55
|
|
|
12
56
|
Availability: **since 1.2.0**, with engine `v1.2.0`'s capability extension and
|
|
@@ -96,6 +140,35 @@ arbitrary order shape is supported in a live run; engine `v1.3.0` does not read
|
|
|
96
140
|
Existing capability and confirmed-bar receipts, including their order
|
|
97
141
|
classifications, remain unchanged.
|
|
98
142
|
|
|
143
|
+
Every generated strategy library also defines `strategy_id_sites_api_version()`,
|
|
144
|
+
which returns 1, and
|
|
145
|
+
`strategy_id_sites_receipt(handle, json, capacity, required, error, error_capacity)`,
|
|
146
|
+
beside the order-shapes receipt and with the same checked-settings buffer
|
|
147
|
+
protocol, whether or not the script places orders. Its immutable canonical JSON
|
|
148
|
+
(sorted keys, no whitespace) is `{"strategy":{"ids":{"freshPerBar":K}},"version":1}`,
|
|
149
|
+
where `K` is the number of lowered `strategy.entry`, `strategy.order` and
|
|
150
|
+
`strategy.exit` sites that can create an order id the script computes: sites whose
|
|
151
|
+
`id` is not a literal string. A literal or empty `id` adds nothing, and
|
|
152
|
+
`strategy.close`, `strategy.close_all`, `strategy.cancel`, `strategy.cancel_all` and
|
|
153
|
+
drawings are never counted. A site in a user function or method counts once per
|
|
154
|
+
static call of that function, transitively, so a function called twice from a
|
|
155
|
+
function called twice counts four times. A site in a `for` loop whose start, end
|
|
156
|
+
and step are known when the script is translated counts once per iteration. When a
|
|
157
|
+
`while` or `for ... in` loop, a `for` loop with a computed bound, or a recursive
|
|
158
|
+
call surrounds a computed `id`, the count has no static bound and the JSON is
|
|
159
|
+
`{"strategy":{"ids":{"freshPerBarStatus":"unbounded"}},"version":1}`, with no
|
|
160
|
+
`freshPerBar` key; a count above 4294967295 is reported the same way. A loop that
|
|
161
|
+
holds only literal ids does not make the count unbounded. `K` is an upper bound,
|
|
162
|
+
not an exact count: both arms of a conditional count, a method call counts by the
|
|
163
|
+
method's name, and a function parameter used as an `id` counts as computed. It
|
|
164
|
+
counts sites per execution of the script body, not per bar: the translator cannot bound how often
|
|
165
|
+
the body runs on one bar, because `calc_on_order_fills` (set by the script or by a
|
|
166
|
+
run-time override) runs it again after each fill. A host can size its order-id
|
|
167
|
+
bookkeeping from `K` times the number of executions it expects, and should treat
|
|
168
|
+
the demand as unbounded when `calc_on_order_fills` is on. The receipt describes the compiled script
|
|
169
|
+
and adds metadata only: generated trading code is unchanged, and a host that does
|
|
170
|
+
not look for the export is unaffected.
|
|
171
|
+
|
|
99
172
|
Version 1 has `version`, `declarations`, `requests`, `requirements` and `unresolved`
|
|
100
173
|
keys. Declarations include calculation cadence, close execution, magnifier,
|
|
101
174
|
standard-OHLC fill mode, limit verification, currency and clock settings. Requests
|
|
@@ -152,8 +225,10 @@ the 1.3.0 harness used the legacy setters. Some requests that previously
|
|
|
152
225
|
returned success now fail before execution: a shared `Period` key set to `"7"`
|
|
153
226
|
is `setting_rejected` with reason `ambiguous_key`, textual color `"color.blue"`
|
|
154
227
|
is `expected_integer`, and `"15"` outside choices `[10, 20, 30]` is
|
|
155
|
-
`invalid_input_option`. The color manifest's `string` type and Pine-spelling
|
|
156
|
-
default
|
|
228
|
+
`invalid_input_option`. The 1.4.0 color manifest's `string` type and Pine-spelling
|
|
229
|
+
default did not describe the native setter's packed-integer encoding. Current
|
|
230
|
+
manifests use `type: "color"` with a packed integer default, as defined under
|
|
231
|
+
[Input manifest and override keys](#input-manifest-and-override-keys). Validate
|
|
157
232
|
presets against the compiled settings, including types, bounds and options;
|
|
158
233
|
the checked path also refuses unknown keys and invalid numeric, boolean or
|
|
159
234
|
enum values. An input with `supported: false` rejects a supplied value with
|
|
@@ -410,9 +485,9 @@ errors together with either nonfatal level.
|
|
|
410
485
|
### Input manifest and override keys
|
|
411
486
|
|
|
412
487
|
Each manifest entry has `title` (string), `type` (one of `int`, `float`,
|
|
413
|
-
`bool`, `string`, `source`, `enum`), `default` (a literal scalar or
|
|
414
|
-
`supported` (boolean; the manifests of releases up to 1.3.0 lack it).
|
|
415
|
-
also have `min`, `max`, `step` numeric values and an `options` list. Since 1.1.0,
|
|
488
|
+
`bool`, `string`, `source`, `enum`, `color`), `default` (a literal scalar or
|
|
489
|
+
`None`) and `supported` (boolean; the manifests of releases up to 1.3.0 lack it).
|
|
490
|
+
It may also have `min`, `max`, `step` numeric values and an `options` list. Since 1.1.0,
|
|
416
491
|
an `input.symbol` entry also has `kind` equal to `"symbol"`. An optional field
|
|
417
492
|
is omitted when its argument is absent or cannot be reduced to the supported
|
|
418
493
|
literal form.
|
|
@@ -454,6 +529,22 @@ them identically.
|
|
|
454
529
|
- An enum input publishes its `Enum.member` choices in declaration order as
|
|
455
530
|
`options` and keeps its `Enum.member` `default`, which the receipt encodes as
|
|
456
531
|
the member's index (map it through the receipt's `option_values`).
|
|
532
|
+
- A color input (`input.color`) has `type: "color"`. Its literal-foldable
|
|
533
|
+
`default` is an unsigned packed `0xAARRGGBB` integer (0 through 4294967295),
|
|
534
|
+
where `AA` is opacity: 255 is opaque and 0 is transparent. Named Pine v6
|
|
535
|
+
constants, hex color literals, and `color.new` / `color.rgb` with literal
|
|
536
|
+
arguments publish the value the generated `get_input_int64` default uses,
|
|
537
|
+
including transparency. For example, `input.color(color.red, "Line color")`
|
|
538
|
+
publishes `{"title":"Line color","type":"color","default":4294063685,"supported":true}`
|
|
539
|
+
(`0xFFF23645`); `color.new(color.red, 50)` publishes `0x80F23645` as an
|
|
540
|
+
integer. Preserve the unsigned value when reading the JSON. Pass its decimal
|
|
541
|
+
representation to the native input setter; a Pine expression such as
|
|
542
|
+
`"color.red"` is not a native input value. This corrects the `string` type and
|
|
543
|
+
Pine-spelling default published through 1.7.0. `supported` and other input
|
|
544
|
+
fields, the emitted C++ and the native receipt's storage type (`int`, 64-bit)
|
|
545
|
+
and historical `kind: "string"` are unchanged. An unfoldable color default
|
|
546
|
+
retains its previous unpublished value (`None`/JSON `null`); accepted default
|
|
547
|
+
expressions are unchanged.
|
|
457
548
|
- A typed numeric input (`input.int`, `.float`, `.price`, `.time`) publishes
|
|
458
549
|
numeric `default`, `min`, `max`, `step` and the numeric choices of an
|
|
459
550
|
`options=[...]` dropdown where the receipt's value is a literal: a signed number (`-2.5`), a named constant (`LEN = 14`,
|
|
@@ -471,10 +562,6 @@ them identically.
|
|
|
471
562
|
field is omitted when any choice is unfoldable. These gaps are pinned in
|
|
472
563
|
`tests/test_input_metadata_receipt.py`'s `KNOWN_LIMITS`; its test view maps
|
|
473
564
|
an absent options field to `[]`, which is not the public manifest shape.
|
|
474
|
-
An `input.color`'s
|
|
475
|
-
`default` is its Pine spelling (`"color.red"`) and its `type` `string`, where
|
|
476
|
-
the receipt holds the packed integer required by the checked native setter.
|
|
477
|
-
Do not submit the manifest's Pine-spelling string as a native color value.
|
|
478
565
|
Apart from the source-input case
|
|
479
566
|
above, a plain `input(...)` whose default is not a literal is typed
|
|
480
567
|
`string` with a `None` default.
|
|
@@ -26,11 +26,14 @@ def _parse_bounded(pine_source: str, filename: str, budget: TimeBudget | None =
|
|
|
26
26
|
ensure_recursion_headroom()
|
|
27
27
|
check_source_size(pine_source, filename)
|
|
28
28
|
budget = budget or TimeBudget(filename)
|
|
29
|
+
# Normalize once before the pre-pass; all stages use the lexer's text.
|
|
30
|
+
lexer = Lexer(pine_source, filename=filename, budget=budget)
|
|
31
|
+
pine_source = lexer.source
|
|
29
32
|
pragmas = extract_pf_trace_pragmas(
|
|
30
33
|
pine_source, filename=filename, budget=budget,
|
|
31
34
|
)
|
|
32
35
|
budget.check(phase=Phase.LEXER)
|
|
33
|
-
tokens =
|
|
36
|
+
tokens = lexer.tokenize()
|
|
34
37
|
budget.check(phase=Phase.LEXER)
|
|
35
38
|
ast = Parser(tokens, source=pine_source, filename=filename,
|
|
36
39
|
budget=budget).parse()
|
|
@@ -170,6 +173,8 @@ def transpile_full(pine_source: str, *, check_support: bool = True,
|
|
|
170
173
|
``min`` / ``max`` / ``step`` / ``options`` (omitted when the
|
|
171
174
|
corresponding signature argument is absent or is not a literal the
|
|
172
175
|
receipt holds); an ``input.symbol`` entry also has ``kind: "symbol"``.
|
|
176
|
+
An ``input.color`` has ``type: "color"`` and an unsigned packed
|
|
177
|
+
``0xAARRGGBB`` integer default when its color expression is literal-foldable.
|
|
173
178
|
See :meth:`CodeGen.extract_input_manifest`.
|
|
174
179
|
- ``strategyParams``: the literal ``strategy(...)`` kwargs the analyzer
|
|
175
180
|
surfaced (e.g. ``initial_capital``, ``pyramiding``).
|