Communitygithub.com

vibe-motion/skills

Erstelle animierte Finanz-Kerzencharts (Candlestick) in Remotion-Projekten. Deckt Datenabruf (Yahoo Finance), Plugin-Architektur (config/timeline/Scene/plugin), Canvas-Frame-by-Frame-Rendering, Dark-Trading-Terminal-Design sowie Remotion Studio Vorschau und Rendering ab. Auslösewörter: K线图, 蜡烛图, candlestick, OHLC, 股票动画, 金融图表视频, Remotion 图表.

Was ist skills?

Dieses Skill beschreibt den vollständigen Workflow zur Erstellung eines animierten S&P 500 Kerzencharts (Candlestick-Diagramm) in einem Remotion-Projekt (vibe-motion-app). Es richtet sich an Entwickler, die hochwertige, datengesteuerte Finanzanimationen für Videos oder Präsentationen erstellen möchten – typische Anwendungsfälle sind Börsenberichte, Erklärvideos oder automatisierte Chartvisualisierungen. Der Prozess beginnt mit dem Abruf historischer OHLC-Daten über die Yahoo Finance API (kostenlos, kein API-Key nötig) und speichert diese als lokale JSON-Datei. Anschließend wird eine mehrteilige Plugin-Architektur aufgebaut: Konfiguration (config.js), zeitlicher Animationsablauf (timeline.js), die eigentliche Canvas-Zeichenkomponente (Scene.jsx) und die Registrierung im Plugin-System (plugin.js). Die Animation verwendet einen effizienten Canvas-Ansatz mit HD-DPI-Unterstützung, sanften Einblend- und Wachstumsanimationen sowie einem dunklen Trading-Terminal-Farbschema. Alle Zustände basieren ausschließlich auf dem `frame`-Parameter, was paralleles Rendering in Remotion ermöglicht. Das Skill unterstützt das vollständige Remotion-Ökosystem: Überprüfung der Kompositionen, interaktive Vorschau im Studio, Rendern einzelner Frames sowie die Ausgabe kompletter Videos inklusive benutzerdefinierter Render-Presets. Es ist speziell auf die vorhandene Projektstruktur mit pnpm, React 19 und TailwindCSS v4 zugeschnitten.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/vibe-motion/skills/tree/HEAD/remotion-candlestick

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Remotion Kerzenchart (Candlestick) Animationsablauf

Dieses Skill dokumentiert den vollständigen Erstellungsprozess eines S&P 500 Kerzencharts im Remotion-Projekt vibe-motion-app.

Voraussetzungen

  • Remotion 4.0.438 Projekt mit React 19 + TailwindCSS v4
  • Plugin-Architektur: motion/ definiert Szenen, remotion/ kümmert sich um die Remotion-Kompositionspipeline
  • pnpm als Paketmanager

Schritt 1: Finanzdaten abrufen

Yahoo Finance bietet kostenlose historische OHLC-Daten (kein API-Key erforderlich).

Erstelle scripts/fetch-sp500-data.mjs:

// Kern: Yahoo Finance Chart API aufrufen
const url = `https://query1.finance.yahoo.com/v8/finance/chart/%5EGSPC?period1=${PERIOD1}&period2=${PERIOD2}&interval=1wk`;
const resp = await fetch(url);
const json = await resp.json();
const result = json.chart?.result?.[0];
const ts = result.timestamp;
const quote = result.indicators.quote[0];
// Extrahiere { t: timestamp, o: open, h: high, l: low, c: close }

Speichere in public/data/sp500-weekly.json, damit Remotion es über staticFile() laden kann.

Parameterbeschreibung:

  • %5EGSPC = Yahoo-Symbol für S&P 500 (URL-kodiertes ^GSPC)
  • interval=1wk = Wochenkerzen; alternativ 1d, 1mo
  • period1 / period2 = Unix-Zeitstempel, deckt etwa 40 Jahre ab (1984-2026)

