Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,96 @@ const tickChart = resampleTicksByCount(airbnb_ticks, {
});
```

## CLI Usage

The package includes a command-line interface for resampling OHLCV data between timeframes and file formats.

### Basic Usage

```bash
# Resample CSV file with default timeframes (1m -> 5m)
ohlc-resample -i input.csv

# Resample JSON file with custom timeframes
ohlc-resample -i input.json -b 60 -n 300

# Save output to file with specific format
ohlc-resample -i input.csv -o output.json -f json
```

### Options

```bash
Options:
-V, --version Show version number
-i, --input <char> Input file path (csv, json) or use pipe
-o, --output <char> Output file path (csv, json) or use pipe
-f, --format <char> Output file format (csv, json) (default: "json")
--input-format <char> Input format when using pipe (csv, json, auto) (default: "auto")
-b, --base-timeframe <number> Base timeframe in seconds (default: "60")
-n, --new-timeframe <number> New timeframe in seconds (default: "300")
-h, --help Display help for command
```

### Input Formats

The CLI supports both CSV and JSON input formats:

#### CSV Format
```csv
time,open,high,low,close,volume
1609459200000,100,105,95,102,1000
1609459260000,102,107,101,106,1200
```

#### JSON Format
```json
[
{
"time": 1609459200000,
"open": 100,
"high": 105,
"low": 95,
"close": 102,
"volume": 1000
}
]
```

### Pipe Input

You can pipe data into the CLI from other commands. The format is automatically detected, or you can specify it:

```bash
# Auto-detect format
cat data.json | ohlc-resample
cat data.csv | ohlc-resample

# Force specific format
cat data.json | ohlc-resample --input-format json
cat data.csv | ohlc-resample --input-format csv
```

The CLI supports two types of pipe input:
1. JSON files/strings with OHLCV objects
2. CSV files/strings with headers (time,open,high,low,close,volume)

### Examples

```bash
# Resample 1-minute data to 5-minute candles
ohlc-resample -i data.csv -b 60 -n 300

# Convert CSV to JSON format
ohlc-resample -i data.csv -f json

# Pipe data and save to file
cat data.csv | ohlc-resample -o output.json

# Resample with custom timeframes and save as CSV
ohlc-resample -i data.json -b 300 -n 3600 -f csv -o output.csv
```

## Contributors

👤 **Adil Shaikh <hello@adils.me> (https://adils.me)**
Expand Down
Loading