MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / generateCandlestickChunk

Function generateCandlestickChunk

examples/worker-rendering/main.ts:338–363  ·  view source on GitHub ↗
(
  startIndex: number,
  count: number
)

Source from the content-addressed store, hash-verified

336}
337
338function generateCandlestickChunk(
339 startIndex: number,
340 count: number
341): OHLCDataPoint[] {
342 const data: OHLCDataPoint[] = new Array(count);
343 let basePrice = 100;
344
345 for (let i = 0; i < count; i++) {
346 const timestamp = startIndex + i;
347
348 // Random walk with trend
349 const trend = Math.sin(i * 0.002) * 0.5;
350 const volatility = 2 + Math.random() * 3;
351
352 const open = basePrice;
353 const change = (Math.random() - 0.5) * volatility + trend;
354 const close = open + change;
355 const high = Math.max(open, close) + Math.random() * volatility * 0.5;
356 const low = Math.min(open, close) - Math.random() * volatility * 0.5;
357
358 data[i] = [timestamp, open, close, low, high];
359 basePrice = close; // Continue from close price
360 }
361
362 return data;
363}
364
365// ============================================================================
366// Chart Management

Callers 1

generateChunkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected