fix: detect candle interval dynamically instead of hardcoded 60s
Replace the hardcoded 60-second assumption in CandleChart.tsx with dynamic interval detection: compute interval as candles[1].time - candles[0].time when at least 2 candles are available, fall back to 60 otherwise. Used for span-to-prediction-time mapping iteration. Marks task 8.6 as done in tasks.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8395f23744
commit
d6d844a003
2 changed files with 5 additions and 2 deletions
|
|
@ -472,11 +472,14 @@ const CandleChart = forwardRef<CandleChartHandle, CandleChartProps>(
|
|||
// Build candle price lookup for histogram values
|
||||
const candleMap = new Map(candles.map((c) => [c.time, c]));
|
||||
|
||||
// Detect candle interval from data (fall back to 60s if fewer than 2 candles)
|
||||
const candleInterval = candles.length >= 2 ? candles[1].time - candles[0].time : 60;
|
||||
|
||||
// Build a map from prediction time to its span for disagreement lookup
|
||||
const predictionTimeToSpan = new Map<number, PredictionSpan>();
|
||||
predictionSpans.forEach((span) => {
|
||||
// Associate all times in the span with the span object
|
||||
for (let t = span.start_time; t <= span.end_time; t += 60) { // Assuming 1-minute candles, adjust if needed
|
||||
for (let t = span.start_time; t <= span.end_time; t += candleInterval) {
|
||||
predictionTimeToSpan.set(t, span);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue