Hello,
When I try to use:
api.polygon.historic_agg_v2('AAPL', multiplier =1, timespan="day", _from=start, to=(end))
I get the following error:
Traceback (most recent call last):
File “historicalTest.py”, line 46, in
df = api.polygon.historic_agg_v2(‘AAPL’, multiplier =1, timespan=“day”, _from=start, to=(end)).df
File “/Users/aky/Documents/Algo/venv/lib/python3.7/site-packages/alpaca_trade_api/polygon/rest.py”, line 204, in historic_agg_v2
to=fix_daily_bar_date(format_date_for_api_call(to), timespan)
File “/Users/aky/Documents/Algo/venv/lib/python3.7/site-packages/alpaca_trade_api/polygon/rest.py”, line 65, in fix_daily_bar_date
date = dateutil.parser.parse(date)
File “/Users/aky/Documents/Algo/venv/lib/python3.7/site-packages/dateutil/parser/_parser.py”, line 1374, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File “/Users/aky/Documents/Algo/venv/lib/python3.7/site-packages/dateutil/parser/_parser.py”, line 646, in parse
res, skipped_tokens = self._parse(timestr, **kwargs)
File “/Users/aky/Documents/Algo/venv/lib/python3.7/site-packages/dateutil/parser/_parser.py”, line 725, in _parse
l = _timelex.split(timestr) # Splits the timestr into tokens
File “/Users/aky/Documents/Algo/venv/lib/python3.7/site-packages/dateutil/parser/_parser.py”, line 207, in split
return list(cls(s))
File “/Users/aky/Documents/Algo/venv/lib/python3.7/site-packages/dateutil/parser/_parser.py”, line 76, in init
‘{itype}’.format(itype=instream.class.name))
TypeError: Parser must be a string or character stream, not int
The code works for any other timespan like minute, hour, month, week, etc. It just doesn’t work for day. Anyone know why?