finvader 0.1.0

Finance-aware sentiment analysis for Rust — VADER extended with a financial lexicon, phrase rules, and catalyst detection for news headlines and market text
Documentation
//! Financial word valences, neutral overrides, negations and boosters.
//!
//! Valences use VADER's -4.0..=4.0 scale. The word lists are original to
//! this crate (MIT licensed), informed by the category structure of the
//! Loughran-McDonald financial sentiment research: general-purpose
//! sentiment dictionaries misread a large share of financial vocabulary,
//! so finance terms need their own valences.

/// Single-word valences for financial news text.
pub const WORDS: &[(&str, f64)] = &[
    // earnings & estimates
    ("beat", 2.4),
    ("beats", 2.4),
    ("blowout", 3.2),
    ("exceeded", 2.2),
    ("exceeds", 2.0),
    ("topped", 2.2),
    ("tops", 1.8),
    ("miss", -2.4),
    ("misses", -2.4),
    ("missed", -2.4),
    ("shortfall", -2.2),
    // analyst actions
    ("upgrade", 2.2),
    ("upgraded", 2.2),
    ("upgrades", 2.0),
    ("downgrade", -2.2),
    ("downgraded", -2.2),
    ("downgrades", -2.0),
    // growth & momentum
    ("accelerating", 2.2),
    ("accelerates", 2.0),
    ("acceleration", 2.2),
    ("decelerating", -2.0),
    ("decelerates", -1.8),
    ("deceleration", -2.0),
    ("slowdown", -1.8),
    ("slowing", -1.4),
    ("growth", 1.2),
    ("growing", 1.2),
    ("grew", 1.2),
    ("doubled", 2.2),
    ("tripled", 2.6),
    ("momentum", 1.4),
    ("expansion", 1.4),
    ("rebound", 1.6),
    ("rebounded", 1.8),
    ("recovery", 1.4),
    ("recovering", 1.2),
    ("turnaround", 1.6),
    // price action
    ("surged", 2.6),
    ("surges", 2.6),
    ("surge", 2.2),
    ("soared", 2.8),
    ("soars", 2.8),
    ("jumped", 2.0),
    ("jumps", 2.0),
    ("rallied", 2.0),
    ("rallies", 1.8),
    ("rally", 1.8),
    ("climbed", 1.6),
    ("climbs", 1.4),
    ("rose", 1.4),
    ("rises", 1.4),
    ("gained", 1.4),
    ("gains", 1.2),
    ("breakout", 2.0),
    ("plunge", -2.8),
    ("plunged", -2.8),
    ("plunges", -2.8),
    ("plummeted", -3.0),
    ("plummets", -3.0),
    ("tumbled", -2.4),
    ("tumbles", -2.4),
    ("sank", -2.2),
    ("sinks", -2.0),
    ("slump", -2.0),
    ("slumped", -2.2),
    ("slumps", -2.0),
    ("slid", -1.6),
    ("slide", -1.6),
    ("fell", -1.4),
    ("falling", -1.2),
    ("declined", -1.4),
    ("declines", -1.4),
    ("decline", -1.4),
    ("dropped", -1.4),
    ("drops", -1.4),
    ("selloff", -2.0),
    ("sell-off", -2.0),
    // quality of business
    ("profitable", 1.6),
    ("profitability", 1.4),
    ("unprofitable", -2.0),
    ("robust", 1.6),
    ("resilient", 1.4),
    ("bullish", 2.2),
    ("bearish", -2.2),
    ("optimistic", 1.6),
    ("pessimistic", -1.6),
    ("undervalued", 1.6),
    ("overvalued", -1.6),
    ("tailwind", 1.6),
    ("tailwinds", 1.6),
    ("headwind", -1.6),
    ("headwinds", -1.6),
    ("weak", -1.6),
    ("weakness", -1.6),
    ("weakening", -1.8),
    ("weakens", -1.8),
    ("bookings", 0.8),
    ("buys", 1.0),
    ("purchase", 0.6),
    // capital returns & structure
    ("buyback", 1.8),
    ("buybacks", 1.8),
    ("repurchase", 1.6),
    ("oversubscribed", 2.0),
    ("dilution", -1.8),
    ("dilutive", -1.8),
    ("raises", 1.2),
    // corporate distress & legal
    ("warning", -1.8),
    ("warned", -1.8),
    ("warns", -1.8),
    ("layoffs", -1.4),
    ("layoff", -1.4),
    ("restructuring", -0.8),
    ("impairment", -2.4),
    ("writedown", -2.4),
    ("write-down", -2.4),
    ("writeoff", -2.2),
    ("write-off", -2.2),
    ("restatement", -3.0),
    ("restated", -2.6),
    ("investigation", -2.6),
    ("investigating", -2.2),
    ("probe", -2.4),
    ("subpoena", -2.8),
    ("lawsuit", -1.8),
    ("litigation", -1.8),
    ("sued", -1.8),
    ("fraud", -3.6),
    ("fraudulent", -3.6),
    ("bankruptcy", -3.8),
    ("bankrupt", -3.8),
    ("insolvency", -3.4),
    ("insolvent", -3.4),
    ("default", -3.0),
    ("defaulted", -3.0),
    ("delisting", -3.4),
    ("delisted", -3.4),
    ("scandal", -2.8),
    ("recall", -2.0),
    ("recalls", -2.0),
    ("recalled", -2.0),
    ("breach", -2.2),
    ("hacked", -2.2),
    ("halted", -1.8),
    ("halt", -1.4),
    ("suspended", -2.0),
    ("suspends", -2.0),
    ("resigns", -1.2),
    ("resigned", -1.2),
    ("resignation", -1.4),
    ("failure", -2.0),
    ("concerns", -1.0),
    ("delays", -1.4),
    ("delayed", -1.4),
    ("delay", -1.2),
    ("cancellation", -1.8),
    ("canceled", -1.6),
    ("cancelled", -1.6),
    ("terminates", -1.6),
    ("terminated", -1.6),
    // supply / demand / macro
    ("oversupply", -1.6),
    ("glut", -1.8),
    ("churn", -1.2),
    ("attrition", -1.2),
    ("downturn", -1.8),
    ("recession", -2.2),
    ("contraction", -1.6),
    ("bubble", -1.6),
    ("correction", -1.2),
    ("volatile", -0.6),
    ("volatility", -0.5),
    ("uncertain", -0.8),
    ("uncertainty", -0.8),
    ("losses", -1.6),
    ("loss", -1.4),
    // approvals & milestones
    ("approval", 1.8),
    ("approved", 1.8),
    ("approves", 1.8),
    ("clearance", 1.4),
    ("milestone", 1.4),
    ("wins", 1.2),
    ("hiring", 1.2),
];

