Closed GSLabIt closed 2 years ago
no but u can convert it by d.strftime('%m/%d/%Y') d for dateformat
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
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'
Could you at least change:
d['date] = [ '13:25 09/01/2022' .....]
to [ '09/01/2022 13:25' .....]
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?
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 👍🏻
Hi @InnovArul, sure you're right, I'll probably roll back investiny
to use investpy
format by default, which is dd/mm/yyyy
👍🏻
@alvarobartt thats awesome. thanks! :)
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! 🤗
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.
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
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 😅
@GSLabIt let me think about that! 👍🏻
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
Any chance to use
yyyy-mm-dd
date format instead ofm/d/Y
?