abzdel / Swing-Trading-Stock-Bot

A Python-based bot that uses the Alpaca API and swing trading principles to buy and sell securities.
46 stars 19 forks source link

Error in biz_bot_scrape.py #1

Open omnicortex opened 1 month ago

omnicortex commented 1 month ago

When running biz_bot_final_script.py, I got the following error.

Traceback (most recent call last):
File "biz_bot_place_orders.py", line 1, in <module>
import biz_bot_scrape as bb1
File "/swingtrade/biz_bot_scrape.py", line 42, in <module>
t = datetime.fromtimestamp(bar['t']) # change from UNIX timestamp to datetime object
TypeError: string indices must be integers

I couldn't figure out what's going on.

abzdel commented 1 month ago

@omnicortex I haven't checked on this project in quite a while, but I made a note on my to-do list to try to jog my memory and get you a solution on this. I'll try to get you a proper response sometime this week!

omnicortex commented 1 month ago

@abzdel Thanks. I am looking forward to it.

abzdel commented 3 weeks ago

@omnicortex It's looking like a lot of the endpoints I used to use for this don't work in the same way as they used to. Unfortunately, I didn't have the best exception handling or testing skills when I made this so these issues are hard to catch without the program just running into them. In this particular issue, no stock dates are getting returned from the endpoint, so we can't convert them to datetime.

I'm still planning to look further during my free time, but if you're interested, the Alpaca documentation for its Python SDK is really good. All I was doing in the scraping script was getting all the stocks I wanted to check on and getting daily bars for each. I'll ping you again if I end up going deeper into the rabbit hole and finding a fix for this.

omnicortex commented 3 weeks ago

@abzdel Thank you for looking into this. I will take a look at the Alpaca docs and see if I can get something going. I will make a pull request if I can get it to run.

omnicortex commented 2 weeks ago

Unfortunately, the Data API v1 has been deprecated on September 26th, 2021. So I will try to update this to Data API v2 since they are pretty similar, instead of the SDK (which looks quite different).