alvarobartt / investiny

🤏🏻 `investpy` but made tiny
https://alvarobartt.github.io/investiny
MIT License
316 stars 36 forks source link

Date format #30

Closed GSLabIt closed 2 years ago

GSLabIt commented 2 years ago

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

ramakrishnamekala129 commented 2 years ago

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

GSLabIt commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Could you at least change:

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

InnovArul commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

InnovArul commented 2 years ago

@alvarobartt thats awesome. thanks! :)

alvarobartt commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@GSLabIt let me think about that! 👍🏻

alvarobartt commented 2 years ago

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