Metadata-Version: 2.4
Name: opencode-pine2pyne
Version: 0.1.0
Summary: Pine Script v6 to PyneCore Python transpiler
Author: rubycell
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/rubycell/pine2pyne
Project-URL: Repository, https://github.com/rubycell/pine2pyne
Keywords: pinescript,tradingview,transpiler,pynecore,backtesting
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: runtime
Requires-Dist: opencode-pyneruntime; extra == "runtime"
Dynamic: license-file

# PyneCore - Pine Script to Python Transpiler

## Installation (New Computer)

```bash
# 1. Navigate to the pynecore directory
cd pynecore

# 2. Create virtual environment
python3 -m venv .venv

# 3. Install pynecore runtime (editable mode)
.venv/bin/pip install -e ~/workspace/github/pynecore

# 4. Install required dependencies
.venv/bin/pip install typer typing_extensions

# 5. Activate the virtual environment
source .venv/bin/activate  # On Linux/mac
# OR
.venv\Scripts\activate     # On Windows
```

**Note**: All commands below assume you are in the `pynecore` directory with the venv activated.

## How to Convert Pine Script to Python

### Single File Conversion

```bash
python -m pine2pyne path/to/script.pine -o path/to/output.py
```

### Batch Conversion

```bash
python -m pine2pyne "sample/pinescript/*.pine" -o workdir/scripts/
```

## Running Tests

### Run All Test Samples

```bash
python test_all_samples.py
```

### Run Specific Pattern

```bash
python test_all_samples.py "ex_001*"          # Filter by pattern
python test_all_samples.py "ex_347_*"        # Single file pattern
```

### Additional Options

```bash
python test_all_samples.py --timeout 30       # Custom timeout (default: 15s)
python test_all_samples.py --verbose           # Show stderr on failure
```

### Test Framework Details

- **Source directory**: `sample/pinescript/`
- **Output directory**: `workdir/scripts/`
- **Test data**: `workdir/data/`
- **Results**: `test_results.json` and `test_results.txt`

## For Claude Code / LLM Development

See `CLAUDE.md` in this directory for transpiler architecture, output format specs, optimizer documentation, and CSV rounding rules. See `pine2pyne/README.md` for transpiler internals and transformation rules.

## Optimizing Strategies

Quick start: `pyne optimize script.py data.ohlcv params.json -n 20`

See [Optimizer.md](./Optimizer.md) for full documentation (parameter JSON format, parallel execution, output files).

### Distributed Optimization (multi-machine)

Two tools distribute `pyne optimize` across SSH clusters:

| Tool | Model | Best for |
|------|-------|----------|
| `pyne-dynamic.sh` | Flat-queue (on-demand dispatch) | Multi-variant runs, heterogeneous clusters, long jobs |
| `pyne-parallel.sh` | Static pre-assignment | Quick jobs on similar-speed machines |

```bash
# Dynamic (recommended): flat-queue, pre-syncs once, auto-adapts to machine speed
# Run from workdir/ directory:
../tools/pyne-dynamic.sh scripts/strategy.py data/data.ohlcv optimize_variants/ \
  -H ../tools/machines.txt -C 24 --name my_run --output-dir runs/output/

# Static: pre-assigns chunks by core count
./tools/pyne-parallel.sh scripts/strategy.py data/data.ohlcv optimize.json \
  -H tools/machines.txt --sync

# Check progress / collect results
../tools/pyne-dynamic.sh --status
../tools/pyne-dynamic.sh --collect
```

Both use the same `machines.txt` format. See `CLAUDE.md` for cluster setup, machine file format, and troubleshooting.
