Free Stock Prices in Python & Excel Export | yFinance

Поділитися
Вставка
  • Опубліковано 5 жов 2024

КОМЕНТАРІ • 18

  • @RyanOConnellCFA
    @RyanOConnellCFA  Рік тому +1

    💻 Code here: ryanoconnellfinance.com/downloading-historical-stock-prices-and-exporting-to-excel-using-yfinance-and-python/
    👨‍💼 My Freelance Financial Modeling Services:
    ► Custom financial modeling solutions tailored for your needs: ryanoconnellfinance.com/freelance-finance-services/

  • @hungrysquishybrain
    @hungrysquishybrain 5 місяців тому +1

    Would love to know how to go from Python to Google Sheets without downloading an exported file, all via Python into Google Sheets, of the Yahoo Finance - Analysis - Growth Estimates numbers. Thanks! 👏

  • @yaaymaiko1629
    @yaaymaiko1629 Рік тому +3

    Thanks for this useful video. At first, I had a problem when running this code. After some digging, I discovered that my Python interpreter could not find the openpyxl module. All I had to do was to type pip install openpyxl in cmd.

    • @RyanOConnellCFA
      @RyanOConnellCFA  Рік тому +1

      Thank you for sharing this fix for people who may have the same problem as you in the future!

    • @srendahl14
      @srendahl14 6 місяців тому

      THANK you. I had the same problem

  • @AntonioPale-x1i
    @AntonioPale-x1i Рік тому +1

    Exactly what i was looking for, many thanks!

  • @amiralshoq
    @amiralshoq 4 місяці тому

    Great lesson, thank you very much
    Is it possible to explain how to download market data for MetaStock?
    Which is as follows
    ,,,,,,,,

  • @daviddalton9350
    @daviddalton9350 6 місяців тому +1

    Having Problem Exporting the Dataframe on Macintosh Os to Excel. Different from your path name since you are using a PC computer

  • @mkarvj
    @mkarvj Рік тому +1

    Hey Ryan, another awsome video!!! Is it possible to provide intervals to this code. Currenty we extarct for 2 years. So if we want to extract the data for every 1m, 3m, 5m, 1h timeframe intervals. Also, is it possible to update the stock price on live market. Here we currently pull data only for close price, I want to extract the Open Price, High Price, Low Price and Current Price for a list of stocks in 1 min timeframe. Please do the needful

    • @RyanOConnellCFA
      @RyanOConnellCFA  Рік тому

      Hi, thank you for your comment and questions.
      Certainly, it is possible to extract data at different intervals, as well as different types of prices, like Open, High, Low, and Current. I am happy to share an updated code snippet below that addresses your requests.
      Please note, for real-time data, Yahoo Finance doesn't provide it for free. This example will only provide the latest price when you request it.
      Firstly, for the interval, you can pass it as a parameter to the yf.download() method. Accepted interval values are: '1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo'.
      python
      Copy code
      import yfinance as yf
      import pandas as pd
      from datetime import datetime, timedelta
      # Define the list of tickers
      tickers = ['SPY','BND','GLD','QQQ','VTI']
      # Set the end date to today
      end_date = datetime.today()
      # Set the start date to 2 years ago
      start_date = end_date - timedelta(days = 2*365)
      # Define the time interval
      interval = '1m' # 1 minute intervals
      # Create an empty DataFrame to store the data
      data_df = pd.DataFrame()
      # Download the open, high, low, close, and current prices for each ticker
      for ticker in tickers:
      data = yf.download(tickers=ticker, start=start_date, end=end_date, interval=interval)
      data_df[ticker] = data[['Open', 'High', 'Low', 'Close', 'Adj Close']]
      # Display the DataFrame
      print(data_df)

    • @mkarvj
      @mkarvj Рік тому

      @@RyanOConnellCFA One more help Ryan, How do we export the output to csv file? Also, assume that the market is live, in that case how does the data get update in our csv file in realtime... do we need to execute the every minute? My expectation is like all this data should be saved in a csv or excel file and this file should be open and update the price in live market. Is that possible?

  • @jacobtt-
    @jacobtt- 8 місяців тому +1

    Hello, I know this is an old video, but hope you'll answer.
    Is there a smart way on how I can get the log returns in the same file as the prices?

    • @RyanOConnellCFA
      @RyanOConnellCFA  8 місяців тому

      Doesn't matter how old the video is, I still reply to all the comments :)
      You can get the log returns in python, or you can also do it in Excel following what I did at the start of this video: ua-cam.com/video/XQS17YrZvEs/v-deo.html

  • @dannyalashi9727
    @dannyalashi9727 Рік тому +1

    Would you like to refer to a good source to learn Python for beginners ?

    • @bp56789
      @bp56789 Рік тому

      Python 3: Fundamentals by Fred Baptiste

    • @RyanOConnellCFA
      @RyanOConnellCFA  Рік тому +1

      Hey Danny, I made this video specifically as a beginner video for people who are interested in using Python for Finance: ua-cam.com/video/uOqPElBsBmM/v-deo.html