@hoox-sh/pynets 0.2.0 → 0.4.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 CHANGED
@@ -7,6 +7,62 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.0] - 2026-09-27
11
+
12
+ Interpret and compile for the next Python `Runtime.run` slice: bar-mode `ta.*` detectors, strategy field emit, drawing-book emit, and host helpers. `array.from` on the compile path collects its arguments.
13
+
14
+ ### Added
15
+ - `ta.hammer`, `ta.gap_detector`, `ta.macd_signal`, `ta.acceleration_factor`, `ta.stoch_smooth`, `ta.engulfing`, `ta.inside_bar_pattern`, `ta.double_top_bottom`, `ta.voi`, `ta.bid_ask_imbalance`, `ta.rsi_oversold_overbought`, `ta.rsi_divergence`, `ta.cumulative_delta`, `ta.volume_momentum`, `ta.volume_profile_high`, `ta.volume_profile_low`, `ta.volume_thrust` (interpret and compile; v3/v4 bare aliases). Several are Python’s bar-mode sentinels (`ta.engulfing` is false every bar; `ta.stoch_smooth` is `na` unless both smooth lengths are 1).
16
+ - Compile emit for `strategy.cash` free cash, trade-history getters, and `oca` / `direction` / `commission` constants. `default_qty_type=strategy.cash` still sizes entries as cash.
17
+ - Compile emit for `timenow` / `timenow()`, `max_bars_back`, `alertcondition`, `plot.linestyle_*`, bare `random`, bare `security_lower_tf`.
18
+ - Compile emit for drawing getters and remaining setters, `*.all`, `*.copy`, `chart.point.*`, and `line.fill`.
19
+
20
+ ### Changed
21
+ - Compile `array.from` collects its arguments. It no longer lowers to `array.new(size, initial)`.
22
+
23
+ ### Notes
24
+ - Still unwired because a chart-series plot is `na` on every bar: `ta.skewness`, `ta.kurtosis`, `ta.sma_weighted`, `ta.atr_normalized`, `ta.parkinson`, `ta.garman_klass`, `ta.volume_weighted_momentum`, and `ta.beta`, `ta.r_squared`, `ta.comovement`, `ta.apo`.
25
+ - Footprint / `volume_row`, realtime `once` rollback, and the extension-analytics `ta.*` list are still open.
26
+
27
+ ## [0.3.0] - 2026-09-23
28
+
29
+ `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.
30
+
31
+ ### Added
32
+ - `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
33
+ - multi-value `switch` arms (`1, 2 =>`) match any element on interpret and compile
34
+ - `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`
35
+ - `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)
36
+ - `timeframe.change`, `time_close`, `syminfo.prefix`, bare `round_to_mintick`, v4 `array.new*` constructors, `plotcandle` / `plotbar`
37
+ - JS compile emit for those TA / matrix / host names so `compileToResult` matches interpret
38
+ - Drawing getters/setters, `*.all`, `*.copy`, remaining deletes, `chart.point.*`, `line.fill`
39
+ - `strategy.cash` is free cash (tagged for `default_qty_type`); trade-history fields; `oca` / `direction` / `commission` constants; zero-arg `strategy.netprofit()` calls
40
+ - `timenow`, `max_bars_back`, `alertcondition`, `plot.linestyle_*`, bare `random`, bare `security` / `security_lower_tf`
41
+ - `FunctionDef.returns` — UDF/method return types survive parse → unparse (`int ilog2(...)`)
42
+ - `Runtime.run(..., timeout_seconds)` — interpret wall-clock circuit breaker (every 32 bars); `timed_out` + `error_kind=runtime`
43
+ - `Runtime.run(..., libraries=[{namespace, name, version, source}])` — same list shape as Python `Runtime.run`
44
+ - `Type.new(...)` positional args fill fields in declaration order (kwargs still override)
45
+ - `ta.vpt` / `vpt` alias of `ta.pvt` (Python `ta.pvt` / `ta.vpt` cumulative)
46
+ - `strategy.exit` pending stop/limit/trail, tick `profit`/`loss`, `qty_percent`, `from_entry`; `trail_points=0`/`na` does not disable `trail_offset`
47
+ - UDT array cells; `array.sort` / `binary_search*` `sort_field` (default `0` on UDT arrays)
48
+ - Incremental `ta.cmf` / `ta.klinger`; `ta.wad` volume-scaled; `ta.wvad` is WAD / rolling volume
49
+ - ASDL `AugAssign`, `Qualify`/`Specialize`, bitwise/shift (`& | ^ << >>`)
50
+ - Incremental interpret `ta.ao` / `ta.aroon` (SMA(hl2,5)−SMA(hl2,34); Aroon pair, ties keep oldest)
51
+
52
+ ### Changed
53
+ - Parser regen from PYNE 0.3.11: left-factored typed names; bare `x =` is `Assign`; `=` reassignment only on attribute/subscript
54
+ - Compile `strategy.exit` uses `placeExit` (trail / ticks / `qty_percent` / `from_entry`)
55
+ - Compile arrays keep UDT/object cells; `sort` / `binary_search*` pass `sort_field`
56
+ - Compile `ta.wad` / `ta.wvad` / `ta.cmf` / `ta.klinger` match interpret kernels
57
+ - Compile emit bitwise/shift, `AugAssign`, and zero-arg `ta.*` attributes
58
+ - Interpret `order.ascending` / `order.descending` (1 / -1)
59
+ - Interpret `plot(ta.wvad)` / `plot(ta.cmf)` as the 0-arg forms (period 20)
60
+ - `matrix.sort` / `matrix.sort_indices` take `sort_field`; UDT cells allowed
61
+ - Pine namespace constants (`order`/`format`/`display`/`shape`/`dayofweek`/`month`/…) on interpret and compile
62
+ - Compile matrix UDT cells and `matrix.sort_indices`
63
+ - Interpret `strategy(..., avg_price_model=, leverage=)` plus `strategy.leverage` / liquidation price
64
+ - 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
65
+
10
66
  ## [0.2.0] - 2026-08-16
11
67
 
12
68
  JS compile backend (`mode: "compile" | "auto"`). Interpret unchanged.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # PyneTS
2
2
 
3
+ [![CI](https://img.shields.io/github/actions/workflow/status/hoox-sh/pynets/ci.yml?branch=main&style=flat-square&label=CI)](https://github.com/hoox-sh/pynets/actions/workflows/ci.yml)
4
+ [![codecov](https://codecov.io/gh/hoox-sh/pynets/graph/badge.svg)](https://codecov.io/gh/hoox-sh/pynets)
5
+ [![npm](https://img.shields.io/npm/v/@hoox-sh/pynets?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@hoox-sh/pynets)
6
+ [![License](https://img.shields.io/github/license/hoox-sh/pynets?style=flat-square)](LICENSE)
7
+ [![Bun](https://img.shields.io/badge/Bun-1.4-000000?style=flat-square&logo=bun&logoColor=white)](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) · [missing features](https://hoox.sh/pyne/docs/pynets/missing-features) · [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` (`interpret` / `compile` / `auto`) | `Runtime.run` (`interpret` / `compile` / `auto`) |
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
 
