@pineforge/codegen-pyodide 0.10.4 → 1.0.0-rc.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/README.md +16 -16
- package/glue.py +24 -16
- package/package.json +1 -1
- package/pineforge_codegen/__init__.py +125 -34
- package/pineforge_codegen/analyzer/__init__.py +2 -0
- package/pineforge_codegen/analyzer/base.py +754 -76
- package/pineforge_codegen/analyzer/call_handlers.py +260 -40
- package/pineforge_codegen/analyzer/contracts.py +37 -0
- package/pineforge_codegen/analyzer/diagnostics.py +30 -4
- package/pineforge_codegen/analyzer/tables.py +49 -8
- package/pineforge_codegen/analyzer/types.py +33 -1
- package/pineforge_codegen/ast_nodes.py +32 -1
- package/pineforge_codegen/block_locals.py +185 -0
- package/pineforge_codegen/builtin_keywords.py +42 -0
- package/pineforge_codegen/codegen/base.py +896 -156
- package/pineforge_codegen/codegen/constant_fold.py +131 -0
- package/pineforge_codegen/codegen/drawing.py +221 -79
- package/pineforge_codegen/codegen/emit_top.py +946 -213
- package/pineforge_codegen/codegen/helpers.py +435 -14
- package/pineforge_codegen/codegen/host_members.py +162 -0
- package/pineforge_codegen/codegen/input.py +252 -85
- package/pineforge_codegen/codegen/security.py +4372 -377
- package/pineforge_codegen/codegen/session_market.py +71 -0
- package/pineforge_codegen/codegen/ta.py +1188 -100
- package/pineforge_codegen/codegen/tables.py +193 -71
- package/pineforge_codegen/codegen/tv_number_format.py +270 -0
- package/pineforge_codegen/codegen/types.py +1882 -78
- package/pineforge_codegen/codegen/visit_call.py +920 -131
- package/pineforge_codegen/codegen/visit_expr.py +738 -57
- package/pineforge_codegen/codegen/visit_stmt.py +595 -49
- package/pineforge_codegen/external_requests.py +877 -0
- package/pineforge_codegen/lexer.py +104 -22
- package/pineforge_codegen/library_inline.py +1304 -0
- package/pineforge_codegen/library_modules.py +126 -0
- package/pineforge_codegen/library_v5.py +683 -0
- package/pineforge_codegen/limits.py +138 -0
- package/pineforge_codegen/method_binding.py +33 -0
- package/pineforge_codegen/parser.py +384 -68
- package/pineforge_codegen/pine_libraries.py +266 -0
- package/pineforge_codegen/pine_spelling.py +216 -0
- package/pineforge_codegen/pragmas.py +64 -10
- package/pineforge_codegen/security_contexts.py +1585 -0
- package/pineforge_codegen/session_reads.py +84 -0
- package/pineforge_codegen/signatures.py +48 -23
- package/pineforge_codegen/support_checker.py +1106 -85
- package/pineforge_codegen-1.0.0-rc.1.tar.gz +0 -0
- package/release.json +2 -2
- package/tables.json +23 -21
- package/transpile.worker.mjs +24 -16
- package/pineforge_codegen-0.10.4.tar.gz +0 -0
|
Binary file
|
package/release.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"codegen": "0.
|
|
2
|
+
"codegen": "1.0.0-rc.1",
|
|
3
3
|
"pyodide": "314.0.0",
|
|
4
4
|
"python": "3.14.0",
|
|
5
5
|
"emscripten": "emscripten_5_0_3",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "b692b0d616595a9b6260481bef7d88a5d63f11d094c7e30ce63bea420619af71"
|
|
7
7
|
}
|
package/tables.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"CODEGEN_VERSION": "0.
|
|
2
|
+
"CODEGEN_VERSION": "1.0.0-rc.1",
|
|
3
3
|
"TA_CLASS_MAP_KEYS": [
|
|
4
4
|
"sma",
|
|
5
5
|
"ema",
|
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
"percentile_linear_interpolation",
|
|
56
56
|
"vwap",
|
|
57
57
|
"vwap_bands",
|
|
58
|
+
"vwap_anchored",
|
|
59
|
+
"vwap_anchored_bands",
|
|
58
60
|
"obv",
|
|
59
61
|
"accdist",
|
|
60
62
|
"nvi",
|
|
@@ -488,10 +490,11 @@
|
|
|
488
490
|
"length"
|
|
489
491
|
],
|
|
490
492
|
"ta.alma": [
|
|
491
|
-
"
|
|
493
|
+
"series",
|
|
492
494
|
"length",
|
|
493
495
|
"offset",
|
|
494
|
-
"sigma"
|
|
496
|
+
"sigma",
|
|
497
|
+
"floor"
|
|
495
498
|
],
|
|
496
499
|
"ta.swma": [
|
|
497
500
|
"source"
|
|
@@ -528,7 +531,7 @@
|
|
|
528
531
|
"length"
|
|
529
532
|
],
|
|
530
533
|
"ta.cmo": [
|
|
531
|
-
"
|
|
534
|
+
"series",
|
|
532
535
|
"length"
|
|
533
536
|
],
|
|
534
537
|
"ta.tsi": [
|
|
@@ -550,24 +553,26 @@
|
|
|
550
553
|
"siglen"
|
|
551
554
|
],
|
|
552
555
|
"ta.bb": [
|
|
553
|
-
"
|
|
556
|
+
"series",
|
|
554
557
|
"length",
|
|
555
558
|
"mult"
|
|
556
559
|
],
|
|
557
560
|
"ta.kc": [
|
|
558
|
-
"
|
|
561
|
+
"series",
|
|
559
562
|
"length",
|
|
560
|
-
"mult"
|
|
563
|
+
"mult",
|
|
564
|
+
"useTrueRange"
|
|
561
565
|
],
|
|
562
566
|
"ta.bbw": [
|
|
563
|
-
"
|
|
567
|
+
"series",
|
|
564
568
|
"length",
|
|
565
569
|
"mult"
|
|
566
570
|
],
|
|
567
571
|
"ta.kcw": [
|
|
568
|
-
"
|
|
572
|
+
"series",
|
|
569
573
|
"length",
|
|
570
|
-
"mult"
|
|
574
|
+
"mult",
|
|
575
|
+
"useTrueRange"
|
|
571
576
|
],
|
|
572
577
|
"ta.atr": [
|
|
573
578
|
"length"
|
|
@@ -891,7 +896,7 @@
|
|
|
891
896
|
"string"
|
|
892
897
|
],
|
|
893
898
|
"str.format": [
|
|
894
|
-
"
|
|
899
|
+
"formatString"
|
|
895
900
|
],
|
|
896
901
|
"str.format_time": [
|
|
897
902
|
"time",
|
|
@@ -944,7 +949,8 @@
|
|
|
944
949
|
],
|
|
945
950
|
"str.repeat": [
|
|
946
951
|
"source",
|
|
947
|
-
"
|
|
952
|
+
"repeat",
|
|
953
|
+
"separator"
|
|
948
954
|
],
|
|
949
955
|
"str.match": [
|
|
950
956
|
"source",
|
|
@@ -1121,11 +1127,11 @@
|
|
|
1121
1127
|
"x"
|
|
1122
1128
|
],
|
|
1123
1129
|
"nz": [
|
|
1124
|
-
"
|
|
1125
|
-
"
|
|
1130
|
+
"source",
|
|
1131
|
+
"replacement"
|
|
1126
1132
|
],
|
|
1127
1133
|
"fixnan": [
|
|
1128
|
-
"
|
|
1134
|
+
"source"
|
|
1129
1135
|
],
|
|
1130
1136
|
"timestamp": [
|
|
1131
1137
|
"year",
|
|
@@ -1429,10 +1435,6 @@
|
|
|
1429
1435
|
"24x7"
|
|
1430
1436
|
],
|
|
1431
1437
|
"HARD_REJECT_FUNC": {
|
|
1432
|
-
"request.financial": "External fundamentals data not available in PineForge.",
|
|
1433
|
-
"request.dividends": "External corporate-action data not available in PineForge.",
|
|
1434
|
-
"request.earnings": "External corporate-action data not available in PineForge.",
|
|
1435
|
-
"request.splits": "External corporate-action data not available in PineForge.",
|
|
1436
1438
|
"request.seed": "External seed data feeds not available in PineForge.",
|
|
1437
1439
|
"request.quandl": "External Quandl data not available in PineForge.",
|
|
1438
1440
|
"request.currency_rate": "Currency conversion data not available in PineForge.",
|
|
@@ -1550,8 +1552,8 @@
|
|
|
1550
1552
|
"text": "is a visual/style constant with no runtime value in PineForge backtests; it is only accepted as an argument to visual calls (plot, plotshape, hline, label.new, table.cell, ...), which PineForge parses and skips.",
|
|
1551
1553
|
"xloc": "is a visual/style constant with no runtime value in PineForge backtests; it is only accepted as an argument to visual calls (plot, plotshape, hline, label.new, table.cell, ...), which PineForge parses and skips.",
|
|
1552
1554
|
"yloc": "is a visual/style constant with no runtime value in PineForge backtests; it is only accepted as an argument to visual calls (plot, plotshape, hline, label.new, table.cell, ...), which PineForge parses and skips.",
|
|
1553
|
-
"barmerge": "is
|
|
1554
|
-
"alert": "is
|
|
1555
|
+
"barmerge": "is not a barmerge constant; only barmerge.gaps_on, barmerge.gaps_off, barmerge.lookahead_on and barmerge.lookahead_off exist.",
|
|
1556
|
+
"alert": "is not a Pine alert constant; only alert.freq_all, alert.freq_once_per_bar and alert.freq_once_per_bar_close exist."
|
|
1555
1557
|
},
|
|
1556
1558
|
"UNSUPPORTED_MEMBERS": {},
|
|
1557
1559
|
"UNSUPPORTED_NAMESPACE_VARS": {
|
package/transpile.worker.mjs
CHANGED
|
@@ -22,26 +22,34 @@ from pineforge_codegen import transpile_full
|
|
|
22
22
|
from pineforge_codegen.errors import CompileError
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
def _diagnostic_entries(diagnostics) -> list:
|
|
26
|
+
diags = []
|
|
27
|
+
for d in diagnostics:
|
|
28
|
+
loc = d.location
|
|
29
|
+
message = d.message + " — " + d.hint if getattr(d, "hint", None) else d.message
|
|
30
|
+
entry = {
|
|
31
|
+
"line": loc.line if loc else 1,
|
|
32
|
+
"col": loc.col if loc else 1,
|
|
33
|
+
"message": message,
|
|
34
|
+
"severity": getattr(d.level, "value", "error"),
|
|
35
|
+
}
|
|
36
|
+
end_col = getattr(loc, "end_col", None) if loc else None
|
|
37
|
+
if end_col is not None:
|
|
38
|
+
entry["endCol"] = end_col
|
|
39
|
+
diags.append(entry)
|
|
40
|
+
return diags
|
|
41
|
+
|
|
42
|
+
|
|
25
43
|
def transpile_json(source: str) -> str:
|
|
26
44
|
try:
|
|
27
45
|
full = transpile_full(source)
|
|
28
46
|
except CompileError as e:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"col": loc.col if loc else 1,
|
|
36
|
-
"message": message,
|
|
37
|
-
"severity": getattr(d.level, "value", "error"),
|
|
38
|
-
}
|
|
39
|
-
end_col = getattr(loc, "end_col", None) if loc else None
|
|
40
|
-
if end_col is not None:
|
|
41
|
-
entry["endCol"] = end_col
|
|
42
|
-
diags.append(entry)
|
|
43
|
-
return json.dumps({"ok": False, "error": str(e), "diagnostics": diags})
|
|
44
|
-
return json.dumps({"ok": True, "cpp": full["cpp"], "inputs": full["inputs"], "strategyParams": full["strategyParams"]})
|
|
47
|
+
return json.dumps({"ok": False, "error": str(e),
|
|
48
|
+
"diagnostics": _diagnostic_entries(e.diagnostics)})
|
|
49
|
+
# A script that transpiled carries its warnings in the same entry format.
|
|
50
|
+
return json.dumps({"ok": True, "cpp": full["cpp"], "inputs": full["inputs"],
|
|
51
|
+
"strategyParams": full["strategyParams"],
|
|
52
|
+
"diagnostics": _diagnostic_entries(full["diagnostics"])})
|
|
45
53
|
`;
|
|
46
54
|
|
|
47
55
|
const post = (m) => self.postMessage(m);
|
|
Binary file
|