{"record":{"id":"98deffdcafdf7b55","repo":"HKUDS/Vibe-Trading","slug":"comps-flowmetricperiods-fiscal-year-end-month-mus","errorCode":null,"errorMessage":"comps.FlowMetricPeriods: fiscal_year_end_month must be 1-12, got {self.fiscal_year_end_month!r}","messagePattern":"comps\\.FlowMetricPeriods: fiscal_year_end_month must be 1-12, got (.+?)","errorType":"exception","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/comps.py","lineNumber":205,"sourceCode":"            `last_full_fiscal_year` (ending one calendar year later).\n            Required for the `\"calendar_year\"` policy whenever\n            `fiscal_year_end_month != 12` -- a December fiscal year end needs\n            no second year, because month-weighting already resolves to 100%\n            of `last_full_fiscal_year`.\n\n    Raises:\n        ValuationError: If `fiscal_year_end_month` is not in 1..12.\n    \"\"\"\n\n    fiscal_year_end_month: int\n    last_full_fiscal_year: float\n    current_year_to_date: float | None = None\n    prior_year_to_date: float | None = None\n    next_full_fiscal_year: float | None = None\n\n    def __post_init__(self) -> None:\n        if not 1 <= int(self.fiscal_year_end_month) <= 12:\n            raise ValuationError(\n                \"comps.FlowMetricPeriods: fiscal_year_end_month must be 1-12, \"\n                f\"got {self.fiscal_year_end_month!r}\"\n            )\n\n\n@dataclass(frozen=True)\nclass CalendarisedMetric:\n    \"\"\"One flow metric after fiscal-calendar alignment.\n\n    Attributes:\n        policy: Which convention produced `value` -- `\"ltm\"` or\n            `\"calendar_year\"`.\n        value: The aligned metric value.\n        fiscal_year_end_month: Carried through from the input, for audit.\n        weights: For `\"calendar_year\"`, the `(early_fy_weight,\n            late_fy_weight)` used to blend the two fiscal years. `None` for\n            `\"ltm\"`, which has no month-weighting step.\n    \"\"\"","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/comps.py#L187-L223","documentation":"FlowMetricPeriods validates that fiscal_year_end_month is an integer-like value between 1 and 12 (January..December). Out-of-range values (0, 13, 'FY') raise a ValuationError because calendarisation weights depend on a real month.","triggerScenarios":"FlowMetricPeriods(fiscal_year_end_month=0 or 13); a typo like month=12 but off-by-one code yielding 0; strings like 'Dec' that fail int() or compare out of range.","commonSituations":"Parsing fiscal year end from filings ('FYE: March') without month-name mapping; config files with 0-based months; user input of month names instead of numbers.","solutions":["Use the numeric month 1-12 (March = 3, December = 12).","Map month names via a lookup (e.g. datetime.strptime(s, '%B').month) before constructing.","Reject 0-based month values at config load."],"exampleFix":"# before\nFlowMetricPeriods(fiscal_year_end_month=0, ...)  # 0-based bug\n# after\nFlowMetricPeriods(fiscal_year_end_month=1, ...)  # January in 1-based","handlingStrategy":"validation","validationCode":"if not 1 <= int(fiscal_year_end_month) <= 12:\n    raise ValueError(f\"fiscal_year_end_month must be 1-12, got {fiscal_year_end_month!r}\")","typeGuard":"def is_valid_month(m) -> bool:\n    try:\n        return 1 <= int(m) <= 12\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":null,"preventionTips":["Use 1-based months everywhere; map month names via strptime('%B').month.","Validate fiscal-year-end config once at load time."],"tags":["python","comps","fiscal-calendar","validation"],"backgroundTag":"month-out-of-range","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}