fix: trade log Invalid Date and equity curve duplicate timestamp crash
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:
Viktor Barzin 2026-02-28 11:05:37 +00:00
parent 4f60ef453f
commit e92cbc1bc4
No known key found for this signature in database
GPG key ID: 0EB088298288D958
2 changed files with 10 additions and 5 deletions

View file

@ -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);