Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: start-date parsing in market_data.py #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

reallyrehan
Copy link

Fixes #40

@virattt
Copy link
Owner

virattt commented Dec 31, 2024

Thanks @reallyrehan

I think we can achieve this using relativedelta, as well, yeah?

from datetime import datetime
from dateutil.relativedelta import relativedelta

if not data["start_date"]:
    end_date_obj = datetime.strptime(end_date, "%Y-%m-%d")
    start_date_obj = end_date_obj - relativedelta(months=3)
    data["start_date"] = start_date_obj.strftime("%Y-%m-%d")

@reallyrehan
Copy link
Author

@virattt Originally, I used relativedelta, but realised dateutil doesn't come packaged as default with python - so calendar would be a better option to not add an additional package requirement

The relativedelta code is indeed much cleaner though! What would you suggest?

@virattt
Copy link
Owner

virattt commented Jan 2, 2025

I think the relativedelta 3-line change is cleaner @reallyrehan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception for Specific Dates
2 participants