Schritt 2: Plugin-Dateistruktur erstellen

Jedes Remotion-Plugin benötigt 4 Kern-Dateien + ein Render-Preset:

motion/pluginname/
  config.js                 → Standardparameter
  timeline.js               → Szenenkontext + Frame-für-Frame-Animation
  Scene.jsx                 → React-Komponente (Canvas-Zeichnung)
  plugin.js                 → Plugin-Registrierungsobjekt
  render-presets/
    default.json            → Render-Preset

2a. config.js — Standardparameter

export const DEFAULT_LAYOUT_PARAMS = Object.freeze({
  videoWidth: 1920,    // 16:9 Querformat
  videoHeight: 1080,
});

export const DEFAULT_ANIMATION_PARAMS = Object.freeze({
  durationSeconds: 28,  // Gesamte Animationsdauer
  title: "S&P 500",
  subtitle: "Letzte 40 Jahre · Wochen-Kerzenchart",
});

export const DEFAULT_MOTION_PROPS = Object.freeze({
  ...DEFAULT_LAYOUT_PARAMS,
  ...DEFAULT_ANIMATION_PARAMS,
});

2b. timeline.js — Animationslogik

Drei Kernfunktionen müssen implementiert werden:

// 1. Szenenkontext: Validierung + Typumwandlung aller Parameter
export const resolveXxxSceneContext = (pluginParams) => { ... }

// 2. Dauerberechnung: durationSeconds * fps
export const getXxxDurationInFrames = ({ fps, sceneContext }) => { ... }

// 3. Frame-basierte Props: Berechne progress und andere Animationswerte aus frame/fps
export const buildXxxSceneProps = ({ frame, fps, loop, sceneContext }) => { ... }

Wichtiges Designprinzip: Alle Animationszustände hängen nur vom frame-Parameter ab, um Remotions paralleles Rendering zu unterstützen.

2c. Scene.jsx — Canvas-Zeichenkomponente

Verwende <canvas> statt vieler DOM-Elemente für bessere Performance.

Datenlademuster:

const [dataHandle] = useState(() => delayRender("Lade Daten"));

useEffect(() => {
  fetch(staticFile("data/xxx.json"))
    .then(r => r.json())
    .then(data => { setData(data); continueRender(dataHandle); })
    .catch(err => cancelRender(err));
}, [dataHandle]);

Canvas-Zeichenkernlogik:

const draw = useCallback(() => {
  const ctx = canvas.getContext("2d");
  const dpr = window.devicePixelRatio || 1;

  // HD-DPI Anpassung
  canvas.width = W * dpr;
  canvas.height = H * dpr;
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);

  // 1. Hintergrund füllen
  // 2. Gitterlinien + Y-Achsen-Preisbeschriftung
  // 3. Kerzen zeichnen (Docht + Körper)
  // 4. X-Achsen-Jahresbeschriftung
  // 5. Titel/Untertitel/Statistiken
  // 6. Fortschrittsbalken
}, [data, progress, ...]);

useEffect(() => { draw(); }, [draw]);

Wichtige Parameter für Kerzenzeichnung:

const CANDLE_GAP_RATIO = 0.28;  // Abstandsverhältnis zwischen Kerzen
const CANDLE_FADE_FRAMES = 22;  // Einblend-Animationsframes
const MAX_CANDLE_W = 8;         // Maximale Kerzenbreite (nach Skalierung)
const MIN_CANDLE_W = 0.6;       // Minimale Kerzenbreite

// Kerzenbreite passt sich der sichtbaren Anzahl an
const slotW = plotWidth / visibleCount;
const bodyW = Math.max(MIN_CANDLE_W, Math.min(MAX_CANDLE_W * scale, slotW * (1 - GAP_RATIO)));

Einblend-Animation (fade-in + Wachstum von unten):

const appearFrame = (i / (N - 1)) * revealEndFrame;
const candleAge = currentFrame - appearFrame;
const fadeAlpha = Math.min(1, Math.max(0, candleAge / CANDLE_FADE_FRAMES));

