#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Catalyst {
pub pattern: &'static str,
pub bullish: bool,
}
const PATTERNS: &[(&str, bool)] = &[
("fda approval", true),
("fda approves", true),
("fda approved", true),
("fda clearance", true),
("breakthrough therapy", true),
("met primary endpoint", true),
("missed primary endpoint", false),
("failed primary endpoint", false),
("complete response letter", false),
("fda rejects", false),
("fda rejection", false),
("to be acquired", true),
("buyout offer", true),
("takeover bid", true),
("merger agreement", true),
("strategic partnership", true),
("added to s&p", true),
("joins s&p", true),
("s&p 500 inclusion", true),
("index inclusion", true),
("removed from s&p", false),
("government contract", true),
("defense contract", true),
("contract award", true),
("awarded contract", true),
("record quarter", true),
("record revenue", true),
("beat and raise", true),
("chapter 11", false),
("chapter 7", false),
("going concern", false),
("sec charges", false),
("accounting fraud", false),
("auditor resigns", false),
];
const CO_OCCURRENCE: &[(&str, &str, bool)] = &[
("awarded", "contract", true),
("wins", "contract", true),
("won", "contract", true),
];
pub(crate) fn detect(padded_norm: &str) -> Option<Catalyst> {
for &(pattern, bullish) in PATTERNS {
if padded_norm.contains(&format!(" {pattern} ")) {
return Some(Catalyst { pattern, bullish });
}
}
for &(a, b, bullish) in CO_OCCURRENCE {
if padded_norm.contains(&format!(" {a} ")) && padded_norm.contains(&format!(" {b} ")) {
return Some(Catalyst {
pattern: a,
bullish,
});
}
}
None
}