pineforge-codegen 1.0.1__tar.gz → 1.1.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.0.1 → pineforge_codegen-1.1.0}/CHANGELOG.md +221 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/CONTRIBUTING.md +5 -4
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/PKG-INFO +70 -39
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/README.md +69 -38
- pineforge_codegen-1.1.0/VERSION +1 -0
- pineforge_codegen-1.1.0/docs/PUBLIC_CONTRACT.md +221 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/docs/pine-cap-activation.md +5 -5
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/__init__.py +24 -9
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/analyzer/base.py +1 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/analyzer/call_handlers.py +2 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/analyzer/contracts.py +3 -0
- pineforge_codegen-1.1.0/pineforge_codegen/codegen/checked_settings.py +272 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/emit_top.py +44 -9
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/helpers.py +7 -1
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/host_members.py +8 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/input.py +36 -3
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/external_requests.py +3 -0
- pineforge_codegen-1.1.0/pineforge_codegen/request_discovery.py +506 -0
- pineforge_codegen-1.0.1/VERSION +0 -1
- pineforge_codegen-1.0.1/docs/PUBLIC_CONTRACT.md +0 -118
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/.gitignore +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/LEGAL.md +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/LICENSE +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/docs/codegen-coverage-gaps.md +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/analyzer/__init__.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/analyzer/diagnostics.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/analyzer/tables.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/analyzer/types.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/ast_nodes.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/block_locals.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/builtin_keywords.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/__init__.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/base.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/collection_history.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/constant_fold.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/drawing.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/helpers_syminfo.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/security.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/session_market.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/ta.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/tables.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/tv_number_format.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/types.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/visit_call.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/visit_expr.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/codegen/visit_stmt.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/collection_history.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/errors.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/finite_ta_length.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/lexer.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/library_inline.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/library_modules.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/library_v5.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/limits.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/method_binding.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/parser.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/pine_libraries.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/pine_spelling.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/pragmas.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/security_contexts.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/session_reads.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/signatures.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/support_checker.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/symbols.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/tokens.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pineforge_codegen/tv_input_choices.py +0 -0
- {pineforge_codegen-1.0.1 → pineforge_codegen-1.1.0}/pyproject.toml +0 -0
|
@@ -20,6 +20,227 @@ 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
|
+
## 1.1.0 — 2026-10-04
|
|
24
|
+
|
|
25
|
+
A minor release: generated strategy libraries gain the checked settings
|
|
26
|
+
functions that engine `v1.1.0` adds to the C ABI, and `transpile_full()` lists
|
|
27
|
+
the other symbols' feeds a script requests. It covers the changes merged to
|
|
28
|
+
`main` since 1.0.1:
|
|
29
|
+
[#159](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/159)
|
|
30
|
+
changes the emitted C++,
|
|
31
|
+
[#164](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/164)
|
|
32
|
+
adds request discovery to the Python and JSON results, and
|
|
33
|
+
[#160](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/160) and
|
|
34
|
+
[#162](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/162) the
|
|
35
|
+
documentation. Codegen `1.1.0` supports only engine `v1.1.0`. Engine
|
|
36
|
+
`v1.1.0` declares six functions in `<pineforge/pineforge.h>`
|
|
37
|
+
([pineforge-engine#317](https://github.com/pineforge-4pass/pineforge-engine/pull/317))
|
|
38
|
+
that the C++ of codegen 1.1.0 defines; the pair keeps C ABI version 4 and the
|
|
39
|
+
script ABI epoch `engine_script_run_v19`.
|
|
40
|
+
|
|
41
|
+
### Compatibility and migration
|
|
42
|
+
|
|
43
|
+
- Regenerate C++ with 1.1.0 and relink it against engine `v1.1.0`'s headers
|
|
44
|
+
and `libpineforge.a`. The C++ includes `pineforge/checked_settings.hpp` and
|
|
45
|
+
compiles the checked settings functions only when the engine's headers
|
|
46
|
+
provide that file and define `PF_SETTINGS_API_VERSION` in
|
|
47
|
+
`pineforge/pineforge.h`, as engine `v1.1.0`'s do. Engine `v1.1.0`'s library
|
|
48
|
+
refuses to begin a run of a strategy whose setter failed (see "Exceptions at
|
|
49
|
+
the C ABI"). C++ generated by 1.0.1 has neither the checked functions nor
|
|
50
|
+
the exception handling.
|
|
51
|
+
- Every generated C++ file changes: it gains the settings code and the
|
|
52
|
+
exception handlers described below. Beyond that, the C++ changes only for
|
|
53
|
+
the enum defaults and the renamed names described below: for the engine's
|
|
54
|
+
325 public corpus sources and this repository's 277 gate fixtures, 1.1.0's
|
|
55
|
+
C++ with the settings code removed (`tests/_legacy_cpp.py`) is 1.0.1's C++
|
|
56
|
+
byte for byte, and the 13 fixtures the gate expects to be refused are refused
|
|
57
|
+
with the same message.
|
|
58
|
+
- Request discovery does not change the emitted C++
|
|
59
|
+
([#164](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/164)):
|
|
60
|
+
the engine's 325 public corpus sources and this repository's 540
|
|
61
|
+
test-fixture `.pine` files transpile to the same C++ as before it, byte for
|
|
62
|
+
byte, each in a fresh process, and the 51 refused are refused with the same
|
|
63
|
+
message.
|
|
64
|
+
- The Python and JSON contract is additive: `transpile_full()`'s result and
|
|
65
|
+
`gate/glue.py`'s `transpile_json` success envelope gain the key `requests`,
|
|
66
|
+
and each `input.symbol` entry of the input manifest gains
|
|
67
|
+
`"kind": "symbol"` (see "Request discovery"). No argument, result key or
|
|
68
|
+
envelope is removed or renamed, and `transpile()` and the error envelope are
|
|
69
|
+
unchanged. One value changes: the `default` reported for an `input.enum`
|
|
70
|
+
whose default is a variable (see "Enum input defaults").
|
|
71
|
+
- Report keys: the JSON report of the engine's Docker harness
|
|
72
|
+
(`docker/run_json.py`, which the `pineforge-release` image runs) keeps every
|
|
73
|
+
key it had with 1.0.1, `metrics.equity.sharpe_tv` and `sortino_tv` included,
|
|
74
|
+
and adds `applied_runtime.syminfo`, `{"qty_step": v, "mincontract": v}`,
|
|
75
|
+
present only when the `--syminfo` / `PINEFORGE_SYMINFO` file carries a valid
|
|
76
|
+
`syminfo.mincontract`, which the harness now applies as the lot grid
|
|
77
|
+
([pineforge-engine#322](https://github.com/pineforge-4pass/pineforge-engine/pull/322));
|
|
78
|
+
1.0.1 ignored it. `fingerprint.provenance.runtime` equals
|
|
79
|
+
`applied_runtime`, so a run on such a grid has a different fingerprint; for a
|
|
80
|
+
run without one, #322 changes no byte of the report apart from
|
|
81
|
+
`elapsed_seconds`. A `mincontract` the harness cannot apply is new failure
|
|
82
|
+
output: one stdout line `{"engine":"pineforge","error":...}`, harness exit
|
|
83
|
+
status 1 and image entrypoint exit status 4 (the existing backtest-failure
|
|
84
|
+
status), with `syminfo.mincontract must be a positive finite number, got
|
|
85
|
+
<json>` for an invalid value, or `the strategy library has no
|
|
86
|
+
strategy_set_syminfo_metadata, so syminfo.mincontract cannot be applied` for
|
|
87
|
+
a library without that function.
|
|
88
|
+
- The same harness also installs other symbols' bars for `request.security`
|
|
89
|
+
on another symbol: `--symbol-feeds <index.json>` (the image's
|
|
90
|
+
`PINEFORGE_SYMBOL_FEEDS`), a JSON index keyed by the exact symbol string the
|
|
91
|
+
script passes and by timeframe, each feed an OHLCV CSV, with the symbol's
|
|
92
|
+
catalog `syminfo`
|
|
93
|
+
([pineforge-engine#327](https://github.com/pineforge-4pass/pineforge-engine/pull/327),
|
|
94
|
+
[pineforge-release#23](https://github.com/pineforge-4pass/pineforge-release/pull/23)).
|
|
95
|
+
It needs one feed per requested timeframe: nothing aggregates another
|
|
96
|
+
symbol's bars. It installs them through `strategy_set_symbol_facts` and
|
|
97
|
+
`strategy_set_symbol_feed`, C ABI calls since 1.0.0, so the generated C++
|
|
98
|
+
does not change for it. What it installed is recorded as
|
|
99
|
+
`applied_runtime.symbol_feeds`, `{"canonicalization": ..., "symbols":
|
|
100
|
+
{"<symbol>": {"facts": {...}, "feeds": {"<timeframe>": {"bars": ...,
|
|
101
|
+
"first_ts": ..., "last_ts": ..., "source_values_sha256": ...}}}}}`, present
|
|
102
|
+
only when it installed a symbol, so such a run has its own fingerprint. An
|
|
103
|
+
index or a feed it cannot install fails the run the same way: one stdout
|
|
104
|
+
line `{"engine":"pineforge","error":"--symbol-feeds: ..."}`, harness exit
|
|
105
|
+
status 1, image entrypoint exit status 4.
|
|
106
|
+
- Between 1.0.1 and 1.1.0 a report's fingerprint differs in any case, since it
|
|
107
|
+
records the engine and codegen versions and the generated C++'s hash, and
|
|
108
|
+
the Pine adapter changes in engine `v1.1.0`
|
|
109
|
+
([pineforge-engine#315](https://github.com/pineforge-4pass/pineforge-engine/pull/315),
|
|
110
|
+
[#316](https://github.com/pineforge-4pass/pineforge-engine/pull/316)) can
|
|
111
|
+
change a run's trades.
|
|
112
|
+
|
|
113
|
+
### Checked strategy settings
|
|
114
|
+
|
|
115
|
+
Built against engine `v1.1.0`, a generated strategy library defines
|
|
116
|
+
`strategy_settings_api_version()`, which returns 1, and five checked functions
|
|
117
|
+
([#159](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/159)).
|
|
118
|
+
Each returns a `pf_settings_status_t`, writes its message to an optional
|
|
119
|
+
caller buffer and lets no exception through. The legacy setters still accept
|
|
120
|
+
or ignore what they accepted or ignored, an unknown key included; a value that
|
|
121
|
+
makes one of them throw now fails the strategy (see "Exceptions at the C
|
|
122
|
+
ABI").
|
|
123
|
+
|
|
124
|
+
- `strategy_set_input_checked` takes the key the legacy getters read: the
|
|
125
|
+
input's title, else its variable's name, else the empty key. Before it
|
|
126
|
+
changes anything, it refuses an unknown key, a key two inputs share, an
|
|
127
|
+
invalid boolean, enum member or option, trailing characters (`3x`), a
|
|
128
|
+
fractional or out-of-range int (`5.5`, `2147483648.0`), `NaN` and `Inf`, and
|
|
129
|
+
a value outside the input's `minval` / `maxval`. `step` is not enforced. An
|
|
130
|
+
`input.enum` is supported only when its options are literal members of one
|
|
131
|
+
enum.
|
|
132
|
+
- `strategy_set_override_checked` takes `initial_capital`,
|
|
133
|
+
`commission_value`, `default_qty_value`, `pyramiding`, `slippage`,
|
|
134
|
+
`process_orders_on_close`, `calc_on_order_fills`, `close_entries_rule`,
|
|
135
|
+
`default_qty_type` and `commission_type`, with the aliases the legacy setter
|
|
136
|
+
accepts (such as `strategy.cash`), and refuses an unknown key and an invalid
|
|
137
|
+
enum value, boolean or number.
|
|
138
|
+
- Both setters refuse once a run has processed a bar or a stream has begun.
|
|
139
|
+
- `strategy_create_checked` refuses a nonempty `params_json`, which the legacy
|
|
140
|
+
factory ignores.
|
|
141
|
+
- `strategy_get_effective_settings` writes a JSON receipt of every declared
|
|
142
|
+
input, inline inputs included, in source order, and of the overrides above:
|
|
143
|
+
type, options, default and effective value as canonical strings, and
|
|
144
|
+
`min` / `max` / `step` as numbers or `null`. Called with a NULL buffer and 0,
|
|
145
|
+
it returns `PF_SETTINGS_BUFFER_TOO_SMALL` and the size to allocate.
|
|
146
|
+
- `run_backtest_full_checked` runs the batch `run_backtest_full` runs and
|
|
147
|
+
returns `PF_SETTINGS_RUN_FAILED` for a failure the run reports and
|
|
148
|
+
`PF_SETTINGS_EXCEPTION` for an exception.
|
|
149
|
+
- Script names that the settings code uses (`config_`, `inputs_`,
|
|
150
|
+
`override_`, `last_error`, `last_error_`, `script_bars_processed`,
|
|
151
|
+
`stream_phase_`, `StreamPhase`, `checked_settings` and the `_pf_` helpers)
|
|
152
|
+
are renamed in the C++, so a script cannot shadow that code. Input keys are
|
|
153
|
+
unaffected.
|
|
154
|
+
|
|
155
|
+
The engine's `pineforge/pineforge.h` and `docs/checked-settings.md` give the
|
|
156
|
+
signatures, the statuses and the buffer rules.
|
|
157
|
+
|
|
158
|
+
### Exceptions at the C ABI
|
|
159
|
+
|
|
160
|
+
1.0.1's C++ let an exception thrown in a generated entry point propagate into
|
|
161
|
+
the host, where a C caller cannot catch it. From
|
|
162
|
+
[#159](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/159):
|
|
163
|
+
|
|
164
|
+
- `strategy_create`, `run_backtest`, `run_backtest_full`,
|
|
165
|
+
`strategy_set_input`, `strategy_set_override`,
|
|
166
|
+
`strategy_set_magnifier_volume_weighted`, `strategy_free` and `report_free`
|
|
167
|
+
catch every exception. `strategy_create` then returns NULL; `run_backtest`
|
|
168
|
+
and `run_backtest_full` zero the report and record `run_backtest: <message>`
|
|
169
|
+
(or `run_backtest_full: …`) as the error `strategy_get_last_error` returns.
|
|
170
|
+
- A legacy setter that throws, such as
|
|
171
|
+
`strategy_set_override(s, "pyramiding", "abc")`, fails the strategy for good.
|
|
172
|
+
`strategy_get_last_error` returns `strategy_set_override: <message>`;
|
|
173
|
+
`run_backtest` and `run_backtest_full` return an empty report;
|
|
174
|
+
`run_backtest_full_checked`, the checked setters and
|
|
175
|
+
`strategy_get_effective_settings` return `PF_SETTINGS_RUN_FAILED` with that
|
|
176
|
+
message; `strategy_stream_begin` returns -1 and `strategy_last_run_status`
|
|
177
|
+
1 (not completed). A call that clears the last error, such as feed
|
|
178
|
+
configuration, does not clear the failure: the next run reports it again.
|
|
179
|
+
Free the strategy and create a new one. A stream already running keeps the
|
|
180
|
+
settings it began with. A legacy setter that does not throw behaves as
|
|
181
|
+
before.
|
|
182
|
+
- With engine `v1.1.0`, `strategy_stream_begin` also fails with the message
|
|
183
|
+
and status 1 when preparing the script throws for any other reason; a batch
|
|
184
|
+
run keeps 1.0.1's empty report and completed status for such a failure
|
|
185
|
+
([pineforge-engine#317](https://github.com/pineforge-4pass/pineforge-engine/pull/317)).
|
|
186
|
+
|
|
187
|
+
### Enum input defaults
|
|
188
|
+
|
|
189
|
+
From [#159](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/159):
|
|
190
|
+
|
|
191
|
+
- A value that came out silently wrong: an `input.enum` whose default is a
|
|
192
|
+
variable, as in `defaultSide = Side.long` followed by
|
|
193
|
+
`input.enum(defaultSide, "Side")`, now defaults to that member. 1.0.1's C++
|
|
194
|
+
read the variable before the script assigned it, so unless the host set the
|
|
195
|
+
input, it held the enum's first member for the whole run.
|
|
196
|
+
- `transpile_full()`'s `inputs` and `transpile_json` report that member
|
|
197
|
+
(`"Side.long"`) as the input's `default`, where 1.0.1 reported `null`.
|
|
198
|
+
- This holds for a top-level variable declared once before the input, never
|
|
199
|
+
reassigned, and set to a literal member, directly or through another such
|
|
200
|
+
variable. With any other variable, such as a `var` or one set by an
|
|
201
|
+
expression (`c ? Side.long : Side.short`), the input reads it as 1.0.1's C++
|
|
202
|
+
does; `strategy_set_input_checked` refuses such an input as unsupported, and
|
|
203
|
+
the receipt reports its default as `na`.
|
|
204
|
+
|
|
205
|
+
### Request discovery
|
|
206
|
+
|
|
207
|
+
From [#164](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/164):
|
|
208
|
+
|
|
209
|
+
- `transpile_full()` returns a new key, `requests`: every request site that
|
|
210
|
+
reads another symbol's feed, so a host can fetch the bars a run needs before
|
|
211
|
+
it starts it. Each entry gives the request's `line` and `fn`, its symbol
|
|
212
|
+
(`literal`, `input` with its override key and default, `computed` with its
|
|
213
|
+
value at the inputs' defaults where literals and inputs compute it, or
|
|
214
|
+
`unresolvable`), its timeframe (`literal` in the engine's feed spelling,
|
|
215
|
+
`chart`, `input` or `computed`), `lookahead`, `gaps` and
|
|
216
|
+
`ignore_invalid_symbol`. A request lowered to `na` (its value reaches only
|
|
217
|
+
plots and alerts) is not listed. See the
|
|
218
|
+
[public contract](docs/PUBLIC_CONTRACT.md#request-discovery).
|
|
219
|
+
- `gate/glue.py`'s `transpile_json` success envelope carries the same list
|
|
220
|
+
under `requests`.
|
|
221
|
+
- The input manifest marks each `input.symbol` entry with `"kind": "symbol"`;
|
|
222
|
+
its `title`, `type` and `default` are unchanged.
|
|
223
|
+
|
|
224
|
+
### Documentation
|
|
225
|
+
|
|
226
|
+
- The README's parity scoreboard renders from the public facts tokens of
|
|
227
|
+
[`pineforge-release`](https://github.com/pineforge-4pass/pineforge-release),
|
|
228
|
+
and a release's grades are stated apart from the scoreboard of `main`
|
|
229
|
+
([#160](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/160));
|
|
230
|
+
no fact marker starts a line, so GitHub renders each sentence in its
|
|
231
|
+
paragraph ([#162](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/162)).
|
|
232
|
+
Release 1.1.0 is graded on registry baseline
|
|
233
|
+
`pineforge-parity-baseline-20261004-engine-7b596622`: 7,951 excellent and
|
|
234
|
+
38 strong of 7,989 graded probes, with engine 7b596622, which v1.1.0 equals
|
|
235
|
+
in behaviour: v1.1.0 adds a performance fix that its merge gate shows
|
|
236
|
+
changes no trade or report. This repository was at c5d97ee, whose emitted
|
|
237
|
+
C++ is codegen 1.1.0's.
|
|
238
|
+
- `docs/PUBLIC_CONTRACT.md` describes the checked settings functions and the
|
|
239
|
+
exception handling
|
|
240
|
+
([#159](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/159))
|
|
241
|
+
and request discovery
|
|
242
|
+
([#164](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/164)).
|
|
243
|
+
|
|
23
244
|
## 1.0.1 — 2026-10-02
|
|
24
245
|
|
|
25
246
|
A patch release of translation fixes. It covers the changes merged to `main`
|
|
@@ -47,11 +47,12 @@ before treating a run as complete.
|
|
|
47
47
|
|
|
48
48
|
## Engine pairing
|
|
49
49
|
|
|
50
|
-
Codegen `main` is developed and tested against engine `main`. Codegen 1.0
|
|
51
|
-
pairs with engine `v1.0
|
|
50
|
+
Codegen `main` is developed and tested against engine `main`. Codegen 1.1.0
|
|
51
|
+
pairs with engine `v1.1.0`, the pair the
|
|
52
52
|
[`pineforge-release`](https://github.com/pineforge-4pass/pineforge-release)
|
|
53
|
-
image `1.0
|
|
54
|
-
|
|
53
|
+
image `1.1.0` ships, codegen 1.0.1 with engine `v1.0.1`, the pair of the image
|
|
54
|
+
`1.0.1`, and codegen 1.0.0 with engine `v1.0.0`, the pair of the image
|
|
55
|
+
`1.0.0`. On the 0.x line the two version lineages are independent:
|
|
55
56
|
the last 0.x release, codegen 0.10.4, pairs with engine `v0.13.1`, the pair
|
|
56
57
|
the `pineforge-release` image `0.1.25` ships.
|
|
57
58
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pineforge-codegen
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.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
|
|
@@ -232,22 +232,16 @@ A pure-Python library that turns a PineScript v6 strategy into a complete C++
|
|
|
232
232
|
source file you can compile against the [`pineforge-engine`](https://github.com/pineforge-4pass/pineforge-engine)
|
|
233
233
|
runtime.
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
merged: this repository at 67892cd, the code of codegen 1.0.1, with engine
|
|
246
|
-
b2a578ce, whose library source is `v1.0.0`'s, graded the same 7,989 probes
|
|
247
|
-
with no probe changing tier (baseline
|
|
248
|
-
`pineforge-parity-baseline-20261001-codegen-67892cda`). Engine `v1.0.1`
|
|
249
|
-
changes only documentation since `v1.0.0`. The
|
|
250
|
-
engine's [validation scoreboard](https://github.com/pineforge-4pass/pineforge-engine#validation-scoreboard)
|
|
235
|
+
**Measured <!-- pf:scoreboard.date -->2026-10-04<!-- /pf -->** on main engine <!-- pf:scoreboard.engineCommit|short-code -->`7b596622`<!-- /pf --> with codegen-oss <!-- pf:scoreboard.codegenCommit|short-code -->`c5d97ee5`<!-- /pf --> (baseline <!-- pf:scoreboard.id|code -->`pineforge-parity-baseline-20261004-engine-7b596622`<!-- /pf -->, snapshot <!-- pf:scoreboard.snapshotSha256|short-code -->`af86f13e`<!-- /pf -->): <!-- pf:scoreboard.excellent|int -->7,951<!-- /pf --> of <!-- pf:scoreboard.graded|int -->7,989<!-- /pf --> TradingView probes
|
|
236
|
+
graded excellent and <!-- pf:scoreboard.strong|int -->38<!-- /pf --> strong, with <!-- pf:scoreboard.belowStrong|int -->0<!-- /pf --> below strong; <!-- pf:scoreboard.anomaliesExcluded|int -->17<!-- /pf --> more probes are held out as TradingView-side anomalies.
|
|
237
|
+
A probe is a strategy exported from TradingView with its trade list and replayed
|
|
238
|
+
trade for trade on the same bars.
|
|
239
|
+
|
|
240
|
+
Release **1.1.0 grades <!-- pf:releases[1.1.0].scoreboard.excellent|int -->7,951<!-- /pf --> excellent / <!-- pf:releases[1.1.0].scoreboard.strong|int -->38<!-- /pf --> strong until the next release**, on <!-- pf:releases[1.1.0].scoreboard.graded|int -->7,989<!-- /pf --> probes (baseline <!-- pf:releases[1.1.0].scoreboard.id|code -->`pineforge-parity-baseline-20261004-engine-7b596622`<!-- /pf -->, <!-- pf:releases[1.1.0].scoreboard.date -->2026-10-04<!-- /pf -->). A main scoreboard advance does not change release results.
|
|
241
|
+
|
|
242
|
+
The quantities above render from the public [facts tokens](https://github.com/pineforge-4pass/pineforge-release/blob/main/facts/facts.json). Maintain them with `lab facts render --repo . --facts <local facts file or pinned raw URL>`; `lab facts check` with the same inputs reports drift. Grades are registry-derived; the authored-script and closed-trade inventory is explicitly sourced to a historical public README for the identical population, not to registry row or slug totals.
|
|
243
|
+
|
|
244
|
+
The engine's [validation scoreboard](https://github.com/pineforge-4pass/pineforge-engine#validation-scoreboard)
|
|
251
245
|
describes how a probe is graded.
|
|
252
246
|
|
|
253
247
|
It is **source-available and free for personal trading** — research, backtest,
|
|
@@ -267,7 +261,7 @@ for the changes in each release from 1.0.0 on and the release-note policy.
|
|
|
267
261
|
## Releases and this README
|
|
268
262
|
|
|
269
263
|
<!-- Release lane: before a release is tagged, add it to the Engine pairing
|
|
270
|
-
table and update every line that names `1.0
|
|
264
|
+
table and update every line that names `1.1.0` or `v1.1.0` as the current
|
|
271
265
|
release or pair (this section's version and date, the baseline paragraph at
|
|
272
266
|
the top, the engine `src/source/` link, the `@pf-trace` note, the clone
|
|
273
267
|
command and its example output, "This section describes …", the timing note)
|
|
@@ -277,7 +271,7 @@ hosted-server line name no version. -->
|
|
|
277
271
|
|
|
278
272
|
This README ships with each release as its package description on PyPI
|
|
279
273
|
(`pineforge-codegen`); releases from 0.7.0 on are also on npm as
|
|
280
|
-
`@pineforge/codegen-pyodide`. It describes 1.0
|
|
274
|
+
`@pineforge/codegen-pyodide`. It describes 1.1.0 (2026-10-04) and what changed
|
|
281
275
|
since 0.10.4. The
|
|
282
276
|
[PyPI release history](https://pypi.org/project/pineforge-codegen/#history)
|
|
283
277
|
lists every release; the
|
|
@@ -317,8 +311,8 @@ It does **not** own execution semantics. Order lifecycle, bracket legs,
|
|
|
317
311
|
fill-price and slippage rules, `process_orders_on_close` / `calc_on_order_fills`,
|
|
318
312
|
margin revival and trail/stop behaviour — everything TradingView parity depends
|
|
319
313
|
on at run time — live in the engine's source-adapter runtime
|
|
320
|
-
([`src/source/`](https://github.com/pineforge-4pass/pineforge-engine/tree/v1.0
|
|
321
|
-
in engine `v1.0
|
|
314
|
+
([`src/source/`](https://github.com/pineforge-4pass/pineforge-engine/tree/v1.1.0/src/source)
|
|
315
|
+
in engine `v1.1.0`), which maps them onto the engine's Pine-agnostic kernel. See
|
|
322
316
|
the engine's [architecture notes](https://github.com/pineforge-4pass/pineforge-engine#architecture-kernel-vs-parity).
|
|
323
317
|
|
|
324
318
|
---
|
|
@@ -409,16 +403,52 @@ transpile_full(
|
|
|
409
403
|
```
|
|
410
404
|
|
|
411
405
|
It returns `{"cpp": str, "inputs": list[dict], "strategyParams": dict,
|
|
412
|
-
"diagnostics": list[Diagnostic]}` on success (0.10.4
|
|
413
|
-
keys
|
|
414
|
-
`
|
|
415
|
-
`
|
|
416
|
-
`
|
|
417
|
-
the
|
|
406
|
+
"diagnostics": list[Diagnostic], "requests": list[dict]}` on success (0.10.4
|
|
407
|
+
returns the first three keys; `requests` is new in 1.1.0). `inputs` is the input
|
|
408
|
+
manifest; its `title` is the actual override key, and an `input.symbol` entry
|
|
409
|
+
also has `"kind": "symbol"` (since 1.1.0). `diagnostics` contains nonfatal
|
|
410
|
+
warnings. `requests` lists the other symbols' feeds the script reads (see
|
|
411
|
+
[List the other symbols a script requests](#list-the-other-symbols-a-script-requests)).
|
|
412
|
+
A rejected script raises `CompileError` with its diagnostics. The Pyodide
|
|
413
|
+
package ships `gate/glue.py`'s `transpile_json(source) -> str`, whose JSON
|
|
414
|
+
success and error envelopes carry the same manifest and, since 1.0.0, the same
|
|
415
|
+
warnings; since 1.1.0 the success envelope also carries `requests`. See the
|
|
418
416
|
[1.0 public contract](https://github.com/pineforge-4pass/pineforge-codegen-oss/blob/main/docs/PUBLIC_CONTRACT.md)
|
|
419
417
|
for the exact fields, severity values, and input key rules. There is no
|
|
420
418
|
installed CLI or exit-code contract.
|
|
421
419
|
|
|
420
|
+
### List the other symbols a script requests
|
|
421
|
+
|
|
422
|
+
A run reads another symbol's bars only from the feed it is given for that
|
|
423
|
+
symbol string and timeframe, matched byte for byte. `transpile_full()`'s
|
|
424
|
+
`requests` (new in 1.1.0) names those feeds before the run, one entry per
|
|
425
|
+
request site:
|
|
426
|
+
|
|
427
|
+
```python
|
|
428
|
+
from pineforge_codegen import transpile_full
|
|
429
|
+
|
|
430
|
+
full = transpile_full(open("my_strategy.pine").read())
|
|
431
|
+
for request in full["requests"]:
|
|
432
|
+
print(request)
|
|
433
|
+
# {'line': 7, 'fn': 'request.security',
|
|
434
|
+
# 'symbol': {'kind': 'input', 'title': 'Other symbol', 'default': 'BINANCE:ETHUSDT'},
|
|
435
|
+
# 'timeframe': {'kind': 'chart'},
|
|
436
|
+
# 'lookahead': False, 'gaps': False, 'ignore_invalid_symbol': False}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
The symbol is a `literal` (its `value`), an `input` (its override key `title`
|
|
440
|
+
and its `default`: the run keys the feed on the override, else the default),
|
|
441
|
+
`computed` (its `expr`, the `value` at the inputs' defaults when it can be
|
|
442
|
+
computed, and the `inputs` it reads) or `unresolvable` (a request PineForge
|
|
443
|
+
cannot key before the first bar: the run stops where its value is read). The
|
|
444
|
+
timeframe is a `literal` in the engine's spelling (whole minutes such as
|
|
445
|
+
`"240"`, `<n>D|W|M|S` such as `"1D"`, Pine's bare `"D"` as `"1D"`), the
|
|
446
|
+
`chart`'s, an `input` or `computed` (an empty `value` is the chart's). A
|
|
447
|
+
request whose value reaches only plots and alerts is lowered to `na` and
|
|
448
|
+
reads no feed, so it is not listed. The
|
|
449
|
+
[public contract](https://github.com/pineforge-4pass/pineforge-codegen-oss/blob/main/docs/PUBLIC_CONTRACT.md)
|
|
450
|
+
gives every field.
|
|
451
|
+
|
|
422
452
|
### Transpile a file to a `.cpp`
|
|
423
453
|
|
|
424
454
|
```python
|
|
@@ -508,7 +538,7 @@ fields, such as `// @pf-trace gap=close - e` or
|
|
|
508
538
|
`// @pf-trace body=math.abs(close - open)`. A `ta.*` call written in the
|
|
509
539
|
pragma itself is not computed: `// @pf-trace rsi=ta.rsi(close, 14)` records
|
|
510
540
|
`na` on every bar, and its C++ carries an `/* unsupported: ta.rsi */` marker.
|
|
511
|
-
0.10.4, 1.0.0
|
|
541
|
+
0.10.4, 1.0.0, 1.0.1 and 1.1.0 all behave this way.
|
|
512
542
|
|
|
513
543
|
### Advanced: run the pipeline stages directly
|
|
514
544
|
|
|
@@ -553,9 +583,9 @@ does not bypass them.
|
|
|
553
583
|
|
|
554
584
|
The last column was measured on 2026-09-29 with 70c2b4a (the same code as
|
|
555
585
|
1.0.0) on CPython 3.14 on an Apple M4 Max, over the engine corpus that engine
|
|
556
|
-
35db01c8 pins (as `v1.0.0` and `v1.0
|
|
557
|
-
`tests/gate-corpus`. On 2026-10-
|
|
558
|
-
transpiled each of those sources in
|
|
586
|
+
35db01c8 pins (as `v1.0.0`, `v1.0.1` and `v1.1.0` do) and this repository's
|
|
587
|
+
`tests/gate-corpus`. On 2026-10-04, on CPython 3.14 on an Apple M4 Max, 1.1.0
|
|
588
|
+
transpiled each of those sources in under 0.1 seconds.
|
|
559
589
|
|
|
560
590
|
Nesting counts brackets, indented blocks, prefix operators, `?:` and
|
|
561
591
|
`else if` chains, and the depth of the parsed syntax tree, in which an
|
|
@@ -604,6 +634,7 @@ Generated C++ compiles only against the engine it was generated for:
|
|
|
604
634
|
| 0.10.4 (PyPI, 2026-09-06) | `v0.13.1` | The last 0.x pair, which the `pineforge-release` image `0.1.25` ships. Its C++ does not compile against engine `v1.0.0`. |
|
|
605
635
|
| 1.0.0 (PyPI, 2026-09-30) | `v1.0.0` | The pair the `pineforge-release` image `1.0.0` ships. Its C++ needs `pineforge/source/pine_strategy_host.hpp`, which engine `v0.13.1` does not have. |
|
|
606
636
|
| 1.0.1 (PyPI, 2026-10-02) | `v1.0.1` | The pair the `pineforge-release` image `1.0.1` ships. Engine `v1.0.1` changes only documentation since `v1.0.0`; regenerate and relink all the same. |
|
|
637
|
+
| 1.1.0 (PyPI, 2026-10-04) | `v1.1.0` | The pair the `pineforge-release` image `1.1.0` ships. Its C++ defines the checked settings functions that engine `v1.1.0` adds to `<pineforge/pineforge.h>`; regenerate and relink. |
|
|
607
638
|
| Later `X.Y.Z` releases | `vX.Y.Z` of the same version | See below. |
|
|
608
639
|
|
|
609
640
|
On the 0.x line the engine and codegen versions are independent, and the
|
|
@@ -629,8 +660,8 @@ Pine as `strategy.pine`, write `strategy.generated.cpp` with the
|
|
|
629
660
|
[file example](#transpile-a-file-to-a-cpp) above, then from the same directory:
|
|
630
661
|
|
|
631
662
|
```bash
|
|
632
|
-
# 1.0
|
|
633
|
-
git clone --branch v1.0
|
|
663
|
+
# 1.1.0 pairs with engine v1.1.0. For 0.10.4 use --branch v0.13.1.
|
|
664
|
+
git clone --branch v1.1.0 https://github.com/pineforge-4pass/pineforge-engine.git
|
|
634
665
|
cd pineforge-engine
|
|
635
666
|
cp ../strategy.generated.cpp tutorial/macd/generated.cpp # the tutorial's strategy slot
|
|
636
667
|
bash tutorial/run.sh # needs cmake, a C++17 compiler and python3
|
|
@@ -639,7 +670,7 @@ bash tutorial/run.sh # needs cmake, a C++17 compiler and python3
|
|
|
639
670
|
`run.sh` configures CMake once, builds `libpineforge.a` and
|
|
640
671
|
`tutorial/macd/strategy.so`, and runs `tutorial/run.py`, which loads the `.so`,
|
|
641
672
|
feeds it the bars and reads back the closed trades. For the quick-start SMA
|
|
642
|
-
cross, 1.0
|
|
673
|
+
cross, 1.1.0 with engine `v1.1.0` prints:
|
|
643
674
|
|
|
644
675
|
```
|
|
645
676
|
MACD(12,26,9) on BTCUSDT 15m — 672 bars, 2026-04-29 18:15 → 2026-05-06 18:00 UTC
|
|
@@ -647,7 +678,7 @@ MACD(12,26,9) on BTCUSDT 15m — 672 bars, 2026-04-29 18:15 → 2026-05-06 18:00
|
|
|
647
678
|
net pnl: +738.20
|
|
648
679
|
best/worst:+679.22 / -335.02
|
|
649
680
|
max dd: -788.79
|
|
650
|
-
elapsed: 1.
|
|
681
|
+
elapsed: 1.0 ms
|
|
651
682
|
```
|
|
652
683
|
|
|
653
684
|
The `MACD(12,26,9)` label on the first line is fixed text in `run.py`,
|
|
@@ -657,7 +688,7 @@ order sizing: 1.0.0 gives an omitted
|
|
|
657
688
|
`initial_capital`, `default_qty_type` and `default_qty_value` TradingView's
|
|
658
689
|
Pine v6 defaults (100,000, `strategy.percent_of_equity`, 100), where 0.10.4
|
|
659
690
|
leaves the engine's own (1,000,000 and 1 contract). Declaring those in
|
|
660
|
-
`strategy()` books the same 13 trades on 1.0.
|
|
691
|
+
`strategy()` books the same 13 trades on 1.1.0.
|
|
661
692
|
|
|
662
693
|
Since 1.0.0, generated strategies reset persistent Pine state before each new
|
|
663
694
|
batch or stream warmup through the engine's script-run preparation hook. Input
|
|
@@ -719,7 +750,7 @@ hosted/embedded use. Email **luis@4pass.com.tw** with your use case for a quote.
|
|
|
719
750
|
|
|
720
751
|
## Explicit Pine execution attachment
|
|
721
752
|
|
|
722
|
-
This section describes 1.0
|
|
753
|
+
This section describes 1.1.0 and engine `v1.1.0`. The Pine execution adapter is
|
|
723
754
|
the engine's full Pine execution runtime (`PineExecutionAdapter` and
|
|
724
755
|
`PineStrategyHost` in the engine's `src/source/`): order lifecycle, bracket
|
|
725
756
|
legs, fill-price and slippage rules, POOC / `calc_on_order_fills`, margin
|
|
@@ -742,9 +773,9 @@ Regenerate old generated C++ before using a new engine for Pine execution. C++
|
|
|
742
773
|
generated before the source-layer cut
|
|
743
774
|
([#129](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/129)),
|
|
744
775
|
0.10.4's included, derives from `BacktestEngine` and does not compile against
|
|
745
|
-
engine `v1.0
|
|
776
|
+
engine `v1.1.0`; old cap-only C++ does not attach the priority rule, and
|
|
746
777
|
metadata cannot silently restore it. Rebuild all modules against the
|
|
747
|
-
new matching C++ layout (`engine_script_run_v19` in engine `v1.0
|
|
778
|
+
new matching C++ layout (`engine_script_run_v19` in engine `v1.1.0`); old
|
|
748
779
|
fingerprint versions are not comparable. The extraction preserves Pine policy
|
|
749
780
|
under explicit attachment; it does not implement the generic native
|
|
750
781
|
child-activation scheduler or prove campaign neutrality. Compile-only corpus
|