Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f5ff60c
feat(api): add PyneSys API client and compilation support
itsmahadi007 Jul 30, 2025
2928ccf
feat(cli): improve error messages for api configuration
itsmahadi007 Jul 30, 2025
9da94f9
fix(cli): improve rate limit exceeded error message
itsmahadi007 Jul 30, 2025
26811a2
refactor(cli): simplify api configuration by removing redundant options
itsmahadi007 Jul 30, 2025
5ac4db0
feat(cli): add direct api key testing to status command
itsmahadi007 Jul 30, 2025
458291e
feat(compiler): implement smart compilation with hash tracking
itsmahadi007 Jul 31, 2025
0575032
style(cli): improve rate limit error messages consistency
itsmahadi007 Jul 31, 2025
eff3714
refactor(cli): centralize api error handling in commands
itsmahadi007 Jul 31, 2025
b815347
refactor(compiler): replace md5 hash with mtime for compilation check
itsmahadi007 Jul 31, 2025
27a85b0
refactor(api): improve code quality and modernize type hints
wallneradam Aug 1, 2025
2324b1b
Massive simplification
wallneradam Aug 2, 2025
eb33509
feat(api): add local JWT token validation and enhance CLI usage display
wallneradam Aug 2, 2025
2919e7b
feat(cli): improve compile command API usage display and error messages
wallneradam Aug 2, 2025
a157507
fix(api): improve error handling and message formatting
itsmahadi007 Aug 3, 2025
f83a476
docs(cli): add compile command documentation and update related files
itsmahadi007 Aug 3, 2025
7505f71
refactor(api_error_handler): improve error parsing logic and readability
itsmahadi007 Aug 3, 2025
3d7c094
docs: update Discord invite link and clarify PineComp usage
wallneradam Aug 3, 2025
caeecb6
feat(data): add automatic data file conversion to OHLCV format
itsmahadi007 Aug 4, 2025
154ed7f
feat(data): add smart defaults for symbol and timeframe detection
itsmahadi007 Aug 5, 2025
f0db8e2
refactor(cli): remove timeframe option and simplify conversion logic
itsmahadi007 Aug 6, 2025
6fbc4e6
Merge branch 'feature/smart-ohlcv-conversion' into merging_branch
itsmahadi007 Aug 6, 2025
81b5a96
fix(data): handle missing data files and improve path resolution
itsmahadi007 Aug 6, 2025
433533a
Merge branch 'main' into feature/smart-ohlcv-conversion
itsmahadi007 Aug 9, 2025
9695e5e
feat(data): improve symbol detection and timeframe handling
itsmahadi007 Aug 9, 2025
69a9c26
Merge branch 'main' into feature/smart-ohlcv-conversion
itsmahadi007 Aug 17, 2025
8cf76ad
feat(data): add advanced OHLCV analysis and improved symbol handling
wallneradam Aug 17, 2025
204d618
fix(core): cast buffer in struct.unpack to fix IDE warning
wallneradam Aug 17, 2025
5567125
docs: improve data conversion docs for smart OHLCV detection and auto…
wallneradam Aug 17, 2025
78a31d2
Merge branch 'main' into feature/smart-ohlcv-conversion
itsmahadi007 Aug 18, 2025
6f7a90c
feat(data_converter): add support for txt file format in data conversion
itsmahadi007 Aug 18, 2025
b4fe7fb
Remove redundant type checks and streamline last close handling
itsmahadi007 Aug 18, 2025
f997518
refactor(ohlcv_file): replace csv module with custom parser for txt f…
itsmahadi007 Aug 19, 2025
3378cf8
fix(pytest.ini): update ignored glob pattern for test discovery
wallneradam Aug 19, 2025
67bb9e5
refactor(ohlcv_file): extract timestamp parsing logic to eliminate co…
wallneradam Aug 19, 2025
780ba92
feat: fix formatting of OHLCV CSV output for better readability
wallneradam Aug 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions docs/cli/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,33 @@ PyneCore uses a binary format (`.ohlcv`) for storing OHLCV data efficiently. How

