@backtest-kit/pinets 5.10.0 → 5.11.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/README.md CHANGED
@@ -32,7 +32,8 @@ Port your TradingView strategies to backtest-kit with zero rewrite. Powered by [
32
32
  |----------|-------------|
33
33
  | **`getSignal()`** | Run Pine Script and get structured `ISignalDto` (position, TP/SL, estimated time) |
34
34
  | **`run()`** | Run Pine Script and return raw plot data |
35
- | **`extract()`** | Extract values from plots with custom mapping |
35
+ | **`extract()`** | Extract the latest bar values from plots with custom mapping |
36
+ | **`extractRows()`** | Extract all bars as a timestamped row array with custom mapping |
36
37
  | **`dumpPlotData()`** | Dump plot data to markdown files for debugging |
37
38
  | **`usePine()`** | Register custom Pine constructor |
38
39
  | **`setLogger()`** | Configure custom logger |
@@ -166,6 +167,52 @@ const data = await extract(plots, {
166
167
  // data = { rsi: 55.2, macd: 12.5, prevRsi: 52.1, trendStrength: 'strong' }
167
168
  ```
168
169
 
170
+ ### Historical Rows Extraction
171
+
172
+ `extractRows()` returns **every bar** as a typed row with a `timestamp` field — useful for building datasets, detecting crossovers across history, or feeding data into downstream analysis.
173
+
174
+ ```typescript
175
+ import { File, run, extractRows } from '@backtest-kit/pinets';
176
+
177
+ const source = File.fromPath('indicators.pine');
178
+
179
+ const plots = await run(source, {
180
+ symbol: 'ETHUSDT',
181
+ timeframe: '1h',
182
+ limit: 200,
183
+ });
184
+
185
+ const rows = await extractRows(plots, {
186
+ // Simple: plot name -> number | null
187
+ rsi: 'RSI',
188
+ macd: 'MACD',
189
+
190
+ // Advanced: with lookback and optional transform
191
+ prevRsi: {
192
+ plot: 'RSI',
193
+ barsBack: 1,
194
+ },
195
+ trend: {
196
+ plot: 'ADX',
197
+ transform: (v) => v > 25 ? 'strong' : 'weak',
198
+ },
199
+ });
200
+
201
+ // rows[0] = { timestamp: '2024-01-01T00:00:00.000Z', rsi: 48.3, macd: -2.1, prevRsi: null, trend: 'weak' }
202
+ // rows[1] = { timestamp: '2024-01-01T01:00:00.000Z', rsi: 52.1, macd: -1.5, prevRsi: 48.3, trend: 'weak' }
203
+ // ...
204
+ ```
205
+
206
+ **Difference between `extract()` and `extractRows()`:**
207
+
208
+ | | `extract()` | `extractRows()` |
209
+ |---|---|---|
210
+ | Returns | Single object (latest bar) | Array of objects (all bars) |
211
+ | Missing value | `0` (fallback) | `null` |
212
+ | `timestamp` field | No | Yes — ISO string from the bar's time |
213
+ | `barsBack` | Looks back from the last bar | Looks back from each bar's own index |
214
+ | Use case | Signal generation at current bar | Dataset export, historical analysis |
215
+
169
216
  ### Debug with Plot Dump
170
217
 
171
218
  Dump plot data to markdown files for analysis and debugging:
package/build/index.cjs CHANGED
@@ -130,6 +130,8 @@ const INTERVAL_MINUTES = {
130
130
  "4h": 240,
131
131
  "6h": 360,
132
132
  "8h": 480,
133
+ "1d": 1440,
134
+ "1w": 10080,
133
135
  };
134
136
  const AXIS_SYMBOL = "_AXIS";
135
137
  class AxisProviderService {
package/build/index.mjs CHANGED
@@ -127,6 +127,8 @@ const INTERVAL_MINUTES = {
127
127
  "4h": 240,
128
128
  "6h": 360,
129
129
  "8h": 480,
130
+ "1d": 1440,
131
+ "1w": 10080,
130
132
  };
131
133
  const AXIS_SYMBOL = "_AXIS";
132
134
  class AxisProviderService {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtest-kit/pinets",
3
- "version": "5.10.0",
3
+ "version": "5.11.0",
4
4
  "description": "Run TradingView Pine Script strategies in Node.js self hosted environment. Execute existing Pine Script indicators and generate trading signals with 1:1 syntax compatibility via PineTS runtime.",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -69,11 +69,11 @@
69
69
  "ts-morph": "27.0.2",
70
70
  "tslib": "2.7.0",
71
71
  "typedoc": "0.27.9",
72
- "backtest-kit": "5.10.0",
72
+ "backtest-kit": "5.11.0",
73
73
  "worker-testbed": "1.0.12"
74
74
  },
75
75
  "peerDependencies": {
76
- "backtest-kit": "^5.10.0",
76
+ "backtest-kit": "^5.11.0",
77
77
  "pinets": "^0.9.8",
78
78
  "typescript": "^5.0.0"
79
79
  },