pinets 0.3.0 → 0.5.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.
Files changed (67) hide show
  1. package/README.md +3 -0
  2. package/dist/pinets.dev.browser.js +3739 -1372
  3. package/dist/pinets.dev.cjs +3734 -1368
  4. package/dist/pinets.dev.cjs.map +1 -1
  5. package/dist/pinets.dev.es.js +3688 -1326
  6. package/dist/pinets.dev.es.js.map +1 -1
  7. package/dist/pinets.min.browser.js +15 -11
  8. package/dist/pinets.min.cjs +15 -11
  9. package/dist/pinets.min.es.js +5 -1
  10. package/dist/types/Context.class.d.ts +61 -15
  11. package/dist/types/PineTS.class.d.ts +11 -1
  12. package/dist/types/namespaces/Core.d.ts +1 -0
  13. package/dist/types/namespaces/array/methods/from.d.ts +1 -1
  14. package/dist/types/namespaces/request/methods/security.d.ts +1 -1
  15. package/dist/types/namespaces/request/types/barmerge.type.d.ts +7 -0
  16. package/dist/types/namespaces/request/utils/findLTFContextIdx.d.ts +1 -0
  17. package/dist/types/namespaces/ta/getters/obv.d.ts +12 -0
  18. package/dist/types/namespaces/ta/methods/accdist.d.ts +7 -0
  19. package/dist/types/namespaces/ta/methods/alma.d.ts +18 -0
  20. package/dist/types/namespaces/ta/methods/barssince.d.ts +6 -0
  21. package/dist/types/namespaces/ta/methods/bb.d.ts +17 -0
  22. package/dist/types/namespaces/ta/methods/bbw.d.ts +9 -0
  23. package/dist/types/namespaces/ta/methods/cci.d.ts +20 -0
  24. package/dist/types/namespaces/ta/methods/cmo.d.ts +17 -0
  25. package/dist/types/namespaces/ta/methods/cog.d.ts +18 -0
  26. package/dist/types/namespaces/ta/methods/correlation.d.ts +7 -0
  27. package/dist/types/namespaces/ta/methods/cross.d.ts +15 -0
  28. package/dist/types/namespaces/ta/methods/cum.d.ts +14 -0
  29. package/dist/types/namespaces/ta/methods/dmi.d.ts +24 -0
  30. package/dist/types/namespaces/ta/methods/falling.d.ts +15 -0
  31. package/dist/types/namespaces/ta/methods/highestbars.d.ts +7 -0
  32. package/dist/types/namespaces/ta/methods/iii.d.ts +7 -0
  33. package/dist/types/namespaces/ta/methods/kc.d.ts +12 -0
  34. package/dist/types/namespaces/ta/methods/kcw.d.ts +11 -0
  35. package/dist/types/namespaces/ta/methods/lowestbars.d.ts +7 -0
  36. package/dist/types/namespaces/ta/methods/macd.d.ts +18 -0
  37. package/dist/types/namespaces/ta/methods/mfi.d.ts +15 -0
  38. package/dist/types/namespaces/ta/methods/mode.d.ts +6 -0
  39. package/dist/types/namespaces/ta/methods/nvi.d.ts +10 -0
  40. package/dist/types/namespaces/ta/methods/obv.d.ts +12 -0
  41. package/dist/types/namespaces/ta/methods/percentile_linear_interpolation.d.ts +6 -0
  42. package/dist/types/namespaces/ta/methods/percentile_nearest_rank.d.ts +7 -0
  43. package/dist/types/namespaces/ta/methods/percentrank.d.ts +6 -0
  44. package/dist/types/namespaces/ta/methods/pvi.d.ts +10 -0
  45. package/dist/types/namespaces/ta/methods/pvt.d.ts +12 -0
  46. package/dist/types/namespaces/ta/methods/range.d.ts +7 -0
  47. package/dist/types/namespaces/ta/methods/rising.d.ts +15 -0
  48. package/dist/types/namespaces/ta/methods/sar.d.ts +12 -0
  49. package/dist/types/namespaces/ta/methods/stoch.d.ts +21 -0
  50. package/dist/types/namespaces/ta/methods/supertrend.d.ts +23 -0
  51. package/dist/types/namespaces/ta/methods/swma.d.ts +14 -0
  52. package/dist/types/namespaces/ta/methods/tr.d.ts +1 -0
  53. package/dist/types/namespaces/ta/methods/tsi.d.ts +17 -0
  54. package/dist/types/namespaces/ta/methods/valuewhen.d.ts +6 -0
  55. package/dist/types/namespaces/ta/methods/vwap.d.ts +14 -0
  56. package/dist/types/namespaces/ta/methods/wad.d.ts +11 -0
  57. package/dist/types/namespaces/ta/methods/wpr.d.ts +17 -0
  58. package/dist/types/namespaces/ta/methods/wvad.d.ts +7 -0
  59. package/dist/types/namespaces/ta/ta.index.d.ts +120 -5
  60. package/dist/types/transpiler/analysis/ScopeManager.d.ts +11 -0
  61. package/dist/types/transpiler/index.d.ts +4 -1
  62. package/dist/types/transpiler/transformers/InjectionTransformer.d.ts +6 -0
  63. package/dist/types/transpiler/transformers/MainTransformer.d.ts +4 -1
  64. package/dist/types/transpiler/transformers/NormalizationTransformer.d.ts +15 -0
  65. package/dist/types/transpiler/transformers/WrapperTransformer.d.ts +9 -0
  66. package/dist/types/transpiler/utils/ASTFactory.d.ts +2 -0
  67. package/package.json +1 -1
