add options rules

This commit is contained in:
MuslemRahimi 2024-12-30 23:45:51 +01:00
parent 2b3846a8c1
commit b4d555526a
3 changed files with 84 additions and 6 deletions

View File

@ -108,7 +108,7 @@ export const computeGrowthSingleList = (data, actualList) => {
export const groupScreenerRules = (allRows) => { export const groupScreenerRules = (allRows) => {
const categoryOrder = [ const categoryOrder = [
"Most Popular", "Company Info","Price & Volume", "Valuation & Ratios", "Valuation & Price Targets", "Margins", "Most Popular", "Company Info","Price & Volume", "Options Activity","Valuation & Ratios", "Valuation & Price Targets", "Margins",
"Performance","Technical Analysis","Forecasts, Analysts & Price Targets", "Dividends", "Revenue / Sales", "Net Income", "Other Profits","Cash Flow", "Debt", "Shares Statistics", "Short Selling Statistics", "Others" "Performance","Technical Analysis","Forecasts, Analysts & Price Targets", "Dividends", "Revenue / Sales", "Net Income", "Other Profits","Cash Flow", "Debt", "Shares Statistics", "Short Selling Statistics", "Others"
]; ];

View File

@ -1371,6 +1371,76 @@
defaultValue: "any", defaultValue: "any",
category: "Company Info", category: "Company Info",
}, },
gexRatio: {
label: "Gex Ratio",
step: [20, 10, 5, 3, 1, 0.5, 0],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
ivRank: {
label: "IV Rank",
step: [50, 30, 20, 10, 5, 1, 0],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
iv30d: {
label: "IV 30d",
step: [1, 0.5, 0.3, 0.1, 0],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
totalOI: {
label: "Total OI",
step: ["500K", "300K", "200K", "100K", "50K", "10K", "1K"],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
changeOI: {
label: "Change OI",
step: ["5K", "3K", "1K", "500", "300", "100"],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
netCallPrem: {
label: "Net Call Prem",
step: ["1M", "500K", "100K", "50K", "-50K", "-100K", "-500K", "-1M"],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
netPutPrem: {
label: "Net Put Prem",
step: ["1M", "500K", "100K", "50K", "-50K", "-100K", "-500K", "-1M"],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
callVolume: {
label: "Call Volume",
step: ["100K", "50K", "20K", "10K", "5K", "1K"],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
putVolume: {
label: "Put Volume",
step: ["100K", "50K", "20K", "10K", "5K", "1K"],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
pcRatio: {
label: "P/C Ratio",
step: [10, 5, 3, 2, 1, 0.5],
defaultCondition: "over",
defaultValue: "any",
category: "Options Activity",
},
}; };
let filteredData = []; let filteredData = [];
@ -1602,6 +1672,16 @@
if ( if (
data?.user?.tier !== "Pro" && data?.user?.tier !== "Pro" &&
[ [
"gexRatio",
"ivRank",
"iv30d",
"totalOI",
"changeOI",
"netCallPrem",
"netPutPrem",
"callVolume",
"putVolume",
"pcRatio",
"topAnalystRating", "topAnalystRating",
"topAnalystCounter", "topAnalystCounter",
"topAnalystPriceTarget", "topAnalystPriceTarget",
@ -3602,7 +3682,7 @@ const handleKeyDown = (event) => {
<div <div
class="flex w-full items-center space-x-1.5 py-1.5 md:w-1/2 lg:w-1/3 lg:py-1" class="flex w-full items-center space-x-1.5 py-1.5 md:w-1/2 lg:w-1/3 lg:py-1"
> >
{#if ["topAnalystRating", "topAnalystCounter", "topAnalystPriceTarget", "topAnalystUpside", "score"]?.includes(row?.rule) && data?.user?.tier !== "Pro"} {#if ["gexRatio", "ivRank", "iv30d", "totalOI", "changeOI", "netCallPrem", "netPutPrem", "callVolume", "putVolume", "pcRatio", "topAnalystRating", "topAnalystCounter", "topAnalystPriceTarget", "topAnalystUpside", "score"]?.includes(row?.rule) && data?.user?.tier !== "Pro"}
<label id={row?.rule} on:click={() => changeRule(row?.rule)}> <label id={row?.rule} on:click={() => changeRule(row?.rule)}>
<svg <svg
class="w-4 h-4 mb-1 inline-block text-[#A3A3A3] sm:hover:text-white cursor-pointer" class="w-4 h-4 mb-1 inline-block text-[#A3A3A3] sm:hover:text-white cursor-pointer"

View File

@ -84,8 +84,7 @@ function convertUnitToValue(input: string | number | string[]) {
// Handle units (B, M, K) // Handle units (B, M, K)
const units = { B: 1_000_000_000, M: 1_000_000, K: 1_000 }; const units = { B: 1_000_000_000, M: 1_000_000, K: 1_000 };
const match = input.match(/^(\d+(\.\d+)?)([BMK])?$/); const match = input.match(/^(-?\d+(\.\d+)?)([BMK])?$/); // Allow optional '-' at the beginning
if (match) { if (match) {
const value = parseFloat(match[1]); const value = parseFloat(match[1]);
const unit = match[3] as keyof typeof units; const unit = match[3] as keyof typeof units;
@ -171,12 +170,11 @@ function createRuleCheck(rule, ruleName, ruleValue) {
// Default numeric comparisons // Default numeric comparisons
return (item) => { return (item) => {
const itemValue = item[rule.name]; const itemValue = item[rule.name];
if (itemValue === null) return false; if (itemValue === null) return false;
if (rule.condition === 'exactly' && itemValue !== ruleValue) return false; if (rule.condition === 'exactly' && itemValue !== ruleValue) return false;
if (rule.condition === 'over' && itemValue <= ruleValue) return false; if (rule.condition === 'over' && itemValue <= ruleValue) return false;
if (rule.condition === 'under' && itemValue >= ruleValue) return false; if (rule.condition === 'under' && itemValue > ruleValue) return false;