pinets 0.2.0 → 0.3.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 -16
- package/dist/pinets.dev.browser.js +3201 -2527
- package/dist/pinets.dev.cjs +3419 -2577
- package/dist/pinets.dev.cjs.map +1 -1
- package/dist/pinets.dev.es.js +2949 -2120
- package/dist/pinets.dev.es.js.map +1 -1
- package/dist/pinets.min.browser.js +11 -12
- package/dist/pinets.min.cjs +11 -12
- package/dist/pinets.min.es.js +1 -2
- package/dist/types/Context.class.d.ts +17 -6
- package/dist/types/PineTS.class.d.ts +78 -4
- 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/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/utils/TIMEFRAMES.d.ts +1 -0
- package/dist/types/namespaces/request/utils/findSecContextIdx.d.ts +1 -0
- package/dist/types/namespaces/ta/getters/tr.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/atr.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/change.d.ts +1 -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/dev.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/ema.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/highest.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/hma.d.ts +1 -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/median.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/mom.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/param.d.ts +2 -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/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/sma.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/stdev.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/supertrend.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/variance.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/vwma.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/wma.d.ts +1 -0
- package/dist/types/namespaces/ta/ta.index.d.ts +84 -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 +36 -0
- package/dist/types/transpiler/transformers/ExpressionTransformer.d.ts +7 -0
- package/dist/types/transpiler/transformers/MainTransformer.d.ts +3 -0
- package/dist/types/transpiler/transformers/StatementTransformer.d.ts +9 -0
- package/dist/types/transpiler/utils/ASTFactory.d.ts +18 -0
- package/package.json +12 -3
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/pinets)
|
|
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/)
|
|
6
|
+
|
|
1
7
|
This project aims to provide a Javascript/Typescript port for Tradingview's Pine Script.
|
|
2
8
|
The current version does not run Pine Script directly, instead it runs a close Javascript equivalent called PineTS.
|
|
3
9
|
|
|
@@ -16,8 +22,8 @@ PineTS enables seamless conversion of Pine Script indicators to JavaScript/TypeS
|
|
|
16
22
|
Bellow are two ports of Pine Script indicators running in the browser.
|
|
17
23
|
PineTS is used to generate plot data, and tradingview light weight chart is used to display the plot.
|
|
18
24
|
|
|
19
|
-
- [Williams Vix Fix](https://
|
|
20
|
-
- [Squeeze Momentum](https://
|
|
25
|
+
- [Williams Vix Fix](https://quantforgeorg.github.io/PineTS/indicators/willvixfix/)
|
|
26
|
+
- [Squeeze Momentum](https://quantforgeorg.github.io/PineTS/indicators/sqzmom/)
|
|
21
27
|
|
|
22
28
|
## Key Features
|
|
23
29
|
|
|
@@ -60,7 +66,13 @@ npm install pinets
|
|
|
60
66
|
|
|
61
67
|
Original Pine Script:
|
|
62
68
|
|
|
69
|
+
<table>
|
|
70
|
+
<tr>
|
|
71
|
+
<td>
|
|
72
|
+
|
|
63
73
|
```javascript
|
|
74
|
+
/*==[ Original Pine Script ]==*/
|
|
75
|
+
|
|
64
76
|
//@version=5
|
|
65
77
|
indicator('My EMA Cross Strategy');
|
|
66
78
|
|
|
@@ -77,22 +89,32 @@ _oo = open;
|
|
|
77
89
|
_oo = math.abs(open[1] - close[2]);
|
|
78
90
|
```
|
|
79
91
|
|
|
80
|
-
|
|
92
|
+
</td>
|
|
93
|
+
<td>
|
|
81
94
|
|
|
82
95
|
```javascript
|
|
83
|
-
|
|
84
|
-
const ema18 = ta.ema(close, 18);
|
|
96
|
+
/*==[ Equivalent PineTS ]==*/
|
|
85
97
|
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
//
|
|
99
|
+
//'My EMA Cross Strategy';
|
|
88
100
|
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
let ema9 = ta.ema(close, 9);
|
|
102
|
+
let ema18 = ta.ema(close, 18);
|
|
103
|
+
|
|
104
|
+
let bull_bias = ema9 > ema18;
|
|
105
|
+
let bear_bias = ema9 < ema18;
|
|
106
|
+
|
|
107
|
+
let prev_close = close[1];
|
|
108
|
+
let diff_close = close - prev_close;
|
|
91
109
|
|
|
92
110
|
let _oo = open;
|
|
93
111
|
_oo = math.abs(open[1] - close[2]);
|
|
94
112
|
```
|
|
95
113
|
|
|
114
|
+
</td>
|
|
115
|
+
</tr>
|
|
116
|
+
</table>
|
|
117
|
+
|
|
96
118
|
### Running PineTS Code
|
|
97
119
|
|
|
98
120
|
```javascript
|
|
@@ -106,14 +128,14 @@ const { result } = await pineTS.run((context) => {
|
|
|
106
128
|
const { ta, math } = context;
|
|
107
129
|
const { close, open } = context.data;
|
|
108
130
|
|
|
109
|
-
|
|
110
|
-
|
|
131
|
+
let ema9 = ta.ema(close, 9);
|
|
132
|
+
let ema18 = ta.ema(close, 18);
|
|
111
133
|
|
|
112
|
-
|
|
113
|
-
|
|
134
|
+
let bull_bias = ema9 > ema18;
|
|
135
|
+
let bear_bias = ema9 < ema18;
|
|
114
136
|
|
|
115
|
-
|
|
116
|
-
|
|
137
|
+
let prev_close = close[1];
|
|
138
|
+
let diff_close = close - prev_close;
|
|
117
139
|
|
|
118
140
|
let _oo = open;
|
|
119
141
|
_oo = math.abs(open[1] - close[2]);
|
|
@@ -122,7 +144,7 @@ const { result } = await pineTS.run((context) => {
|
|
|
122
144
|
});
|
|
123
145
|
```
|
|
124
146
|
|
|
125
|
-
> **📖 For detailed documentation on initialization options, parameters, and advanced usage, see the [Initialization and Usage Guide](https://
|
|
147
|
+
> **📖 For detailed documentation on initialization options, parameters, and advanced usage, see the [Initialization and Usage Guide](https://quantforgeorg.github.io/PineTS/initialization-and-usage/)**
|
|
126
148
|
|
|
127
149
|
## Key Differences from Pine Script
|
|
128
150
|
|