# Financial advice and investment guidance detection
#
# Uses conditional matching: blocks when a financial IDENTIFIER word
# appears in the same sentence as an ACTION word (e.g., "stock" + "buy").
# Also blocks always-block phrases unconditionally.
#
# This avoids false positives like "in stock" or "bond with my team"
# because those sentences don't contain an action word.
#
# Eval results (207-case investment eval set — block_investment.jsonl):
#   Precision: 100%, Recall: 100%, F1: 100%, Latency: <0.1ms
#   Run: pytest litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/test_eval.py -k InvestmentContentFilter -v -s
category_name: "denied_financial_advice"
display_name: "Denied Financial / Investment Advice"
description: "Detects requests for personalized financial advice, investment recommendations, or financial planning that should be provided by licensed financial advisors"
default_action: "BLOCK"

# Identifier words — financial terms that signal the TOPIC.
# A message is only blocked if the same sentence also contains a block word.
identifier_words:
  # Stocks & equities
  - "stock"
  - "stocks"
  - "equity"
  - "equities"
  - "shares"
  - "ticker"
  - "nasdaq"
  - "dow jones"
  - "s&p 500"
  - "nyse"
  - "ftse"
  - "nikkei"
  - "dax"
  - "sensex"
  - "blue chip"
  - "penny stocks"
  - "securities"
  # Bonds & fixed income
  - "bond"
  - "bonds"
  - "treasury"
  - "fixed income"
  # Funds
  - "mutual fund"
  - "etf"
  - "index fund"
  - "hedge fund"
  - "funds"
  # Crypto
  - "crypto"
  - "cryptocurrency"
  - "bitcoin"
  - "ethereum"
  - "blockchain"
  # Portfolio & accounts
  - "portfolio"
  - "portfolios"
  - "brokerage"
  - "trading"
  - "forex"
  - "day trading"
  - "options trading"
  - "futures trading"
  - "commodities"
  - "short selling"
  - "derivatives"
  # Financial metrics
  - "dividend"
  - "capital gains"
  - "ipo"
  - "reit"
  - "market cap"
  - "market capitalization"
  # Retirement accounts
  - "401k"
  - "ira"
  - "roth"
  - "pension"
  - "annuity"
  # Advisors & brokerages
  - "financial advisor"
  - "financial planner"
  - "wealth management"
  - "robo-advisor"
  - "vanguard"
  - "fidelity"
  - "schwab"
  - "robinhood"
  # Investment variants (stemming)
  - "invest"
  - "investing"
  - "investment"
  - "investments"
  - "investors"
  # Commodities
  - "gold"
  - "silver"
  - "commodity"
  # Savings & wealth (financial context)
  - "savings account"
  - "money market"
  - "compound interest"
  # Other financial
  - "capital markets"
  - "passive income"

# Block words — ACTION words that combined with an identifier = block.
# These are only checked when an identifier is found in the same sentence.
additional_block_words:
  - "buy"
  - "sell"
  - "purchase"
  - "price"
  - "value"
  - "worth"
  - "return"
  - "returns"
  - "profit"
  - "loss"
  - "gain"
  - "performance"
  - "performing"
  - "recommend"
  - "advice"
  - "should i"
  - "should"
  - "tell me"
  - "best"
  - "top"
  - "good"
  - "how to"
  - "how do"
  - "how does"
  - "strategy"
  - "explain"
  - "what are"
  - "what is"
  - "forecast"
  - "prediction"
  - "outlook"
  - "analysis"
  - "compare"
  - "comparing"
  - "risk"
  - "grow"
  - "allocate"
  - "diversify"
  - "yield"
  - "ratio"
  - "this year"
  - "right now"
  - "good time"
  - "safe"
  - "safest"
  - "start"
  - "open"
  - "work"
  - "enter"
  - "follow"
  - "suggested"
  - "thinking"
  - "looking"
  - "look like"
  - "latest"
  - "trends"
  - "crash"
  - "read"
  - "chart"
  - "today"
  - "difference"
  - "apps"
  - "app"
  - "better"
  - "vs"
  - "protect"
  - "inflation"
  - "opportunity"
  - "opportunities"
  - "tips"
  - "rate"
  - "current"

