pinets 0.2.1 → 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 (189) hide show
  1. package/README.md +38 -18
  2. package/dist/pinets.dev.browser.js +6029 -2997
  3. package/dist/pinets.dev.cjs +5982 -2783
  4. package/dist/pinets.dev.cjs.map +1 -1
  5. package/dist/pinets.dev.es.js +5368 -2186
  6. package/dist/pinets.dev.es.js.map +1 -1
  7. package/dist/pinets.min.browser.js +15 -12
  8. package/dist/pinets.min.cjs +15 -12
  9. package/dist/pinets.min.es.js +5 -2
  10. package/dist/types/Context.class.d.ts +73 -16
  11. package/dist/types/PineTS.class.d.ts +89 -5
  12. package/dist/types/Series.d.ts +10 -0
  13. package/dist/types/TimeSeries.class.d.ts +49 -0
  14. package/dist/types/TimeSeries.d.ts +15 -0
  15. package/dist/types/marketData/Mock/MockProvider.class.d.ts +77 -0
  16. package/dist/types/marketData/Provider.class.d.ts +6 -3
  17. package/dist/types/namespaces/Core.d.ts +1 -0
  18. package/dist/types/namespaces/array/PineArrayObject.d.ts +5 -0
  19. package/dist/types/namespaces/array/array.index.d.ts +135 -0
  20. package/dist/types/namespaces/array/methods/abs.d.ts +2 -0
  21. package/dist/types/namespaces/array/methods/avg.d.ts +2 -0
  22. package/dist/types/namespaces/array/methods/clear.d.ts +2 -0
  23. package/dist/types/namespaces/array/methods/concat.d.ts +2 -0
  24. package/dist/types/namespaces/array/methods/copy.d.ts +2 -0
  25. package/dist/types/namespaces/array/methods/covariance.d.ts +2 -0
  26. package/dist/types/namespaces/array/methods/every.d.ts +2 -0
  27. package/dist/types/namespaces/array/methods/fill.d.ts +2 -0
  28. package/dist/types/namespaces/array/methods/first.d.ts +2 -0
  29. package/dist/types/namespaces/array/methods/from.d.ts +2 -0
  30. package/dist/types/namespaces/array/methods/get.d.ts +2 -0
  31. package/dist/types/namespaces/array/methods/includes.d.ts +2 -0
  32. package/dist/types/namespaces/array/methods/indexof.d.ts +2 -0
  33. package/dist/types/namespaces/array/methods/insert.d.ts +2 -0
  34. package/dist/types/namespaces/array/methods/join.d.ts +2 -0
  35. package/dist/types/namespaces/array/methods/last.d.ts +2 -0
  36. package/dist/types/namespaces/array/methods/lastindexof.d.ts +2 -0
  37. package/dist/types/namespaces/array/methods/max.d.ts +2 -0
  38. package/dist/types/namespaces/array/methods/min.d.ts +2 -0
  39. package/dist/types/namespaces/array/methods/new.d.ts +2 -0
  40. package/dist/types/namespaces/array/methods/new_bool.d.ts +2 -0
  41. package/dist/types/namespaces/array/methods/new_float.d.ts +2 -0
  42. package/dist/types/namespaces/array/methods/new_int.d.ts +2 -0
  43. package/dist/types/namespaces/array/methods/new_string.d.ts +2 -0
  44. package/dist/types/namespaces/array/methods/param.d.ts +1 -0
  45. package/dist/types/namespaces/array/methods/pop.d.ts +2 -0
  46. package/dist/types/namespaces/array/methods/push.d.ts +2 -0
  47. package/dist/types/namespaces/array/methods/range.d.ts +2 -0
  48. package/dist/types/namespaces/array/methods/remove.d.ts +2 -0
  49. package/dist/types/namespaces/array/methods/reverse.d.ts +2 -0
  50. package/dist/types/namespaces/array/methods/set.d.ts +2 -0
  51. package/dist/types/namespaces/array/methods/shift.d.ts +2 -0
  52. package/dist/types/namespaces/array/methods/size.d.ts +2 -0
  53. package/dist/types/namespaces/array/methods/slice.d.ts +2 -0
  54. package/dist/types/namespaces/array/methods/some.d.ts +2 -0
  55. package/dist/types/namespaces/array/methods/sort.d.ts +2 -0
  56. package/dist/types/namespaces/array/methods/sort_indices.d.ts +2 -0
  57. package/dist/types/namespaces/array/methods/standardize.d.ts +2 -0
  58. package/dist/types/namespaces/array/methods/stdev.d.ts +2 -0
  59. package/dist/types/namespaces/array/methods/sum.d.ts +2 -0
  60. package/dist/types/namespaces/array/methods/unshift.d.ts +2 -0
  61. package/dist/types/namespaces/array/methods/variance.d.ts +2 -0
  62. package/dist/types/namespaces/input/input.index.d.ts +53 -0
  63. package/dist/types/namespaces/input/methods/any.d.ts +2 -0
  64. package/dist/types/namespaces/input/methods/bool.d.ts +2 -0
  65. package/dist/types/namespaces/input/methods/color.d.ts +2 -0
  66. package/dist/types/namespaces/input/methods/enum.d.ts +2 -0
  67. package/dist/types/namespaces/input/methods/float.d.ts +2 -0
  68. package/dist/types/namespaces/input/methods/int.d.ts +2 -0
  69. package/dist/types/namespaces/input/methods/param.d.ts +1 -0
  70. package/dist/types/namespaces/input/methods/price.d.ts +2 -0
  71. package/dist/types/namespaces/input/methods/session.d.ts +2 -0
  72. package/dist/types/namespaces/input/methods/source.d.ts +2 -0
  73. package/dist/types/namespaces/input/methods/string.d.ts +2 -0
  74. package/dist/types/namespaces/input/methods/symbol.d.ts +2 -0
  75. package/dist/types/namespaces/input/methods/text_area.d.ts +2 -0
  76. package/dist/types/namespaces/input/methods/time.d.ts +2 -0
  77. package/dist/types/namespaces/input/methods/timeframe.d.ts +2 -0
  78. package/dist/types/namespaces/input/types.d.ts +4 -0
  79. package/dist/types/namespaces/math/math.index.d.ts +77 -0
  80. package/dist/types/namespaces/math/methods/__eq.d.ts +1 -0
  81. package/dist/types/namespaces/math/methods/abs.d.ts +1 -0
  82. package/dist/types/namespaces/math/methods/acos.d.ts +1 -0
  83. package/dist/types/namespaces/math/methods/asin.d.ts +1 -0
  84. package/dist/types/namespaces/math/methods/atan.d.ts +1 -0
  85. package/dist/types/namespaces/math/methods/avg.d.ts +1 -0
  86. package/dist/types/namespaces/math/methods/ceil.d.ts +1 -0
  87. package/dist/types/namespaces/math/methods/cos.d.ts +1 -0
  88. package/dist/types/namespaces/math/methods/exp.d.ts +1 -0
  89. package/dist/types/namespaces/math/methods/floor.d.ts +1 -0
  90. package/dist/types/namespaces/math/methods/ln.d.ts +1 -0
  91. package/dist/types/namespaces/math/methods/log.d.ts +1 -0
  92. package/dist/types/namespaces/math/methods/log10.d.ts +1 -0
  93. package/dist/types/namespaces/math/methods/max.d.ts +1 -0
  94. package/dist/types/namespaces/math/methods/min.d.ts +1 -0
  95. package/dist/types/namespaces/math/methods/param.d.ts +1 -0
  96. package/dist/types/namespaces/math/methods/pow.d.ts +1 -0
  97. package/dist/types/namespaces/math/methods/random.d.ts +1 -0
  98. package/dist/types/namespaces/math/methods/round.d.ts +1 -0
  99. package/dist/types/namespaces/math/methods/sin.d.ts +1 -0
  100. package/dist/types/namespaces/math/methods/sqrt.d.ts +1 -0
  101. package/dist/types/namespaces/math/methods/sum.d.ts +1 -0
  102. package/dist/types/namespaces/math/methods/tan.d.ts +1 -0
  103. package/dist/types/namespaces/request/methods/param.d.ts +1 -0
  104. package/dist/types/namespaces/request/methods/security.d.ts +1 -0
  105. package/dist/types/namespaces/request/request.index.d.ts +14 -0
  106. package/dist/types/namespaces/request/types/barmerge.type.d.ts +7 -0
  107. package/dist/types/namespaces/request/utils/TIMEFRAMES.d.ts +1 -0
  108. package/dist/types/namespaces/request/utils/findLTFContextIdx.d.ts +1 -0
  109. package/dist/types/namespaces/request/utils/findSecContextIdx.d.ts +1 -0
  110. package/dist/types/namespaces/ta/getters/obv.d.ts +12 -0
  111. package/dist/types/namespaces/ta/getters/tr.d.ts +1 -0
  112. package/dist/types/namespaces/ta/methods/accdist.d.ts +7 -0
  113. package/dist/types/namespaces/ta/methods/alma.d.ts +18 -0
  114. package/dist/types/namespaces/ta/methods/atr.d.ts +1 -0
  115. package/dist/types/namespaces/ta/methods/barssince.d.ts +6 -0
  116. package/dist/types/namespaces/ta/methods/bb.d.ts +17 -0
  117. package/dist/types/namespaces/ta/methods/bbw.d.ts +9 -0
  118. package/dist/types/namespaces/ta/methods/cci.d.ts +20 -0
  119. package/dist/types/namespaces/ta/methods/change.d.ts +1 -0
  120. package/dist/types/namespaces/ta/methods/cmo.d.ts +17 -0
  121. package/dist/types/namespaces/ta/methods/cog.d.ts +18 -0
  122. package/dist/types/namespaces/ta/methods/correlation.d.ts +7 -0
  123. package/dist/types/namespaces/ta/methods/cross.d.ts +15 -0
  124. package/dist/types/namespaces/ta/methods/crossover.d.ts +1 -0
  125. package/dist/types/namespaces/ta/methods/crossunder.d.ts +1 -0
  126. package/dist/types/namespaces/ta/methods/cum.d.ts +14 -0
  127. package/dist/types/namespaces/ta/methods/dev.d.ts +1 -0
  128. package/dist/types/namespaces/ta/methods/dmi.d.ts +24 -0
  129. package/dist/types/namespaces/ta/methods/ema.d.ts +1 -0
  130. package/dist/types/namespaces/ta/methods/falling.d.ts +15 -0
  131. package/dist/types/namespaces/ta/methods/highest.d.ts +1 -0
  132. package/dist/types/namespaces/ta/methods/highestbars.d.ts +7 -0
  133. package/dist/types/namespaces/ta/methods/hma.d.ts +1 -0
  134. package/dist/types/namespaces/ta/methods/iii.d.ts +7 -0
  135. package/dist/types/namespaces/ta/methods/kc.d.ts +12 -0
  136. package/dist/types/namespaces/ta/methods/kcw.d.ts +11 -0
  137. package/dist/types/namespaces/ta/methods/linreg.d.ts +1 -0
  138. package/dist/types/namespaces/ta/methods/lowest.d.ts +1 -0
  139. package/dist/types/namespaces/ta/methods/lowestbars.d.ts +7 -0
  140. package/dist/types/namespaces/ta/methods/macd.d.ts +18 -0
  141. package/dist/types/namespaces/ta/methods/median.d.ts +1 -0
  142. package/dist/types/namespaces/ta/methods/mfi.d.ts +15 -0
  143. package/dist/types/namespaces/ta/methods/mode.d.ts +6 -0
  144. package/dist/types/namespaces/ta/methods/mom.d.ts +1 -0
  145. package/dist/types/namespaces/ta/methods/nvi.d.ts +10 -0
  146. package/dist/types/namespaces/ta/methods/obv.d.ts +12 -0
  147. package/dist/types/namespaces/ta/methods/param.d.ts +2 -0
  148. package/dist/types/namespaces/ta/methods/percentile_linear_interpolation.d.ts +6 -0
  149. package/dist/types/namespaces/ta/methods/percentile_nearest_rank.d.ts +7 -0
  150. package/dist/types/namespaces/ta/methods/percentrank.d.ts +6 -0
  151. package/dist/types/namespaces/ta/methods/pivothigh.d.ts +1 -0
  152. package/dist/types/namespaces/ta/methods/pivotlow.d.ts +1 -0
  153. package/dist/types/namespaces/ta/methods/pvi.d.ts +10 -0
  154. package/dist/types/namespaces/ta/methods/pvt.d.ts +12 -0
  155. package/dist/types/namespaces/ta/methods/range.d.ts +7 -0
  156. package/dist/types/namespaces/ta/methods/rising.d.ts +15 -0
  157. package/dist/types/namespaces/ta/methods/rma.d.ts +1 -0
  158. package/dist/types/namespaces/ta/methods/roc.d.ts +1 -0
  159. package/dist/types/namespaces/ta/methods/rsi.d.ts +1 -0
  160. package/dist/types/namespaces/ta/methods/sar.d.ts +12 -0
  161. package/dist/types/namespaces/ta/methods/sma.d.ts +1 -0
  162. package/dist/types/namespaces/ta/methods/stdev.d.ts +1 -0
  163. package/dist/types/namespaces/ta/methods/stoch.d.ts +21 -0
  164. package/dist/types/namespaces/ta/methods/supertrend.d.ts +24 -0
  165. package/dist/types/namespaces/ta/methods/swma.d.ts +14 -0
  166. package/dist/types/namespaces/ta/methods/tr.d.ts +1 -0
  167. package/dist/types/namespaces/ta/methods/tsi.d.ts +17 -0
  168. package/dist/types/namespaces/ta/methods/valuewhen.d.ts +6 -0
  169. package/dist/types/namespaces/ta/methods/variance.d.ts +1 -0
  170. package/dist/types/namespaces/ta/methods/vwap.d.ts +14 -0
  171. package/dist/types/namespaces/ta/methods/vwma.d.ts +1 -0
  172. package/dist/types/namespaces/ta/methods/wad.d.ts +11 -0
  173. package/dist/types/namespaces/ta/methods/wma.d.ts +1 -0
  174. package/dist/types/namespaces/ta/methods/wpr.d.ts +17 -0
  175. package/dist/types/namespaces/ta/methods/wvad.d.ts +7 -0
  176. package/dist/types/namespaces/ta/ta.index.d.ts +199 -0
  177. package/dist/types/namespaces/ta/utils/pivothigh.d.ts +1 -0
  178. package/dist/types/namespaces/ta/utils/pivotlow.d.ts +1 -0
  179. package/dist/types/transpiler/analysis/AnalysisPass.d.ts +5 -0
  180. package/dist/types/transpiler/analysis/ScopeManager.d.ts +47 -0
  181. package/dist/types/transpiler/index.d.ts +4 -1
  182. package/dist/types/transpiler/transformers/ExpressionTransformer.d.ts +7 -0
  183. package/dist/types/transpiler/transformers/InjectionTransformer.d.ts +6 -0
  184. package/dist/types/transpiler/transformers/MainTransformer.d.ts +6 -0
  185. package/dist/types/transpiler/transformers/NormalizationTransformer.d.ts +15 -0
  186. package/dist/types/transpiler/transformers/StatementTransformer.d.ts +9 -0
  187. package/dist/types/transpiler/transformers/WrapperTransformer.d.ts +9 -0
  188. package/dist/types/transpiler/utils/ASTFactory.d.ts +20 -0
  189. package/package.json +12 -3
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Positive Volume Index (PVI)
3
+ *
4
+ * Formula:
5
+ * If close or close[1] is 0, pvi = pvi[1]
6
+ * Else if volume > volume[1], pvi = pvi[1] + ((close - close[1]) / close[1]) * pvi[1]
7
+ * Else pvi = pvi[1]
8
+ * Initial value is 1.0
9
+ */
10
+ export declare function pvi(context: any): (_callId?: string) => any;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Price-Volume Trend (PVT)
3
+ *
4
+ * The PVT function calculates the Price-Volume Trend, which is a cumulative
5
+ * total of volume adjusted by the percentage change in price.
6
+ *
7
+ * Formula:
8
+ * PVT = Previous PVT + ((Current Close - Previous Close) / Previous Close) * Volume
9
+ *
10
+ * @returns The PVT series
11
+ */
12
+ export declare function pvt(context: any): (_callId?: string) => any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Range
3
+ *
4
+ * Returns the difference between the highest and lowest values of a series over a given length.
5
+ * Formula: ta.highest(source, length) - ta.lowest(source, length)
6
+ */
7
+ export declare function range(context: any): (source: any, _length: any, _callId?: string) => any;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Rising Detection
3
+ *
4
+ * Tests if the source series is now rising for length bars long.
5
+ * Returns true if the series has been consecutively rising for length bars.
6
+ *
7
+ * Formula:
8
+ * For length=2: source[0] > source[1] AND source[1] > source[2]
9
+ * For length=n: source[i] > source[i+1] for all i from 0 to n-1
10
+ *
11
+ * @param source - Series of values to process
12
+ * @param length - Number of bars to check (lookback period)
13
+ * @returns true if consecutively rising for length bars, false otherwise
14
+ */
15
+ export declare function rising(context: any): (source: any, _length: any, _callId?: string) => boolean;
@@ -0,0 +1 @@
1
+ export declare function rma(context: any): (source: any, _period: any, _callId?: string) => any;
@@ -0,0 +1 @@
1
+ export declare function roc(context: any): (source: any, _length: any, _callId?: string) => any;
@@ -0,0 +1 @@
1
+ export declare function rsi(context: any): (source: any, _period: any, _callId?: string) => any;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Parabolic SAR (Stop and Reverse)
3
+ *
4
+ * Parabolic SAR is a method devised by J. Welles Wilder, Jr., to find potential reversals
5
+ * in the market price direction.
6
+ *
7
+ * @param start - Start acceleration factor
8
+ * @param inc - Increment acceleration factor
9
+ * @param max - Maximum acceleration factor
10
+ * @returns Parabolic SAR value
11
+ */
12
+ export declare function sar(context: any): (_start: any, _inc: any, _max: any, _callId?: string) => any;
@@ -0,0 +1 @@
1
+ export declare function sma(context: any): (source: any, _period: any, _callId?: string) => any;
@@ -0,0 +1 @@
1
+ export declare function stdev(context: any): (source: any, _length: any, _bias?: any, _callId?: string) => any;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Stochastic Oscillator (STOCH)
3
+ *
4
+ * The Stochastic Oscillator is a momentum indicator that shows the location of the close
5
+ * relative to the high-low range over a set number of periods.
6
+ *
7
+ * Formula:
8
+ * STOCH = 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length))
9
+ *
10
+ * @param source - Source series (typically close price)
11
+ * @param high - Series of high prices
12
+ * @param low - Series of low prices
13
+ * @param length - Number of bars back (lookback period)
14
+ * @returns Stochastic value (0-100)
15
+ *
16
+ * @remarks
17
+ * - NaN values in the source series are ignored
18
+ * - Returns NaN during initialization period (when not enough data)
19
+ * - Returns NaN if highest equals lowest (to avoid division by zero)
20
+ */
21
+ export declare function stoch(context: any): (source: any, high: any, low: any, _length: any, _callId?: string) => any;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * SuperTrend Indicator
3
+ *
4
+ * The Supertrend is a trend following indicator based on ATR.
5
+ *
6
+ * Pine Script Formula:
7
+ * src = hl2
8
+ * atr = ta.atr(atrPeriod)
9
+ * upperBand = src + factor * atr
10
+ * lowerBand = src - factor * atr
11
+ * prevLowerBand = nz(lowerBand[1])
12
+ * prevUpperBand = nz(upperBand[1])
13
+ *
14
+ * lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
15
+ * upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
16
+ *
17
+ * direction: 1 (down/bearish), -1 (up/bullish)
18
+ * superTrend := direction == -1 ? lowerBand : upperBand
19
+ *
20
+ * @param factor - The multiplier by which the ATR will get multiplied
21
+ * @param atrPeriod - Length of ATR
22
+ * @returns Tuple [supertrend, direction] where direction is 1 (down) or -1 (up)
23
+ */
24
+ export declare function supertrend(context: any): (_factor: any, _atrPeriod: any, _callId?: string) => any[][];
@@ -0,0 +1,14 @@
1
+ /**
2
+ * SWMA - Symmetrically Weighted Moving Average
3
+ *
4
+ * Pine Script's ta.swma() uses a fixed period of 4 bars with symmetric weights.
5
+ * The weights are applied symmetrically: the current and 3 previous bars.
6
+ *
7
+ * Weights for 4-bar period: [1, 2, 2, 1]
8
+ * Formula: SWMA = (price[3]*1 + price[2]*2 + price[1]*2 + price[0]*1) / 6
9
+ *
10
+ * @param source - The data source (typically close price)
11
+ *
12
+ * Note: Unlike other moving averages, SWMA has a fixed period of 4 in Pine Script
13
+ */
14
+ export declare function swma(context: any): (source: any, _callId?: string) => any;
@@ -0,0 +1 @@
1
+ export declare function tr(context: any): (handle_na?: boolean, _callId?: string) => number;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * True Strength Index (TSI)
3
+ *
4
+ * True strength index uses moving averages of the underlying momentum of a financial instrument.
5
+ *
6
+ * Formula:
7
+ * pc = change(source) // Price change
8
+ * double_smoothed_pc = ema(ema(pc, long_length), short_length)
9
+ * double_smoothed_abs_pc = ema(ema(abs(pc), long_length), short_length)
10
+ * tsi = double_smoothed_pc / double_smoothed_abs_pc
11
+ *
12
+ * @param source - Source series (typically close)
13
+ * @param shortLength - Short EMA length
14
+ * @param longLength - Long EMA length
15
+ * @returns TSI value in range [-1, 1]
16
+ */
17
+ export declare function tsi(context: any): (source: any, _shortLength: any, _longLength: any, _callId?: string) => any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Value When
3
+ *
4
+ * Returns the value of the source series on the bar where the condition was true on the nth most recent occurrence.
5
+ */
6
+ export declare function valuewhen(context: any): (condition: any, source: any, _occurrence: any, _callId?: string) => any;
@@ -0,0 +1 @@
1
+ export declare function variance(context: any): (source: any, _length: any, _callId?: string) => any;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * VWAP - Volume Weighted Average Price
3
+ *
4
+ * VWAP calculates the average price weighted by volume for a trading session.
5
+ * It resets at the start of each new session (typically daily).
6
+ *
7
+ * Formula: VWAP = Σ(Price × Volume) / Σ(Volume)
8
+ *
9
+ * @param source - The price source (typically close, hlc3, or ohlc4)
10
+ *
11
+ * Note: This implementation resets VWAP at the start of each trading session
12
+ * based on detecting new trading days (when openTime changes to a new day).
13
+ */
14
+ export declare function vwap(context: any): (source: any, _callId?: string) => any;
@@ -0,0 +1 @@
1
+ export declare function vwma(context: any): (source: any, _period: any, _callId?: string) => any;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Williams Accumulation/Distribution (WAD)
3
+ *
4
+ * Formula:
5
+ * trueHigh = math.max(high, close[1])
6
+ * trueLow = math.min(low, close[1])
7
+ * mom = ta.change(close)
8
+ * gain = (mom > 0) ? close - trueLow : (mom < 0) ? close - trueHigh : 0
9
+ * ta.cum(gain)
10
+ */
11
+ export declare function wad(context: any): (_callId?: string) => any;
@@ -0,0 +1 @@
1
+ export declare function wma(context: any): (source: any, _period: any, _callId?: string) => any;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Williams %R (WPR)
3
+ *
4
+ * The oscillator shows the current closing price in relation to the high and low
5
+ * of the past 'length' bars.
6
+ *
7
+ * Formula:
8
+ * %R = (Highest High - Close) / (Highest High - Lowest Low) * -100
9
+ *
10
+ * Note: Williams %R produces values between -100 and 0
11
+ * - Values near -100 indicate oversold conditions
12
+ * - Values near 0 indicate overbought conditions
13
+ *
14
+ * @param length - Number of bars (lookback period)
15
+ * @returns Williams %R value (-100 to 0)
16
+ */
17
+ export declare function wpr(context: any): (_length: any, _callId?: string) => any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Williams Variable Accumulation/Distribution (WVAD)
3
+ *
4
+ * Formula:
5
+ * (close - open) / (high - low) * volume
6
+ */
7
+ export declare function wvad(context: any): (_callId?: string) => any;
@@ -0,0 +1,199 @@
1
+ import { accdist } from './methods/accdist';
2
+ import { alma } from './methods/alma';
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';
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';
13
+ import { crossover } from './methods/crossover';
14
+ import { crossunder } from './methods/crossunder';
15
+ import { cum } from './methods/cum';
16
+ import { dev } from './methods/dev';
17
+ import { dmi } from './methods/dmi';
18
+ import { ema } from './methods/ema';
19
+ import { falling } from './methods/falling';
20
+ import { highest } from './methods/highest';
21
+ import { highestbars } from './methods/highestbars';
22
+ import { hma } from './methods/hma';
23
+ import { iii } from './methods/iii';
24
+ import { kc } from './methods/kc';
25
+ import { kcw } from './methods/kcw';
26
+ import { linreg } from './methods/linreg';
27
+ import { lowest } from './methods/lowest';
28
+ import { lowestbars } from './methods/lowestbars';
29
+ import { macd } from './methods/macd';
30
+ import { median } from './methods/median';
31
+ import { mfi } from './methods/mfi';
32
+ import { mode } from './methods/mode';
33
+ import { mom } from './methods/mom';
34
+ import { nvi } from './methods/nvi';
35
+ import { obv } from './methods/obv';
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';
40
+ import { pivothigh } from './methods/pivothigh';
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';
46
+ import { rma } from './methods/rma';
47
+ import { roc } from './methods/roc';
48
+ import { rsi } from './methods/rsi';
49
+ import { sar } from './methods/sar';
50
+ import { sma } from './methods/sma';
51
+ import { stdev } from './methods/stdev';
52
+ import { stoch } from './methods/stoch';
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';
58
+ import { variance } from './methods/variance';
59
+ import { vwap } from './methods/vwap';
60
+ import { vwma } from './methods/vwma';
61
+ import { wad } from './methods/wad';
62
+ import { wma } from './methods/wma';
63
+ import { wpr } from './methods/wpr';
64
+ import { wvad } from './methods/wvad';
65
+ declare const methods: {
66
+ accdist: typeof accdist;
67
+ alma: typeof alma;
68
+ atr: typeof atr;
69
+ barssince: typeof barssince;
70
+ bb: typeof bb;
71
+ bbw: typeof bbw;
72
+ cci: typeof cci;
73
+ change: typeof change;
74
+ cmo: typeof cmo;
75
+ cog: typeof cog;
76
+ correlation: typeof correlation;
77
+ cross: typeof cross;
78
+ crossover: typeof crossover;
79
+ crossunder: typeof crossunder;
80
+ cum: typeof cum;
81
+ dev: typeof dev;
82
+ dmi: typeof dmi;
83
+ ema: typeof ema;
84
+ falling: typeof falling;
85
+ highest: typeof highest;
86
+ highestbars: typeof highestbars;
87
+ hma: typeof hma;
88
+ iii: typeof iii;
89
+ kc: typeof kc;
90
+ kcw: typeof kcw;
91
+ linreg: typeof linreg;
92
+ lowest: typeof lowest;
93
+ lowestbars: typeof lowestbars;
94
+ macd: typeof macd;
95
+ median: typeof median;
96
+ mfi: typeof mfi;
97
+ mode: typeof mode;
98
+ mom: typeof mom;
99
+ nvi: typeof nvi;
100
+ obv: typeof obv;
101
+ param: typeof param;
102
+ percentile_linear_interpolation: typeof percentile_linear_interpolation;
103
+ percentile_nearest_rank: typeof percentile_nearest_rank;
104
+ percentrank: typeof percentrank;
105
+ pivothigh: typeof pivothigh;
106
+ pivotlow: typeof pivotlow;
107
+ pvi: typeof pvi;
108
+ pvt: typeof pvt;
109
+ range: typeof range;
110
+ rising: typeof rising;
111
+ rma: typeof rma;
112
+ roc: typeof roc;
113
+ rsi: typeof rsi;
114
+ sar: typeof sar;
115
+ sma: typeof sma;
116
+ stdev: typeof stdev;
117
+ stoch: typeof stoch;
118
+ supertrend: typeof supertrend;
119
+ swma: typeof swma;
120
+ tr: typeof tr;
121
+ tsi: typeof tsi;
122
+ valuewhen: typeof valuewhen;
123
+ variance: typeof variance;
124
+ vwap: typeof vwap;
125
+ vwma: typeof vwma;
126
+ wad: typeof wad;
127
+ wma: typeof wma;
128
+ wpr: typeof wpr;
129
+ wvad: typeof wvad;
130
+ };
131
+ export declare class TechnicalAnalysis {
132
+ private context;
133
+ accdist: ReturnType<typeof methods.accdist>;
134
+ alma: ReturnType<typeof methods.alma>;
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>;
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>;
145
+ crossover: ReturnType<typeof methods.crossover>;
146
+ crossunder: ReturnType<typeof methods.crossunder>;
147
+ cum: ReturnType<typeof methods.cum>;
148
+ dev: ReturnType<typeof methods.dev>;
149
+ dmi: ReturnType<typeof methods.dmi>;
150
+ ema: ReturnType<typeof methods.ema>;
151
+ falling: ReturnType<typeof methods.falling>;
152
+ highest: ReturnType<typeof methods.highest>;
153
+ highestbars: ReturnType<typeof methods.highestbars>;
154
+ hma: ReturnType<typeof methods.hma>;
155
+ iii: ReturnType<typeof methods.iii>;
156
+ kc: ReturnType<typeof methods.kc>;
157
+ kcw: ReturnType<typeof methods.kcw>;
158
+ linreg: ReturnType<typeof methods.linreg>;
159
+ lowest: ReturnType<typeof methods.lowest>;
160
+ lowestbars: ReturnType<typeof methods.lowestbars>;
161
+ macd: ReturnType<typeof methods.macd>;
162
+ median: ReturnType<typeof methods.median>;
163
+ mfi: ReturnType<typeof methods.mfi>;
164
+ mode: ReturnType<typeof methods.mode>;
165
+ mom: ReturnType<typeof methods.mom>;
166
+ nvi: ReturnType<typeof methods.nvi>;
167
+ obv: ReturnType<typeof methods.obv>;
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>;
172
+ pivothigh: ReturnType<typeof methods.pivothigh>;
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>;
178
+ rma: ReturnType<typeof methods.rma>;
179
+ roc: ReturnType<typeof methods.roc>;
180
+ rsi: ReturnType<typeof methods.rsi>;
181
+ sar: ReturnType<typeof methods.sar>;
182
+ sma: ReturnType<typeof methods.sma>;
183
+ stdev: ReturnType<typeof methods.stdev>;
184
+ stoch: ReturnType<typeof methods.stoch>;
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>;
190
+ variance: ReturnType<typeof methods.variance>;
191
+ vwap: ReturnType<typeof methods.vwap>;
192
+ vwma: ReturnType<typeof methods.vwma>;
193
+ wad: ReturnType<typeof methods.wad>;
194
+ wma: ReturnType<typeof methods.wma>;
195
+ wpr: ReturnType<typeof methods.wpr>;
196
+ wvad: ReturnType<typeof methods.wvad>;
197
+ constructor(context: any);
198
+ }
199
+ export default TechnicalAnalysis;
@@ -0,0 +1 @@
1
+ export declare function pivothigh(source: number[], leftbars: number, rightbars: number): number[];
@@ -0,0 +1 @@
1
+ export declare function pivotlow(source: number[], leftbars: number, rightbars: number): number[];
@@ -0,0 +1,5 @@
1
+ import ScopeManager from './ScopeManager';
2
+ export declare function transformNestedArrowFunctions(ast: any): void;
3
+ export declare function preProcessContextBoundVars(ast: any, scopeManager: ScopeManager): void;
4
+ export declare function transformArrowFunctionParams(node: any, scopeManager: ScopeManager, isRootFunction?: boolean): void;
5
+ export declare function runAnalysisPass(ast: any, scopeManager: ScopeManager): string | undefined;
@@ -0,0 +1,47 @@
1
+ export declare class ScopeManager {
2
+ private scopes;
3
+ private scopeTypes;
4
+ private scopeCounts;
5
+ private contextBoundVars;
6
+ private arrayPatternElements;
7
+ private rootParams;
8
+ private localSeriesVars;
9
+ private varKinds;
10
+ private loopVars;
11
+ private loopVarNames;
12
+ private paramIdCounter;
13
+ private cacheIdCounter;
14
+ private tempVarCounter;
15
+ private taCallIdCounter;
16
+ private hoistingStack;
17
+ private suppressHoisting;
18
+ get nextParamIdArg(): any;
19
+ get nextCacheIdArg(): any;
20
+ getNextTACallId(): any;
21
+ constructor();
22
+ pushScope(type: string): void;
23
+ popScope(): void;
24
+ getCurrentScopeType(): string;
25
+ getCurrentScopeCount(): number;
26
+ addLocalSeriesVar(name: string): void;
27
+ isLocalSeriesVar(name: string): boolean;
28
+ addContextBoundVar(name: string, isRootParam?: boolean): void;
29
+ removeContextBoundVar(name: any): void;
30
+ addArrayPatternElement(name: string): void;
31
+ isContextBound(name: string): boolean;
32
+ isArrayPatternElement(name: string): boolean;
33
+ isRootParam(name: string): boolean;
34
+ addLoopVariable(originalName: string, transformedName: string): void;
35
+ getLoopVariableName(name: string): string | undefined;
36
+ isLoopVariable(name: string): boolean;
37
+ addVariable(name: string, kind: string): string;
38
+ getVariable(name: string): [string, string];
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;
46
+ }
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,7 @@
1
+ import ScopeManager from '../analysis/ScopeManager';
2
+ export declare function transformArrayIndex(node: any, scopeManager: ScopeManager): void;
3
+ export declare function addArrayAccess(node: any, scopeManager: ScopeManager): void;
4
+ export declare function transformIdentifier(node: any, scopeManager: ScopeManager): void;
5
+ export declare function transformMemberExpression(memberNode: any, originalParamName: string, scopeManager: ScopeManager): void;
6
+ export declare function transformFunctionArgument(arg: any, namespace: string, scopeManager: ScopeManager): any;
7
+ export declare function transformCallExpression(node: any, scopeManager: ScopeManager, namespace?: string): void;
@@ -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;
@@ -0,0 +1,6 @@
1
+ import ScopeManager from '../analysis/ScopeManager';
2
+ export declare function transformEqualityChecks(ast: any): 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
+ import ScopeManager from '../analysis/ScopeManager';
2
+ export declare function transformAssignmentExpression(node: any, scopeManager: ScopeManager): void;
3
+ export declare function transformVariableDeclaration(varNode: any, scopeManager: ScopeManager): void;
4
+ export declare function transformForStatement(node: any, scopeManager: ScopeManager, c: any): void;
5
+ export declare function transformWhileStatement(node: any, scopeManager: ScopeManager, c: any): void;
6
+ export declare function transformExpression(node: any, scopeManager: ScopeManager): void;
7
+ export declare function transformIfStatement(node: any, scopeManager: ScopeManager, c: any): void;
8
+ export declare function transformReturnStatement(node: any, scopeManager: ScopeManager): void;
9
+ export declare function transformFunctionDeclaration(node: any, scopeManager: ScopeManager, c: 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;
@@ -0,0 +1,20 @@
1
+ export declare const CONTEXT_NAME = "$";
2
+ export declare const ASTFactory: {
3
+ createIdentifier(name: string): any;
4
+ createLiteral(value: any): any;
5
+ createMemberExpression(object: any, property: any, computed?: boolean): any;
6
+ createContextIdentifier(): any;
7
+ createContextVariableReference(kind: string, name: string): any;
8
+ createContextVariableAccess0(kind: string, name: string): any;
9
+ createArrayAccess(object: any, index: any): any;
10
+ createCallExpression(callee: any, args: any[]): any;
11
+ createAssignmentExpression(left: any, right: any, operator?: string): any;
12
+ createExpressionStatement(expression: any): any;
13
+ createInitCall(targetVarRef: any, value: any, lookbehind?: any): any;
14
+ createInitVarCall(targetVarRef: any, value: any): any;
15
+ createGetCall(source: any, index: any): any;
16
+ createSetCall(target: any, value: any): any;
17
+ createMathEqCall(left: any, right: any): any;
18
+ createWrapperFunction(body: any): any;
19
+ createVariableDeclaration(name: string, init: any): any;
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinets",
3
- "version": "0.2.1",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "main": "dist/pinets.dev.es.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -10,11 +10,19 @@
10
10
  "type": "module",
11
11
  "scripts": {
12
12
  "test": "cross-env TEST_ENV=true vitest --reporter verbose",
13
- "build:dev:all": "npm run build:dev:browser && npm run build:dev:cjs && npm run build:dev:es && tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
13
+ "test:coverage": "cross-env TEST_ENV=true vitest run --coverage",
14
+ "test:coverage:badge": "cross-env TEST_ENV=true vitest run --coverage --exclude tests/_local/**",
15
+ "badge": "npm run test:coverage:badge && node scripts/generate-coverage-badge.js",
16
+ "generate:ta-index": "node scripts/generate-ta-index.js",
17
+ "generate:math-index": "node scripts/generate-math-index.js",
18
+ "generate:array-index": "node scripts/generate-array-index.js",
19
+ "generate:input-index": "node scripts/generate-input-index.js",
20
+ "generate:request-index": "node scripts/generate-request-index.js",
21
+ "build:dev:all": "npm run generate:ta-index && npm run generate:math-index && npm run generate:array-index && npm run generate:input-index && npm run generate:request-index && npm run build:dev:browser && npm run build:dev:cjs && npm run build:dev:es && tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
14
22
  "build:dev:cjs": "cross-env BUILD=dev FORMAT=cjs rollup -c ./rollup.config.js",
15
23
  "build:dev:browser": "cross-env BUILD=dev FORMAT=browser rollup -c ./rollup.config.js",
16
24
  "build:dev:es": "cross-env BUILD=dev rollup -c ./rollup.config.js",
17
- "build:prod:all": "npm run build:prod:browser && npm run build:prod:cjs && npm run build:prod:es && tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
25
+ "build:prod:all": "npm run generate:ta-index && npm run generate:math-index && npm run generate:array-index && npm run generate:input-index && npm run generate:request-index && npm run build:prod:browser && npm run build:prod:cjs && npm run build:prod:es && tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
18
26
  "build:prod:cjs": "cross-env BUILD=prod FORMAT=cjs rollup -c ./rollup.config.js",
19
27
  "build:prod:browser": "cross-env BUILD=prod FORMAT=browser rollup -c ./rollup.config.js",
20
28
  "build:prod:es": "cross-env BUILD=prod rollup -c ./rollup.config.js",
@@ -32,6 +40,7 @@
32
40
  "@rollup/plugin-json": "^6.1.0",
33
41
  "@rollup/plugin-node-resolve": "^16.0.0",
34
42
  "@vitest/coverage-v8": "^2.0.0",
43
+ "badgen": "^3.2.3",
35
44
  "cross-env": "^7.0.3",
36
45
  "knip": "^5.43.6",
37
46
  "rollup": "^2.79.2",