pinets 0.9.10 → 0.9.12
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 +28 -51
- package/dist/pinets.min.browser.es.js +15 -15
- package/dist/pinets.min.browser.es.js.map +1 -1
- package/dist/pinets.min.browser.js +15 -15
- package/dist/pinets.min.browser.js.map +1 -1
- package/dist/pinets.min.cjs +17 -17
- package/dist/pinets.min.cjs.map +1 -1
- package/dist/pinets.min.es.js +15 -15
- package/dist/pinets.min.es.js.map +1 -1
- package/dist/types/PineTS.class.d.ts +28 -0
- package/dist/types/marketData/FMP/FMPProvider.class.d.ts +12 -3
- package/dist/types/namespaces/Time.d.ts +15 -1
- package/dist/types/namespaces/Timeframe.d.ts +8 -0
- package/package.json +1 -1
|
@@ -148,6 +148,34 @@ export declare class PineTS {
|
|
|
148
148
|
* @private
|
|
149
149
|
*/
|
|
150
150
|
private _removeLastResult;
|
|
151
|
+
/**
|
|
152
|
+
* Snapshot the var/let/const/params Series state for streaming rollback.
|
|
153
|
+
* Captures the data array length and last value for each variable so we can
|
|
154
|
+
* restore to this exact state before re-executing the last bar.
|
|
155
|
+
*
|
|
156
|
+
* PERF NOTE: This currently snapshots ALL scopes (const, var, let, params).
|
|
157
|
+
* In practice, only `var` variables need snapshot/restore because:
|
|
158
|
+
* - `let` variables are re-initialized every bar via $.init() — they reset naturally
|
|
159
|
+
* - `const` variables are set once and never modified
|
|
160
|
+
* - `params` are function parameters, not modified across bars
|
|
161
|
+
* Only `var` variables persist and get modified in-place by $.set() (e.g. n += 1),
|
|
162
|
+
* which causes drift on streaming re-execution.
|
|
163
|
+
* If this becomes a bottleneck, narrow to `['var']` only.
|
|
164
|
+
*
|
|
165
|
+
* An even lighter alternative: make $.set() on var Series append-only (push
|
|
166
|
+
* instead of in-place modify). Then the existing pop-based _removeLastResult
|
|
167
|
+
* would correctly revert var state without any snapshot. This would require
|
|
168
|
+
* changes to the core Series/set mechanics.
|
|
169
|
+
*
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
private _snapshotVarState;
|
|
173
|
+
/**
|
|
174
|
+
* Restore var/let/const/params Series state from a snapshot.
|
|
175
|
+
* Truncates each Series' data array back to the snapshotted length.
|
|
176
|
+
* @private
|
|
177
|
+
*/
|
|
178
|
+
private _restoreVarState;
|
|
151
179
|
/**
|
|
152
180
|
* Initialize a new context for running Pine Script code
|
|
153
181
|
* @private
|
|
@@ -36,6 +36,8 @@ export declare class FMPProvider extends BaseProvider<FMPProviderConfig> {
|
|
|
36
36
|
private _apiKey;
|
|
37
37
|
private _baseUrl;
|
|
38
38
|
private _profileCache;
|
|
39
|
+
private _symbolInfoCache;
|
|
40
|
+
private _mintickCache;
|
|
39
41
|
constructor(config?: FMPProviderConfig);
|
|
40
42
|
configure(config: FMPProviderConfig): void;
|
|
41
43
|
protected getSupportedTimeframes(): Set<string>;
|
|
@@ -50,6 +52,13 @@ export declare class FMPProvider extends BaseProvider<FMPProviderConfig> {
|
|
|
50
52
|
*/
|
|
51
53
|
private _fetchIntradayData;
|
|
52
54
|
getSymbolInfo(tickerId: string): Promise<ISymbolInfo>;
|
|
55
|
+
/**
|
|
56
|
+
* Estimate mintick from historical OHLC data.
|
|
57
|
+
* Computes the smallest non-zero |close - open| and |high - low| diff,
|
|
58
|
+
* then rounds to the nearest power-of-10 bucket.
|
|
59
|
+
* Returns undefined if no valid diffs found.
|
|
60
|
+
*/
|
|
61
|
+
private _estimateMintick;
|
|
53
62
|
private _fetchProfile;
|
|
54
63
|
/**
|
|
55
64
|
* Resolve session string and timezone for a ticker by fetching its profile.
|
|
@@ -62,8 +71,8 @@ export declare class FMPProvider extends BaseProvider<FMPProviderConfig> {
|
|
|
62
71
|
private _dateStrToMs;
|
|
63
72
|
/** Convert FMP datetime string "YYYY-MM-DD HH:MM:SS" to ms timestamp. */
|
|
64
73
|
private _dateTimeStrToMs;
|
|
65
|
-
/** Heuristic:
|
|
66
|
-
private _isCrypto;
|
|
67
|
-
/** Heuristic: forex pairs are 6 chars, two 3-letter currency codes. */
|
|
74
|
+
/** Heuristic: forex pairs are exactly 6 uppercase chars (two 3-letter currency codes). */
|
|
68
75
|
private _isForex;
|
|
76
|
+
/** Heuristic: crypto tickers end with USD/USDT/BTC/ETH and are not forex pairs. */
|
|
77
|
+
private _isCrypto;
|
|
69
78
|
}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a Pine Script timeframe string to a canonical form.
|
|
3
|
+
* e.g. "1D" → "D", "60" → "60", "1W" → "W", "" → ""
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeTimeframe(tf: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Compute the opening timestamp of the higher-timeframe bar that contains the given timestamp.
|
|
8
|
+
*
|
|
9
|
+
* For intraday TFs (minutes): floor to the nearest multiple of the TF duration within the day.
|
|
10
|
+
* For daily: floor to UTC day start (00:00 UTC).
|
|
11
|
+
* For weekly: floor to Monday 00:00 UTC.
|
|
12
|
+
* For monthly: floor to 1st of month 00:00 UTC.
|
|
13
|
+
*/
|
|
14
|
+
export declare function alignToTimeframe(timestamp: number, tf: string): number;
|
|
1
15
|
interface DateParts {
|
|
2
16
|
year: number;
|
|
3
17
|
month: number;
|
|
@@ -28,7 +42,7 @@ export declare class TimeHelper {
|
|
|
28
42
|
constructor(context: any, dataField?: string);
|
|
29
43
|
get __value(): any;
|
|
30
44
|
param(source: any, index?: number): any;
|
|
31
|
-
any(...args: any[]):
|
|
45
|
+
any(...args: any[]): number;
|
|
32
46
|
/**
|
|
33
47
|
* Basic session check: parses "HHMM-HHMM" format and tests if
|
|
34
48
|
* the timestamp falls within the session window.
|
|
@@ -17,6 +17,14 @@ export declare class Timeframe {
|
|
|
17
17
|
get isseconds(): boolean;
|
|
18
18
|
get isminutes(): boolean;
|
|
19
19
|
get isintraday(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Detects changes in the specified timeframe.
|
|
22
|
+
* Returns true on the first bar of a new HTF period, false otherwise.
|
|
23
|
+
*
|
|
24
|
+
* Works by aligning current and previous bar timestamps to the target
|
|
25
|
+
* timeframe and comparing — if they differ, a new period has started.
|
|
26
|
+
*/
|
|
27
|
+
change(timeframe: any): boolean;
|
|
20
28
|
from_seconds(seconds: number): string | number;
|
|
21
29
|
in_seconds(timeframe?: string): number;
|
|
22
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinets",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"description": "Run Pine Script anywhere. PineTS is an open-source transpiler and runtime that brings Pine Script logic to Node.js and the browser with 1:1 syntax compatibility. Reliably write, port, and run indicators or strategies on your own infrastructure.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Pine Script",
|