candlestick-chart-generator
Version:
A Node.js library for generating candlestick chart screenshots using financial data
134 lines (104 loc) • 3.8 kB
Markdown
# Chart Generator SDK Examples
This directory contains comprehensive examples demonstrating the capabilities of the Candlestick Chart Generator SDK.
## 📂 Example Files Overview
### 🔥 **Bitcoin Multi-Timeframe Analysis**
- **`bitcoin_multi_timeframe.js`** - Comprehensive Bitcoin chart generation across multiple timeframes (1H/4H/1D/1W)
### 🚀 **Basic Examples**
- **`basic_usage.js`** - Simple examples showing core functionality
- **`test_simple.js`** - Basic canvas-based chart generation tests
- **`test_canvas.js`** - Canvas renderer testing
### 🎨 **Advanced Examples**
- **`advanced_usage.js`** - Complex scenarios with multiple assets, custom styling, and various configurations
### 📊 **Generated Charts**
- **`aapl_daily_chart.png`** - Apple daily stock chart
- **`btc_hourly_chart.png`** - Bitcoin hourly chart
- **`eurusd_1m_chart.png`** - EUR/USD 1-minute forex chart
## 🎯 Quick Start
### Run Basic Examples
```bash
# Basic usage with core features
node examples/basic_usage.js
# Advanced features and multiple assets
node examples/advanced_usage.js
# NEW: Bitcoin multi-timeframe analysis
node examples/bitcoin_multi_timeframe.js
```
### Test Different Renderers
```bash
# Test canvas renderer
node examples/test_canvas.js
# Test simple renderer
node examples/test_simple.js
```
## 🌟 Featured Example: Bitcoin Multi-Timeframe
The new **`bitcoin_multi_timeframe.js`** example demonstrates:
### 📈 **Multiple Timeframes**
- **1H Charts** - Last 7 days for day trading analysis
- **4H Charts** - Last 30 days for swing trading
- **1D Charts** - Last 6 months for trend analysis
- **1W Charts** - Last 2 years for long-term investment
### 🎨 **Custom Styling**
- Bitcoin-themed orange color scheme
- Dark background optimized for crypto analysis
- Professional grid and axis styling
### 💡 **Trading Insights**
- Usage recommendations for each timeframe
- Pro tips for multi-timeframe analysis
- Context for different trading strategies
### 🔄 **Multiple Output Formats**
- PNG files for reports and documentation
- Base64 data for web application integration
- Multiple styling themes (dark, light, bitcoin orange)
## 📋 Supported Assets & Intervals
### 🏢 **Asset Types**
- **Stocks**: `AAPL`, `GOOGL`, `MSFT`, `TSLA`, etc.
- **Crypto**: `BTC-USD`, `ETH-USD`, `ADA-USD`, etc.
- **Forex**: `EURUSD=X`, `GBPUSD=X`, `USDJPY=X`, etc.
### ⏱️ **Time Intervals**
- **Intraday**: `1m`, `2m`, `5m`, `15m`, `30m`, `1h`, `4h`
- **Daily+**: `1d`, `5d`, `1wk`, `1mo`, `3mo`
## 🛠️ Advanced Configuration Examples
### Custom Chart Styling
```javascript
const chartOptions = {
layout: {
background: { color: '#000000' },
textColor: '#ffffff'
},
grid: {
vertLines: { color: '#1a1a1a' },
horzLines: { color: '#1a1a1a' }
}
};
```
### Multi-Asset Generation
```javascript
const symbols = ['AAPL', 'GOOGL', 'MSFT'];
for (const symbol of symbols) {
await generator.generateChartScreenshot({
symbol,
interval: '1d',
outputPath: `charts/${symbol.toLowerCase()}_chart.png`
});
}
```
### Base64 for Web Integration
```javascript
const base64Data = await generator.generateChartBase64({
symbol: 'BTC-USD',
interval: '1d',
width: 800,
height: 400
});
// Use base64Data in web applications
```
## 🎨 Chart Themes Available
1. **Dark Theme** - Professional dark background
2. **Light Theme** - Clean light background
3. **Bitcoin Orange** - Crypto-themed orange accent
4. **Custom** - Full customization support
## 🚀 Performance Tips
- Use `{ headless: true }` for production environments
- Batch multiple chart generations for efficiency
- Consider chart dimensions for file size optimization
- Always call `generator.close()` to free resources