Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: type object argument after * must be an iterable, not float #26

Open
AwesomeCap opened this issue Feb 10, 2023 · 3 comments
Open

Comments

@AwesomeCap
Copy link

I tested the code in Python3.7:

from yahoo_historical import Fetcher
import datetime
import time

# create unix timestamp representing January 1st, 2007
timestamp = time.mktime(datetime.datetime(2007, 1, 1).timetuple())

data = Fetcher("AAPL", timestamp)
print(data.get_historical())

And I got:


TypeError Traceback (most recent call last)
/var/folders/5z/nfxgl_ps6qlf5tvrct964q980000gn/T/ipykernel_77052/2760101674.py in
6 timestamp = time.mktime(datetime.datetime(2007, 1, 1).timetuple())
7
----> 8 data = Fetcher("AAPL", timestamp)
9 print(data.get_historical())

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/yahoo_historical/fetch.py in init(self, ticker, start, end, interval)
20 self.ticker = ticker.upper()
21 self.interval = interval
---> 22 self.start = int(cal.timegm(dt.datetime(*start).timetuple()))
23
24 if end is not None:

TypeError: type object argument after * must be an iterable, not float

@belugame
Copy link

Could you use a later python version? 3.7 will be deprecated in only a few months.
Your code snippet works fine with 3.11:

Python 3.11.1 (main, Dec 31 2022, 10:23:59) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from yahoo_historical import Fetcher
>>> import datetime
>>> import time
>>> 
>>> # create unix timestamp representing January 1st, 2007
>>> timestamp = time.mktime(datetime.datetime(2007, 1, 1).timetuple())
>>> 
>>> data = Fetcher("AAPL", timestamp)
>>> print(data.get_historical())
            Date        Open        High         Low       Close   Adj Close      Volume
0     2007-01-03    3.081786    3.092143    2.925000    2.992857    2.551165  1238319600
1     2007-01-04    3.001786    3.069643    2.993571    3.059286    2.607790   847260400
2     2007-01-05    3.063214    3.078571    3.014286    3.037500    2.589219   834741600
3     2007-01-08    3.070000    3.090357    3.045714    3.052500    2.602006   797106800
4     2007-01-09    3.087500    3.320714    3.041071    3.306071    2.818154  3349298400
...          ...         ...         ...         ...         ...         ...         ...
4050  2023-02-03  148.029999  157.380005  147.830002  154.500000  154.500000   154279900
4051  2023-02-06  152.570007  153.100006  150.779999  151.729996  151.729996    69858300
4052  2023-02-07  150.639999  155.229996  150.639999  154.649994  154.649994    83322600
4053  2023-02-08  153.880005  154.580002  151.169998  151.919998  151.919998    64120100
4054  2023-02-09  153.779999  154.330002  150.419998  150.869995  150.869995    55921800

[4055 rows x 7 columns]

@AwesomeCap
Copy link
Author

Big thanks belugame!

@AndrewRPorter
Copy link
Owner

AndrewRPorter commented Feb 10, 2023

Thanks for reporting! This should definitely still be working in Python 3.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants