@pineforge/codegen-pyodide 0.9.0 → 0.10.1
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.
- package/package.json +1 -1
- package/pineforge_codegen/__init__.py +3 -0
- package/pineforge_codegen/analyzer/base.py +3999 -140
- package/pineforge_codegen/analyzer/call_handlers.py +662 -48
- package/pineforge_codegen/analyzer/contracts.py +104 -7
- package/pineforge_codegen/analyzer/types.py +951 -14
- package/pineforge_codegen/codegen/base.py +2359 -249
- package/pineforge_codegen/codegen/drawing.py +94 -14
- package/pineforge_codegen/codegen/emit_top.py +732 -172
- package/pineforge_codegen/codegen/security.py +1456 -150
- package/pineforge_codegen/codegen/ta.py +435 -99
- package/pineforge_codegen/codegen/tables.py +224 -77
- package/pineforge_codegen/codegen/types.py +1196 -215
- package/pineforge_codegen/codegen/visit_call.py +1168 -99
- package/pineforge_codegen/codegen/visit_expr.py +354 -33
- package/pineforge_codegen/codegen/visit_stmt.py +1144 -200
- package/pineforge_codegen/finite_ta_length.py +798 -0
- package/pineforge_codegen/method_binding.py +163 -0
- package/pineforge_codegen/parser.py +48 -9
- package/pineforge_codegen/signatures.py +4 -4
- package/pineforge_codegen/support_checker.py +194 -19
- package/pineforge_codegen/symbols.py +65 -0
- package/pineforge_codegen-0.10.1.tar.gz +0 -0
- package/release.json +2 -2
- package/tables.json +9 -11
- package/pineforge_codegen-0.9.0.tar.gz +0 -0
|
@@ -56,9 +56,74 @@ class TypeSpec:
|
|
|
56
56
|
return f"array<{self.element}>"
|
|
57
57
|
if self.kind == "map" and self.key is not None and self.value is not None:
|
|
58
58
|
return f"map<{self.key},{self.value}>"
|
|
59
|
+
if self.kind == "matrix" and self.element is not None:
|
|
60
|
+
return f"matrix<{self.element}>"
|
|
59
61
|
return self.name or self.kind
|
|
60
62
|
|
|
61
63
|
|
|
64
|
+
def method_receiver_type_name(spec: TypeSpec | None) -> str | None:
|
|
65
|
+
"""Canonical Pine type name used to key a user method receiver.
|
|
66
|
+
|
|
67
|
+
``MethodDef.type_name`` is the parser-normalized spelling (for example
|
|
68
|
+
``array<int>``). Calls are resolved from structured ``TypeSpec`` values,
|
|
69
|
+
so both sides need one lossless spelling across primitive, UDT, and
|
|
70
|
+
collection receivers. Incomplete collection specs stay unresolved rather
|
|
71
|
+
than accidentally colliding under a coarse ``array``/``map``/``matrix``
|
|
72
|
+
key.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
if spec is None:
|
|
76
|
+
return None
|
|
77
|
+
if spec.kind in {"primitive", "udt"}:
|
|
78
|
+
return spec.name
|
|
79
|
+
if spec.kind == "array" and spec.element is not None:
|
|
80
|
+
element = method_receiver_type_name(spec.element)
|
|
81
|
+
return f"array<{element}>" if element is not None else None
|
|
82
|
+
if spec.kind == "map" and spec.key is not None and spec.value is not None:
|
|
83
|
+
key = method_receiver_type_name(spec.key)
|
|
84
|
+
value = method_receiver_type_name(spec.value)
|
|
85
|
+
if key is not None and value is not None:
|
|
86
|
+
return f"map<{key},{value}>"
|
|
87
|
+
return None
|
|
88
|
+
if spec.kind == "matrix" and spec.element is not None:
|
|
89
|
+
element = method_receiver_type_name(spec.element)
|
|
90
|
+
return f"matrix<{element}>" if element is not None else None
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def method_receiver_cpp_token(
|
|
95
|
+
spec: TypeSpec | None,
|
|
96
|
+
fallback_name: str | None = None,
|
|
97
|
+
) -> str:
|
|
98
|
+
"""Return a stable C++ identifier fragment for a method receiver type.
|
|
99
|
+
|
|
100
|
+
Existing primitive, UDT, and drawing receiver spellings remain unchanged.
|
|
101
|
+
Generic Pine types cannot be embedded directly in an identifier, so their
|
|
102
|
+
structure is encoded recursively (``array<int>`` -> ``array_int``). The
|
|
103
|
+
fallback only supports older/synthetic ``FuncInfo`` records that lack the
|
|
104
|
+
structured receiver spec.
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
if spec is not None:
|
|
108
|
+
if spec.kind in {"primitive", "udt"} and spec.name:
|
|
109
|
+
return spec.name
|
|
110
|
+
if spec.kind == "array" and spec.element is not None:
|
|
111
|
+
return f"array_{method_receiver_cpp_token(spec.element)}"
|
|
112
|
+
if spec.kind == "map" and spec.key is not None and spec.value is not None:
|
|
113
|
+
return (
|
|
114
|
+
f"map_{method_receiver_cpp_token(spec.key)}_"
|
|
115
|
+
f"{method_receiver_cpp_token(spec.value)}"
|
|
116
|
+
)
|
|
117
|
+
if spec.kind == "matrix" and spec.element is not None:
|
|
118
|
+
return f"matrix_{method_receiver_cpp_token(spec.element)}"
|
|
119
|
+
|
|
120
|
+
raw = fallback_name or "receiver"
|
|
121
|
+
token = "".join(ch if ch.isalnum() or ch == "_" else "_" for ch in raw)
|
|
122
|
+
if token and token[0].isdigit():
|
|
123
|
+
token = f"type_{token}"
|
|
124
|
+
return token or "receiver"
|
|
125
|
+
|
|
126
|
+
|
|
62
127
|
@dataclass
|
|
63
128
|
class Symbol:
|
|
64
129
|
name: str
|
|
Binary file
|
package/release.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"codegen": "0.
|
|
2
|
+
"codegen": "0.10.1",
|
|
3
3
|
"pyodide": "314.0.0",
|
|
4
4
|
"python": "3.14.0",
|
|
5
5
|
"emscripten": "emscripten_5_0_3",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "e0d1ec121b40e4be39c958e338900789768fb1e6ec39b99b4cb3301c80f13a89"
|
|
7
7
|
}
|
package/tables.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"CODEGEN_VERSION": "0.
|
|
2
|
+
"CODEGEN_VERSION": "0.10.1",
|
|
3
3
|
"TA_CLASS_MAP_KEYS": [
|
|
4
4
|
"sma",
|
|
5
5
|
"ema",
|
|
@@ -861,14 +861,14 @@
|
|
|
861
861
|
"qty",
|
|
862
862
|
"qty_percent",
|
|
863
863
|
"alert_message",
|
|
864
|
-
"
|
|
865
|
-
"
|
|
864
|
+
"immediately",
|
|
865
|
+
"disable_alert"
|
|
866
866
|
],
|
|
867
867
|
"strategy.close_all": [
|
|
868
868
|
"comment",
|
|
869
869
|
"alert_message",
|
|
870
|
-
"
|
|
871
|
-
"
|
|
870
|
+
"immediately",
|
|
871
|
+
"disable_alert"
|
|
872
872
|
],
|
|
873
873
|
"strategy.cancel": [
|
|
874
874
|
"id"
|
|
@@ -1449,16 +1449,16 @@
|
|
|
1449
1449
|
},
|
|
1450
1450
|
"DIVERGENT_VARS": {
|
|
1451
1451
|
"bar_index": "bar_index depends on the data window; PineForge and TradingView produce different values for the same script.",
|
|
1452
|
-
"last_bar_index": "last_bar_index is
|
|
1452
|
+
"last_bar_index": "last_bar_index is the final index of PineForge's fed data window; it can diverge from TradingView when the window does not cover the same chart history.",
|
|
1453
1453
|
"timenow": "timenow is aliased to the current bar timestamp in PineForge; it is not real wall-clock time."
|
|
1454
1454
|
},
|
|
1455
1455
|
"BARSTATE_APPROX_VARS": {
|
|
1456
|
-
"barstate.islast": "barstate.islast is
|
|
1456
|
+
"barstate.islast": "In direct batch chart-scope evaluation, barstate.islast is true only on the final bar of PineForge's fed chart-data window. Inside a request.security() history index, PineForge currently selects the false branch; requested-context last-bar state is not modeled.",
|
|
1457
1457
|
"barstate.ishistory": "barstate.ishistory is always true in PineForge batch backtests.",
|
|
1458
1458
|
"barstate.isrealtime": "barstate.isrealtime is always false in PineForge batch backtests.",
|
|
1459
1459
|
"barstate.isnew": "barstate.isnew follows PineForge first-tick execution state.",
|
|
1460
1460
|
"barstate.isconfirmed": "barstate.isconfirmed follows PineForge last-tick execution state.",
|
|
1461
|
-
"barstate.islastconfirmedhistory": "barstate.islastconfirmedhistory
|
|
1461
|
+
"barstate.islastconfirmedhistory": "In direct historical batch chart-scope evaluation, PineForge approximates barstate.islastconfirmedhistory as true only on the final bar of the fed chart-data window. Inside a request.security() history index, PineForge currently selects the false branch; TradingView's requested-context and realtime-boundary semantics are not modeled."
|
|
1462
1462
|
},
|
|
1463
1463
|
"STRATEGY_UNSUPPORTED_PARAMS": {
|
|
1464
1464
|
"entry": [
|
|
@@ -1487,9 +1487,7 @@
|
|
|
1487
1487
|
],
|
|
1488
1488
|
"close_all": [
|
|
1489
1489
|
"alert_message",
|
|
1490
|
-
"
|
|
1491
|
-
"disable_alert",
|
|
1492
|
-
"immediately"
|
|
1490
|
+
"disable_alert"
|
|
1493
1491
|
]
|
|
1494
1492
|
},
|
|
1495
1493
|
"CLOSED_TRADE_ACCESSOR_METHODS": [
|
|
Binary file
|