Skip to content

Ticker seems to be bugged on certain types of input #336

@Sanjurjo7

Description

@Sanjurjo7

Intermittently putting in an array from df.index.levels[0].to_list() causes a problem on the historical prices.

Have a dataframe with the symbols as an index (I have multiindexed to 0: symbol and 1: datetime)

gets = df.index.levels[0].to_list()
gets[0]
'A'
trial = Ticker(gets, asynchronous=True)
data = trial.history(period='4d', interval='1m')
Traceback (most recent call last):
File "", line 1, in
File "/home/sanjurjo/backtesting/.yfin/lib/python3.12/site-packages/yahooquery/ticker.py", line 1285, in history
df = self._historical_data_to_dataframe(data, params, adj_timezone)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sanjurjo/backtesting/.yfin/lib/python3.12/site-packages/yahooquery/ticker.py", line 1312, in _historical_data_to_dataframe
if "timestamp" in data[symbol]:
~~~~^^^^^^^^
KeyError: 'A'
Ticker(['A'], asynchronous=True).history(period='4d', interval='1m')
open high low close volume
symbol date
A 2026-01-08 09:30:00-05:00 146.740005 146.970001 146.520004 146.889999 14164.0
...
2026-01-13 12:13:33-05:00 146.550003 146.550003 146.550003 146.550003 0.0

[1271 rows x 5 columns]

Ticker(['A'], asynchronous=True).symbols
['A']
len(gets)
500
trial.symbols
['A', 'AAPL', ... 'ZTS']
len(trial.symbols)
500

** Expectation
Should return the data, it does most of the time, but sometimes it just misses, like this

Desktop (please complete the following information):

  • OS: Ubuntu Server
  • Browser Command Line

Additional context
I saw that there was another mention of this, but I am experiencing it intermittently, so I'm not sure what the problem is, actually, other than something funky with the build of the array that's being put into the Ticker command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions