UNPKG

@neabyte/chart-to-image

Version:

Convert trading charts to images using Node.js canvas with advanced features: 6 chart types, VWAP/EMA/SMA indicators, custom colors, themes, hide elements, scaling, and PNG/JPEG export formats.

135 lines (134 loc) 3.4 kB
export interface WatermarkConfig { text: string; position?: 'top' | 'center' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; color?: string; fontSize?: number; opacity?: number; } export interface ChartConfig { symbol: string; timeframe: string; exchange?: string; outputPath: string; width: number; height: number; theme: 'light' | 'dark'; chartType: 'candlestick' | 'line' | 'area' | 'heikin-ashi' | 'renko' | 'line-break'; indicators: string[]; watermark?: string | WatermarkConfig; customBarColors?: { bullish?: string; bearish?: string; wick?: string; border?: string; }; horizontalLevels?: HorizontalLevel[]; title?: string; showTitle?: boolean; showTimeAxis?: boolean; showGrid?: boolean; showVWAP?: boolean; showEMA?: boolean; emaPeriod?: number; showSMA?: boolean; smaPeriod?: number; showBollingerBands?: boolean; bbPeriod?: number; bbStandardDeviations?: number; bbColors?: { upper?: string; middle?: string; lower?: string; background?: string; backgroundOpacity?: number; }; backgroundColor?: string; textColor?: string; scale?: { x?: number; y?: number; autoScale?: boolean; minScale?: number; maxScale?: number; }; } export interface HorizontalLevel { value: number; color: string; lineStyle: 'solid' | 'dotted'; label?: string; type?: 'support' | 'resistance' | 'custom'; } export interface ChartData { timestamp: number; open: number; high: number; low: number; close: number; volume?: number; } export interface ChartOptions { width: number; height: number; backgroundColor: string; textColor: string; gridColor: string; borderColor: string; chartType?: 'candlestick' | 'line' | 'area' | 'heikin-ashi' | 'renko' | 'line-break'; watermark?: string | WatermarkConfig; watermarkColor?: string; watermarkOpacity?: number; customBarColors?: { bullish: string; bearish: string; wick: string; border: string; }; horizontalLevels?: HorizontalLevel[]; title?: string; showTitle?: boolean; showTimeAxis?: boolean; showGrid?: boolean; showVWAP?: boolean; showEMA?: boolean; emaPeriod?: number; showSMA?: boolean; smaPeriod?: number; showBollingerBands?: boolean; bbPeriod?: number; bbStandardDeviations?: number; bbColors?: { upper?: string; middle?: string; lower?: string; background?: string; backgroundOpacity?: number; }; scale?: { x?: number; y?: number; autoScale?: boolean; minScale?: number; maxScale?: number; }; margin?: { top?: number; bottom?: number; left?: number; right?: number; }; } export interface RenderResult { success: boolean; outputPath?: string; error?: string; dataUrl?: string; } export type Timeframe = '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d' | '1w'; export type Exchange = 'binance' | 'coinbase' | 'kraken' | 'kucoin' | 'okx'; export interface ExchangeConfig { name: Exchange; apiKey?: string; secret?: string; sandbox?: boolean; }