@@ -1,84 +1,199 @@
1
- import { tr } from './getters/tr';
1
+ import { accdist } from './methods/accdist';
2
+ import { alma } from './methods/alma';
2
3
  import { atr } from './methods/atr';
4
+ import { barssince } from './methods/barssince';
5
+ import { bb } from './methods/bb';
6
+ import { bbw } from './methods/bbw';
7
+ import { cci } from './methods/cci';
3
8
  import { change } from './methods/change';
9
+ import { cmo } from './methods/cmo';
10
+ import { cog } from './methods/cog';
11
+ import { correlation } from './methods/correlation';
12
+ import { cross } from './methods/cross';
4
13
  import { crossover } from './methods/crossover';
5
14
  import { crossunder } from './methods/crossunder';
15
+ import { cum } from './methods/cum';
6
16
  import { dev } from './methods/dev';
17
+ import { dmi } from './methods/dmi';
7
18
  import { ema } from './methods/ema';
19
+ import { falling } from './methods/falling';
8
20
  import { highest } from './methods/highest';
21
+ import { highestbars } from './methods/highestbars';
9
22
  import { hma } from './methods/hma';
23
+ import { iii } from './methods/iii';
24
+ import { kc } from './methods/kc';
25
+ import { kcw } from './methods/kcw';
10
26
  import { linreg } from './methods/linreg';
11
27
  import { lowest } from './methods/lowest';
28
+ import { lowestbars } from './methods/lowestbars';
29
+ import { macd } from './methods/macd';
12
30
  import { median } from './methods/median';
31
+ import { mfi } from './methods/mfi';
32
+ import { mode } from './methods/mode';
13
33
  import { mom } from './methods/mom';
34
+ import { nvi } from './methods/nvi';
35
+ import { obv } from './methods/obv';
14
36
  import { param } from './methods/param';
37
+ import { percentile_linear_interpolation } from './methods/percentile_linear_interpolation';
38
+ import { percentile_nearest_rank } from './methods/percentile_nearest_rank';
39
+ import { percentrank } from './methods/percentrank';
15
40
  import { pivothigh } from './methods/pivothigh';
16
41
  import { pivotlow } from './methods/pivotlow';
42
+ import { pvi } from './methods/pvi';
43
+ import { pvt } from './methods/pvt';
44
+ import { range } from './methods/range';
45
+ import { rising } from './methods/rising';
17
46
  import { rma } from './methods/rma';
18
47
  import { roc } from './methods/roc';
19
48
  import { rsi } from './methods/rsi';
49
+ import { sar } from './methods/sar';
20
50
  import { sma } from './methods/sma';
21
51
  import { stdev } from './methods/stdev';
