add new filter for options flow page moneyness
This commit is contained in:
parent
48293f38ae
commit
2471ce872a
@ -90,6 +90,11 @@
|
|||||||
defaultCondition: "over",
|
defaultCondition: "over",
|
||||||
defaultValue: "any",
|
defaultValue: "any",
|
||||||
},
|
},
|
||||||
|
moneyness: {
|
||||||
|
label: "Moneyness",
|
||||||
|
step: ["ITM", "OTM"],
|
||||||
|
defaultValue: "any",
|
||||||
|
},
|
||||||
put_call: {
|
put_call: {
|
||||||
label: "Contract Type",
|
label: "Contract Type",
|
||||||
step: ["Calls", "Puts"],
|
step: ["Calls", "Puts"],
|
||||||
@ -212,6 +217,7 @@
|
|||||||
let newRule;
|
let newRule;
|
||||||
|
|
||||||
switch (ruleName) {
|
switch (ruleName) {
|
||||||
|
case "moneyness":
|
||||||
case "put_call":
|
case "put_call":
|
||||||
case "sentiment":
|
case "sentiment":
|
||||||
case "execution_estimate":
|
case "execution_estimate":
|
||||||
@ -343,6 +349,7 @@
|
|||||||
// Specific rule handling for options-related rules
|
// Specific rule handling for options-related rules
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
|
"moneyness",
|
||||||
"put_call",
|
"put_call",
|
||||||
"sentiment",
|
"sentiment",
|
||||||
"execution_estimate",
|
"execution_estimate",
|
||||||
@ -1123,7 +1130,7 @@
|
|||||||
<DropdownMenu.Content
|
<DropdownMenu.Content
|
||||||
class="w-64 min-h-auto max-h-72 overflow-y-auto scroller"
|
class="w-64 min-h-auto max-h-72 overflow-y-auto scroller"
|
||||||
>
|
>
|
||||||
{#if !["put_call", "sentiment", "execution_estimate", "option_activity_type", "underlying_type"]?.includes(row?.rule)}
|
{#if !["moneyness", "put_call", "sentiment", "execution_estimate", "option_activity_type", "underlying_type"]?.includes(row?.rule)}
|
||||||
<DropdownMenu.Label
|
<DropdownMenu.Label
|
||||||
class="absolute mt-2 h-11 border-gray-800 border-b -top-1 z-20 fixed sticky bg-[#09090B]"
|
class="absolute mt-2 h-11 border-gray-800 border-b -top-1 z-20 fixed sticky bg-[#09090B]"
|
||||||
>
|
>
|
||||||
@ -1283,7 +1290,7 @@
|
|||||||
></div>
|
></div>
|
||||||
{/if}
|
{/if}
|
||||||
<DropdownMenu.Group class="min-h-10 mt-2">
|
<DropdownMenu.Group class="min-h-10 mt-2">
|
||||||
{#if !["put_call", "sentiment", "execution_estimate", "option_activity_type", "underlying_type"]?.includes(row?.rule)}
|
{#if !["moneyness", "put_call", "sentiment", "execution_estimate", "option_activity_type", "underlying_type"]?.includes(row?.rule)}
|
||||||
{#each row?.step as newValue, index}
|
{#each row?.step as newValue, index}
|
||||||
{#if ruleCondition[row?.rule] === "between"}
|
{#if ruleCondition[row?.rule] === "between"}
|
||||||
{#if newValue && row?.step[index + 1]}
|
{#if newValue && row?.step[index + 1]}
|
||||||
@ -1327,7 +1334,7 @@
|
|||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{:else if ["put_call", "sentiment", "execution_estimate", "option_activity_type", "underlying_type"]?.includes(row?.rule)}
|
{:else if ["moneyness", "put_call", "sentiment", "execution_estimate", "option_activity_type", "underlying_type"]?.includes(row?.rule)}
|
||||||
{#each row?.step as item}
|
{#each row?.step as item}
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
class="sm:hover:bg-[#2A2E39]"
|
class="sm:hover:bg-[#2A2E39]"
|
||||||
|
|||||||
@ -17,7 +17,7 @@ function convertUnitToValue(
|
|||||||
`Expected a string or number, but received ${typeof input}`,
|
`Expected a string or number, but received ${typeof input}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const lowerInput = input.toLowerCase();
|
const lowerInput = input?.toLowerCase();
|
||||||
const nonNumericValues = new Set([
|
const nonNumericValues = new Set([
|
||||||
"any",
|
"any",
|
||||||
"puts",
|
"puts",
|
||||||
@ -34,6 +34,8 @@ function convertUnitToValue(
|
|||||||
"trade",
|
"trade",
|
||||||
"stock",
|
"stock",
|
||||||
"etf",
|
"etf",
|
||||||
|
"itm",
|
||||||
|
"otm",
|
||||||
]);
|
]);
|
||||||
if (nonNumericValues.has(lowerInput)) return input;
|
if (nonNumericValues.has(lowerInput)) return input;
|
||||||
if (input.endsWith("%")) {
|
if (input.endsWith("%")) {
|
||||||
@ -70,6 +72,29 @@ function createRuleCheck(rule, ruleName, ruleValue) {
|
|||||||
const now = new Date(new Date().toLocaleString("en-US", { timeZone: "America/New_York" }));
|
const now = new Date(new Date().toLocaleString("en-US", { timeZone: "America/New_York" }));
|
||||||
|
|
||||||
|
|
||||||
|
if (ruleName === 'moneyness') {
|
||||||
|
return (item) => {
|
||||||
|
|
||||||
|
if (ruleValue === 'any') return true;
|
||||||
|
|
||||||
|
const currentPrice = parseFloat(item?.underlying_price);
|
||||||
|
const strikePrice = parseFloat(item?.strike_price);
|
||||||
|
const optionType = item?.put_call;
|
||||||
|
if (isNaN(currentPrice) || isNaN(strikePrice)) return false;
|
||||||
|
|
||||||
|
// Determine moneyness
|
||||||
|
let moneyness = '';
|
||||||
|
if (optionType === 'Calls') {
|
||||||
|
moneyness = currentPrice > strikePrice ? 'ITM' : 'OTM';
|
||||||
|
} else if (optionType === 'Puts') {
|
||||||
|
moneyness = currentPrice < strikePrice ? 'ITM' : 'OTM';
|
||||||
|
}
|
||||||
|
// Check if the item matches the ruleValue ('itm' or 'otm')
|
||||||
|
if (!ruleValue?.includes(moneyness)) return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (ruleName === 'volumeoiratio') {
|
if (ruleName === 'volumeoiratio') {
|
||||||
return (item) => {
|
return (item) => {
|
||||||
const volume = parseFloat(item.volume);
|
const volume = parseFloat(item.volume);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user