Building a LIVE Algorithmic Trading Bot with Python, Lumibot and Alpaca: A Step by Step Guide

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ต.ค. 2024
  • ​‪@MattMacarty‬
    #algotrading #python #tradingbots
    How to Code a Trading Bot in Python
    Building a LIVE Stock Trading Bot with Python, Lumibot and Alpaca: A Step by Step Guide
    ✅ Please SUBSCRIBE:
    www.youtube.co...
    ✅ Get the code: github.com/mjm...
    ✅ Lumibot Documentation: lumibot.lumiwe...
    ✅ Alpaca Markets: alpaca.markets
    ✅ Visit alphabench.com for more Excel, Python and MySQL tutorials
    ✅ Interested in backtesting in general? • How to Backtest Tradin...
    ✅ Want to see a trading algorithm in action: • How to Build a Python ...
    **This video is for educational purposes only. It should not be construed as investment advice.**
    Take your trading to the next level with a bot. In this tutorial, we'll show you step by step how to implement a trading bot on Alpaca.markets using the Lumibot Python library. From connecting to your Alpaca account to backtesting and deploying your strategy, we'll cover everything you need to know to get started. Learn about the features and capabilities of Lumibot and how it can help you automate your trades and increase your profits. Whether you're a seasoned developer or new to bot trading, this video is perfect for anyone looking to get started with Alpaca and Lumibot.

