pinets-cli 0.1.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/LICENSE +661 -0
- package/README.md +316 -0
- package/dist/pinets-cli.dev.cjs +4713 -0
- package/dist/pinets-cli.dev.cjs.map +1 -0
- package/dist/pinets-cli.min.cjs +149 -0
- package/dist/pinets-cli.min.cjs.map +1 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>pinets-cli</strong><br>
|
|
3
|
+
Run Pine Script indicators from the command line
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://www.npmjs.com/package/pinets-cli"><img src="https://img.shields.io/npm/v/pinets-cli.svg?style=flat-square" alt="npm version"></a>
|
|
8
|
+
<a href="https://opensource.org/licenses/AGPL-3.0"><img src="https://img.shields.io/badge/License-AGPL--3.0-blue.svg?style=flat-square" alt="License"></a>
|
|
9
|
+
<a href="https://github.com/QuantForgeOrg/PineTS"><img src="https://img.shields.io/badge/powered%20by-PineTS-blue?style=flat-square" alt="Powered by PineTS"></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="#quick-start">Quick Start</a> •
|
|
14
|
+
<a href="#usage">Usage</a> •
|
|
15
|
+
<a href="#options">Options</a> •
|
|
16
|
+
<a href="#examples">Examples</a> •
|
|
17
|
+
<a href="docs/README.md">Full Docs</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## What is pinets-cli?
|
|
23
|
+
|
|
24
|
+
**pinets-cli** is a command-line interface for [PineTS](https://github.com/QuantForgeOrg/PineTS), the open-source Pine Script transpiler and runtime. It lets you execute TradingView Pine Script indicators directly from your terminal, with live market data or custom JSON datasets.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pinets run rsi.pine --symbol BTCUSDT --timeframe 60
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
No code to write. No project to set up. Just point it at a `.pine` file and go.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
### Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install -g pinets-cli
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Run your first indicator
|
|
43
|
+
|
|
44
|
+
Create a file called `sma_cross.pine`:
|
|
45
|
+
|
|
46
|
+
```pinescript
|
|
47
|
+
//@version=5
|
|
48
|
+
indicator("SMA Cross", overlay=true)
|
|
49
|
+
fast = ta.sma(close, 9)
|
|
50
|
+
slow = ta.sma(close, 21)
|
|
51
|
+
plot(fast, "Fast SMA", color=color.blue)
|
|
52
|
+
plot(slow, "Slow SMA", color=color.red)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Run it:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pinets run sma_cross.pine --symbol BTCUSDT --timeframe 60
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
That's it. You'll get JSON output with the calculated SMA values for the last 500 hourly candles.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
pinets run [options] [file]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The `run` command executes a Pine Script indicator and outputs the results as JSON.
|
|
72
|
+
|
|
73
|
+
### Indicator source
|
|
74
|
+
|
|
75
|
+
Provide the indicator as a **file argument** or via **piped stdin**:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# From a file
|
|
79
|
+
pinets run my_indicator.pine --symbol BTCUSDT
|
|
80
|
+
|
|
81
|
+
# Piped from stdin (works on Linux, macOS, and Windows)
|
|
82
|
+
cat my_indicator.pine | pinets run --symbol BTCUSDT
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Data source
|
|
86
|
+
|
|
87
|
+
Choose between **live market data** or a **local JSON file**:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Live data from Binance
|
|
91
|
+
pinets run rsi.pine --symbol BTCUSDT --timeframe 60
|
|
92
|
+
|
|
93
|
+
# Custom data from a JSON file
|
|
94
|
+
pinets run rsi.pine --data ./my_candles.json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Options
|
|
100
|
+
|
|
101
|
+
### Data Source
|
|
102
|
+
|
|
103
|
+
| Option | Short | Description | Default |
|
|
104
|
+
|--------|-------|-------------|---------|
|
|
105
|
+
| `--symbol <ticker>` | `-s` | Symbol to query (e.g., `BTCUSDT`, `ETHUSDT.P`) | — |
|
|
106
|
+
| `--timeframe <tf>` | `-t` | Timeframe: `1`, `5`, `15`, `60`, `240`, `1D`, `1W`, `1M` | `60` |
|
|
107
|
+
| `--data <path>` | `-d` | Path to a JSON data file (alternative to `--symbol`) | — |
|
|
108
|
+
|
|
109
|
+
### Output
|
|
110
|
+
|
|
111
|
+
| Option | Short | Description | Default |
|
|
112
|
+
|--------|-------|-------------|---------|
|
|
113
|
+
| `--output <path>` | `-o` | Write output to a file instead of stdout | stdout |
|
|
114
|
+
| `--format <type>` | `-f` | Output format: `default` or `full` | `default` |
|
|
115
|
+
| `--pretty` | — | Force pretty-printed JSON | auto |
|
|
116
|
+
|
|
117
|
+
### Candle Control
|
|
118
|
+
|
|
119
|
+
| Option | Short | Description | Default |
|
|
120
|
+
|--------|-------|-------------|---------|
|
|
121
|
+
| `--candles <count>` | `-n` | Number of candles in the output | `500` |
|
|
122
|
+
| `--warmup <count>` | `-w` | Extra candles for indicator warmup (not included in output) | `0` |
|
|
123
|
+
|
|
124
|
+
### Other
|
|
125
|
+
|
|
126
|
+
| Option | Short | Description |
|
|
127
|
+
|--------|-------|-------------|
|
|
128
|
+
| `--debug` | — | Show the transpiled code (for debugging) |
|
|
129
|
+
| `--quiet` | `-q` | Suppress all informational messages |
|
|
130
|
+
| `--version` | `-v` | Show version number |
|
|
131
|
+
| `--help` | `-h` | Show help |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Examples
|
|
136
|
+
|
|
137
|
+
### Basic indicator with live data
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pinets run rsi.pine --symbol BTCUSDT --timeframe 1D --candles 100
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Indicator warmup
|
|
144
|
+
|
|
145
|
+
Many indicators need historical data to initialize (e.g., a 200-period SMA needs at least 200 bars before producing meaningful output). Use `--warmup` to fetch extra candles that are processed but excluded from the output:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Fetch 700 candles (200 warmup + 500 output), return only the last 500
|
|
149
|
+
pinets run ema200.pine --symbol ETHUSDT --timeframe 60 --candles 500 --warmup 200
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Save output to a file
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
pinets run macd.pine --symbol BTCUSDT --timeframe 15 -o results.json
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Pipe into other tools
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Pretty-print with jq
|
|
162
|
+
pinets run rsi.pine -s BTCUSDT -t 60 -q | jq '.plots'
|
|
163
|
+
|
|
164
|
+
# Extract last RSI value
|
|
165
|
+
pinets run rsi.pine -s BTCUSDT -t 60 -q | jq '.plots.RSI.data[-1].value'
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Use custom JSON data
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pinets run my_indicator.pine --data ./historical_btc.json --candles 50 --pretty
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Pipe indicator from stdin
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
cat my_indicator.pine | pinets run --symbol BTCUSDT --timeframe 60
|
|
178
|
+
|
|
179
|
+
# Or on Windows PowerShell
|
|
180
|
+
Get-Content my_indicator.pine | pinets run --symbol BTCUSDT --timeframe 60
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Full execution context
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
pinets run rsi.pine --symbol BTCUSDT --format full --pretty
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Debug transpilation
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
pinets run my_indicator.pine --symbol BTCUSDT --debug
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Output Formats
|
|
198
|
+
|
|
199
|
+
### `default` format
|
|
200
|
+
|
|
201
|
+
Contains the indicator metadata and all plot data:
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"indicator": {
|
|
206
|
+
"title": "RSI",
|
|
207
|
+
"overlay": false
|
|
208
|
+
},
|
|
209
|
+
"plots": {
|
|
210
|
+
"RSI": {
|
|
211
|
+
"title": "RSI",
|
|
212
|
+
"options": { "color": "#7E57C2" },
|
|
213
|
+
"data": [
|
|
214
|
+
{ "time": 1704067200000, "value": 65.42 },
|
|
215
|
+
{ "time": 1704070800000, "value": 62.18 }
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### `full` format
|
|
223
|
+
|
|
224
|
+
Everything in `default`, plus the raw execution result and market data:
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"indicator": { ... },
|
|
229
|
+
"plots": { ... },
|
|
230
|
+
"result": { ... },
|
|
231
|
+
"marketData": [
|
|
232
|
+
{ "openTime": 1704067200000, "open": 42000, "high": 42500, "low": 41800, "close": 42300, "volume": 1234.5 },
|
|
233
|
+
...
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## JSON Data Format
|
|
241
|
+
|
|
242
|
+
When using `--data`, provide a JSON file with an array of candle objects:
|
|
243
|
+
|
|
244
|
+
```json
|
|
245
|
+
[
|
|
246
|
+
{
|
|
247
|
+
"openTime": 1704067200000,
|
|
248
|
+
"open": 42000.50,
|
|
249
|
+
"high": 42500.00,
|
|
250
|
+
"low": 41800.00,
|
|
251
|
+
"close": 42300.00,
|
|
252
|
+
"volume": 1234.56,
|
|
253
|
+
"closeTime": 1704070799999
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Required fields**: `open`, `high`, `low`, `close`, `volume`
|
|
259
|
+
|
|
260
|
+
**Recommended fields**: `openTime`, `closeTime` (millisecond timestamps)
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## How It Works
|
|
265
|
+
|
|
266
|
+
pinets-cli is a self-contained binary that bundles the [PineTS](https://github.com/QuantForgeOrg/PineTS) library. When you run an indicator:
|
|
267
|
+
|
|
268
|
+
1. The Pine Script file is read and passed to the PineTS transpiler
|
|
269
|
+
2. Market data is fetched from Binance (or loaded from your JSON file)
|
|
270
|
+
3. The indicator is executed bar-by-bar with full time-series semantics
|
|
271
|
+
4. Plot data is collected and output as structured JSON
|
|
272
|
+
|
|
273
|
+
There are no runtime dependencies. The single bundled file includes everything needed.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Supported Timeframes
|
|
278
|
+
|
|
279
|
+
| Value | Description |
|
|
280
|
+
|-------|-------------|
|
|
281
|
+
| `1` | 1 minute |
|
|
282
|
+
| `3` | 3 minutes |
|
|
283
|
+
| `5` | 5 minutes |
|
|
284
|
+
| `15` | 15 minutes |
|
|
285
|
+
| `30` | 30 minutes |
|
|
286
|
+
| `60` | 1 hour |
|
|
287
|
+
| `120` | 2 hours |
|
|
288
|
+
| `240` | 4 hours |
|
|
289
|
+
| `1D` or `D` | 1 day |
|
|
290
|
+
| `1W` or `W` | 1 week |
|
|
291
|
+
| `1M` or `M` | 1 month |
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Related Projects
|
|
296
|
+
|
|
297
|
+
- **[PineTS](https://github.com/QuantForgeOrg/PineTS)** : The underlying transpiler and runtime engine
|
|
298
|
+
- **[QFChart](https://github.com/QuantForgeOrg/QFChart)** : Charting library optimized for PineTS visualization
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Contributing
|
|
303
|
+
|
|
304
|
+
Contributions are welcome! Please feel free to open issues or submit pull requests.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## License
|
|
309
|
+
|
|
310
|
+
AGPL-3.0 - See [LICENSE](LICENSE) for details.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
<p align="center">
|
|
315
|
+
<sub>Built with <a href="https://github.com/QuantForgeOrg/PineTS">PineTS</a> by <a href="https://quantforge.org">QuantForge</a></sub>
|
|
316
|
+
</p>
|