You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Entity.py,
You are converting the timestamp by multiply 1e9 and this cause the datatype to change to Float64 which is not accepted in the panda library and returns TypeError.
Can we do something like this?
if not df.empty:
df.index = pd.to_datetime(
(df.index * 1e9).astype('int64'), utc=True,
).tz_convert(NY)
File "/Users/jiawensun/Alpaca/samplealgo/algo.py", line 59, in _get_prices
return barset.df
File "/usr/local/lib/python3.7/site-packages/alpaca_trade_api/entity.py", line 107, in df
df = bars.df.copy()
File "/usr/local/lib/python3.7/site-packages/alpaca_trade_api/entity.py", line 85, in df
df.index * 1e9, utc=True,
File "/usr/local/lib/python3.7/site-packages/pandas/core/tools/datetimes.py", line 603, in to_datetime
result = convert_listlike(arg, box, format)
File "/usr/local/lib/python3.7/site-packages/pandas/core/tools/datetimes.py", line 223, in _convert_listlike_datetimes
arg, _ = maybe_convert_dtype(arg, copy=False)
File "/usr/local/lib/python3.7/site-packages/pandas/core/arrays/datetimes.py", line 1914, in maybe_convert_dtype
data = data.astype(_NS_DTYPE)
File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/numeric.py", line 330, in astype
raise TypeError(msg)
TypeError: Cannot convert Float64Index to dtype datetime64[ns]; integer values are required for conversion
The text was updated successfully, but these errors were encountered:
In Entity.py,
You are converting the timestamp by multiply 1e9 and this cause the datatype to change to Float64 which is not accepted in the panda library and returns TypeError.
Can we do something like this?
File "/Users/jiawensun/Alpaca/samplealgo/algo.py", line 59, in _get_prices
return barset.df
File "/usr/local/lib/python3.7/site-packages/alpaca_trade_api/entity.py", line 107, in df
df = bars.df.copy()
File "/usr/local/lib/python3.7/site-packages/alpaca_trade_api/entity.py", line 85, in df
df.index * 1e9, utc=True,
File "/usr/local/lib/python3.7/site-packages/pandas/core/tools/datetimes.py", line 603, in to_datetime
result = convert_listlike(arg, box, format)
File "/usr/local/lib/python3.7/site-packages/pandas/core/tools/datetimes.py", line 223, in _convert_listlike_datetimes
arg, _ = maybe_convert_dtype(arg, copy=False)
File "/usr/local/lib/python3.7/site-packages/pandas/core/arrays/datetimes.py", line 1914, in maybe_convert_dtype
data = data.astype(_NS_DTYPE)
File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/numeric.py", line 330, in astype
raise TypeError(msg)
TypeError: Cannot convert Float64Index to dtype datetime64[ns]; integer values are required for conversion
The text was updated successfully, but these errors were encountered: