Skip to content

Bug: _days_to_expiration uses datetime.now() — off-by-one on expiration day #57

Description

@bradsmithmba

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions