How to use the yfinance.download function in yfinance

To help you get started, we’ve selected a few yfinance examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cuemacro / findatapy / findatapy / market / datavendorweb.py View on Github external
def download_daily(self, market_data_request):
        logger = LoggerManager().getLogger(__name__)

        trials = 0

        data_frame = None

        ticker_list = ' '.join(market_data_request.tickers)
        data_frame = yf.download(ticker_list, start=market_data_request.start_date, end=market_data_request.finish_date)

        while (trials < 5):


            try:
                data_frame = yf.download(ticker_list, start=market_data_request.start_date, end=market_data_request.finish_date)

                break
            except Exception as e:
                print(str(e))
                trials = trials + 1
                logger.info("Attempting... " + str(trials) + " request to download from Yahoo")

        if trials == 5:
            logger.error("Couldn't download from ONS after several attempts!")
github paduel / streamlit_finance_chart / app.py View on Github external
def load_quotes(asset):
    return yfinance.download(asset)
github fmilthaler / FinQuant / finquant / portfolio.py View on Github external
if isinstance(start_date, str):
            start_date = datetime.datetime.strptime(end_date, "%Y-%m-%d")
        if isinstance(end_date, str):
            end_date = datetime.datetime.strptime(end_date, "%Y-%m-%d")
    except ImportError:
        print(
            "The following package is required:\n - `datetime`\n"
            + "Please make sure that it is installed."
        )
    except Exception:
        raise Exception("Please provide valid values for  and ")

    # unlike quandl, yfinance does not have a prefix in front of the ticker
    # thus we do not need to correct them
    try:
        resp = yf.download(names, start=start_date, end=end_date)
    except Exception:
        raise Exception("Error during download of stock data from Yahoo Finance with `yfinance`.")
    return resp