@@ -125,17 +134,17 @@ Wired through one dispatcher (`src/runtime/interpret.ts`). Not a second engine.
125
134
 
126
135
  **Language** — `var` / `varip` / `:=`, tuples, `if` / `for` / `while` / `switch`, UDFs, `type` / `enum`, `import`, `library()`.
127
136
 
128
- **`ta.*`** — SMA/EMA/RMA/WMA/VWMA/HMA/ALMA/DEMA/TEMA/KAMA/SWMA, RSI, ATR, Supertrend, Keltner, BB/BBW, MACD, Stoch, CCI, WPR, DMI/ADX, SAR, MFI, CMO, TSI, COG, stdev/dev/variance, highest/lowest, crossover/crossunder, volume (OBV, PVT, AD, WAD, NVI/PVI, III, WVAD), pivots, barssince, valuewhen, percentiles, and the v3/v4 bare names.
137
+ **`ta.*`** — SMA/EMA/RMA/WMA/VWMA/HMA/ALMA/DEMA/TEMA/KAMA/SWMA, RSI, ATR, Supertrend, Keltner, BB/BBW, MACD, Stoch, CCI, WPR, DMI/ADX, SAR, MFI, CMO, TSI, COG, stdev/dev/variance, highest/lowest, crossover/crossunder, volume (OBV, PVT, AD, WAD, NVI/PVI, III, WVAD), pivots, barssince, valuewhen, percentiles, and the v3/v4 bare names. Also `uo`, `rci`, `dpo`, `kst`, `stochrsi`, `donchian`, `ichimoku`, `bb_pct`, `emv`, `fractal`, `atr_stop`, `zigzag`, and the Python bar-mode detectors (`hammer`, `gap_detector`, `macd_signal`, `acceleration_factor`, `stoch_smooth`, `engulfing`, `inside_bar_pattern`, `double_top_bottom`, `voi`, `bid_ask_imbalance`, `rsi_oversold_overbought`, `rsi_divergence`, `cumulative_delta`, `volume_momentum`, `volume_profile_high` / `low`, `volume_thrust`). Compile emits the same names. A chart-series plot that Python leaves `na` (`beta`, `r_squared`, `comovement`, `apo`, `skewness`, `kurtosis`, `parkinson`, `garman_klass`, and the same class) stays unwired.
129
138
 
130
139
  **`math.*` / `str.*` / `color.*` / `input.*` / `log.*`** — the Python set, including `nz`, `iff`, `fixnan`, `timestamp`, `weekofyear`, `time_tradingday`.
131
140
 
132
141
  **`array.*`** — new/from, get/set, push/pop/shift/unshift, slice/copy/concat, sort/search (binary + leftmost/rightmost), aggregates (avg/min/max/sum/median/mode/range/stdev/variance/covariance), percentiles, standardize, sort_indices.
133
142
 
134
- **`matrix.*`** — shape ops, predicates, `mult` / `inv` / **`pinv`** / `pow` / `kron` / `rank` / **eigenvalues / eigenvectors**.
143
+ **`matrix.*`** — shape ops, predicates, `mult` / `inv` / **`pinv`** / `pow` / `kron` / `rank` / **eigenvalues / eigenvectors**, plus row/col `sum` / `avg` / `min` / `max` / `mode`, fill, reverse, copy, `stdev`, `variance`.
135
144
 
136
- **`strategy.*`** — entry/exit/order, pending limit/stop, commission/slippage/pyramiding, open/closed trade accessors, **`strategy.risk.*`**, **OCA cancel/reduce**.
145
+ **`strategy.*`** — entry/exit/order, pending limit/stop, commission/slippage/pyramiding, open/closed trade accessors, **`strategy.risk.*`**, **OCA cancel/reduce**. `strategy.cash` is free cash and still selects cash sizing for `default_qty_type`.
137
146
 
138
- **Drawings / alerts** — `line` / `label` / `box` / `table` events; `alert` / `alertcondition`.
147
+ **Drawings / alerts** — `line` / `label` / `box` / `table` / `polyline` / `linefill` getters and setters, `*.all`, `*.copy`, `chart.point.*`; `alert` / `alertcondition`. `timenow` is the dataset last-bar time on every bar.
139
148
 
140
149
  ---
141
150