dpguthrie / dpguthrie/yahooquery
BUG: Ticker.formatted=False formats some dates as strings
- Dominant language
- Python
- Stars
- 920
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Documentation indicates that using `Ticker(format=False)` or `Ticker.formatted = False` provides raw data. However, some timestamps are formatted into strings instead of being provided as raw data.
**To Reproduce**
Steps to reproduce the behavior:
```python
import yahooquery
stock = 'ZM'
yqt = yahooquery.Ticker([stock], format=False)
price_data = yqt.price
for key in ['regularMarketTime', 'postMarketTime', 'preMarketTime']:
if key in price_data[stock]:
print(f"{key: <17s} is type {type(price_data[stock][key])} with value: {price_data[stock][key]}")
```
Output of the above code:
```
regularMarketTime is type value: 2021-07-26 14:00:02
postMarketTime is type value: 1627331433
preMarketTime is type value: 2021-07-26 07:29:58
```
_(Note that sometimes one of the above timestmaps will be missing, which appears to be a normal effect of the yahoo api and not related to this library.)_
**Expected behavior**
I would expect that with `formatted=False`, all timestamps are `int` data types (raw data) not a mixture of `int` (raw) and `str` (formatted) data.
A string timestamp is useful for display (formatted data), but is useless for python code examining date-time values. An integer timestamp is expected in this case, as it can be utilized directly or easily converted into a python datetime or pandas Timestamp object. The fact that some dates remain integers while other dates are formatted as strings makes this bug particularly irritating to work with.
The formatted strings are particularly irritating because they have been converted into the local timezone, not a timezone representative of the market in question or UTC.
**Environment**
- OS: MacOS BigSur (11.2.1)
- Python: 3.9.5
- yahooquery: 2.2.15
**Addional Context**
URL generated for the above example of this bug:
```
https://query2.finance.yahoo.com/v10/finance/quoteSummary/ZM?modules=price&formatted=false&lang=en-US®ion=US&corsDomain=finance.yahoo.com
```
Note that all time values in the above URL are integer values.
Contributor guide
Assessment
This issue has not been assessed yet.