|
|
|
@ -16,6 +16,7 @@ import {
|
|
|
|
|
Paper,
|
|
|
|
|
Popper,
|
|
|
|
|
ClickAwayListener,
|
|
|
|
|
Stack,
|
|
|
|
|
} from "@mui/material";
|
|
|
|
|
import {
|
|
|
|
|
availableUnderlyings,
|
|
|
|
@ -38,9 +39,9 @@ import {
|
|
|
|
|
refreshStockPriceChartData,
|
|
|
|
|
} from "./HistoricalCalendarPrices/actions.js";
|
|
|
|
|
import { EditableUnderlying } from "./HistoricalCalendarPrices/EditableUnderlying.js";
|
|
|
|
|
import { EditableDaysToFrontExpiration } from "./HistoricalCalendarPrices/EditableDaysToFrontExpiration.js";
|
|
|
|
|
import { EditableExitToFrontExpiration } from "./HistoricalCalendarPrices/EditableExitToFrontExpiration.js";
|
|
|
|
|
import { EditableDaysBetweenFrontAndBackExpiration } from "./HistoricalCalendarPrices/EditableDaysBetweenFrontAndBackExpiration.js";
|
|
|
|
|
import { EditableOpenDTE } from "./HistoricalCalendarPrices/EditableOpenDTE.js";
|
|
|
|
|
import { EditableExitDTE } from "./HistoricalCalendarPrices/EditableExitDTE.js";
|
|
|
|
|
import { EditableSpan } from "./HistoricalCalendarPrices/EditableSpan.js";
|
|
|
|
|
import { EditableLookbackPeriodStart } from "./HistoricalCalendarPrices/EditableLookbackPeriodStart.js";
|
|
|
|
|
import { EditableLookbackPeriodEnd } from "./HistoricalCalendarPrices/EditableLookbackPeriodEnd.js";
|
|
|
|
|
|
|
|
|
@ -64,16 +65,16 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
return (
|
|
|
|
|
<Container maxWidth="lg">
|
|
|
|
|
<Grid2 container spacing={4} columns={12}>
|
|
|
|
|
<Grid2 size={{ xs: 12 }}>
|
|
|
|
|
{/* <Grid2 size={{ xs: 12 }}>
|
|
|
|
|
|
|
|
|
|
<Typography variant="h4" gutterBottom>
|
|
|
|
|
<EditableUnderlying /> :
|
|
|
|
|
<EditableDaysBetweenFrontAndBackExpiration />
|
|
|
|
|
<EditableSpan />
|
|
|
|
|
-Day Calendar @ <EditableStrike />
|
|
|
|
|
%-from-the-money
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography variant="h5" gutterBottom sx={{ pl: 1 }}>
|
|
|
|
|
Opening at <EditableDaysToFrontExpiration /> DTE, Closing at{" "}
|
|
|
|
|
<EditableExitToFrontExpiration />
|
|
|
|
|
Opening at <EditableOpenDTE /> DTE, Closing at <EditableExitDTE />
|
|
|
|
|
DTE
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography variant="h5" gutterBottom>
|
|
|
|
@ -93,17 +94,65 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
</Paper>
|
|
|
|
|
</Popper>
|
|
|
|
|
</ClickAwayListener>
|
|
|
|
|
</Grid2>
|
|
|
|
|
</Grid2> */}
|
|
|
|
|
|
|
|
|
|
<Grid2 size={{ xs: 12 }}>
|
|
|
|
|
<Paper elevation={3} sx={{ p: 3, minHeight: "28em", height: "100%" }}>
|
|
|
|
|
<Stack direction="row" spacing={2}>
|
|
|
|
|
<Typography gutterBottom minWidth={"8em"}>
|
|
|
|
|
Underlying
|
|
|
|
|
</Typography>
|
|
|
|
|
<EditableUnderlying />
|
|
|
|
|
</Stack>
|
|
|
|
|
<Stack direction="row" spacing={2}>
|
|
|
|
|
<Typography gutterBottom minWidth={"8em"}>
|
|
|
|
|
Open DTE
|
|
|
|
|
</Typography>
|
|
|
|
|
<EditableOpenDTE />
|
|
|
|
|
</Stack>
|
|
|
|
|
<Stack direction="row" spacing={2}>
|
|
|
|
|
<Typography gutterBottom minWidth={"8em"}>
|
|
|
|
|
Exit DTE
|
|
|
|
|
</Typography>
|
|
|
|
|
<EditableExitDTE />
|
|
|
|
|
</Stack>
|
|
|
|
|
<Stack direction="row" spacing={2}>
|
|
|
|
|
<Typography gutterBottom minWidth={"8em"}>
|
|
|
|
|
Span
|
|
|
|
|
</Typography>
|
|
|
|
|
<EditableSpan />
|
|
|
|
|
</Stack>
|
|
|
|
|
<Stack direction="row" spacing={2}>
|
|
|
|
|
<Typography gutterBottom minWidth={"8em"}>
|
|
|
|
|
Lookback Period
|
|
|
|
|
</Typography>
|
|
|
|
|
<EditableLookbackPeriodStart />-
|
|
|
|
|
<EditableLookbackPeriodEnd />
|
|
|
|
|
</Stack>
|
|
|
|
|
<ClickAwayListener
|
|
|
|
|
onClickAway={() => {
|
|
|
|
|
isPopperOpen.value = false;
|
|
|
|
|
// refreshSimilarCalendarPriceChartData();
|
|
|
|
|
console.log("clicked away");
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Popper open={isPopperOpen.value} anchorEl={popperAnchorEl.value}>
|
|
|
|
|
<Paper elevation={3} sx={{ p: 3 }}>
|
|
|
|
|
{popperContent.value}
|
|
|
|
|
</Paper>
|
|
|
|
|
</Popper>
|
|
|
|
|
</ClickAwayListener>
|
|
|
|
|
</Grid2>
|
|
|
|
|
|
|
|
|
|
<Grid2 size={{ xs: 12, md: 6 }}>
|
|
|
|
|
<Paper elevation={3} sx={{ p: 3, minHeight: "28em" }}>
|
|
|
|
|
{underlying.value !== null &&
|
|
|
|
|
stockPriceChartData.value.length > 0 ? (
|
|
|
|
|
similarCalendarPriceChartData.value.length > 0 ? (
|
|
|
|
|
<Scatter
|
|
|
|
|
data={{
|
|
|
|
|
datasets: [
|
|
|
|
|
{
|
|
|
|
|
label: "Stock Open Price",
|
|
|
|
|
data: stockPriceChartData.value,
|
|
|
|
|
label: "Calendar Open Price",
|
|
|
|
|
data: similarCalendarPriceChartData.value,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
|
|
|
@ -124,17 +173,13 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
max: new Date(lookbackPeriodEnd.value).getTime() / 1000,
|
|
|
|
|
},
|
|
|
|
|
y: {
|
|
|
|
|
beginAtZero: false,
|
|
|
|
|
beginAtZero: true,
|
|
|
|
|
ticks: {
|
|
|
|
|
callback: (value, index, ticks) =>
|
|
|
|
|
`$${value.toString()}`,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
elements: {
|
|
|
|
|
point: {
|
|
|
|
|
radius: 1,
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
min: 0,
|
|
|
|
|
max: maxChartPrice.value,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
plugins: {
|
|
|
|
@ -146,7 +191,7 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
display: true,
|
|
|
|
|
text: "Stock Price",
|
|
|
|
|
text: "Calendar Price (Under Like Conditions)",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
animation: false,
|
|
|
|
@ -167,26 +212,24 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
data={{
|
|
|
|
|
datasets: [
|
|
|
|
|
{
|
|
|
|
|
label: "Calendar Open Price",
|
|
|
|
|
data: similarCalendarPriceChartData.value,
|
|
|
|
|
label: "Calendar Exit Price",
|
|
|
|
|
data: calendarExitPriceChartData.value,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
|
|
|
|
options={{
|
|
|
|
|
scales: {
|
|
|
|
|
x: {
|
|
|
|
|
type: "linear",
|
|
|
|
|
beginAtZero: false,
|
|
|
|
|
title: {
|
|
|
|
|
display: true,
|
|
|
|
|
text: "Time",
|
|
|
|
|
text: "%-From-the-Money",
|
|
|
|
|
},
|
|
|
|
|
ticks: {
|
|
|
|
|
callback: (value, index, ticks) =>
|
|
|
|
|
new Date((value as number) * 1000)
|
|
|
|
|
.toISOString()
|
|
|
|
|
.substring(0, 10),
|
|
|
|
|
`${value.toString()}%`,
|
|
|
|
|
},
|
|
|
|
|
min: new Date(lookbackPeriodStart.value).getTime() / 1000,
|
|
|
|
|
max: new Date(lookbackPeriodEnd.value).getTime() / 1000,
|
|
|
|
|
},
|
|
|
|
|
y: {
|
|
|
|
|
beginAtZero: true,
|
|
|
|
@ -198,6 +241,18 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
max: maxChartPrice.value,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
elements: {
|
|
|
|
|
point: {
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
backgroundColor: (context) => {
|
|
|
|
|
const n = (
|
|
|
|
|
context.raw as { x: number; y: number; n: number }
|
|
|
|
|
).n;
|
|
|
|
|
const alpha = n / maxN.value;
|
|
|
|
|
return `rgba(0, 0, 0, ${alpha})`;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
plugins: {
|
|
|
|
|
tooltip: {
|
|
|
|
|
enabled: false,
|
|
|
|
@ -207,7 +262,10 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
display: true,
|
|
|
|
|
text: "Calendar Price (Under Like Conditions)",
|
|
|
|
|
text: [
|
|
|
|
|
"Calendar Prices at Exit",
|
|
|
|
|
"by %-age from-the-money",
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
animation: false,
|
|
|
|
@ -220,53 +278,47 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
)}
|
|
|
|
|
</Paper>
|
|
|
|
|
</Grid2>
|
|
|
|
|
<Grid2 size={{ xs: 12, md: 6 }}>
|
|
|
|
|
<Paper elevation={3} sx={{ p: 3, minHeight: "28em" }}>
|
|
|
|
|
<Grid2 size={{ xs: 12 }}>
|
|
|
|
|
<Paper elevation={3} sx={{ p: 3, minHeight: "28em", height: "100%" }}>
|
|
|
|
|
{underlying.value !== null &&
|
|
|
|
|
similarCalendarPriceChartData.value.length > 0 ? (
|
|
|
|
|
stockPriceChartData.value.length > 0 ? (
|
|
|
|
|
<Scatter
|
|
|
|
|
data={{
|
|
|
|
|
datasets: [
|
|
|
|
|
{
|
|
|
|
|
label: "Calendar Exit Price",
|
|
|
|
|
data: calendarExitPriceChartData.value,
|
|
|
|
|
label: "Stock Open Price",
|
|
|
|
|
data: stockPriceChartData.value,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
|
|
|
|
options={{
|
|
|
|
|
scales: {
|
|
|
|
|
x: {
|
|
|
|
|
type: "linear",
|
|
|
|
|
beginAtZero: false,
|
|
|
|
|
title: {
|
|
|
|
|
display: true,
|
|
|
|
|
text: "%-From-the-Money",
|
|
|
|
|
text: "Time",
|
|
|
|
|
},
|
|
|
|
|
ticks: {
|
|
|
|
|
callback: (value, index, ticks) =>
|
|
|
|
|
`${value.toString()}%`,
|
|
|
|
|
new Date((value as number) * 1000)
|
|
|
|
|
.toISOString()
|
|
|
|
|
.substring(0, 10),
|
|
|
|
|
},
|
|
|
|
|
min: new Date(lookbackPeriodStart.value).getTime() / 1000,
|
|
|
|
|
max: new Date(lookbackPeriodEnd.value).getTime() / 1000,
|
|
|
|
|
},
|
|
|
|
|
y: {
|
|
|
|
|
beginAtZero: true,
|
|
|
|
|
beginAtZero: false,
|
|
|
|
|
ticks: {
|
|
|
|
|
callback: (value, index, ticks) =>
|
|
|
|
|
`$${value.toString()}`,
|
|
|
|
|
},
|
|
|
|
|
min: 0,
|
|
|
|
|
max: maxChartPrice.value,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
elements: {
|
|
|
|
|
point: {
|
|
|
|
|
radius: 1,
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
backgroundColor: (context) => {
|
|
|
|
|
const n = (
|
|
|
|
|
context.raw as { x: number; y: number; n: number }
|
|
|
|
|
).n;
|
|
|
|
|
const alpha = n / maxN.value;
|
|
|
|
|
return `rgba(0, 0, 0, ${alpha})`;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
plugins: {
|
|
|
|
@ -278,10 +330,7 @@ export function HistoricalCalendarPrices() {
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
display: true,
|
|
|
|
|
text: [
|
|
|
|
|
"Calendar Prices at Exit",
|
|
|
|
|
"by %-age from-the-money",
|
|
|
|
|
],
|
|
|
|
|
text: "Stock Price",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
animation: false,
|
|
|
|
|