@hoox-sh/pynets 0.2.0 → 0.3.0
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/CHANGELOG.md +39 -0
- package/README.md +17 -8
- package/dist/browser.js +89 -84
- package/dist/index.js +19482 -12937
- package/package.json +1 -1
- package/src/ast/builder.ts +235 -12
- package/src/ast/nodes.ts +114 -4
- package/src/ast/unparse.ts +192 -17
- package/src/cli/rich.ts +1 -1
- package/src/generated/PinescriptLexer.interp +5 -1
- package/src/generated/PinescriptLexer.tokens +97 -95
- package/src/generated/PinescriptLexer.ts +512 -502
- package/src/generated/PinescriptParser.interp +8 -1
- package/src/generated/PinescriptParser.tokens +97 -95
- package/src/generated/PinescriptParser.ts +1907 -1287
- package/src/generated/PinescriptParserVisitor.ts +36 -1
- package/src/index.ts +1 -0
- package/src/runtime/array.ts +238 -68
- package/src/runtime/compile/collections.ts +187 -34
- package/src/runtime/compile/emit.ts +266 -9
- package/src/runtime/compile/emit_call.ts +425 -35
- package/src/runtime/compile/runtime.ts +62 -2
- package/src/runtime/compile/strategy.ts +87 -6
- package/src/runtime/compile/types.ts +2 -0
- package/src/runtime/drawings.ts +405 -8
- package/src/runtime/interpret.ts +2201 -277
- package/src/runtime/matrix.ts +371 -42
- package/src/runtime/strategy.ts +695 -33
- package/src/runtime/ta.ts +654 -20
- package/src/runtime/timeframe.ts +199 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,45 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-09-23
|
|
11
|
+
|
|
12
|
+
`once` / multi-value `switch`, and a Python `Runtime.run` interpret parity slice (drawings, strategy fields, host helpers, TA/matrix). Compile emit for the TA/matrix/host names from that slice.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- `once [cond]` structure — parse / unparse / interpret / compile fire the body the first time the test is true (or bar 0 with no test), regen from PYNE grammar
|
|
16
|
+
- multi-value `switch` arms (`1, 2 =>`) match any element on interpret and compile
|
|
17
|
+
- `matrix.sum_row` / `sum_col`, `avg_*`, `min_*`, `max_*`, `mode_*`, `copy_row` / `copy_col`, `fill_row` / `fill_col` / `fill_diagonal`, `reverse_rows` / `reverse_cols`, `stdev`, `variance`
|
|
18
|
+
- `ta.uo`, `ta.rci`, `ta.dpo`, `ta.kst`, `ta.stochrsi`, `ta.donchian`, `ta.ichimoku`, `ta.bb_pct`, `ta.emv`, `ta.fractal`, `ta.atr_stop`, `ta.zigzag` (interpret; v3/v4 bare aliases)
|
|
19
|
+
- `timeframe.change`, `time_close`, `syminfo.prefix`, bare `round_to_mintick`, v4 `array.new*` constructors, `plotcandle` / `plotbar`
|
|
20
|
+
- JS compile emit for those TA / matrix / host names so `compileToResult` matches interpret
|
|
21
|
+
- Drawing getters/setters, `*.all`, `*.copy`, remaining deletes, `chart.point.*`, `line.fill`
|
|
22
|
+
- `strategy.cash` is free cash (tagged for `default_qty_type`); trade-history fields; `oca` / `direction` / `commission` constants; zero-arg `strategy.netprofit()` calls
|
|
23
|
+
- `timenow`, `max_bars_back`, `alertcondition`, `plot.linestyle_*`, bare `random`, bare `security` / `security_lower_tf`
|
|
24
|
+
- `FunctionDef.returns` — UDF/method return types survive parse → unparse (`int ilog2(...)`)
|
|
25
|
+
- `Runtime.run(..., timeout_seconds)` — interpret wall-clock circuit breaker (every 32 bars); `timed_out` + `error_kind=runtime`
|
|
26
|
+
- `Runtime.run(..., libraries=[{namespace, name, version, source}])` — same list shape as Python `Runtime.run`
|
|
27
|
+
- `Type.new(...)` positional args fill fields in declaration order (kwargs still override)
|
|
28
|
+
- `ta.vpt` / `vpt` alias of `ta.pvt` (Python `ta.pvt` / `ta.vpt` cumulative)
|
|
29
|
+
- `strategy.exit` pending stop/limit/trail, tick `profit`/`loss`, `qty_percent`, `from_entry`; `trail_points=0`/`na` does not disable `trail_offset`
|
|
30
|
+
- UDT array cells; `array.sort` / `binary_search*` `sort_field` (default `0` on UDT arrays)
|
|
31
|
+
- Incremental `ta.cmf` / `ta.klinger`; `ta.wad` volume-scaled; `ta.wvad` is WAD / rolling volume
|
|
32
|
+
- ASDL `AugAssign`, `Qualify`/`Specialize`, bitwise/shift (`& | ^ << >>`)
|
|
33
|
+
- Incremental interpret `ta.ao` / `ta.aroon` (SMA(hl2,5)−SMA(hl2,34); Aroon pair, ties keep oldest)
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Parser regen from PYNE 0.3.11: left-factored typed names; bare `x =` is `Assign`; `=` reassignment only on attribute/subscript
|
|
37
|
+
- Compile `strategy.exit` uses `placeExit` (trail / ticks / `qty_percent` / `from_entry`)
|
|
38
|
+
- Compile arrays keep UDT/object cells; `sort` / `binary_search*` pass `sort_field`
|
|
39
|
+
- Compile `ta.wad` / `ta.wvad` / `ta.cmf` / `ta.klinger` match interpret kernels
|
|
40
|
+
- Compile emit bitwise/shift, `AugAssign`, and zero-arg `ta.*` attributes
|
|
41
|
+
- Interpret `order.ascending` / `order.descending` (1 / -1)
|
|
42
|
+
- Interpret `plot(ta.wvad)` / `plot(ta.cmf)` as the 0-arg forms (period 20)
|
|
43
|
+
- `matrix.sort` / `matrix.sort_indices` take `sort_field`; UDT cells allowed
|
|
44
|
+
- Pine namespace constants (`order`/`format`/`display`/`shape`/`dayofweek`/`month`/…) on interpret and compile
|
|
45
|
+
- Compile matrix UDT cells and `matrix.sort_indices`
|
|
46
|
+
- Interpret `strategy(..., avg_price_model=, leverage=)` plus `strategy.leverage` / liquidation price
|
|
47
|
+
- Compile `strategy(...)` folds `leverage` / `avg_price_model` / default qty / margins; `strategy.leverage` / `position_avg_price` / `margin_liquidation_price`; omitted entry qty uses `resolveDefaultQty`; close passes qty
|
|
48
|
+
|
|
10
49
|
## [0.2.0] - 2026-08-16
|
|
11
50
|
|
|
12
51
|
JS compile backend (`mode: "compile" | "auto"`). Interpret unchanged.
|
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# PyneTS
|
|
2
2
|
|
|
3
|
+
[](https://github.com/hoox-sh/pynets/actions/workflows/ci.yml)
|
|
4
|
+
[](https://codecov.io/gh/hoox-sh/pynets)
|
|
5
|
+
[](https://www.npmjs.com/package/@hoox-sh/pynets)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://bun.sh)
|
|
8
|
+
|
|
3
9
|
TypeScript / Bun library for **Pine Script**: parse, unparse, and interpret.
|
|
4
10
|
|
|
5
11
|
<p align="center">
|
|
@@ -9,6 +15,8 @@ TypeScript / Bun library for **Pine Script**: parse, unparse, and interpret.
|
|
|
9
15
|
Same public names as Python [`pynescript`](https://github.com/hoox-sh/pyne): `parse`, `unparse`, `Runtime.run`.
|
|
10
16
|
Python `pynescript.runtime` is the **source of truth**. When semantics disagree, Python wins. This is not a TradingView platform certification.
|
|
11
17
|
|
|
18
|
+
**Docs (hoox.sh):** [PyneTS](https://hoox.sh/pyne/docs/pynets) · [install](https://hoox.sh/pyne/docs/pynets/install) · [runtime](https://hoox.sh/pyne/docs/pynets/runtime) · [CLI](https://hoox.sh/pyne/docs/pynets/cli) · [JS compile](https://hoox.sh/pyne/docs/pynets/compile) · [parity](https://hoox.sh/pyne/docs/pynets/parity) · [ecosystem](https://hoox.sh/pyne/docs/reference/ecosystem)
|
|
19
|
+
|
|
12
20
|
```ts
|
|
13
21
|
import { parse, unparse, Runtime } from "@hoox-sh/pynets";
|
|
14
22
|
|
|
@@ -81,15 +89,16 @@ Most TypeScript Pine ports rewrite the language. PyneTS does not. It is the libr
|
|
|
81
89
|
|
|
82
90
|
Family map — library vs edge host, same SoT:
|
|
83
91
|
|
|
84
|
-
| | [pynescript](https://github.com/hoox-sh/pyne) | [pyne-worker](https://github.com/hoox-sh/pyne-worker) | **PyneTS** |
|
|
85
|
-
|
|
86
|
-
| Role | SoT library | Production **Python** Cloudflare Worker | TS / Bun library + CLI |
|
|
87
|
-
| Engine | interpret + Numba compile | Vendors `pynescript.runtime` | interpret + **JS compile** |
|
|
88
|
-
| Grammar | `*.g4` | Same Python engine (not a fork) | **same `.g4`**, TS ANTLR target |
|
|
89
|
-
| How you call it | `Runtime.run` | `POST /run`
|
|
90
|
-
| Extra | LSP, Pro API | R2 OHLCV, 1m cron, alerts, trade-worker | Local TTY (`check` / `format` / `run` / `dump`) |
|
|
92
|
+
| | [pynescript](https://github.com/hoox-sh/pyne) | [pyne-worker](https://github.com/hoox-sh/pyne-worker) | [pyne-agent-worker](https://github.com/hoox-sh/pyne-agent-worker) | **PyneTS** |
|
|
93
|
+
|---|---|---|---|---|
|
|
94
|
+
| Role | SoT library | Production **Python** Cloudflare Worker | NL **authoring** (Workers AI™) | TS / Bun library + CLI |
|
|
95
|
+
| Engine | interpret + Numba compile | Vendors `pynescript.runtime` | Writes source; optional `/run` validate | interpret + **JS compile** |
|
|
96
|
+
| Grammar | `*.g4` | Same Python engine (not a fork) | — | **same `.g4`**, TS ANTLR target |
|
|
97
|
+
| How you call it | `Runtime.run` | `POST /run` | `POST /v1/chat` | `Runtime.run` (`interpret` / `compile` / `auto`) |
|
|
98
|
+
| Extra | LSP, Pro API | R2 OHLCV, 1m cron, alerts, trade-worker | AXIS plugin | Local TTY (`check` / `format` / `run` / `dump`) |
|
|
99
|
+
| Docs | [hoox.sh/pyne/docs](https://hoox.sh/pyne/docs) | [pyne-worker](https://hoox.sh/pyne/docs/pyne-worker) | [agent](https://hoox.sh/pyne/docs/agent) | [pynets](https://hoox.sh/pyne/docs/pynets) |
|
|
91
100
|
|
|
92
|
-
[pyne-worker](https://github.com/hoox-sh/pyne-worker) is the edge evaluate host of the **Python** engine. PyneTS is the TypeScript library you import and the CLI you run on a laptop. They share the PYNE contract; this repo is not a Worker.
|
|
101
|
+
[pyne-worker](https://github.com/hoox-sh/pyne-worker) is the edge evaluate host of the **Python** engine. [pyne-agent-worker](https://github.com/hoox-sh/pyne-agent-worker) writes scripts. PyneTS is the TypeScript library you import and the CLI you run on a laptop. They share the PYNE contract; this repo is not a Worker.
|
|
93
102
|
|
|
94
103
|
This repository is the standalone `@hoox-sh/pynets` checkout. PYNE consumes it **only** as the `pynets/` git submodule — never copy sources back into `hoox-sh/pyne`.
|
|
95
104
|
|