Quotes from JSON (Timezones Not Treated As UTC)
See original GitHub issueI’m pulling crypto price quotes from a JSON API. It works, except for one issue: the dates it receives are always “ahead” by a day, thus it’s not actually showing the latest quote - it’s showing the quote from one day prior.
My assumption is that this is an issue of timezone: although the JSON API is providing standard times in UTC, the software seems to be treating them as “local time.” As a result, it thinks the latest quote is one day in the future, and instead displays yesterday’s quote for today.
I’ve experienced this issue with 3 different JSON APIs, so it definitely seems to be on the side of PP. It’s true whether the API returns the timestamp as a string (i.e. “2021-02-26T06:19:00Z”) or epoch (i.e. “1614297600”).
Here’s an example of an API you can try as-is, without needing a key:
URL: https://min-api.cryptocompare.com/data/v2/histoday?fsym=EWT&tsym=USD&limit=5
Path To Date: $.Data.Data[*].time
Path To Close: $.Data.Data[*].close
My local system is in Pacific Standard Time. The chart at the bottom of the “Historical Quotes” dialog shows all the correct quotes - but the latest quote is shown as tomorrow’s date, and the quote actually used by the software is always one day behind (aka the second quote in the list).
Issue Analytics
- State:
- Created 3 years ago
- Comments:31 (28 by maintainers)
I figured out a way to workaround this (on Linux), if/until it gets fixed. If you launch it like:
You’ll fool it into running as UTC timezone, & then quotes & amounts will show the proper values.
That is an argument. I have now merged your short-term fix. I have slightly edited the change to a) only apply to the latest prices (in order to not the move the historical prices by a date) and b) avoid that the resulting list has two prices for the same date
I believe the short-term fix should not change the behavior for Australian users. You are (just as I am) before UTC. On the date boundary, it moves only the latest quote up by one day (that will be overwritten in later updates with the end of day closing).
For the long term fix outlined above, I need more time (also to get the storage format right).