{"record":{"id":"e0f6cd5d1d28527b","repo":"HKUDS/Vibe-Trading","slug":"unknown-day-count-day-count-r-expected-one-of","errorCode":null,"errorMessage":"unknown day_count {day_count!r}; expected one of {DAY_COUNT_CONVENTIONS}","messagePattern":"unknown day_count (.+?); expected one of (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/fixedincome.py","lineNumber":84,"sourceCode":"    day_count: str = DEFAULT_DAY_COUNT,\n) -> float:\n    \"\"\"Accrual factor between two dates under a named day-count convention.\n\n    Args:\n        start: Period start (accrual runs from this date, inclusive).\n        end: Period end (accrual runs to this date, exclusive).\n        day_count: One of :data:`DAY_COUNT_CONVENTIONS`. ``ACT/ACT`` is the\n            ISDA variant: each calendar year contributes\n            ``days_in_that_year / (365 or 366)``.\n\n    Returns:\n        Year fraction as a float. Negative if ``end`` precedes ``start``.\n\n    Raises:\n        ValueError: If ``day_count`` is not a recognised convention.\n    \"\"\"\n    if day_count not in DAY_COUNT_CONVENTIONS:\n        raise ValueError(\n            f\"unknown day_count {day_count!r}; expected one of {DAY_COUNT_CONVENTIONS}\"\n        )\n\n    if end < start:\n        return -year_fraction(end, start, day_count)\n\n    if day_count == \"ACT/365F\":\n        return (end - start).days / 365.0\n    if day_count == \"ACT/360\":\n        return (end - start).days / 360.0\n    if day_count in (\"30/360\", \"30E/360\"):\n        d1, d2 = start.day, end.day\n        if day_count == \"30/360\":\n            # US bond basis: clip D1 to 30, then clip D2 when adjusted D1 is 30.\n            if d1 == 31:\n                d1 = 30\n            if d2 == 31 and d1 == 30:\n                d2 = 30","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/fixedincome.py#L66-L102","documentation":"year_fraction implements a fixed set of accrual day-count conventions (DAY_COUNT_CONVENTIONS) and rejects anything outside that whitelist, printing the accepted values in the message.","triggerScenarios":"year_fraction(d1, d2, 'act/360') with a slash instead of 'act360', or a value like 'ACT365' with wrong case, or an unsupported convention like 'nl/365'.","commonSituations":"Convention strings parsed from term sheets or config with inconsistent formatting ('30E/360' vs '30e360'); case differences; a convention simply not implemented.","solutions":["Print DAY_COUNT_CONVENTIONS (imported from fixedincome) and match the string exactly","Normalize incoming strings (lowercase, strip separators) via a mapping before calling","If the convention is truly unsupported, implement/fallback outside the API"],"exampleFix":"# before\nyf = year_fraction(d1, d2, 'ACT/360')\n# after\nyf = year_fraction(d1, d2, 'act360')  # exact whitelist spelling","handlingStrategy":"validation","validationCode":"from agent.src.quantlib.fixedincome import DAY_COUNT_CONVENTIONS\nassert day_count in DAY_COUNT_CONVENTIONS, DAY_COUNT_CONVENTIONS","typeGuard":"def is_known_day_count(dc: str, known) -> bool:\n    return dc in known","tryCatchPattern":null,"preventionTips":["Normalize term-sheet conventions through a single mapping function","Validate convention strings at config load, not at computation time"],"tags":["quantlib","fixedincome","day-count","enum-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}