### Converting to Other Formats

The `convert-to` command converts PyneCore format to CSV or JSON:
The `convert-to` command converts PyneCore OHLCV format to CSV or JSON:

```bash
pyne data convert-to PROVIDER [OPTIONS]
pyne data convert-to OHLCV_FILE [OPTIONS]
```

Where `OHLCV_FILE` is the path to the OHLCV file to convert.

Options:
- `--symbol`, `-s`: Symbol to convert
- `--timeframe`, `-tf`: Timeframe in TradingView format
- `--format`, `-f`: Output format (csv, json)
- `--format`, `-f`: Output format (csv or json, default: csv)
- `--as-datetime`, `-dt`: Save timestamp as datetime instead of UNIX timestamp

The command automatically:
- Adds `.ohlcv` extension if not specified
- Creates output file with the same name but different extension
- Looks in `workdir/data/` if only filename is provided

Example:
```bash
# Convert Bitcoin data to CSV
pyne data convert-to ccxt --symbol "BINANCE:BTC/USDT" --timeframe "1D" --format "csv"
# Convert OHLCV file to CSV
pyne data convert-to BTCUSDT_1D.ohlcv

# Convert to JSON with human-readable dates
pyne data convert-to BTCUSDT_1D.ohlcv --format json --as-datetime

# Convert with human-readable dates
pyne data convert-to ccxt --symbol "BINANCE:BTC/USDT" --timeframe "1D" --format "csv" --as-datetime
# Short form (extension optional)
pyne data convert-to BTCUSDT_1D -f csv -dt
```

### Converting from Other Formats
Expand All @@ -172,21 +180,44 @@ pyne data convert-from FILE_PATH [OPTIONS]
Where `FILE_PATH` is the path to the CSV or JSON file to convert.

Options:
- `--provider`, `-p`: Data provider name (can be any name, defaults to "custom")
- `--symbol`, `-s`: Symbol name
- `--timeframe`, `-tf`: Timeframe in TradingView format
- `--fmt`, `-f`: Input format (csv, json) - defaults to the file extension if not specified
- `--provider`, `-p`: Data provider name (defaults to auto-detected from filename)
- `--symbol`, `-s`: Symbol name (defaults to auto-detected from filename)
- `--timezone`, `-tz`: Timezone of the timestamps (defaults to UTC)

**Automatic Detection Features:**
- **Symbol Detection**: The command automatically detects symbols from common filename patterns
- **Provider Detection**: Recognizes provider names in filenames (BINANCE, BYBIT, CAPITALCOM, etc.)
- **Format Support**: Supports CSV and JSON files, auto-detected from file extension

**Filename Pattern Examples:**
- `BTCUSDT.csv` → Symbol: BTC/USDT
- `EUR_USD.csv` → Symbol: EUR/USD
- `ccxt_BYBIT_BTC_USDT.csv` → Symbol: BTC/USDT, Provider: bybit
- `BINANCE_ETHUSDT_1h.csv` → Symbol: ETH/USDT, Provider: binance
- `capitalcom_EURUSD.csv` → Symbol: EUR/USD, Provider: capitalcom

Example:
```bash
# Convert CSV to PyneCore format
pyne data convert-from ./data/btcusd.csv --symbol "CUSTOM:BTC/USD" --timeframe "1D"
# Convert CSV with automatic detection
pyne data convert-from ./data/BTCUSDT.csv # Auto-detects BTC/USDT

# Override auto-detected values if needed
pyne data convert-from ./data/btcusd.csv --symbol "BTC/USD" --provider "kraken"

# Convert with timezone specification
pyne data convert-from ./data/eurusd.csv --symbol "CUSTOM:EUR/USD" --timeframe "60" --timezone "Europe/London"
pyne data convert-from ./data/eurusd.csv --timezone "Europe/London"
```

**Generated TOML Configuration:**