// Wachstumsanimation
if (candleAge < CANDLE_FADE_FRAMES && candleAge > 0) {
  const growT = easeOutCubic(candleAge / CANDLE_FADE_FRAMES);
  displayBodyBottom = lerp(lowY, bodyBottom, growT);
}

ctx.globalAlpha = fadeAlpha;
// ... zeichne Docht + Körper ...
ctx.globalAlpha = 1;

Dark-Theme-Farben:

const COLORS = {
  bg: "#1a1a19",
  grid: "#2c2c2a",
  upBorder: "#e66767",       // Rahmen für bullische Kerze (rot)
  upFill: "rgba(230,103,103,0.15)",  // Füllung für bullische Kerze (halftransparent)
  downFill: "#199e70",        // Füllung für bärische Kerze (grün)
  textPrimary: "#ffffff",
  textSecondary: "#c3c2b7",
  textMuted: "#898781",
  accent: "#3987e5",
};

2d. plugin.js — Plugin-Registrierung

export const xxxPlugin = Object.freeze({
  id: "PluginID",
  defaultProps: DEFAULT_MOTION_PROPS,
  SceneComponent: XxxScene,
  waitForSceneLayoutReady: true,  // Warte, bis Daten geladen sind

  resolveSceneContext: (params) => ...,
  getDurationInFrames: ({ fps, sceneContext }) => ...,
  buildSceneProps: ({ frame, fps, loop, sceneContext }) => ...,
  getLayout: ({ sceneContext }) => sceneContext.layout,
});

waitForSceneLayoutReady: true stellt sicher, dass die Szene onAutoLayoutReady() aufruft, bevor Frames gerendert werden.

2e. render-presets/default.json

{
  "title": "S&P 500",
  "subtitle": "Letzte 40 Jahre · Wochen-Kerzenchart",
  "videoWidth": 1920,
  "videoHeight": 1080,
  "durationSeconds": 28
}

Schritt 3: Komposition registrieren

Ändere motion/project.js, um ACTIVE_COMPOSITION auf das neue Plugin zu setzen:

import { xxxPlugin } from "./xxx/plugin.js";

export const ACTIVE_COMPOSITION = Object.freeze({
  id: "SP500Kline",
  fps: 30,
  plugin: xxxPlugin,
});

Schritt 4: Überprüfen und Rendern

# Kompositionen überprüfen
pnpm run remotion:compositions

# Studio-Vorschau starten (mit Zeitleisten-Scrollen und Parameter-Anpassung)
pnpm run dev

# Einzelframe-Screenshot rendern
npx remotion still SP500Kline out/frame.png --frame=420

# Komplettes Video rendern
npx remotion render SP500Kline out/output.mp4

# Mit Preset rendern
REMOTION_PROPS_FILE=motion/xxx/render-presets/default.json pnpm run remotion:render

Häufige Probleme

Yahoo Finance API CORS-Probleme

In der Remotion-Renderumgebung (Node.js Headless Browser) gibt es keine CORS-Probleme. Wenn in der Browser-Vorschau CORS auftritt, verwende staticFile(), um eine vorab geladene lokale JSON-Datei zu laden.

Canvas unscharf auf HD-DPI-Bildschirmen

Immer mit devicePixelRatio multiplizieren:

canvas.width = W * dpr;
canvas.height = H * dpr;
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);

Zu viele Kerzen führen zu sehr geringer Breite

Setze eine minimale Breite von 0,6px. Wenn slotW < 1 ist, verringere den Abstand oder aggregiere die Daten.

Animationsfortschritt steuern

Verwende segmentierte Easing-Funktionen:

  • Die ersten 3% für schnelles Aufbauen der Baseline
  • Mittlere 90% gleichmäßiges Aufdecken
  • Ende leicht verlangsamen für mehr Dramatik

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

Verwandte Skills