AttributeError: 'Asset' object has no attribute 'status'

Hello. I am new to coding (6 months) as well as this is the first time I am posting. My code was working until yesterday ( I have been following a tutorial). I tried to repopulate a stock list after clearing out data from my database (SQL). When I ran the populate_stocks in my code I started getting Attribute Errors (the image). I did not change anything in the code and it has been working for several weeks. After reading the documentation I cannot understand what has happened. Any thoughts, insights or suggestions are welcomed. I am still learning and not well versed in coding jargon, so plain simple language works best. Thank you for your time.

@Quentin_Reynolds It appears you are expecting assets to be a collection (eg a list or dataframe) of Asset objects. However, as your code is looping through the collection it finds an entry which isn’t an Asset object like the rest which doesn’t have either a status or symbol attribute. Somehow you got a non-Asset object into your collection. More correctly, it seems to be as Asset but it’s not an Asset object like those returned by the get_asset API.

To debug, perhaps print out the assets collection before executing the for loop. Perhaps as simple as this

print(assets)
for asset in assets:

That will give you an idea of what is really in the assets collection and possibly help debug. The problem starts before line 25. However you are generating the assets collection it is somehow getting one or more items in it that isn’t an Asset object as expected.

Thank you. I took your advice and the print statement included Asset (next_page_token).

C:/Users/user/Desktop/Full_stack/Full_Stack/populate_stocks.py
[]
[Asset(‘bars’), Asset(‘symbol’), Asset(‘next_page_token’)]

I could not find anything in the documentation so I am not sure if that is correct or not, but I assume not. My research points to page separation needing a page token, but I am not sure if my understanding is correct.

Per your insight the page token maybe in how I am calling the asset collection, but once again I am not 100% on that assumption or even why it is there.

I solved the problem. Apparently the link that my app was pointed at stopped working or something (it had been working for three weeks). I pointed it at a different one and now it’s all good.

broken link: “https://data.alpaca.markets/v2/stocks/AAPL/bars?start=2022-02-11&end=2022-02-11&timeframe=1Min

working link: “base_url=‘https://paper-api.alpaca.markets/’”

Thanks for your help Dan

@Quentin_Reynolds Glad to hear you got it fixed. Good luck!