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
  • НаукаНаука

Комментарии • 50

  • @platinumdelta663
    @platinumdelta663 15 дней назад

    Such a well-oriented tutorial. Answering the "Why?" behind every step was a huge help. Thank you!

  • @pinecedar180
    @pinecedar180 3 месяца назад +3

    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.

  • @rverm1000
    @rverm1000 14 дней назад

    thats nice. i haven't attempted to make an alpaca trading bot yet. your video brings clarity to the subject.

  • @marlopainter8246
    @marlopainter8246 3 месяца назад +2

    Thank you!
    Concise ✅
    Valuable ✅

  • @jazilzaim
    @jazilzaim 3 месяца назад +1

    Amazing vid! Thank you for sharing

  • @rverm1000
    @rverm1000 13 дней назад

    the alpaca documentation is very good.

  • @aristidevonan4661
    @aristidevonan4661 7 дней назад

    thanks, i really like your video

  • @West123w
    @West123w Месяц назад +1

    Thank you very much.👍👍👍

  • @priyanshusingh5708
    @priyanshusingh5708 2 месяца назад

    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 😁

  • @user-kp6sk7ql4j
    @user-kp6sk7ql4j Месяц назад

    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?

  • @emilianovillarreal1744
    @emilianovillarreal1744 4 месяца назад +3

    how would one subscribe to multiple stocks?? Thanks for the content, it's super clear and helpful!

    • @connorcreate
      @connorcreate  4 месяца назад +1

      @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!

    • @emilianovillarreal1744
      @emilianovillarreal1744 4 месяца назад

      @@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

    • @connorcreate
      @connorcreate  4 месяца назад

      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!

  • @rverm1000
    @rverm1000 14 дней назад

    have you tried making a webull or robinhood trading bot? robinhood would be risky since they dont support a api for trading

    • @connorcreate
      @connorcreate  14 дней назад

      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.

  • @RICHWORLDHUSTLE
    @RICHWORLDHUSTLE Месяц назад

    good code

  • @connorcreate
    @connorcreate  4 месяца назад +1

    Let me know what you would like to know next!

    • @RamVipparthi
      @RamVipparthi Месяц назад

      Thank you for the great video. Can you also please post a video for how to make market orders for options?

  • @brianrowe8424
    @brianrowe8424 15 дней назад

    Any thought to an alpaca-py set of examples?

    • @connorcreate
      @connorcreate  14 дней назад

      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. :)

  • @bennyman1359
    @bennyman1359 Месяц назад +1

    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

    • @connorcreate
      @connorcreate  Месяц назад

      Can you send your full code to my email connor.create.things@gmail.com? I can take a closer look there for ya

    • @bennyman1359
      @bennyman1359 Месяц назад

      @@connorcreate I figured it out but thanks for being so quick to respond

    • @connorcreate
      @connorcreate  Месяц назад

      Of course! Glad you enjoyed the tutorial :)

  • @DavidRobertLewis
    @DavidRobertLewis 3 месяца назад

    which VScode python plugin is giving you all the information on alpaca?

    • @connorcreate
      @connorcreate  3 месяца назад

      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 :)

    • @connorcreate
      @connorcreate  3 месяца назад

      I might have the python intellisense installed or whatever vscode recommends but it's nothing extra.

    • @DavidRobertLewis
      @DavidRobertLewis 3 месяца назад

      @@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?

    • @connorcreate
      @connorcreate  3 месяца назад +2

      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.

    • @DavidRobertLewis
      @DavidRobertLewis 3 месяца назад

      @@connorcreateyes, yes, yes

  • @MarkHuswa-gq7cq
    @MarkHuswa-gq7cq 3 месяца назад +1

    I keep getting forbidden error/not found url

    • @connorcreate
      @connorcreate  3 месяца назад

      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.

    • @user-bt8jc4ly6e
      @user-bt8jc4ly6e 2 месяца назад

      @@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."}

  • @financialliteracyfx1189
    @financialliteracyfx1189 4 месяца назад +1

    Make a simple robot that trade rise and fall market in binary options making a specified target every second

  • @pinecedar180
    @pinecedar180 3 месяца назад +1

    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?

    • @connorcreate
      @connorcreate  3 месяца назад +4

      I can't believe you took the time to write this out.

    • @connorcreate
      @connorcreate  3 месяца назад +3

      I just have bad anxiety when on camera

    • @isTheNightfly
      @isTheNightfly 3 месяца назад

      Quit drugs dude.

  • @kamhaq
    @kamhaq 3 месяца назад

    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.

    • @connorcreate
      @connorcreate  3 месяца назад +3

      I like to think I am Altmen

    • @yigitsevim7741
      @yigitsevim7741 2 месяца назад

      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!

  • @aishashaikh1767
    @aishashaikh1767 2 месяца назад +1

    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 ?

    • @connorcreate
      @connorcreate  2 месяца назад +1

      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

    • @connorcreate
      @connorcreate  2 месяца назад +1

      @aishashaikh1767 this comment exactly
      github.com/alpacahq/alpaca-trade-api-python/issues/510#issuecomment-961894450

  • @valeriuvvici7520
    @valeriuvvici7520 2 месяца назад

    @connorcreate how can I contact you ?