How To Build a Stock Trading Bot With Alpaca and Python - Full Beginner Tutorial
HTML-код
- Опубликовано: 14 июн 2024
- This tutorial will teach you how to connect to and use the Alpaca Markets API to trade stocks and stream stock market data.
Link to Alpaca docs with which this tutorial is based on:
alpaca.markets/sdks/python/ge...
🐍 How To Setup and Run a Python File:
Windows: • How to Install Python ...
Mac: • Setup Python Using Vis...
Linux: • How to run a Python sc...
⏱️Timestamps:
00:00 What You're Learning
00:15 Pre-requisites
01:06 Setup your Alpaca Account for API Usage
02:23 Setup Dev Environment And Pip Install
04:02 Connect to the Alpaca API using Python Code And Get Account Info
06:15 Get Historical Data
11:35 Create First Market And Limit Orders
19:53 Get, Cancel and Manage Open Orders
27:50 Stream Data in Real Time Наука
Such a well-oriented tutorial. Answering the "Why?" behind every step was a huge help. Thank you!
Thank you very much... I was able to do this with this video's help! Subbed and gave a thumbsup. Thanks for the video markers, very helpful as well.
thats nice. i haven't attempted to make an alpaca trading bot yet. your video brings clarity to the subject.
Thank you!
Concise ✅
Valuable ✅
Amazing vid! Thank you for sharing
the alpaca documentation is very good.
thanks, i really like your video
Thank you very much.👍👍👍
I personally would love a video on the steps for learning machine learning and neural networking and what was your approach and how you learned it, thanks 😁
I am looking for a trading bot for automated trading. I am not a programmer. Do you have a few suggestions for a good automated trading system?
how would one subscribe to multiple stocks?? Thanks for the content, it's super clear and helpful!
@emilianovillarreal1744
Unfortunately I have tried to use the multiple tickers functionality in the websocket but it always gives an error. I looked through their code and technically you should just be able to pass in a list with all the tickers you want but it seems broken. I would suggest posting a ticket on the GitHub page for alpaca-py because I haven't been able to figure it out otherwise. I am sorry. Glad I was helpful otherwise!
@@connorcreate Hello Connor, I've been able to make it work through the websocket using the following message:
listen_message = {"action": "subscribe", "quotes": ["AMD", "CLDR"]}
ws.send(json.dumps(listen_message))
However, I've been having some issues closing out the websocket so i have a timed close
Awesome, kinda annoying that you had to make the websocket like that instead of using their code wrappers.
If you have any further issues with not being able to close it feel free to email me your code file at connor.create.things@gmail.com and I can look at it there. Otherwise, I'm glad you found a workaround!
have you tried making a webull or robinhood trading bot? robinhood would be risky since they dont support a api for trading
Robinhood is tricky because it's an unofficial API which is technically against their terms of service and can change at any moment. I haven't looked at webull.
good code
Let me know what you would like to know next!
Thank you for the great video. Can you also please post a video for how to make market orders for options?
Any thought to an alpaca-py set of examples?
I would love to make more stuff in this realm as it's a major driver of views to my channel and so people must like this content and tutorial, I just haven't had any motivation. I'll keep it in mind, thanks for the comment and watch! Hope it was helpful. :)
When trying to make a market order I am getting this error: "Field required [type=missing, input_value={'symbol': 'WISA', 'qty':...rType.MARKET: 'market'>}, input_type=dict]" pls help. btw love the video
Can you send your full code to my email connor.create.things@gmail.com? I can take a closer look there for ya
@@connorcreate I figured it out but thanks for being so quick to respond
Of course! Glad you enjoyed the tutorial :)
which VScode python plugin is giving you all the information on alpaca?
I believe it is just the standard intellisense built into vscode. Sometimes library imports work for that info and other times they don't for me, but I'm no expert on getting it to work.
I would recommend googling intellisense import libraries python and do some digging in that region because I believe it might happen if the vscode python installation is different than the one you installed it in.
You can also look at the alpaca markets docs for the functions, but it's way quicker if vscode helps in that regard.
Let me know if I can be of any assistance further but I think that's the general path. And thank you for watching :)
I might have the python intellisense installed or whatever vscode recommends but it's nothing extra.
@@connorcreateThanks for responding. I installed the python intellisense plugin and it wasn't working, then I restarted vscode! Found the tutorial really helpful, next step building a client?
What sort of client would you be interested in? A simple system to trade stocks/crypto. I think right now I'm going to make a tutorial for the options portion of alpaca then work on something in this regard.
@@connorcreateyes, yes, yes
I keep getting forbidden error/not found url
Would you be willing to send the code you're trying to my email connor.create.things@gmail.com and also try resetting your API keys. That sometimes causes issues.
@@connorcreate hey, i am facing same issue.
here is the 1st Error :HTTPError: 403 Client Error: Forbidden for url: paper-api.alpaca.markets/v2/orders
2nd Error: APIError: {"message": "forbidden."}
Make a simple robot that trade rise and fall market in binary options making a specified target every second
I have to say though that in this country's culture, a lot of people think that speaking in voice crack at very low levels is somehow the way to go. I dont understand that at all. The human voice should be at its normal levels at a voice level that is clear to understand, is smooth and there are no voice cracks and no trembles. Its like the person has a freaking elephant standing on their throat and they're not able to speak normally and I'm thinking what the heck is wrong, why are they speaking like that? Culture is a powerful force and it drives everything. Most people cant resist the force of culture. I'm hoping you can somehow speak at normal voice levels and give a big middle finger to whatever culture is making you speak like this. I hope you understand what I'm saying to say. What do you think of what I said.... does it make sense? What do you think of the fact that so many people just follow culture without thinking whether it makes sense or not?
I can't believe you took the time to write this out.
I just have bad anxiety when on camera
Quit drugs dude.
your voice is quite annoying, can't go through more than one minute. Why nowadays people (millennials) think everyone can speak like Altmen and get away with it.
I like to think I am Altmen
at 6:15 he sounded like an actual person for 15 seconds and I was very hopeful for the rest. then he switched back :( I guess its because he starts talking while sitting upright but then slowly lays on his chair in time. anyways, thanks for the tutorial, very helpful!
while streaming data in real time I am getting an error which says:-
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1000)
Could you plz help me with this ?
I found this issue chain on GitHub where some people have had to check SSL certs on their computer with a command, and then download them again.
I'm pretty sure that's what you're facing here.
Honestly, I'm not familiar with web security and SSL certs like this so I'm also not well equipped to help with this but hopefully this gets you on the path.
github.com/alpacahq/alpaca-trade-api-python/issues/510
@aishashaikh1767 this comment exactly
github.com/alpacahq/alpaca-trade-api-python/issues/510#issuecomment-961894450
@connorcreate how can I contact you ?
Depends what you need