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);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ interface Trade {
|
|||
pnl: number | null;
|
||||
strategy_name: string;
|
||||
timestamp: string;
|
||||
created_at: string;
|
||||
status: string;
|
||||
signal_detail?: {
|
||||
direction: string;
|
||||
|
|
@ -210,7 +211,7 @@ export default function TradeLog() {
|
|||
{trade.strategy_name}
|
||||
</td>
|
||||
<td className="py-3 px-4 text-slate-400 text-xs">
|
||||
{new Date(trade.timestamp).toLocaleString()}
|
||||
{new Date(trade.created_at || trade.timestamp).toLocaleString()}
|
||||
</td>
|
||||
<td className="py-3 px-4 text-slate-400">
|
||||
<svg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue