cg-ohlc-0.2.1 is not a library.
cg-ohlc
CLI tool to fetch OHLCV (Open, High, Low, Close, Volume) candlestick data from CoinGecko API.
Features
- Historical price data with configurable time ranges
- Multiple granularities (auto-selected based on range)
- Support for different quote currencies
- 50+ pre-mapped crypto symbols
Installation
Or build from source:
Usage
# Fetch 7 days of Bitcoin OHLC data
# Fetch 1 year of Ethereum data
# Save to file
# Use different quote currency
# Compact JSON output
# Verbose logging
Output
Returns array of OHLC candles:
Candle Granularity
CoinGecko auto-selects granularity based on range:
| Days | Granularity |
|---|---|
| 1-2 | 30-minute candles |
| 3-30 | 4-hour candles |
| 31-90 | Daily candles |
| 90+ | Daily candles |
Note: Free tier may return fewer candles for longer ranges (e.g., ~90 daily candles for 365-day request).
Options
| Option | Description |
|---|---|
--days |
Number of days of history (default: 7) |
--vs-currency |
Quote currency (default: usd) |
-O, --output-file |
Save output to file |
-f, --format |
Output format: json (pretty) or compact |
-v, --verbose |
Enable debug logging |
Rate Limiting
Uses CoinGecko free tier (10 req/min). The client automatically:
- Throttles requests to stay under limit
- Retries on 429 with exponential backoff (30s/60s/120s)
License
MIT