52
+ import { stoch } from './methods/stoch';
22
53
  import { supertrend } from './methods/supertrend';
54
+ import { swma } from './methods/swma';
55
+ import { tr } from './methods/tr';
56
+ import { tsi } from './methods/tsi';
57
+ import { valuewhen } from './methods/valuewhen';
23
58
  import { variance } from './methods/variance';
59
+ import { vwap } from './methods/vwap';
24
60
  import { vwma } from './methods/vwma';
61
+ import { wad } from './methods/wad';
25
62
  import { wma } from './methods/wma';
26
- declare const getters: {
27
- tr: typeof tr;
28
- };
63
+ import { wpr } from './methods/wpr';
64
+ import { wvad } from './methods/wvad';
29
65
  declare const methods: {
66
+ accdist: typeof accdist;
67
+ alma: typeof alma;
30
68
  atr: typeof atr;
69
+ barssince: typeof barssince;
70
+ bb: typeof bb;
71
+ bbw: typeof bbw;
72
+ cci: typeof cci;
31
73
  change: typeof change;
74
+ cmo: typeof cmo;
75
+ cog: typeof cog;
76
+ correlation: typeof correlation;
77
+ cross: typeof cross;
32
78
  crossover: typeof crossover;
33
79
  crossunder: typeof crossunder;
80
+ cum: typeof cum;
34
81
  dev: typeof dev;
82
+ dmi: typeof dmi;
35
83
  ema: typeof ema;
84
+ falling: typeof falling;
36
85
  highest: typeof highest;
86
+ highestbars: typeof highestbars;
37
87
  hma: typeof hma;
88
+ iii: typeof iii;
89
+ kc: typeof kc;
90
+ kcw: typeof kcw;
38
91
  linreg: typeof linreg;
39
92
  lowest: typeof lowest;
93
+ lowestbars: typeof lowestbars;
94
+ macd: typeof macd;
40
95
  median: typeof median;
96
+ mfi: typeof mfi;
97
+ mode: typeof mode;
41
98
  mom: typeof mom;
99
+ nvi: typeof nvi;
100
+ obv: typeof obv;
42
101
  param: typeof param;
102
+ percentile_linear_interpolation: typeof percentile_linear_interpolation;
103
+ percentile_nearest_rank: typeof percentile_nearest_rank;
104
+ percentrank: typeof percentrank;
43
105
  pivothigh: typeof pivothigh;
44
106
  pivotlow: typeof pivotlow;
107
+ pvi: typeof pvi;
108
+ pvt: typeof pvt;
109
+ range: typeof range;
110
+ rising: typeof rising;
45
111
  rma: typeof rma;
46
112
  roc: typeof roc;
47
113
  rsi: typeof rsi;
114
+ sar: typeof sar;
48
115
  sma: typeof sma;
49
116
  stdev: typeof stdev;
117
+ stoch: typeof stoch;
50
118
  supertrend: typeof supertrend;
119
+ swma: typeof swma;
120
+ tr: typeof tr;
121
+ tsi: typeof tsi;
122
+ valuewhen: typeof valuewhen;
51
123
  variance: typeof variance;
124
+ vwap: typeof vwap;
52
125
  vwma: typeof vwma;
126
+ wad: typeof wad;
53
127
  wma: typeof wma;
128
+ wpr: typeof wpr;
129
+ wvad: typeof wvad;
54
130
  };
