yfinance | Finance 's API | Business library

 by   ranaroussi Python Version: 0.2.36 License: Apache-2.0

kandi X-RAY | yfinance Summary

kandi X-RAY | yfinance Summary

yfinance is a Python library typically used in Financial Services, Banks, Payments, Web Site, Business, Pandas applications. yfinance has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can install using 'pip install yfinance' or download it from GitHub, PyPI.

Download market data from Yahoo! Finance's API
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              yfinance has a medium active ecosystem.
              It has 9652 star(s) with 1911 fork(s). There are 224 watchers for this library.
              There were 5 major release(s) in the last 6 months.
              There are 175 open issues and 915 have been closed. On average issues are closed in 229 days. There are 18 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of yfinance is 0.2.36

            kandi-Quality Quality

              yfinance has 0 bugs and 0 code smells.

            kandi-Security Security

              yfinance has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              yfinance code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              yfinance is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              yfinance releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              yfinance saves you 386 person hours of effort in developing the same functionality from scratch.
              It has 1190 lines of code, 84 functions and 10 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed yfinance and discovered the below as its top functions. This is intended to give you an instant insight into yfinance implemented functionality, and help decide if they suit your requirements.
            • Download data from the database
            • Return all quote objects for a given ISIN number
            • Generic download function
            • Updates the progress bar
            • Return an empty DataFrame
            • Prints the progress bar
            • Download data from pandas
            • Download data
            • Advance the progress bar
            • Assign ds to the shared dataframes
            • Download a single ticker
            • Return a namedtuple
            • Download the latest options
            • Convert options to pandas DataFrame
            • Get torrents statistics
            • Get a JSON object from the API
            • List of available options
            Get all kandi verified functions for this library.

            yfinance Key Features

            No Key Features are available at this moment for yfinance.

            yfinance Examples and Code Snippets

            Download market data from Yahoo! Finance's API-Quick Start-The Ticker module
            Pythondot img1Lines of Code : 113dot img1License : Permissive (Apache-2.0)
            copy iconCopy
            import yfinance as yf
            
            msft = yf.Ticker("MSFT")
            
            # get stock info
            msft.info
            
            # get historical market data
            hist = msft.history(period="max")
            
            # show meta information about the history (requires history() to be called first)
            msft.history_metadata
            
            # sh  
            copy iconCopy
            import yfinance as yf
            data = yf.download("SPY AAPL", start="2017-01-01", end="2017-04-30")
            
            data = yf.download(  # or pdr.get_data_yahoo(...
                    # tickers list or string as well
                    tickers = "SPY AAPL MSFT",
            
                    # use "period" instead o  
            Download market data from Yahoo! Finance's API-pandas_datareader override
            Pythondot img3Lines of Code : 7dot img3License : Permissive (Apache-2.0)
            copy iconCopy
            from pandas_datareader import data as pdr
            
            import yfinance as yf
            yf.pdr_override() # <== that's all it takes :-)
            
            # download dataframe
            data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")
              
            Plot horizontal lines between date ranges iterating through pandas dataframe
            Pythondot img4Lines of Code : 70dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import yfinance as yf
            import pandas as pd
            import numpy as np
            import plotly.express as px
            import plotly.graph_objects as go
            from datetime import datetime, timedelta 
            
            df = yf.download( tickers = 'BTC-USD',
                            start = '2021-08-3
            Python mplfinance draw hlines start/end date
            Pythondot img5Lines of Code : 14dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import mplfinance as mpf
            import yfinance as yf
            
            candlesticks = yf.download("AAPL", start="2022-01-01", end="2022-04-01")
            
            #levels = [155,160,180]
            levels = [[('2022-02-16', 160.), ('2022-03-31',160.0)], [('2022-02-16',175.0),('2022-03-31',1
            how to add annotation of last value in stacked area chart?
            Pythondot img6Lines of Code : 31dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import yfinance as yf
            ticker = ['AAPL','GOOGL','TSLA','MSFT']
            data = yf.download(ticker, start="2021-01-01", end="2021-03-01")['Close']
            
            import plotly.graph_objects as go
            
            fig = go.Figure()
            for t in data.columns:
                fig.add_trace(go.Scatt
            retrieve stock price data from specific dates in pandas df
            Pythondot img7Lines of Code : 44dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            df = pd.DataFrame({'Date':['2022-01-27','2021-10-28','2021-07-29','2021-04-29','2021-01-28','2013-07-24','2013-05-01','2013-01-30','2012-10-23','2012-07-26'],
                               'symbol':['CMCSA','CMCSA','CMCSA','CMCSA','CMCSA','FB','FB','
            copy iconCopy
            pip install yfinance
            
            import yfinance as yf
            
            df = yf.download('AAPL', period='5y')
            
            ticker = yf.Ticker('AAPL')
            df = ticker.history(period="5y")
            
            How to create candlestick chart with data that came from yahoo finance?
            Pythondot img9Lines of Code : 14dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import yfinance as yf
            import plotly.graph_objects as go
            
            data = yf.download(tickers='EURUSD=X', period='1d', interval='30m')
            
            fig = go.Figure(data=[go.Candlestick(x=data.index,
                                                 open=data['Open'],
                  
            Trying to plot Earnings and Stock price in the same graph
            Pythondot img10Lines of Code : 26dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import matplotlib.pyplot as plt
            import matplotlib.dates as mdates
            import yfinance as yf
            import pandas as pd
            
            t = yf.Ticker("T")
            
            df1 = t.earnings
            df1.index = pd.to_datetime(df1.index, format='%Y')
            df1.index = mdates.date2num(df1.index)
            ax 

            Community Discussions

            QUESTION

            Plot horizontal lines between date ranges iterating through pandas dataframe
            Asked 2022-Apr-14 at 15:13

            I essentially have two different data frames, one for calculating weekly data (df) and a second one (df1) that has the plot values of the stock/crypto. On df, I have created a pandas column 'pivot' ((open+high+low)/3) using the weekly data to create a set of values containing the weekly pivot values.

            Now I want to plot these weekly data (as lines) onto df1 which has the daily data. Therefore the x1 would be the start of the week and x2 be the end of the week. the y values being the pivot value from the df(weekly). Here is what I would want it to look like:

            My Approach & Problem:

            First of all, I am a beginner in Python, this is my second month of learning. My apologies if this was asked before.

            I know the pivot values can be calculated using a single data frame & pandas group-by but I want to take the issue after this is done, so both ways should be fine if you are approaching this issue. What I would like to have is those final lines with OHLC candlesticks. I would like to plot these results using Plotly OHLC and go Shapes. What I am stuck with is iterating through the pivot weekly data frame and adding the lines as traces on top of the OHLC data daily data.

            Here's my code so far:

            ...

            ANSWER

            Answered 2022-Apr-14 at 14:39

            There are two ways to create a line segment: add a shape or use line mode on a scatter plot. I think the line mode of scatter plots is more advantageous because it allows for more detailed settings. For the data frame, introduce a loop process on a line-by-line basis to get the next line using the idx of the data frame. y-axis values are pivot values. I wanted to get Yokohama, so I moved the legend position up. Also, since we are looping through the scatter plot, we will have many legends for the pivot values, so we set the legend display to True for the first time only.

            Source https://stackoverflow.com/questions/71872140

            QUESTION

            Removing dublicate on PostgreSQL based on 2 columns
            Asked 2022-Apr-02 at 15:21

            I want to drop entries based on 2 columns in Postgres. The code for to get the data is:

            ...

            ANSWER

            Answered 2022-Apr-02 at 15:21

            Revised query. Test before using in production:

            Source https://stackoverflow.com/questions/71716905

            QUESTION

            Y finance Date alignment
            Asked 2022-Mar-21 at 15:27

            This might be a relatively difficult question;

            The scope of the code I want to write, is to automate the aligment of Dates that i pull from yfinance regarding BTC and S&P 500

            since the S&P500 (SPY) is not traded on weekends, but BTC is, I want to automatically delete the columns of dates from BTC that fall on weekends (or days where the S&P isn't treaded), to consistantly allign my 2 Dataframes.

            In this case I have 15 data rows in BTC, whereas I only have 10 in SPY

            I only need data where the dates match

            Does anyone have an idea how I could do that?

            ...

            ANSWER

            Answered 2022-Mar-21 at 15:27

            Here is a faster option for this purpose below:

            Source https://stackoverflow.com/questions/71556914

            QUESTION

            How to make it so that all available data is being pulled instead of specifically typing out a date range for this script?
            Asked 2022-Mar-10 at 20:06

            The available options dates are below. How can I write a code so that it pulls all those dates instead of having to type them all out in a separate row?

            2022-03-11, 2022-03-18, 2022-03-25, 2022-04-01, 2022-04-08, 2022-04-14, 2022-04-22, 2022-05-20, 2022-06-17, 2022-07-15, 2022-10-21, 2023-01-20, 2024-01-19

            ...

            ANSWER

            Answered 2022-Mar-10 at 07:55

            First of all, as these dates have no regular pattern, you should create a list of the dates.

            Source https://stackoverflow.com/questions/71420119

            QUESTION

            How to add new columns to pandas data frame using .loc
            Asked 2022-Feb-28 at 21:40

            I am calculating very simple daily stock calculations in data frame ( for e.g. SMA, VWAP, RSI etc). After I upgraded to anaconda 3.0, my code stopped working and gives followed error. I don't have much experience in coding and need some help.

            KeyError: "Passing list-likes to .loc or [] with any missing labels is no longer supported. The following labels were missing: Index(['RSI', 'ZONE'], dtype='object'). See https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike"

            Followed is the code.

            ...

            ANSWER

            Answered 2022-Feb-28 at 21:40

            A few lines need to be tweaked

            1. Instead of

            Source https://stackoverflow.com/questions/71300628

            QUESTION

            How to get the float value from datetime index
            Asked 2022-Feb-23 at 06:11

            I have the following code:

            ...

            ANSWER

            Answered 2022-Feb-23 at 06:11

            Here b.index.strftime('%Y-%m-%d %I:%M:%S') return one element Index, so for scalar need select first value:

            Source https://stackoverflow.com/questions/71232006

            QUESTION

            Adding arrows to mpf finance plots
            Asked 2022-Feb-22 at 14:55

            I am trying to add an arrow on a given date and price to mpf plot. To do this i have the following code:

            ...

            ANSWER

            Answered 2022-Feb-22 at 14:19

            The data passed into mpf.make_addplot() must be the same length as the dataframe passed into mpf.plot(). To plot only some points, the remaining points must be filled with nan values (float('nan'), or np.nan).

            You can see this clearly in the documentation at cell **In [7]** (and used in the following cells). See there where the signal data is generated as follows:

            Source https://stackoverflow.com/questions/71221308

            QUESTION

            Facing an error while executing the plotly module
            Asked 2022-Feb-16 at 08:32

            I am running the below-mentioned code to create a candlestick chart with traces but an error is being reflected as Exception has occurred: AttributeError 'dict' object has no attribute 'add_trace'

            The code is as follows

            ...

            ANSWER

            Answered 2022-Feb-16 at 08:01

            You can create figures from dictionaries or from graph objects.

            In your example, you create fig as a standard python dictionary. It only becomes a graph object once you plot it. add_trace is not a valid python command for a dictionary, that's why it fails.

            You want to create a graph object, to which you can apply add_trace. See here

            Source https://stackoverflow.com/questions/71137982

            QUESTION

            How to skip weekends and other gaps from MPL finance plot
            Asked 2022-Feb-16 at 07:31

            I have the following code which plots intraday stocks data.

            ...

            ANSWER

            Answered 2022-Feb-16 at 07:07

            QUESTION

            yfinance how to get data if the ticker is same for different exchanges
            Asked 2022-Feb-15 at 06:45

            I want to get historical price data using python and yfinance for Indonesian stocks. I see that there are many stocks that have the same name across different countries, for example AUTO (can be Indonesian company Astra Otoparts Tbk PT or NASDAQ's Autoweb Inc)

            When I do yf.download('AUTO'), it's returning me a price data of Autoweb Inc, instead of Indonesian stock Astra Otoparts Tbk PT.

            How can we select which exchange we want the ticker from?

            Thanks.

            ...

            ANSWER

            Answered 2022-Feb-15 at 06:45

            I've only looked up the brand name in your question, AUTO.JK is the brand name. I have not checked if it is a rule to add abbreviated names.

            Source https://stackoverflow.com/questions/71121619

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install yfinance

            *** IMPORTANT LEGAL DISCLAIMER *** Yahoo!, Y!Finance, and Yahoo! finance are registered trademarks of Yahoo, Inc. yfinance is not affiliated, endorsed, or vetted by Yahoo, Inc. It's an open-source tool that uses Yahoo's publicly available APIs, and is intended for research and educational purposes. You should refer to Yahoo!'s terms of use (here, here, and here) for details on your rights to use the actual data downloaded. Remember - the Yahoo! finance API is intended for personal use only. yfinance offers a threaded and Pythonic way to download market data from Yahoo!Ⓡ finance. → Check out this Blog post for a detailed tutorial with code examples.
            Install yfinance using pip:. To install yfinance using conda, see this.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install yfinance

          • CLONE
          • HTTPS

            https://github.com/ranaroussi/yfinance.git

          • CLI

            gh repo clone ranaroussi/yfinance

          • sshUrl

            git@github.com:ranaroussi/yfinance.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Business Libraries

            tushare

            by waditu

            yfinance

            by ranaroussi

            invoiceninja

            by invoiceninja

            ta-lib

            by mrjbq7

            Manta

            by hql287

            Try Top Libraries by ranaroussi

            quantstats

            by ranaroussiPython

            qtpylib

            by ranaroussiPython

            pystore

            by ranaroussiPython

            pywallet

            by ranaroussiPython

            ezibpy

            by ranaroussiPython