/// Words that generic sentiment dictionaries score as emotional but are
/// neutral (or context-dependent) in finance. They are masked before the
/// base VADER pass so it does not misfire on them.
///
/// Classic examples: "gross" (gross margin), "cancer" (oncology pipeline),
/// "debt" (routine financing), "crude" (crude oil), "vice" (vice president).
pub const NEUTRAL_OVERRIDES: &[&str] = &[
    "gross",
    "share",
    "shares",
    "debt",
    "liability",
    "liabilities",
    "tax",
    "taxes",
    "cancer",
    "tumor",
    "disease",
    "crude",
    "vice",
    "arms",
];

/// Negation words. When one appears within three tokens before a matched
/// term, the term's valence is flipped and damped (VADER's negation rule).
pub const NEGATIONS: &[&str] = &[
    "not",
    "no",
    "never",
    "without",
    "failed",
    "fails",
    "fail",
    "unable",
    "lacks",
    "denied",
    "denies",
    "cannot",
    "didn't",
    "doesn't",
    "isn't",
    "wasn't",
    "won't",
    "don't",
    "couldn't",
    "can't",
    "aren't",
    "hasn't",
    "haven't",
    "wouldn't",
    "shouldn't",
];

/// Intensity boosters that amplify the following term.
pub const BOOSTERS_UP: &[&str] = &[
    "significantly",
    "sharply",
    "substantially",
    "massively",
    "dramatically",
    "strongly",
    "hugely",
    "materially",
];

/// Dampeners that soften the following term.
pub const BOOSTERS_DOWN: &[&str] = &["slightly", "modestly", "marginally", "somewhat", "mildly"];