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

Date format #30

Closed
GSLabIt opened this issue Oct 10, 2022 · 14 comments
Closed

Date format #30

GSLabIt opened this issue Oct 10, 2022 · 14 comments
Assignees
Labels
improvement Something has been improved

Comments

@GSLabIt
Copy link

GSLabIt commented Oct 10, 2022

Any chance to use yyyy-mm-dd date format instead of m/d/Y?

@ramakrishnamekala129
Copy link

no but u can convert it by d.strftime('%m/%d/%Y') d for dateformat

@GSLabIt
Copy link
Author

GSLabIt commented Oct 10, 2022

no but u can convert it by d.strftime('%m/%d/%Y') d for dateformat

well ok ..but yyyy-mm-dd is widely used ..btw ..thx anyway

@GSLabIt
Copy link
Author

GSLabIt commented Oct 10, 2022

found an issue on same day data, try:

d = historical_data(6408, '09/01/2022', '09/01/2022', "1")

i get an error:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "venv-3/lib/python3.8/site-packages/investiny/historical.py", line 48, in historical_data "date": [datetime.fromtimestamp(t).strftime(time_format) for t in data["t"]], # type: ignore KeyError: 't'

@GSLabIt
Copy link
Author

GSLabIt commented Oct 10, 2022

Could you at least change:

d['date] = [ '13:25 09/01/2022' .....] to [ '09/01/2022 13:25' .....]

@InnovArul
Copy link

InnovArul commented Oct 10, 2022

I had a similar question regarding the date format.
In investpy library, the date format followed was %d/%m/%Y. In investiny library, the date format is changed to %m/%d/%Y.
Would it be possible to maintain consistency?
I think its ok to follow any of these formats. If possible, please maintain the same format in both libraries?

@alvarobartt
Copy link
Owner

Hi @GSLabIt I'm still exploring how to add that functionality, but I'll probably add some environment variables or a configuration file to define all those things (like input formats, output formats, timezone, etc.) so that you set it up once and that's it 👍🏻

@alvarobartt
Copy link
Owner

Hi @InnovArul, sure you're right, I'll probably roll back investiny to use investpy format by default, which is dd/mm/yyyy 👍🏻

@InnovArul
Copy link

@alvarobartt thats awesome. thanks! :)

@alvarobartt alvarobartt self-assigned this Oct 10, 2022
@alvarobartt alvarobartt added the improvement Something has been improved label Oct 10, 2022
@alvarobartt
Copy link
Owner

Indeed I don't know why I picked the %m/%d/%Y when it's probably the most confusing date format ever lol... Now this is a breaking change as some developers are already using investiny as a replacement for investpy, so let me figure out the best way to do it without breaking anything. Thanks! 🤗

@GSLabIt
Copy link
Author

GSLabIt commented Oct 11, 2022

found an issue on same day data, try:

d = historical_data(6408, '09/01/2022', '09/01/2022', "1")

i get an error:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "venv-3/lib/python3.8/site-packages/investiny/historical.py", line 48, in historical_data "date": [datetime.fromtimestamp(t).strftime(time_format) for t in data["t"]], # type: ignore KeyError: 't'

I found the issue.. need to use int when interval is numeric a value.

@alvarobartt
Copy link
Owner

Right @GSLabIt, so the intervals are as it follows: 1, 5, 15, 30, 45, 60, 120, 240, 300, "D", "W", "M", find more details at https://alvarobartt.github.io/investiny

@GSLabIt
Copy link
Author

GSLabIt commented Oct 11, 2022

Right @GSLabIt, so the intervals are as it follows: 1, 5, 15, 30, 45, 60, 120, 240, 300, "D", "W", "M", find more details at https://alvarobartt.github.io/investiny

Could you add a check for interval, kind of if interval = int(interval) if interval.isdigit() else interval. This will avoid issues 😅

@alvarobartt
Copy link
Owner

@GSLabIt let me think about that! 👍🏻

@alvarobartt
Copy link
Owner

Hi again @GSLabIt I've decided to use environment variables at the end, I still need to add the documentation page of this newly included feature, but in the meantime you can set the environment values of INVESTINY_DATE_FORMAT and INVESTINY_TIME_FORMAT to use your preferred format for both the date and the date plus the time, default values are %m/%d/%Y and %m/%d/%y %H/%M, respectively.

To install the current unreleased version please run pip install git+https://github.com/alvarobartt/investiny.git

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

No branches or pull requests

4 participants