fix: trade log Invalid Date and equity curve duplicate timestamp crash
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- TradeLog: use created_at (from API) instead of timestamp for date display - EquityCurve: deduplicate data by day before passing to lightweight-charts, preventing "data must be asc ordered by time" assertion failure when multiple snapshots exist on the same day Made-with: Cursor
This commit is contained in:
parent
4f60ef453f
commit
e92cbc1bc4
2 changed files with 10 additions and 5 deletions
|
|
@ -68,10 +68,14 @@ export function EquityCurve({ data, height = 300 }: EquityCurveProps) {
|
|||
useEffect(() => {
|
||||
if (!seriesRef.current || !data.length) return;
|
||||
|
||||
const chartData = data.map((point) => ({
|
||||
time: point.timestamp.split('T')[0] as string,
|
||||
value: point.value,
|
||||
}));
|
||||
const byDay = new Map<string, number>();
|
||||
for (const point of data) {
|
||||
const day = point.timestamp.split('T')[0];
|
||||
byDay.set(day, point.value);
|
||||
}
|
||||
const chartData = Array.from(byDay.entries())
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.map(([time, value]) => ({ time, value }));
|
||||
|
||||
seriesRef.current.setData(chartData as any);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue