Hi, I'm getting an error in my code, which was not present previously. We were using this before and it was working perfectly. Did something change. please help!

request_stock_params = StockBarsRequest(symbol_or_symbols=["AAPL"], timeframe=TimeFrame.Day, start= datetime.date(2022, 7, 1), end= datetime.date(2022, 8, 1))

bars = stock_client.get_stock_bars(request_stock_params)

#bars = client.get_crypto_bars(request_params)

# convert to dataframe
AAPL_data = bars.df

Used this as well:

request_stock_params = StockBarsRequest(symbol_or_symbols=["AAPL"], timeframe=TimeFrame.Day, start="2022-07-01")

bars = stock_client.get_stock_bars(request_stock_params)

#bars = client.get_crypto_bars(request_params)

# convert to dataframe
AAPL_data = bars.df

Got this error:

ValidationError: 2 validation errors for StockBarsRequest
start
  invalid type; expected datetime, string, bytes, int or float (type=type_error)
end
  invalid type; expected datetime, string, bytes, int or float (type=type_error)

Please help. Did something change, or am I doing something wrong?

1 Like

I am getting the exact same error since this weekend…

Any solution? Did anyone figure this out? It was working before this past weekend.

I just got this error as well and I solved it by using datetime.datetime instead of datetime.date.
Hope it helps!

1 Like

Thank you Algot for the response. You should be using a datetime. We will most likely be changing back to support strings in addition to datetimes in Alpaca-py since most people find it intuitive to use strings.

1 Like

Is there any concrete reason for this? I have been using the code for last 4 months and suddenly stopped working with this error. Is this some sort of joke, its a real money. Alpaca needs to build the trust. If this continues I need to explore some other option. I tried changing import as suggested above but it didnt help.