Summary
datetime.strptime(expiration, '%Y-%m-%d') produces midnight of the expiration date. datetime.now() includes the current time of day. At 3pm on expiration day, (midnight - 3pm).days == -1, triggering the days <= 0 early return in _calculate_probability_above and incorrectly excluding valid options from the expiration filter.
Evidence
src/api/enhanced_strategy_recommender.py lines 587-589:
exp_date = datetime.strptime(expiration, '%Y-%m-%d')
return (exp_date - datetime.now()).days
Fix
return (exp_date.date() - datetime.now().date()).days
Comparing dates (not datetimes) gives the correct calendar-day count.
Summary
datetime.strptime(expiration, '%Y-%m-%d')produces midnight of the expiration date.datetime.now()includes the current time of day. At 3pm on expiration day,(midnight - 3pm).days == -1, triggering thedays <= 0early return in_calculate_probability_aboveand incorrectly excluding valid options from the expiration filter.Evidence
src/api/enhanced_strategy_recommender.pylines 587-589:Fix
Comparing dates (not datetimes) gives the correct calendar-day count.