@hoox-sh/pynets 0.4.0 → 0.6.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 +34 -0
- package/README.md +9 -5
- package/dist/browser.js +68 -68
- package/dist/index.js +2196 -206
- package/package.json +1 -1
- package/src/cli/rich.ts +1 -1
- package/src/generated/PinescriptLexerBase.ts +22 -4
- package/src/parser/LexerBase.ts +22 -4
- package/src/runtime/compile/draw.ts +26 -2
- package/src/runtime/compile/emit.ts +17 -0
- package/src/runtime/compile/emit_call.ts +378 -7
- package/src/runtime/compile/helpers.ts +2 -1
- package/src/runtime/compile/runtime.ts +71 -6
- package/src/runtime/compile/strategy.ts +5 -2
- package/src/runtime/footprint.ts +272 -0
- package/src/runtime/interpret.ts +621 -36
- package/src/runtime/request.ts +19 -4
- package/src/runtime/str.ts +3 -2
- package/src/runtime/strategy.ts +164 -12
- package/src/runtime/ta.ts +1090 -149
- package/src/runtime/time.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0] - 2026-11-04
|
|
11
|
+
|
|
12
|
+
Parity upgrade against PYNE 0.6.32: the Python probe now imports the local
|
|
13
|
+
source checkout, incremental TA drift is fixed, and the strategy broker uses
|
|
14
|
+
next-bar market fills.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- Wave 11 statistical / advanced `ta.*`: `sma_weighted`, `apo`, `atr_normalized`, `beta`, `r_squared`, `comovement`, `skewness`, `kurtosis`, `volume_weighted_momentum`, `parkinson`, `garman_klass`, `mean_reversion_score`, `market_condition`, `order_flow_imbalance`, `liquidity_score`, `fear_greed_index`, `crowd_sentiment`, `smart_money_flow`, `trend_confirmation_score`, `max_loss_level`, `profit_lock_level` (interpret + compile).
|
|
18
|
+
- Wave 12 risk / sizing / timing `ta.*`: `position_sizing`, `kelly_criterion`, `risk_reward_ratio`, `risk_reward_asymmetry`, `probability_of_movement`, `trend_strength`, `breakeven_level`, `market_structure_pivot`, `position_sizing_score`, `trailing_exit_level`, `optimal_entry_zone`, `mean_reversion_entry`, `multi_timeframe_signal`, `market_timing_index`, `regime_adaptive_signal`, `strategy_score`, `breakout_detection` (interpret + compile).
|
|
19
|
+
- `PARITY.md` tracking the remaining advanced analytics and history-list quirks.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- Parity tests run against the local PYNE checkout (`$PYNESCRIPT_ROOT/src`) through a `PYTHONPATH` wrapper instead of a stale venv install.
|
|
23
|
+
- Strategy market orders placed on bar N fill at the open of bar N+1; orders never fill on their placement bar; `entry_time` / `exit_time` use bar timestamps. Compile uses the same flow.
|
|
24
|
+
- `ta.stdev`, `ta.variance`, and Bollinger bands use population variance (ddof=0).
|
|
25
|
+
- `ta.atr` seeds bar 0 with `high - low`.
|
|
26
|
+
- Compile `hold()` preserves string values (string-valued TA results survive assignment).
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- Bar-mode incremental parity for `ta.zigzag`, `ta.acceleration_factor`, `ta.stoch_smooth`, `ta.engulfing`, `ta.inside_bar_pattern`, `ta.double_top_bottom`, `ta.rsi_divergence`, `ta.cumulative_delta`, `ta.volume_momentum`, and `ta.volume_thrust`.
|
|
30
|
+
|
|
31
|
+
## [0.5.0] - 2026-09-27
|
|
32
|
+
|
|
33
|
+
Python `Runtime.run` footprint mock, plot style / alert frequency tokens, and `alert()` gating. Compile emits the same names.
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- `request.footprint` Python mock on interpret and compile. `footprint.*` and `volume_row.*` accessors (call form). `request.seed` seeds the mock RNG so numbers match Python.
|
|
37
|
+
- `plot.style_line` … `plot.style_circles` and `alert.freq_once_per_bar` / `once_per_bar_close` / `all` on interpret and compile.
|
|
38
|
+
- `alert()` frequency gating: default once per bar, `"all"` every call, zero-arg is a no-op.
|
|
39
|
+
|
|
40
|
+
### Notes
|
|
41
|
+
- Realtime `once` rollback and the extension-analytics `ta.*` list are still open.
|
|
42
|
+
- Chart-series plots that Python leaves `na` stay unwired (`ta.beta`, `ta.skewness`, `ta.parkinson`, and the rest of that list).
|
|
43
|
+
|
|
10
44
|
## [0.4.0] - 2026-09-27
|
|
11
45
|
|
|
12
46
|
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.
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ TypeScript / Bun library for **Pine Script**: parse, unparse, and interpret.
|
|
|
15
15
|
Same public names as Python [`pynescript`](https://github.com/hoox-sh/pyne): `parse`, `unparse`, `Runtime.run`.
|
|
16
16
|
Python `pynescript.runtime` is the **source of truth**. When semantics disagree, Python wins. This is not a TradingView platform certification.
|
|
17
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)
|
|
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) · [parity status](PARITY.md) · [ecosystem](https://hoox.sh/pyne/docs/reference/ecosystem)
|
|
19
19
|
|
|
20
20
|
```ts
|
|
21
21
|
import { parse, unparse, Runtime } from "@hoox-sh/pynets";
|
|
@@ -134,7 +134,7 @@ Wired through one dispatcher (`src/runtime/interpret.ts`). Not a second engine.
|
|
|
134
134
|
|
|
135
135
|
**Language** — `var` / `varip` / `:=`, tuples, `if` / `for` / `while` / `switch`, UDFs, `type` / `enum`, `import`, `library()`.
|
|
136
136
|
|
|
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`,
|
|
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`, 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`), and the statistical / risk analytics waves: `sma_weighted`, `apo`, `atr_normalized`, `beta`, `r_squared`, `comovement`, `skewness`, `kurtosis`, `volume_weighted_momentum`, `parkinson`, `garman_klass`, `mean_reversion_score`, `market_condition`, `order_flow_imbalance`, `liquidity_score`, `fear_greed_index`, `crowd_sentiment`, `smart_money_flow`, `trend_confirmation_score`, `max_loss_level`, `profit_lock_level`, `position_sizing`, `kelly_criterion`, `risk_reward_ratio`, `risk_reward_asymmetry`, `probability_of_movement`, `trend_strength`, `breakeven_level`, `market_structure_pivot`, `position_sizing_score`, `trailing_exit_level`, `optimal_entry_zone`, `mean_reversion_entry`, `multi_timeframe_signal`, `market_timing_index`, `regime_adaptive_signal`, `strategy_score`, `breakout_detection`. Compile emits the same names. See [`PARITY.md`](PARITY.md) for the remaining advanced analytics.
|
|
138
138
|
|
|
139
139
|
**`math.*` / `str.*` / `color.*` / `input.*` / `log.*`** — the Python set, including `nz`, `iff`, `fixnan`, `timestamp`, `weekofyear`, `time_tradingday`.
|
|
140
140
|
|
|
@@ -142,9 +142,11 @@ Wired through one dispatcher (`src/runtime/interpret.ts`). Not a second engine.
|
|
|
142
142
|
|
|
143
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`.
|
|
144
144
|
|
|
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`.
|
|
145
|
+
**`strategy.*`** — entry/exit/order, pending limit/stop, commission/slippage/pyramiding, open/closed trade accessors, **`strategy.risk.*`**, **OCA cancel/reduce**. Market orders placed on bar N fill at the **open of bar N+1** (PYNE 0.6.29 reference-Pine flow), and trade `entry_time` / `exit_time` use bar timestamps. `strategy.cash` is free cash and still selects cash sizing for `default_qty_type`.
|
|
146
146
|
|
|
147
|
-
**Drawings / alerts** — `line` / `label` / `box` / `table` / `polyline` / `linefill` getters and setters, `*.all`, `*.copy`, `chart.point.*`; `alert` / `alertcondition
|
|
147
|
+
**Drawings / alerts** — `line` / `label` / `box` / `table` / `polyline` / `linefill` getters and setters, `*.all`, `*.copy`, `chart.point.*`; `alert` / `alertcondition` with Python frequency tokens (`alert.freq_*`). `plot.style_*` tokens. `timenow` is the dataset last-bar time on every bar.
|
|
148
|
+
|
|
149
|
+
**`request.*`** — same-symbol `security` passthrough; foreign / HTF without a feed is `na`. `request.footprint` is Python’s mock object (`footprint.*` / `volume_row.*`); `request.seed` seeds that mock.
|
|
148
150
|
|
|
149
151
|
---
|
|
150
152
|
|
|
@@ -287,7 +289,7 @@ import {
|
|
|
287
289
|
|
|
288
290
|
## Development
|
|
289
291
|
|
|
290
|
-
Agent brief: [`AGENTS.md`](AGENTS.md) · contribute: [`CONTRIBUTING.md`](CONTRIBUTING.md) · changes: [`CHANGELOG.md`](CHANGELOG.md)
|
|
292
|
+
Agent brief: [`AGENTS.md`](AGENTS.md) · contribute: [`CONTRIBUTING.md`](CONTRIBUTING.md) · changes: [`CHANGELOG.md`](CHANGELOG.md) · parity status: [`PARITY.md`](PARITY.md)
|
|
291
293
|
|
|
292
294
|
```bash
|
|
293
295
|
git clone https://github.com/hoox-sh/pynets.git
|
|
@@ -297,6 +299,8 @@ bun test
|
|
|
297
299
|
bun run typecheck
|
|
298
300
|
```
|
|
299
301
|
|
|
302
|
+
Parity tests run against the local PYNE checkout (`$PYNESCRIPT_ROOT`, default `/home/jango/Git/pynescript`) by putting `$PYNESCRIPT_ROOT/src` on `PYTHONPATH`; they skip cleanly when PYNE is absent. The current snapshot is verified against **PYNE 0.6.32**.
|
|
303
|
+
|
|
300
304
|
Generated files under `src/generated/` are committed so `bun test` does not require Java. Local development is Bun only — do not add npm/yarn/pnpm lockfiles.
|
|
301
305
|
|
|
302
306
|
### Grammar (do not fork)
|