55
131
  export declare class TechnicalAnalysis {
56
132
  private context;
57
- readonly tr: ReturnType<ReturnType<typeof getters.tr>>;
133
+ accdist: ReturnType<typeof methods.accdist>;
134
+ alma: ReturnType<typeof methods.alma>;
58
135
  atr: ReturnType<typeof methods.atr>;
136
+ barssince: ReturnType<typeof methods.barssince>;
137
+ bb: ReturnType<typeof methods.bb>;
138
+ bbw: ReturnType<typeof methods.bbw>;
139
+ cci: ReturnType<typeof methods.cci>;
59
140
  change: ReturnType<typeof methods.change>;
141
+ cmo: ReturnType<typeof methods.cmo>;
142
+ cog: ReturnType<typeof methods.cog>;
143
+ correlation: ReturnType<typeof methods.correlation>;
144
+ cross: ReturnType<typeof methods.cross>;
60
145
  crossover: ReturnType<typeof methods.crossover>;
61
146
  crossunder: ReturnType<typeof methods.crossunder>;
147
+ cum: ReturnType<typeof methods.cum>;
62
148
  dev: ReturnType<typeof methods.dev>;
149
+ dmi: ReturnType<typeof methods.dmi>;
63
150
  ema: ReturnType<typeof methods.ema>;
151
+ falling: ReturnType<typeof methods.falling>;
64
152
  highest: ReturnType<typeof methods.highest>;
153
+ highestbars: ReturnType<typeof methods.highestbars>;
65
154
  hma: ReturnType<typeof methods.hma>;
155
+ iii: ReturnType<typeof methods.iii>;
156
+ kc: ReturnType<typeof methods.kc>;
157
+ kcw: ReturnType<typeof methods.kcw>;
66
158
  linreg: ReturnType<typeof methods.linreg>;
67
159
  lowest: ReturnType<typeof methods.lowest>;
160
+ lowestbars: ReturnType<typeof methods.lowestbars>;
161
+ macd: ReturnType<typeof methods.macd>;
68
162
  median: ReturnType<typeof methods.median>;
163
+ mfi: ReturnType<typeof methods.mfi>;
164
+ mode: ReturnType<typeof methods.mode>;
69
165
  mom: ReturnType<typeof methods.mom>;
166
+ nvi: ReturnType<typeof methods.nvi>;
167
+ obv: ReturnType<typeof methods.obv>;
70
168
  param: ReturnType<typeof methods.param>;
169
+ percentile_linear_interpolation: ReturnType<typeof methods.percentile_linear_interpolation>;
170
+ percentile_nearest_rank: ReturnType<typeof methods.percentile_nearest_rank>;
171
+ percentrank: ReturnType<typeof methods.percentrank>;
71
172
  pivothigh: ReturnType<typeof methods.pivothigh>;
72
173
  pivotlow: ReturnType<typeof methods.pivotlow>;
174
+ pvi: ReturnType<typeof methods.pvi>;
175
+ pvt: ReturnType<typeof methods.pvt>;
176
+ range: ReturnType<typeof methods.range>;
177
+ rising: ReturnType<typeof methods.rising>;
73
178
  rma: ReturnType<typeof methods.rma>;
74
179
  roc: ReturnType<typeof methods.roc>;
75
180
  rsi: ReturnType<typeof methods.rsi>;
181
+ sar: ReturnType<typeof methods.sar>;
76
182
  sma: ReturnType<typeof methods.sma>;
77
183
  stdev: ReturnType<typeof methods.stdev>;
184
+ stoch: ReturnType<typeof methods.stoch>;
78
185
  supertrend: ReturnType<typeof methods.supertrend>;
186
+ swma: ReturnType<typeof methods.swma>;
187
+ tr: ReturnType<typeof methods.tr>;
188
+ tsi: ReturnType<typeof methods.tsi>;
189
+ valuewhen: ReturnType<typeof methods.valuewhen>;
79
190
  variance: ReturnType<typeof methods.variance>;
191
+ vwap: ReturnType<typeof methods.vwap>;
80
192
  vwma: ReturnType<typeof methods.vwma>;
193
+ wad: ReturnType<typeof methods.wad>;
81
194
  wma: ReturnType<typeof methods.wma>;
195
+ wpr: ReturnType<typeof methods.wpr>;
196
+ wvad: ReturnType<typeof methods.wvad>;
82
197
  constructor(context: any);
83
198
  }
84
199
  export default TechnicalAnalysis;