After conversion, a TOML configuration file is automatically generated with:
- **Smart Symbol Type Detection**: Automatically identifies forex, crypto, or other asset types
- **Tick Size Analysis**: Analyzes price data to determine the minimum price increment
- **Opening Hours Detection**: Detects trading hours from actual trading activity
- **Interval Detection**: Automatically determines the timeframe from timestamp intervals

The generated TOML file includes all detected information and can be manually adjusted if needed.

## Data File Structure

PyneCore uses a structured approach to store OHLCV data:
Expand Down
52 changes: 49 additions & 3 deletions docs/cli/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pyne run SCRIPT DATA [OPTIONS]

Where:
- `SCRIPT`: Path to the PyneCore script (.py) or Pine Script (.pine) file
- `DATA`: Path to the OHLCV data (.ohlcv) file
- `DATA`: Path to the data file (.ohlcv, .csv, .json, or .txt)
- `OPTIONS`: Additional options to customize the execution

## Simple Example
Expand Down Expand Up @@ -81,15 +81,61 @@ Example with API key:
pyne run my_strategy.pine eurusd_data.ohlcv --api-key "your-api-key"
```

## Automatic Data Conversion

The `run` command now supports automatic conversion of non-OHLCV data formats. When you provide a CSV, JSON, or TXT file, the system automatically:

1. **Detects the file format** from the extension
2. **Analyzes the filename** to extract symbol and provider information
3. **Converts the data** to OHLCV format
4. **Generates a TOML configuration** with detected parameters
5. **Runs the script** with the converted data

### Supported Formats and Detection

The automatic conversion supports:
- **CSV files**: Standard comma-separated values
- **JSON files**: JSON formatted OHLCV data
- **TXT files**: Tab, semicolon, or pipe-delimited data (coming soon)

### Filename Pattern Detection

The system recognizes common filename patterns:
- `BTCUSDT.csv` → Symbol: BTC/USDT
- `EUR_USD.json` → Symbol: EUR/USD
- `ccxt_BYBIT_BTC_USDT.csv` → Symbol: BTC/USDT, Provider: bybit
- `BINANCE_ETHUSDT_1h.csv` → Symbol: ETH/USDT, Provider: binance

### Example with Automatic Conversion

```bash
# Run a script with CSV data (automatic conversion)
pyne run my_strategy.py BTCUSDT.csv

# The system will:
# 1. Detect BTC/USDT as the symbol
# 2. Convert CSV to OHLCV format
# 3. Generate BTCUSDT.toml with symbol info
# 4. Run the script with converted data
```

### Advanced Analysis During Conversion

When converting data, the system performs advanced analysis:
- **Tick Size Detection**: Analyzes price movements to determine minimum price increment
- **Trading Hours Detection**: Identifies when the market is actively trading
- **Interval Auto-Correction**: Detects and fixes incorrect timeframe settings
- **Symbol Type Detection**: Identifies forex, crypto, or other asset types

## Command Arguments

The `run` command has two required arguments:

- `SCRIPT`: The script file to run. If only a filename is provided, it will be searched in the `workdir/scripts/` directory.
- `DATA`: The OHLCV data file to use. If only a filename is provided, it will be searched in the `workdir/data/` directory.
- `DATA`: The data file to use. Supports .ohlcv, .csv, .json formats. If only a filename is provided, it will be searched in the `workdir/data/` directory.

<small>
Note: you don't need to write the `.py` and `.ohlcv` extensions in the command.
Note: you don't need to write the file extensions in the command.
</small>

## Command Options
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ log_cli_level = DEBUG
log_cli_format = %(asctime)s %(levelname)6s %(module_func_line)30s - %(message)s
log_cli_date_format = %Y-%m-%d %H:%M:%S

addopts = --import-mode=importlib -rs -x --spec --ignore-glob="**/data/**"
addopts = --import-mode=importlib -rs -x --spec --ignore-glob="**/data/*modified.py"
Loading