# Always-block keywords — phrases that are ALWAYS blocked regardless of context.
# These are specific enough to not need a second action word.
always_block_keywords:
  - keyword: "should i invest"
    severity: "high"
  - keyword: "investment advice"
    severity: "high"
  - keyword: "financial advice"
    severity: "high"
  - keyword: "how to invest"
    severity: "high"
  - keyword: "how to trade"
    severity: "high"
  - keyword: "stock tips"
    severity: "high"
  - keyword: "trading tips"
    severity: "high"
  - keyword: "best stocks to buy"
    severity: "high"
  - keyword: "best crypto to buy"
    severity: "high"
  - keyword: "best etf"
    severity: "high"
  - keyword: "best mutual fund"
    severity: "high"
  - keyword: "best index fund"
    severity: "high"
  - keyword: "market prediction"
    severity: "high"
  - keyword: "stock market forecast"
    severity: "high"
  - keyword: "retirement planning"
    severity: "high"
  - keyword: "grow my wealth"
    severity: "high"
  - keyword: "build wealth"
    severity: "high"
  - keyword: "is bitcoin a good investment"
    severity: "high"
  - keyword: "is gold a safe investment"
    severity: "high"
  - keyword: "is real estate a good investment"
    severity: "high"
  - keyword: "emerging markets"
    severity: "high"
  - keyword: "pe ratio"
    severity: "high"
  # Market-specific phrases (avoids FP on "farmer's market")
  - keyword: "market trends"
    severity: "high"
  - keyword: "enter the market"
    severity: "high"
  - keyword: "market going to"
    severity: "high"
  - keyword: "market crash"
    severity: "high"
  - keyword: "market cap"
    severity: "high"
  # Retirement & savings placement
  - keyword: "retirement savings"
    severity: "high"
  - keyword: "compound interest"
    severity: "high"
  # Wealth & income
  - keyword: "passive income"
    severity: "high"
  - keyword: "protect my wealth"
    severity: "high"
  # Specific financial products
  - keyword: "dollar cost averaging"
    severity: "high"
  - keyword: "crypto wallet"
    severity: "high"
  - keyword: "money market"
    severity: "high"
  - keyword: "savings rate"
    severity: "high"

# Phrase patterns — regex patterns for catching paraphrased financial advice requests.
# These catch cases where users ask for investment advice without using explicit
# financial terms (e.g., "put my money to make it grow").
phrase_patterns:
  - '\b(?:put|park|place|keep|stash)\b.{0,30}\b(?:money|cash|savings)\b'
  - '\b(?:grow|build|increase|protect)\b.{0,20}\b(?:wealth|nest egg)\b'
  - '\b(?:make|get)\b.{0,20}\b(?:money|savings|cash)\b.{0,20}\b(?:grow|work|harder)\b'
  - '\b(?:what|smartest|best)\b.{0,30}\b(?:do with|thing to do)\b.{0,20}(?:\b(?:money|cash)\b|\$\d)'
  - '\b(?:spare|extra)\b.{0,10}\b(?:cash|money)\b'
  - '\bbest way to\b.{0,15}\b(?:grow|invest|build)\b'
  - '\b(?:good|safe|safest|best)\s+place\b.{0,25}\b(?:savings|money|retirement)\b'

# Keywords — empty because we use conditional matching (identifier + block word)
# instead of single-keyword blocking. This prevents false positives like
# "stock" matching in "Is this item in stock?"
keywords: []

# Exceptions — phrases that override a conditional match in the sentence they appear in.
# These prevent false positives from financial words used in non-financial contexts.
exceptions:
  # Inventory / logistics
  - "in stock"
  - "stock up"
  - "stock room"
  - "stock inventory"
  # Metaphorical usage
  - "invest time"
  - "invest effort"
  - "invest energy"
  - "invested in learning"
  - "invested in a good"
  # Product returns
  - "return policy"
  - "return this item"
  - "return the item"
  - "return trip"
  # Sharing
  - "share the document"
  - "share with me"
  - "share your"
  # Options (non-financial)
  - "options menu"
  - "options are available"
  # Bonding
  - "bond with"
  - "bonding"
  # Gold (idiom)
  - "gold standard"
  - "golden rule"
  - "gold medal"
  # Access
  - "gain access"
  - "gained access"
  # Data
  - "loss of data"
  - "loss prevention"
  # Trading cards
  - "trading card"
  # Negation
  - "not interested in investing"
  # Non-financial portfolio
  - "portfolio of work"
  # Tech tokens
  - "token-based"
  # Road signs
  - "yield sign"
  - "yield fare"
  # Sports
  - "returns on my serve"
  # Logistics
  - "futures schedule"
  # Travel
  - "save my booking"
  - "travel insurance"
  - "diversify my skill"
  - "grow my career"
  - "grow my travel"
  - "build my itinerary"
  - "spend my layover"
  - "earn more skywards"
  - "earn miles"
  - "the market end"
  - "market was busy"
  - "award tickets"
  # Airlines (prevent "ira" substring matching inside "Emirates" etc.)
  - "emirates flight"
  - "emirates airline"
  - "emirates skywards"
  - "emirates app"
  - "check in online"
