mars-v2-frontend/pages/portfolio.tsx

99 lines
2.5 KiB
TypeScript
Raw Normal View History

import React from "react";
import Container from "components/Container";
2022-09-08 06:23:02 +00:00
const mockedAccounts = [
{
id: 1,
label: "Subaccount 1",
networth: 100000,
totalPositionValue: 150000,
debt: 50000,
profit: 25000,
leverage: 3,
maxLeverage: 5,
},
{
id: 2,
label: "Subaccount 2",
2022-09-08 06:34:05 +00:00
networth: 33000,
totalPositionValue: 11000,
debt: 20000,
profit: -11366,
leverage: 2,
maxLeverage: 10,
2022-09-08 06:23:02 +00:00
},
{
id: 3,
label: "Subaccount 3",
2022-09-08 06:34:05 +00:00
networth: 0,
totalPositionValue: 12938129,
debt: 9999999999,
profit: -99999999,
2022-09-08 06:23:02 +00:00
leverage: 3,
maxLeverage: 5,
},
{
id: 4,
label: "Subaccount 4",
2022-09-08 06:34:05 +00:00
networth: 33653.22,
totalPositionValue: 100000,
debt: 50001.9,
2022-09-08 06:23:02 +00:00
profit: 25000,
leverage: 3,
maxLeverage: 5,
},
];
const Portfolio = () => {
return (
<div className="flex flex-col gap-4">
<Container className="flex-1">Portfolio Module</Container>
<div className="grid grid-cols-2 gap-4">
2022-09-08 06:23:02 +00:00
{mockedAccounts.map((account) => (
2022-09-08 06:34:05 +00:00
<Container key={account.id}>
<p className="mb-4 text-center font-bold">{account.label}</p>
<div className="grid grid-cols-3 gap-4">
<div>
<p>{formatCurrency(account.networth)}</p>
<p className="text-sm text-white/40">Net worth</p>
</div>
<div>
<p>{formatCurrency(account.totalPositionValue)}</p>
<p className="text-sm text-white/40">Total Position Value</p>
</div>
<div>
<p>{formatCurrency(account.debt)}</p>
<p className="text-sm text-white/40">Debt</p>
</div>
<div>
<p
className={`${
account.profit > 0 ? "text-green-400" : "text-red-500"
}`}
>
{formatCurrency(account.profit)}
</p>
<p className="text-sm text-white/40">P&L</p>
</div>
<div>
<p>{account.leverage}</p>
<p className="text-sm text-white/40">Current Leverage</p>
</div>
<div>
<p>{account.maxLeverage}</p>
<p className="text-sm text-white/40">Max Leverage</p>
</div>
</div>
</Container>
2022-09-08 06:23:02 +00:00
))}
</div>
</div>
);
};
export default Portfolio;
2022-09-08 06:34:05 +00:00
function formatCurrency(value: string | number) {
return Number(value).toLocaleString();
}