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.
- package/README.md +38 -18
- package/dist/pinets.dev.browser.js +6029 -2997
- package/dist/pinets.dev.cjs +5982 -2783
- package/dist/pinets.dev.cjs.map +1 -1
- package/dist/pinets.dev.es.js +5368 -2186
- package/dist/pinets.dev.es.js.map +1 -1
- package/dist/pinets.min.browser.js +15 -12
- package/dist/pinets.min.cjs +15 -12
- package/dist/pinets.min.es.js +5 -2
- package/dist/types/Context.class.d.ts +73 -16
- package/dist/types/PineTS.class.d.ts +89 -5
- package/dist/types/Series.d.ts +10 -0
- package/dist/types/TimeSeries.class.d.ts +49 -0
- package/dist/types/TimeSeries.d.ts +15 -0
- package/dist/types/marketData/Mock/MockProvider.class.d.ts +77 -0
- package/dist/types/marketData/Provider.class.d.ts +6 -3
- package/dist/types/namespaces/Core.d.ts +1 -0
- package/dist/types/namespaces/array/PineArrayObject.d.ts +5 -0
- package/dist/types/namespaces/array/array.index.d.ts +135 -0
- package/dist/types/namespaces/array/methods/abs.d.ts +2 -0
- package/dist/types/namespaces/array/methods/avg.d.ts +2 -0
- package/dist/types/namespaces/array/methods/clear.d.ts +2 -0
- package/dist/types/namespaces/array/methods/concat.d.ts +2 -0
- package/dist/types/namespaces/array/methods/copy.d.ts +2 -0
- package/dist/types/namespaces/array/methods/covariance.d.ts +2 -0
- package/dist/types/namespaces/array/methods/every.d.ts +2 -0
- package/dist/types/namespaces/array/methods/fill.d.ts +2 -0
- package/dist/types/namespaces/array/methods/first.d.ts +2 -0
- package/dist/types/namespaces/array/methods/from.d.ts +2 -0
- package/dist/types/namespaces/array/methods/get.d.ts +2 -0
- package/dist/types/namespaces/array/methods/includes.d.ts +2 -0
- package/dist/types/namespaces/array/methods/indexof.d.ts +2 -0
- package/dist/types/namespaces/array/methods/insert.d.ts +2 -0
- package/dist/types/namespaces/array/methods/join.d.ts +2 -0
- package/dist/types/namespaces/array/methods/last.d.ts +2 -0
- package/dist/types/namespaces/array/methods/lastindexof.d.ts +2 -0
- package/dist/types/namespaces/array/methods/max.d.ts +2 -0
- package/dist/types/namespaces/array/methods/min.d.ts +2 -0
- package/dist/types/namespaces/array/methods/new.d.ts +2 -0
- package/dist/types/namespaces/array/methods/new_bool.d.ts +2 -0
- package/dist/types/namespaces/array/methods/new_float.d.ts +2 -0
- package/dist/types/namespaces/array/methods/new_int.d.ts +2 -0
- package/dist/types/namespaces/array/methods/new_string.d.ts +2 -0
- package/dist/types/namespaces/array/methods/param.d.ts +1 -0
- package/dist/types/namespaces/array/methods/pop.d.ts +2 -0
- package/dist/types/namespaces/array/methods/push.d.ts +2 -0
- package/dist/types/namespaces/array/methods/range.d.ts +2 -0
- package/dist/types/namespaces/array/methods/remove.d.ts +2 -0
- package/dist/types/namespaces/array/methods/reverse.d.ts +2 -0
- package/dist/types/namespaces/array/methods/set.d.ts +2 -0
- package/dist/types/namespaces/array/methods/shift.d.ts +2 -0
- package/dist/types/namespaces/array/methods/size.d.ts +2 -0
- package/dist/types/namespaces/array/methods/slice.d.ts +2 -0
- package/dist/types/namespaces/array/methods/some.d.ts +2 -0
- package/dist/types/namespaces/array/methods/sort.d.ts +2 -0
- package/dist/types/namespaces/array/methods/sort_indices.d.ts +2 -0
- package/dist/types/namespaces/array/methods/standardize.d.ts +2 -0
- package/dist/types/namespaces/array/methods/stdev.d.ts +2 -0
- package/dist/types/namespaces/array/methods/sum.d.ts +2 -0
- package/dist/types/namespaces/array/methods/unshift.d.ts +2 -0
- package/dist/types/namespaces/array/methods/variance.d.ts +2 -0
- package/dist/types/namespaces/input/input.index.d.ts +53 -0
- package/dist/types/namespaces/input/methods/any.d.ts +2 -0
- package/dist/types/namespaces/input/methods/bool.d.ts +2 -0
- package/dist/types/namespaces/input/methods/color.d.ts +2 -0
- package/dist/types/namespaces/input/methods/enum.d.ts +2 -0
- package/dist/types/namespaces/input/methods/float.d.ts +2 -0
- package/dist/types/namespaces/input/methods/int.d.ts +2 -0
- package/dist/types/namespaces/input/methods/param.d.ts +1 -0
- package/dist/types/namespaces/input/methods/price.d.ts +2 -0
- package/dist/types/namespaces/input/methods/session.d.ts +2 -0
- package/dist/types/namespaces/input/methods/source.d.ts +2 -0
- package/dist/types/namespaces/input/methods/string.d.ts +2 -0
- package/dist/types/namespaces/input/methods/symbol.d.ts +2 -0
- package/dist/types/namespaces/input/methods/text_area.d.ts +2 -0
- package/dist/types/namespaces/input/methods/time.d.ts +2 -0
- package/dist/types/namespaces/input/methods/timeframe.d.ts +2 -0
- package/dist/types/namespaces/input/types.d.ts +4 -0
- package/dist/types/namespaces/math/math.index.d.ts +77 -0
- package/dist/types/namespaces/math/methods/__eq.d.ts +1 -0
- package/dist/types/namespaces/math/methods/abs.d.ts +1 -0
- package/dist/types/namespaces/math/methods/acos.d.ts +1 -0
- package/dist/types/namespaces/math/methods/asin.d.ts +1 -0
- package/dist/types/namespaces/math/methods/atan.d.ts +1 -0
- package/dist/types/namespaces/math/methods/avg.d.ts +1 -0
- package/dist/types/namespaces/math/methods/ceil.d.ts +1 -0
- package/dist/types/namespaces/math/methods/cos.d.ts +1 -0
- package/dist/types/namespaces/math/methods/exp.d.ts +1 -0
- package/dist/types/namespaces/math/methods/floor.d.ts +1 -0
- package/dist/types/namespaces/math/methods/ln.d.ts +1 -0
- package/dist/types/namespaces/math/methods/log.d.ts +1 -0
- package/dist/types/namespaces/math/methods/log10.d.ts +1 -0
- package/dist/types/namespaces/math/methods/max.d.ts +1 -0
- package/dist/types/namespaces/math/methods/min.d.ts +1 -0
- package/dist/types/namespaces/math/methods/param.d.ts +1 -0
- package/dist/types/namespaces/math/methods/pow.d.ts +1 -0
- package/dist/types/namespaces/math/methods/random.d.ts +1 -0
- package/dist/types/namespaces/math/methods/round.d.ts +1 -0
- package/dist/types/namespaces/math/methods/sin.d.ts +1 -0
- package/dist/types/namespaces/math/methods/sqrt.d.ts +1 -0
- package/dist/types/namespaces/math/methods/sum.d.ts +1 -0
- package/dist/types/namespaces/math/methods/tan.d.ts +1 -0
- package/dist/types/namespaces/request/methods/param.d.ts +1 -0
- package/dist/types/namespaces/request/methods/security.d.ts +1 -0
- package/dist/types/namespaces/request/request.index.d.ts +14 -0
- package/dist/types/namespaces/request/types/barmerge.type.d.ts +7 -0
- package/dist/types/namespaces/request/utils/TIMEFRAMES.d.ts +1 -0
- package/dist/types/namespaces/request/utils/findLTFContextIdx.d.ts +1 -0
- package/dist/types/namespaces/request/utils/findSecContextIdx.d.ts +1 -0
- package/dist/types/namespaces/ta/getters/obv.d.ts +12 -0
- package/dist/types/namespaces/ta/getters/tr.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/accdist.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/alma.d.ts +18 -0
- package/dist/types/namespaces/ta/methods/atr.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/barssince.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/bb.d.ts +17 -0
- package/dist/types/namespaces/ta/methods/bbw.d.ts +9 -0
- package/dist/types/namespaces/ta/methods/cci.d.ts +20 -0
- package/dist/types/namespaces/ta/methods/change.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/cmo.d.ts +17 -0
- package/dist/types/namespaces/ta/methods/cog.d.ts +18 -0
- package/dist/types/namespaces/ta/methods/correlation.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/cross.d.ts +15 -0
- package/dist/types/namespaces/ta/methods/crossover.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/crossunder.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/cum.d.ts +14 -0
- package/dist/types/namespaces/ta/methods/dev.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/dmi.d.ts +24 -0
- package/dist/types/namespaces/ta/methods/ema.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/falling.d.ts +15 -0
- package/dist/types/namespaces/ta/methods/highest.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/highestbars.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/hma.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/iii.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/kc.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/kcw.d.ts +11 -0
- package/dist/types/namespaces/ta/methods/linreg.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/lowest.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/lowestbars.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/macd.d.ts +18 -0
- package/dist/types/namespaces/ta/methods/median.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/mfi.d.ts +15 -0
- package/dist/types/namespaces/ta/methods/mode.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/mom.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/nvi.d.ts +10 -0
- package/dist/types/namespaces/ta/methods/obv.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/param.d.ts +2 -0
- package/dist/types/namespaces/ta/methods/percentile_linear_interpolation.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/percentile_nearest_rank.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/percentrank.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/pivothigh.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/pivotlow.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/pvi.d.ts +10 -0
- package/dist/types/namespaces/ta/methods/pvt.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/range.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/rising.d.ts +15 -0
- package/dist/types/namespaces/ta/methods/rma.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/roc.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/rsi.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/sar.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/sma.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/stdev.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/stoch.d.ts +21 -0
- package/dist/types/namespaces/ta/methods/supertrend.d.ts +24 -0
- package/dist/types/namespaces/ta/methods/swma.d.ts +14 -0
- package/dist/types/namespaces/ta/methods/tr.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/tsi.d.ts +17 -0
- package/dist/types/namespaces/ta/methods/valuewhen.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/variance.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/vwap.d.ts +14 -0
- package/dist/types/namespaces/ta/methods/vwma.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/wad.d.ts +11 -0
- package/dist/types/namespaces/ta/methods/wma.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/wpr.d.ts +17 -0
- package/dist/types/namespaces/ta/methods/wvad.d.ts +7 -0
- package/dist/types/namespaces/ta/ta.index.d.ts +199 -0
- package/dist/types/namespaces/ta/utils/pivothigh.d.ts +1 -0
- package/dist/types/namespaces/ta/utils/pivotlow.d.ts +1 -0
- package/dist/types/transpiler/analysis/AnalysisPass.d.ts +5 -0
- package/dist/types/transpiler/analysis/ScopeManager.d.ts +47 -0
- package/dist/types/transpiler/index.d.ts +4 -1
- package/dist/types/transpiler/transformers/ExpressionTransformer.d.ts +7 -0
- package/dist/types/transpiler/transformers/InjectionTransformer.d.ts +6 -0
- package/dist/types/transpiler/transformers/MainTransformer.d.ts +6 -0
- package/dist/types/transpiler/transformers/NormalizationTransformer.d.ts +15 -0
- package/dist/types/transpiler/transformers/StatementTransformer.d.ts +9 -0
- package/dist/types/transpiler/transformers/WrapperTransformer.d.ts +9 -0
- package/dist/types/transpiler/utils/ASTFactory.d.ts +20 -0
- package/package.json +12 -3
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/pinets)
|
|
2
2
|
[](https://opensource.org/licenses/AGPL-3.0)
|
|
3
|
-
[](./.github/badges/coverage.svg)
|
|
4
|
+
[](https://quantforgeorg.github.io/PineTS/)
|
|
5
|
+
[](https://www.reddit.com/r/QuantForge/)
|
|
5
6
|
|
|
6
7
|
This project aims to provide a Javascript/Typescript port for Tradingview's Pine Script.
|
|
7
8
|
The current version does not run Pine Script directly, instead it runs a close Javascript equivalent called PineTS.
|
|
@@ -21,12 +22,13 @@ PineTS enables seamless conversion of Pine Script indicators to JavaScript/TypeS
|
|
|
21
22
|
Bellow are two ports of Pine Script indicators running in the browser.
|
|
22
23
|
PineTS is used to generate plot data, and tradingview light weight chart is used to display the plot.
|
|
23
24
|
|
|
24
|
-
- [Williams Vix Fix](https://
|
|
25
|
-
- [Squeeze Momentum](https://
|
|
25
|
+
- [Williams Vix Fix](https://quantforgeorg.github.io/PineTS/indicators/willvixfix/)
|
|
26
|
+
- [Squeeze Momentum](https://quantforgeorg.github.io/PineTS/indicators/sqzmom/)
|
|
26
27
|
|
|
27
28
|
## Key Features
|
|
28
29
|
|
|
29
30
|
- **Pine Script Compatibility**: Supports Pine Script v5+ syntax and functionality
|
|
31
|
+
- **High Precision**: Aims for the same precision as Pine Script (up to the 8th digit)
|
|
30
32
|
- **Time-Series Processing**: Handles historical data and series operations
|
|
31
33
|
- **Technical Analysis Functions**: Comprehensive set of TA indicators and calculations
|
|
32
34
|
- **Mathematical Operations**: Advanced mathematical functions and precision handling
|
|
@@ -65,7 +67,13 @@ npm install pinets
|
|
|
65
67
|
|
|
66
68
|
Original Pine Script:
|
|
67
69
|
|
|
70
|
+
<table>
|
|
71
|
+
<tr>
|
|
72
|
+
<td>
|
|
73
|
+
|
|
68
74
|
```javascript
|
|
75
|
+
/*==[ Original Pine Script ]==*/
|
|
76
|
+
|
|
69
77
|
//@version=5
|
|
70
78
|
indicator('My EMA Cross Strategy');
|
|
71
79
|
|
|
@@ -82,22 +90,32 @@ _oo = open;
|
|
|
82
90
|
_oo = math.abs(open[1] - close[2]);
|
|
83
91
|
```
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
</td>
|
|
94
|
+
<td>
|
|
86
95
|
|
|
87
96
|
```javascript
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
/*==[ Equivalent PineTS ]==*/
|
|
98
|
+
|
|
99
|
+
//
|
|
100
|
+
//'My EMA Cross Strategy';
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
let ema9 = ta.ema(close, 9);
|
|
103
|
+
let ema18 = ta.ema(close, 18);
|
|
93
104
|
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
let bull_bias = ema9 > ema18;
|
|
106
|
+
let bear_bias = ema9 < ema18;
|
|
107
|
+
|
|
108
|
+
let prev_close = close[1];
|
|
109
|
+
let diff_close = close - prev_close;
|
|
96
110
|
|
|
97
111
|
let _oo = open;
|
|
98
112
|
_oo = math.abs(open[1] - close[2]);
|
|
99
113
|
```
|
|
100
114
|
|
|
115
|
+
</td>
|
|
116
|
+
</tr>
|
|
117
|
+
</table>
|
|
118
|
+
|
|
101
119
|
### Running PineTS Code
|
|
102
120
|
|
|
103
121
|
```javascript
|
|
@@ -111,14 +129,14 @@ const { result } = await pineTS.run((context) => {
|
|
|
111
129
|
const { ta, math } = context;
|
|
112
130
|
const { close, open } = context.data;
|
|
113
131
|
|
|
114
|
-
|
|
115
|
-
|
|
132
|
+
let ema9 = ta.ema(close, 9);
|
|
133
|
+
let ema18 = ta.ema(close, 18);
|
|
116
134
|
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
let bull_bias = ema9 > ema18;
|
|
136
|
+
let bear_bias = ema9 < ema18;
|
|
119
137
|
|
|
120
|
-
|
|
121
|
-
|
|
138
|
+
let prev_close = close[1];
|
|
139
|
+
let diff_close = close - prev_close;
|
|
122
140
|
|
|
123
141
|
let _oo = open;
|
|
124
142
|
_oo = math.abs(open[1] - close[2]);
|
|
@@ -127,7 +145,7 @@ const { result } = await pineTS.run((context) => {
|
|
|
127
145
|
});
|
|
128
146
|
```
|
|
129
147
|
|
|
130
|
-
> **📖 For detailed documentation on initialization options, parameters, and advanced usage, see the [Initialization and Usage Guide](https://
|
|
148
|
+
> **📖 For detailed documentation on initialization options, parameters, and advanced usage, see the [Initialization and Usage Guide](https://quantforgeorg.github.io/PineTS/initialization-and-usage/)**
|
|
131
149
|
|
|
132
150
|
## Key Differences from Pine Script
|
|
133
151
|
|
|
@@ -139,6 +157,8 @@ const { result } = await pineTS.run((context) => {
|
|
|
139
157
|
|
|
140
158
|
## Project Goals
|
|
141
159
|
|
|
160
|
+
PineTS aims for **full coverage** of Pine Script functions and capabilities. The ultimate goal is to enable running **original Pine Script code directly** without manual conversion to PineTS syntax.
|
|
161
|
+
|
|
142
162
|
- Runtime Transpiler
|
|
143
163
|
- Core Pine Script functions and variables
|
|
144
164
|
- Series and scope management
|