@@ -5,6 +5,7 @@ export declare class ScopeManager {
5
5
  private contextBoundVars;
6
6
  private arrayPatternElements;
7
7
  private rootParams;
8
+ private localSeriesVars;
8
9
  private varKinds;
9
10
  private loopVars;
10
11
  private loopVarNames;
@@ -12,6 +13,8 @@ export declare class ScopeManager {
12
13
  private cacheIdCounter;
13
14
  private tempVarCounter;
14
15
  private taCallIdCounter;
16
+ private hoistingStack;
17
+ private suppressHoisting;
15
18
  get nextParamIdArg(): any;
16
19
  get nextCacheIdArg(): any;
17
20
  getNextTACallId(): any;
@@ -20,6 +23,8 @@ export declare class ScopeManager {
20
23
  popScope(): void;
21
24
  getCurrentScopeType(): string;
22
25
  getCurrentScopeCount(): number;
26
+ addLocalSeriesVar(name: string): void;
27
+ isLocalSeriesVar(name: string): boolean;
23
28
  addContextBoundVar(name: string, isRootParam?: boolean): void;
24
29
  removeContextBoundVar(name: any): void;
25
30
  addArrayPatternElement(name: string): void;
@@ -32,5 +37,11 @@ export declare class ScopeManager {
32
37
  addVariable(name: string, kind: string): string;
33
38
  getVariable(name: string): [string, string];
34
39
  generateTempVar(): string;
40
+ enterHoistingScope(): void;
41
+ exitHoistingScope(): any[];
42
+ addHoistedStatement(stmt: any): void;
43
+ setSuppressHoisting(suppress: boolean): void;
44
+ shouldSuppressHoisting(): boolean;
45
+ generateParamId(): string;
35
46
  }
36
47
  export default ScopeManager;
@@ -1 +1,4 @@
1
- export declare function transpile(fn: string | Function): Function;
1
+ export declare function transpile(fn: string | Function, options?: {
2
+ debug: boolean;
3
+ ln?: boolean;
4
+ }): Function;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Injects implicit imports for missing context variables (data and pine namespaces)
3
+ * This ensures that users don't have to manually destructure context.data or context.pine
4
+ * @param ast The AST to transform
5
+ */
6
+ export declare function injectImplicitImports(ast: any): void;
@@ -1,3 +1,6 @@
1
1
  import ScopeManager from '../analysis/ScopeManager';
2
2
  export declare function transformEqualityChecks(ast: any): void;
3
- export declare function runTransformationPass(ast: any, scopeManager: ScopeManager, originalParamName: string): void;
3
+ export declare function runTransformationPass(ast: any, scopeManager: ScopeManager, originalParamName: string, options?: {
4
+ debug: boolean;
5
+ ln?: boolean;
6
+ }, sourceLines?: string[]): void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Normalizes imports from context.data and context.pine to prevent renaming of native symbols.
3
+ * This ensures that symbols like 'close' or 'na' are always named 'close' and 'na' in the local scope,
4
+ * satisfying the transpiler's expectation for exact naming of context-bound variables.
5
+ *
6
+ * Transforms:
7
+ * const { close: close2 } = context.data;
8
+ * to
9
+ * const { close } = context.data;
10
+ *
11
+ * And renames all usages of 'close2' to 'close' within the scope.
12
+ *
13
+ * @param ast The AST to transform
14
+ */
15
+ export declare function normalizeNativeImports(ast: any): void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Wraps unwrapped code in a context arrow function.
3
+ * If the code is already wrapped in a function, returns it as-is.
4
+ * Otherwise, wraps it in: (context) => { ... }
5
+ *
6
+ * @param code The input code string
7
+ * @returns The wrapped code string
8
+ */
9
+ export declare function wrapInContextFunction(code: string): string;
@@ -11,8 +11,10 @@ export declare const ASTFactory: {
11
11
  createAssignmentExpression(left: any, right: any, operator?: string): any;
12
12
  createExpressionStatement(expression: any): any;
13
13
  createInitCall(targetVarRef: any, value: any, lookbehind?: any): any;
14
+ createInitVarCall(targetVarRef: any, value: any): any;
14
15
  createGetCall(source: any, index: any): any;
15
16
  createSetCall(target: any, value: any): any;
16
17
  createMathEqCall(left: any, right: any): any;
17
18
  createWrapperFunction(body: any): any;
19
+ createVariableDeclaration(name: string, init: any): any;
18
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinets",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "main": "dist/pinets.dev.es.js",
6
6
  "types": "dist/types/index.d.ts",