Skip to content

Commit

Permalink
Added ITM badges
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhwang committed May 13, 2024
1 parent 7d6cb09 commit e816034
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type TableProps = {
};

const Table: FunctionComponent<TableProps> = ({ name, x, start, current }) => {
const { strategy, underlying } = useContext(OptionLegs);
const { strategy, underlying, optionLegs } = useContext(OptionLegs);

if (!x || !start || !current) return <></>;

Expand All @@ -20,7 +20,22 @@ const Table: FunctionComponent<TableProps> = ({ name, x, start, current }) => {
<tr key={`row-${i}`}>
<td scope="row">{i + 1}</td>
<td>{formatUSD(start.optionLegValues[i])}</td>
<td>{formatUSD(current.optionLegValues[i])}</td>
<td>
<span className="me-2">{formatUSD(current.optionLegValues[i])}</span>
{(optionLegs[i].callPut === "call" && x > optionLegs[i].k) ||
(optionLegs[i].callPut === "put" && x < optionLegs[i].k) ? (
<small
className={
"badge " +
(optionLegs[i].longShort == "long"
? "text-bg-warning"
: "text-bg-danger")
}
>
ITM
</small>
) : null}
</td>
<td>
{formatUSD(current.optionLegValues[i] - start.optionLegValues[i])}
</td>
Expand Down

0 comments on commit e816034

Please sign in to comment.