Intro to Python for Finance: A Beginner's Guide

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

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

  • @RyanOConnellCFA
    @RyanOConnellCFA  ปีที่แล้ว +6

    🎓 Tutor With Me: 1-On-1 Video Call Sessions Available
    ► Join me for personalized finance tutoring tailored to your goals: ryanoconnellfinance.com/finance-tutoring/
    💻 Find the Code Written In this Video Here:
    ► Access the code resources here: ryanoconnellfinance.com/python-for-stock-analysis/

  • @messiasmoretto7457
    @messiasmoretto7457 8 หลายเดือนก่อน +10

    Extremely useful and straightforward video. Found some issues along the way, but could overcome them by myself. Thanks a lot

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

      Part of learning to code is working through all those pesky errors and bugs! Good job

    • @koto-krollik7003
      @koto-krollik7003 4 หลายเดือนก่อน

      hi. thank you for your job. i have one quesiotion - why you dont use the syntax "print" before command in 22:05 ?

  • @samj5476
    @samj5476 25 วันที่ผ่านมา +1

    Thank you for remaining diligent with these useful tutorials, Ryan. I'm a finance major at a non-target university doing everything thing I can to break into investment banking if I can help it, and your lessons are part of my plan to try to set myself apart from my academic peers. Thank you thank you!

  • @jamoladdinomonbaev4121
    @jamoladdinomonbaev4121 ปีที่แล้ว +7

    Thank you very much for these wonderful videos! I've been following you for more than a year, and your videos helped me a lot in my studies. Now I am doing CFA Level 1 and again, the videos you are posting are very helpful, especially this one as it relates to new additions of Level 1 exam. Thank you very much !

    • @RyanOConnellCFA
      @RyanOConnellCFA  ปีที่แล้ว +2

      Wow I really appreciate the feedback Jamoladdin! It's comments like these that give me motivation to keep putting work in. Thank you!

  • @Monika-uv2qp
    @Monika-uv2qp ปีที่แล้ว +4

    Have been following Ryan for quite some time now. Very helpful!! Kudos

  • @mkhakop6257
    @mkhakop6257 28 วันที่ผ่านมา +2

    omg I did this! thank you so much. my first code

    • @RyanOConnellCFA
      @RyanOConnellCFA  26 วันที่ผ่านมา

      Glad I could help! That is a huge milestone, congrats

  • @dannguyen239
    @dannguyen239 ปีที่แล้ว +2

    Thank you for the video. Please post more videos like this in the future.

  • @theemperor.188
    @theemperor.188 ปีที่แล้ว +3

    Bro Ur such a genious😉😉..Closely following in ur footsteps.

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

      Thanks, man! Just sharing what I know, and I'm stoked it's helping you out. Keep up the solid work on your end! 😎

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

      @theemperor.188 not as close as I am

  • @Chris-si4ox
    @Chris-si4ox ปีที่แล้ว +2

    great video - just getting back into coding and this is very helpful. Forgot how fiddly this stuff is.

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

      Glad it was helpful! Good luck brushing up on those skills. It is really fiddly how one thing out of place will break everything

  • @boyangirginov
    @boyangirginov 2 หลายเดือนก่อน +1

    Great examples and explanation, thanks Ryan!

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

    Thanks it is helping us a lot hope you will keep posting more videos like this in future

  • @nicolassepulvedalozano9210
    @nicolassepulvedalozano9210 ปีที่แล้ว +2

    Hi. Awesome video for beginners. Thank you (sorry for bad English)

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

      Thank you Nicolas! And no worries, your English was perfect bro

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

    Thanks this has been very helpful and covers a lot of ground but starts on the fundamentals. I got stuck on the distutils error and also had to install matplotlib but got there in the end :)

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

    Thanks for this great video, Ryan!

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

      It is my pleasure Edwin!

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

    wonderfully explained - many thanks

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

    Hi Ryan, I’ve been following your video really well, but I’m stuck at the part where you have to import the necessary libraries. I am using a MacBook and I’m unable to navigate through the importing process.

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

    Love it. Thank you!

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

    Excellent video, thx a lot!!

  • @mayankkumarlakshakar3393
    @mayankkumarlakshakar3393 14 วันที่ผ่านมา +1

    in my command prompt pip install is not working and showing error as 'pip is not recognized as an internal or external command,
    operable program or batch file'
    help me out please .

  • @NB233___
    @NB233___ ปีที่แล้ว +2

    anyone know why I get at 15:08 ?

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

      Hey! Make sure you've imported the datetime module and aliased it as dt
      If you're still getting an error similar to , that suggests that you may have inadvertently overridden the dt or datetime name in your code. Make sure you don't have any other variables or modules named datetime or dt that could be conflicting with the standard library module.

  • @gloriabukachi1
    @gloriabukachi1 9 หลายเดือนก่อน +2

    Wow! Thank you

  • @igorelperin8277
    @igorelperin8277 9 หลายเดือนก่อน +5

    Hi Ryan, thank for your work - much appreciated. Faced with problem to import all libraries specifically on the step
    from pandas_datereader import data as pdr
    all the time when python tries to interpret this line I have an error with
    ModuleNotFoundError: No module named 'distutils'
    Python version is 3.12, PyCharm, MacOS
    P.S. I checked - all libraries have been installed (you mentioned in your video and all problems with above mentioned line.
    Thanks

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

      same prob here buddy!

    • @igorelperin8277
      @igorelperin8277 6 หลายเดือนก่อน +2

      @@gintama183 sorry to hear but anyway looks like Ryan is not gonna answer and help to fix this issue unfortunately

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

      i just type all of the libraries into the environment

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

      ChatGpt fixed it for me

    • @Benjamin-pf1eb
      @Benjamin-pf1eb 3 หลายเดือนก่อน

      you need to pip install pandas-datareader

  • @m.ssharma535
    @m.ssharma535 ปีที่แล้ว +2

    Hi Ryan. First question after binge watching your videos over the weekend. Please take a look. I have developed a stock value calculator that has 6000 stocks. I have 6 methods and created a dashboard for summary. But I want to get the results for 40 stocks (can get ticker in a text file) and it should be printed to another excel tab or PDF or Python screen. I can just print one row or two rows of summary for each stock ticker (no need of fancy dashboard). Meaning -I need to run the excel dashboard (or file) repeatedly 40 times (40 stock tickers with 2 inputs -ticker and market price) and get the valuation summary. What is the trick to do ? Kindly suggest a method. I think I can do this in Python by accessing Excel repeatedly. Excel or Python?

    • @RyanOConnellCFA
      @RyanOConnellCFA  ปีที่แล้ว +6

      Hi @m.ssharma535,
      Given your requirements, I'd recommend using Python over Excel for this task. Python can effortlessly loop over your 40 tickers, process the data, and store the results. Libraries like pandas can integrate directly with Excel, allowing you to read data, perform calculations, and then write back the results. For your scenario, you can use pandas to load the tickers, compute the valuations for each, and save the summaries to a new Excel tab or PDF. This approach offers automation, flexibility, and scalability compared to manually running processes in Excel.
      I hope this helps! Let me know if you need further clarification.

  • @aarondelarosa3146
    @aarondelarosa3146 ปีที่แล้ว +2

    Excellent. Where do you write on the code "drop nan"?

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

      Thanks Aaron! I did not drop the "nan" values at all. It was not necessary to plot the values for me

  • @mmcatamm6668
    @mmcatamm6668 6 หลายเดือนก่อน +4

    couldn't make it beyond the import libraries - command prompt says everything is installed, but PyCharm tells me "ModuleNotFoundError: No module named 'yfinance'"

    • @RyanOConnellCFA
      @RyanOConnellCFA  5 หลายเดือนก่อน +1

      Did you go to the command prompt and type "pip install yfinance"?

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

      It's showing me same for pandas_datareader

    • @LuigiZambon
      @LuigiZambon วันที่ผ่านมา

      Hi, how did you solve that problem?

  • @BrittanyIsenhart
    @BrittanyIsenhart 3 หลายเดือนก่อน +1

    This is great! Which certification program do you recommend on taking for someone who wants to be certified (I am a Finance professional)

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

      Hey Brittany! That highly depends on what area of finance you want to work in. What area are you most interested in?

  • @satchelbutterfield7470
    @satchelbutterfield7470 ปีที่แล้ว +2

    Why would you use elif if you can just do another if statement underneath? Some sort of referencing insurance?

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

      There are scenarios in which you might opt to nest an 'if' statement within another or use an 'elseif' statement. The 'elseif' statement is versatile as it captures all subsequent conditions, whereas an 'if' statement addresses only the specific condition you're testing for.

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

    Loved this!! How could I watch the graphic of cumulative_log_returns in Sublime Text?

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

      Thank you! Unfortunately I've never used that Python package before so I'm not certain

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

      Np, i made a GPT as it was a python expert and told it to give me excersises to be growing with this python for finance stuff, look at this:
      import yfinance as yf
      import pandas as pd
      import matplotlib.pyplot as plt
      #descargamos datos de la acción
      data = yf.download("GOOG", start = "2021-01-01", end = "2021-12-31")
      #calculamos el retorno diario
      data["Retorno"] = data ["Adj Close"].pct_change()
      #Calculamos retorno diario promedio y volatilidad
      retorno_promedio = data["Retorno"].mean()
      volatilidad = data["Retorno"].std()
      print(f"Retorno diario promedio: {retorno_promedio}")
      print(f"Volatilidad: {volatilidad}")
      #Creamos los gráficos
      data['Retorno'].plot(figsize=(10, 6))
      plt.title('Retorno Diario de GOOG en 2021')
      plt.xlabel('Fecha')
      plt.ylabel('Retorno Diario')
      plt.show()
      @@RyanOConnellCFA

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

    Ryan - Very good of explaining, which is understandable

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

      I really appreciate the feedback and I'm glad you enjoyed it!

  • @JayMoney-w3y
    @JayMoney-w3y 9 วันที่ผ่านมา

    Hi Ryan, I notice when I run df.head() it doesnt show the table. I am using sublime text and I am wondering if the issue is my code or sublime.

    • @RyanOConnellCFA
      @RyanOConnellCFA  4 วันที่ผ่านมา

      It is very difficult for me to tell from just this comment. You can see the code in the pinned comment and see where yours deviates!

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

    Hello Ryan, thanks for the video, i cant really see the graph after doing the code, would you give me a solution? thanks in advance

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

      My pleasure! You can copy the code straight from my website using the code to plot the results. If you have named all the variables the same, it should work fine

  • @lordtony2054
    @lordtony2054 ปีที่แล้ว +4

    Absolute legend.

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

    Hi Ryan, do you books in python for finance for more codes I mean, thanks for your kindness.❤

  • @Mac-i7
    @Mac-i7 14 วันที่ผ่านมา

    How do I “ pip install “ libraries on Mac without Windows “command prompt “ ?

  • @SD-gw5vm
    @SD-gw5vm 9 หลายเดือนก่อน +1

    Hi Ryan, When are the other videos being released?

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

      Hey there, I will continue to release Python videos in the future. I do not have a set schedule for it however

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

    first time coming here i thought its really for beginners

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

    By the way, I've already installed VSC (Visual Studio Code on my computer). Can I run python code directly? I mean, without Anaconda platform?

    • @RyanOConnellCFA
      @RyanOConnellCFA  ปีที่แล้ว +2

      If you have Python and VS Code already installed then it should work for you. You should be able to put the same code in a normal python (.py) file and run it in the terminal. However, I'd recommend using a Jupyter Notebook file (.ipynb) to make it easier on yourself like I did in the video

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

      @@RyanOConnellCFA Well, It's not working. There's a connection with Kernel: Python 3.11.1. Activating Python environment. It's running activation now.

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

      Let me know if it gets up and running for you. It may be worth installing Anaconda just incase

  • @d3yadav
    @d3yadav 9 หลายเดือนก่อน +2

    Hi Ryan. This video is very interesting. I tried to install the yfinance package but I gets the error" there is no module named yfinance". I cross checked in site packages folder and I can see yfiance folder. Can you suggest any help?

    • @LuigiZambon
      @LuigiZambon วันที่ผ่านมา

      hi, did u solve the problem?

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

    Thanks

  • @ΑναστασίαΜπουτζέκη
    @ΑναστασίαΜπουτζέκη ปีที่แล้ว +1

    Hello Ryan, after seeing your video I tried to download everything you showed, however when I try to import the libraries through the command prompt, my laptop doesn't recognize the 'pip' command. What should I do?
    Thank you in advance 😊

    • @RyanOConnellCFA
      @RyanOConnellCFA  ปีที่แล้ว +2

      Hey! This likely means that you do not have Python downloaded on your computer. I would go back to the first step of downloading Python if I were you

    • @ΑναστασίαΜπουτζέκη
      @ΑναστασίαΜπουτζέκη ปีที่แล้ว

      Thank you so much for answering!
      Now I have problems with actually running the commands. Even the "print" doesn't get me results. After hitting the "go" button, my cursor just transports to the search field.

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

      @@ΑναστασίαΜπουτζέκη My pleasure! I'm guessing that means you need to select which version of Python you will run the code with. There will probably only be one option, just select that one

    • @ΑναστασίαΜπουτζέκη
      @ΑναστασίαΜπουτζέκη ปีที่แล้ว +1

      @@RyanOConnellCFA Sorry for bothering again, I hope this will be my last question, it's because I don't have an idea about programming in general. After installing everything in the command prompt as you showed, when i try to run this, it's giving me errors like "yfinance unknown word and datareader unknown word". In the command prompt when I try to install them again it says requirement already satisfied, so I suppose i completed this part correctly. Pandas, datetime and numpy are running without errors.

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

      @@ΑναστασίαΜπουτζέκη No bother at all, I'm here to help! It sounds like you might not have imported the yfinance and datareader modules correctly in your Python script. Before using these modules, ensure to include lines at the beginning of your script to import them, like "import yfinance as yf" and "import pandas_datareader as dr". Give this a try and let me know how it goes!

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

    Hey Ryan!
    I tried installing the yfinance and the other packages but every time I press [Enter] I get a message stating "pip is not recognized as an internal or external command, operable program, or batch file." What should I do?

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

      Hey there! This error usually means that Python's package manager, pip, isn't added to your system's PATH. Try reinstalling Python and ensure that the "Add Python to PATH" option is checked during installation.

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

      @@RyanOConnellCFA Hey, Thank you! That worked to install the pip packages. Although when I enter "import yfinance as yf" and run it, I get an error saying 'ModuleNotFoundError'. I installed the package again but I still get the same error. Also, I'm using JupyterNotebook and not VS code.

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

    Finally code is working in VSC except for plot. Code can't plot cumulative log returns. I installed matplotlib on terminal as pip install matplotlib 3.7.1. However, cumulative log returns plot was not executed.

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

      What was the error message? Sounds like you're 99% of the way there

  • @onwrdandupwrd5303
    @onwrdandupwrd5303 ปีที่แล้ว +2

    lol @ 22:34

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

    so i got stuck along the way
    *********************100%%**********************] 3 of 3 completed
    1 Failed download:
    ['QQQ']: OperationalError('database is locked')

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

      That sounds to me like the problem is not something you did wrong but some bug in the API. Maybe try a different ticker (like AAPL) and see if it works

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

      It was successful, you only need one more line, >>> print(df)

  • @DeepVoiced
    @DeepVoiced 8 หลายเดือนก่อน +1

    22:31 🤨😏

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

    Hi Ryan, I’ve been following your video really well, but I’m stuck at the part where you have to import the necessary libraries. I am using a MacBook and I’m unable to navigate through the importing process.