diff --git a/src/components/TickerName.tsx b/src/components/TickerName.tsx
index 11d0103..39adea4 100644
--- a/src/components/TickerName.tsx
+++ b/src/components/TickerName.tsx
@@ -1,9 +1,14 @@
'use client';
import { ITradeView } from "@/lib/types";
import { shortDateFormatter } from "./trades";
-
+import dayjs from "dayjs";
export const TickerName = (p: { trade: ITradeView; }) => {
const { trade } = p;
- return
{trade.symbol} {trade.strikePrice as unknown as string} {shortDateFormatter(trade.contractExpiry as unknown as string)} x {trade.numberOfContracts}
;
+ const dt = trade.contractExpiry;
+ const isYearAfter = dayjs(dt).diff(dayjs(), 'days') > 365;
+ const fmtDate = isYearAfter ? dayjs(dt).format('M/D/YY') : dayjs(dt).format('M/D');
+ return
+ {trade.symbol} {trade.strikePrice as unknown as string} {fmtDate} x {trade.numberOfContracts}
+
;
};
diff --git a/src/components/progress-bar.tsx b/src/components/progress-bar.tsx
new file mode 100644
index 0000000..0831890
--- /dev/null
+++ b/src/components/progress-bar.tsx
@@ -0,0 +1,90 @@
+import * as React from 'react';
+import { styled } from '@mui/material/styles';
+import { getColor } from '@/lib/color';
+
+interface ProgressBarProps {
+ value: number;
+ formattedValue: string
+}
+
+const Center = styled('div')({
+ height: '100%',
+ display: 'flex',
+ alignItems: 'center',
+});
+
+const Element = styled('div')(({ theme }) => ({
+ // border: `1px solid`,
+ position: 'relative',
+ overflow: 'hidden',
+ width: '100%',
+ height: 26,
+ // borderRadius: 2,
+}));
+
+const Value = styled('div')({
+ position: 'absolute',
+ lineHeight: '24px',
+ width: '100%',
+ display: 'flex',
+ justifyContent: 'center',
+});
+
+const Bar = styled('div')({
+ height: '100%',
+ '&.low': {
+ backgroundColor: '#f44336',
+ },
+ '&.medium': {
+ backgroundColor: '#efbb5aa3',
+ },
+ '&.high': {
+ backgroundColor: '#088208a3',
+ },
+});
+
+export const ProgressBar = React.memo(function ProgressBar(props: ProgressBarProps) {
+ const { value, formattedValue } = props;
+ const valueInPercent = value * 100;
+ let color = getColor(valueInPercent * 10);
+ if (!Number.isNaN(value)) {
+ return (
+
+ {/* */}
+ {/* */}
+ {formattedValue} ({valueInPercent.toFixed()}%)
+
+ {/* {formattedValue} */}
+
+
+ );
+ }
+});
+
+// export function renderProgress(params: GridRenderCellParams) {
+// if (params.value == null) {
+// return '';
+// }
+
+// // If the aggregated value does not have the same unit as the other cell
+// // Then we fall back to the default rendering based on `valueGetter` instead of rendering a progress bar.
+// if (params.aggregation && !params.aggregation.hasCellUnit) {
+// return null;
+// }
+
+// return (
+//
+//
+//
+// );
+// }
\ No newline at end of file
diff --git a/src/components/trades.tsx b/src/components/trades.tsx
index 20bed23..5b8886e 100644
--- a/src/components/trades.tsx
+++ b/src/components/trades.tsx
@@ -6,7 +6,7 @@ import CloseIcon from '@mui/icons-material/Close';
import dayjs from 'dayjs';
import { CloseTradeCloseDialogReason, CloseTradeDialog } from "./close-trade";
import { ConfirmDialog } from "./confirm-dialog";
-import { Card, CardContent, FormControlLabel, Grid, LinearProgress, Paper, Switch, Typography } from "@mui/material";
+import { Box, Card, CardContent, FormControlLabel, Grid, LinearProgress, Paper, Switch, Typography } from "@mui/material";
import { ConditionalFormattingBox } from "./conditional-formatting";
import { useTrades } from "@/lib/useTrades";
@@ -14,10 +14,18 @@ import { currencyFormatter, fixedCurrencyFormatter, percentageFormatter } from "
import { ITradeView } from "@/lib/types";
import { TickerName } from "./TickerName";
import humanFormat from "human-format";
+import { ProgressBar } from "./progress-bar";
const dateFormatter = (v: string) => v && dayjs(v.substring(0, 10)).format('DD/MM/YYYY'); //to avoid utc conversion strip the time part
export const shortDateFormatter = (v: string) => v && dayjs(v.substring(0, 10)).format('DD/MM/YYYY'); //to avoid utc conversion strip the time part
+const ProfitBar = (props: { cost: number, profit: number }) => {
+ const { profit, cost } = props;
+ return
+
+
+}
+
export const TradeList = () => {
const { trades, deleteTrade, reloadTrade, isLoading } = useTrades();
const [showCloseTrades, toggleShowCloseTrades] = useState(false);//useShowCloseTrades();
@@ -57,11 +65,12 @@ export const TradeList = () => {
{ field: 'buyCost', width: 70, headerName: 'Buy Cost', type: 'number', valueFormatter: fixedCurrencyFormatter },
{ field: 'sellCost', width: 70, headerName: 'Sell Cost', type: 'number', valueFormatter: fixedCurrencyFormatter },
{
- field: 'actualProfit', width: 70, headerName: 'PnL', type: 'number', valueFormatter: fixedCurrencyFormatter,
- renderCell: (p) =>
+ field: 'actualProfit', width: 100, headerName: 'PnL', type: 'number', valueFormatter: fixedCurrencyFormatter,
+ // renderCell: (p) =>
+ renderCell: (p) =>
},
{
- field: 'actualAnnualizedReturn', headerName: 'Annualized%', type: 'number', valueFormatter: percentageFormatter,
+ field: 'actualAnnualizedReturn', width: 70, headerName: 'Annualized%', type: 'number', valueFormatter: percentageFormatter,
renderCell: (p) =>
},
{