CIOAgent / frontend /src /components /PortfolioVersions.jsx
bhuvighosh3
Deployment with restored Stress Specialist data
9fbb3f2
Raw History Blame Contribute Delete
1.74 kB
import React from "react";
export default function PortfolioVersions({ snapshots, onRestore }) {
if (!snapshots || snapshots.length === 0) return null;
return (
<div className="section">
<h2>Portfolio History</h2>
<p className="caption">Previous portfolio snapshots. Click to restore.</p>
<table className="data-table">
<thead>
<tr>
<th>#</th>
<th>Label</th>
<th>Date</th>
<th>Tickers</th>
<th>Return</th>
<th>Sharpe</th>
<th></th>
</tr>
</thead>
<tbody>
{snapshots.map((s, i) => (
<tr key={i}>
<td>{i + 1}</td>
<td><strong>{s.label || `Snapshot #${i + 1}`}</strong></td>
<td style={{ fontSize: "0.8rem" }}>
{new Date(s.timestamp * 1000).toLocaleDateString()}
</td>
<td style={{ fontSize: "0.8rem" }}>{s.tickers.join(", ")}</td>
<td>
{s.performance?.annual_return != null
? `${(s.performance.annual_return * 100).toFixed(2)}%`
: "—"}
</td>
<td>
{s.performance?.sharpe_ratio != null
? s.performance.sharpe_ratio.toFixed(2)
: "—"}
</td>
<td>
<button
className="btn"
style={{ padding: "0.2rem 0.5rem", fontSize: "0.75rem" }}
onClick={() => onRestore(s)}
>
Restore
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
);
}