ความคิดเห็น • 61

  • @pinecedar180
    @pinecedar180 7 หลายเดือนก่อน +1

    ok.. I think this is the starting video. I suggest numbering them and tell people in every video that this is a series.

    • @MattMacarty
      @MattMacarty  7 หลายเดือนก่อน

      Thanks. I think I talk about the order to watch these in at the beginning.

  • @gaurav2979
    @gaurav2979 6 หลายเดือนก่อน

    Thanks for sharing Man, keep up the good work

    • @MattMacarty
      @MattMacarty  5 หลายเดือนก่อน

      Thanks. Glad it helped

  • @bigtexnick2188
    @bigtexnick2188 หลายเดือนก่อน

    Great vid, Matt. Question from a non-coder: are you not able to do all of this configuring of your trading strategy logic inside of Alpaca itself?

    • @MattMacarty
      @MattMacarty  หลายเดือนก่อน

      There are limitations to what you can set up in terms of automation directly on Alpaca. So it depends what you are trying to do.

  • @EonEnt
    @EonEnt 11 หลายเดือนก่อน

    Great tutorial Matt! worked for me…. almost - any ideas why it’s rounding decimals back to whole numbers for fractional trading?

    • @MattMacarty
      @MattMacarty  11 หลายเดือนก่อน +1

      Not sure. You may not be able to trade fractional shares, or it could be a limitation of paper trading.

  • @yuxuanlin1971
    @yuxuanlin1971 4 หลายเดือนก่อน

    Thank you for sharing Matt! I have one question - It's very cool to generate a Plotly interactive graph from Lumibot. I wanted to dig into the package and find the code that generated the graph but I couldn't find it. Do you know where in Lumibot embedded this function? It'll be so much easier to leverage it on other data visualization projects.

    • @MattMacarty
      @MattMacarty  4 หลายเดือนก่อน

      Sorry. I haven't examined their code. Try holding control key and click on the lumibot class to open the underlying code.

    • @yuxuanlin1971
      @yuxuanlin1971 4 หลายเดือนก่อน

      @@MattMacartyYea, that's what I did. I was guessing it's in lumibot.strategies but I only found matplotlib library but the graph is generated by plotly. Also, I didn't find where in lumibot is embedded QuantStats neither. Appreciate it if you could help provide some clues.

  • @CreeLegacy
    @CreeLegacy 8 หลายเดือนก่อน

    Hey man! Thanks for the content! I've downloaded your code, set it up, got it up and running, when I run Buy_hold, it opens up my chrome properly and profives the graphs alright, but in my VS terminal I don't get what you call "higher statistics" any clue why?

    • @MattMacarty
      @MattMacarty  8 หลายเดือนก่อน

      Not sure what is happening there. It's possible there was a revision to lumibot such that this functionality doesn't happen automatically.

  • @chentomerify
    @chentomerify 6 หลายเดือนก่อน

    hey matt!, loved the video! i have trouble installing pip lumibot. it says there is something wrong with the package itself(not pip). is it possible that lumibot isnt working with my python version (3.12.12)? thank you!

    • @MattMacarty
      @MattMacarty  6 หลายเดือนก่อน +1

      My guess is it is one of the dependencies such as pandas that is causing the problem. You likely havea newer version of pandas than is supported by lumibot. You can try downgrading to something like 1.5 and see if that solves the probelm. ALso you can contact lumiwealth and they will get you going.

  • @mpumisetshedii
    @mpumisetshedii ปีที่แล้ว

    Thank you for this video, will a gold tracking bot be in the pipeline for this video series?

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว

      Yes, soon

    • @mpumisetshedii
      @mpumisetshedii ปีที่แล้ว

      @@MattMacarty Thank you

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว

      OK here it is: th-cam.com/video/kgTCkD48tKk/w-d-xo.html

  • @shawnholcomb2975
    @shawnholcomb2975 ปีที่แล้ว +1

    Finally! i was able to get most of this code work! haha i got all the results you did except no web page opened.. Got this error: ValueError: Cannot set a DataFrame with multiple columns to the single column plotly_text_sells.. but soo much progress lol

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว

      Nice. Most of the learning comes from debugging. You can always download my code from the github link in the video description, but it is much more instructive to try to replicate the code yourself.

    • @linaspeleckas62
      @linaspeleckas62 ปีที่แล้ว +1

      Same here bro

  • @mdawg998
    @mdawg998 6 หลายเดือนก่อน

    I'm new to coding. I straight up cannot figure out how to get Lumibot available for this program. I went to terminal. Did the pip install. Now what? I cannot find out to actually include it.

    • @MattMacarty
      @MattMacarty  6 หลายเดือนก่อน

      You can follow the link in the description to get the code. You just need to import lumibot in your code

  • @b4f495
    @b4f495 6 หลายเดือนก่อน

    if im buying and holidng why is the growth percentage different from the charts?

    • @MattMacarty
      @MattMacarty  6 หลายเดือนก่อน

      Not sure what you mean by this. If you mean percent change in value that will be somewhat different than an annual growth rate.

    • @b4f495
      @b4f495 6 หลายเดือนก่อน

      @@MattMacarty why is that since im just buying and holding? good video tho thanks!

  • @ihebbibani7122
    @ihebbibani7122 ปีที่แล้ว

    Thanks for the video.
    Any idea please to solve this error :
    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for multidict
    Successfully built aiohttp
    Failed to build multidict
    ERROR: Could not build wheels for multidict, which is required to install pyproject.toml-based projects

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว

      This sounds like there are some version incompatibilities. Try upgrading Lumibot with pip.

    • @ihebbibani7122
      @ihebbibani7122 ปีที่แล้ว

      @@MattMacarty I really thought that I have used the "pip --upgrade ..." Anyway , I successfully installed the package , thank you very much

  • @user62413
    @user62413 2 หลายเดือนก่อน

    How to find the rest of the series?

    • @MattMacarty
      @MattMacarty  2 หลายเดือนก่อน

      Here are my algo videos: th-cam.com/play/PLiPFKCVZWHKqtlvkq-V610SXMr2Ii9uAR.html

  • @andrewgreggs2486
    @andrewgreggs2486 ปีที่แล้ว

    I'm getting an error which says there isn't enough data to create a tearsheet, but I am able to backtest and get that visualization comparing the BuyHold strategy with SPY. Any idea on how I can fix this?

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว

      Hard to diagnose from here. You an download the code from Github and compare using the link in the description of the video.

  • @zaufall
    @zaufall ปีที่แล้ว

    With your lumibot examples I'm getting "TypeError: 'Timestamp' object is not subscriptable". Any help appreciated.

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว

      You can download the demo files here and compare your code: github.com/mjmacarty/algorithmic-trading

    • @zaufall
      @zaufall ปีที่แล้ว

      @@MattMacarty the error is the same with your original code. By the way is Alpaca Pro needed for algo trading?

  • @nikopukkila9594
    @nikopukkila9594 ปีที่แล้ว

    Hi Matt, thanks for the great video! As someone with little to no programming experience, I am running into problem "ImportError: cannot import name 'ALPACA_CONFIG' from 'config'". I've tried to set up my API credentials into Jupyter txt and py files and cant seem to get it work. Any advice concerning this?

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว +1

      The config.py file is a file I made containing my API keys. I did it that way to keep my credentials private. You can just directly use your API keys in place of ALPACA_CONFIG.API_KEY and ALPCA_CONFIG.SECRET_KEY. Also you can skip import config

    • @nikopukkila9594
      @nikopukkila9594 ปีที่แล้ว

      @@MattMacarty Now its working! Thanks for your response brother. Looking forward to your next videos.

  • @xt8382
    @xt8382 ปีที่แล้ว

    very cool!!

    • @xt8382
      @xt8382 ปีที่แล้ว

      have been watching your video and learnt a lot, altho I work as data operation/engineer, still learnt a lot Python3 with your video!

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว

      Thanks. Glad it's helping

  • @waddupitsD
    @waddupitsD ปีที่แล้ว

    tried your code it says No module named 'lumibot' but I installed it,,, could it be that the code never imported lumibot???

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว +1

      Yes it sounds like the environment you are working in can't find lumibot. if you are using Anaconda make sure the environment is activated by running "activate" at the command line. If you are using an IDE make sure it is using Anaconda as the Python interpreter.

  • @jcruz6888
    @jcruz6888 8 หลายเดือนก่อน

    After skipping to the end of the video, I found it hilarious that the bot essentially lost money. I likely missed a lot since I only watched the end. However, I’m curious - would you recommend this as a profitable hobby?
    I'm looking to spend 1 - 2 hours per day on it. I believe I already know enough web development to carry me through this API with JS & some other tools. However, I can't help but think that it's not worth my time as there's not that much discussion about the profits that people on my level may or may not get.

    • @MattMacarty
      @MattMacarty  8 หลายเดือนก่อน

      So the video is just meant to show how to automate trading, not how to make money. Probably most people would not share their money minting strategy on TH-cam. If they did, I would be pretty skeptical. I would focus on a particular security or maybe two if you want to pair trade. For example, I think BIDU does X every day. Can I develop a strategy to take advantage of X? If you have the time you should watch the whole video and others to see the mechanics and then investigate what could work. Alpaca is nice since you can easily test things without risking any money.

  • @joshlazor6208
    @joshlazor6208 ปีที่แล้ว

    Can you do a video on different trading strategies?

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว +3

      Yes I will do a few.

    • @joshlazor6208
      @joshlazor6208 ปีที่แล้ว

      @@MattMacarty Awesome, thanks Matt!

  • @arnoldbabcock6939
    @arnoldbabcock6939 ปีที่แล้ว

    Hello Matt, How can I download lumibot? I looked online and only see documents for download, if you could please include a link in the bio it would greatly be appreciated!

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว

      from the command line run pip install lumibot

    • @arnoldbabcock6939
      @arnoldbabcock6939 ปีที่แล้ว

      @@MattMacarty sorry this is new to me, what does that mean?

    • @arnoldbabcock6939
      @arnoldbabcock6939 ปีที่แล้ว

      Could you make a video, I think I got there but wasn't sure which part to download

  • @officialbubies5153
    @officialbubies5153 ปีที่แล้ว

    Hi, I was following along with the video and when i run the script I am getting this error which then throws alot more other errors:
    "GOOG: No data found for this date range, symbol may be delisted"

    • @MattMacarty
      @MattMacarty  ปีที่แล้ว +1

      Hmmm, that's odd. My guess is there is something else going wrong there. You can try GOOGL if you want. You can also download my code from the github link in the desc.

    • @officialbubies5153
      @officialbubies5153 ปีที่แล้ว

      @@MattMacarty Thanks! I will compare my code with yours.

    • @officialbubies5153
      @officialbubies5153 ปีที่แล้ว

      I was missing alpaca-py.