Skip to content

Commit

Permalink
Added support for underlying securities
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhwang committed May 13, 2024
1 parent be00f57 commit 76f634c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"react-dom": "^17.0.2",
"react-financial-charts": "^1.3.2",
"react-icons": "^4.8.0",
"react-option-charts": "^0.1.2",
"react-option-charts": "^0.2.0",
"sass": "^1.59.3",
"use-immer": "^0.8.1"
},
Expand Down
56 changes: 32 additions & 24 deletions src/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,35 @@ const Editor: FunctionComponent = () => {
/>
</div>
<div className="col-2 px-1 px-sm-2">
<input
className="form-control form-control-sm"
aria-label={`leg ${i + 1} DTE`}
type="number"
value={o.dte}
onChange={(e) =>
setOptionLegs((draft) => {
draft[i].dte = +e.target.value;
})
}
/>
{o.callPut !== "underlying" ? (
<input
className="form-control form-control-sm"
aria-label={`leg ${i + 1} DTE`}
type="number"
value={o.dte}
onChange={(e) =>
setOptionLegs((draft) => {
draft[i].dte = +e.target.value;
})
}
/>
) : null}
</div>
<div className="col-2 px-1 px-sm-2">
<input
className="form-control form-control-sm"
aria-label={`leg ${i + 1} volatility`}
type="number"
value={o.v}
onChange={(e) =>
setOptionLegs((draft) => {
draft[i].v = +e.target.value;
})
}
step=".05"
/>
{o.callPut !== "underlying" ? (
<input
className="form-control form-control-sm"
aria-label={`leg ${i + 1} volatility`}
type="number"
value={o.v}
onChange={(e) =>
setOptionLegs((draft) => {
draft[i].v = +e.target.value;
})
}
step=".05"
/>
) : null}
</div>
<div className="col-2 px-1 px-sm-2">
<select
Expand All @@ -73,12 +77,16 @@ const Editor: FunctionComponent = () => {
value={o.callPut}
onChange={(e) =>
setOptionLegs((draft) => {
draft[i].callPut = e.target.value as "call" | "put";
draft[i].callPut = e.target.value as
| "call"
| "put"
| "underlying";
})
}
>
<option>call</option>
<option>put</option>
<option>underlying</option>
</select>
</div>
<div className="col-2 px-1 px-sm-2 text-center text-sm-start">
Expand Down

0 comments on commit 76f634c

Please sign in to comment.